index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536
  1. <template>
  2. <view class="container">
  3. <u-navbar :is-back="false" title="" :background="{ background: '#f7f7f7' }" :border-bottom="false">
  4. <view class="slot-wrap">
  5. <image src="https://sylwt.top/api/visitor/resources/image?name=/ydl/menber-center/login-icon.png"
  6. mode="aspectFit" style="width: 300rpx;"></image>
  7. </view>
  8. </u-navbar>
  9. <view class="page-content">
  10. <swiper class="swiper" circular indicator-dots style="border-radius: 20rpx;overflow: hidden;height: 200px">
  11. <swiper-item v-for="(data, index) in swiperList" style="width: 100%;height: 100%;" :key="index">
  12. <view class="swiper-item" style="width: 100%;height: 100%;" @click="itemClick(data)">
  13. <image :src="data.imgUrl" mode="aspectFill" style="width: 100%;height: 100%;"></image>
  14. </view>
  15. </swiper-item>
  16. </swiper>
  17. <u-grid :col="4" :border="false" style="margin: 10rpx 0 ;">
  18. <template v-for="(item,index) in navList" :key="index">
  19. <u-grid-item bg-color="none" @click="jumpToPage(item)">
  20. <image
  21. :src="`https://sylwt.top/api/visitor/resources/image?name=/ydl/menber-center/index-icon/${item.image}.png`"
  22. style="height: 70rpx;width: 70rpx;">
  23. </image>
  24. <view class="grid-text">{{item.title}}</view>
  25. </u-grid-item>
  26. </template>
  27. </u-grid>
  28. <u-card padding="20" margin="0rpx 0rpx 30rpx" border-radius="20"
  29. box-shadow="0px 2px 5px rgba(0, 0, 0, 0.1)">
  30. <template v-slot:head>
  31. <u-section title="课程预告" sub-title="查看更多" sub-color="#000000"></u-section>
  32. </template>
  33. <template v-slot:body>
  34. <lg-swiper v-if="courseList.length!=0"
  35. :sildeItems="courseList"
  36. @swiperClick="swiperClick"
  37. image="courseImg" title="courseName"></lg-swiper>
  38. <u-empty text="暂无内容" mode="data" v-else></u-empty>
  39. </template>
  40. </u-card>
  41. <u-card padding="30" margin="0rpx 0rpx 30rpx" border-radius="20"
  42. box-shadow="0px 2px 5px rgba(0, 0, 0, 0.1)">
  43. <template v-slot:head>
  44. <u-section title="研究报告" sub-title="查看更多" sub-color="#000000"></u-section>
  45. </template>
  46. <template v-slot:body>
  47. <view v-if="reportList.length!=0">
  48. <view v-for="(data,index) in reportList" :key="index" class="u-body-item u-flex u-p-t-0 "
  49. style="align-items: inherit;">
  50. <image :src="data.imgUrl" mode="aspectFill"></image>
  51. <view class="u-body-item-content">
  52. <view class="item-content">
  53. <text class="item-content-title text-ellipsis">{{data.title}}</text>
  54. <text class="item-content-type">{{data.type}}</text>
  55. <text class="item-content-price"
  56. v-if="data.viewMode==='3'">¥{{isMember?data.priceMember:data.price}}元</text>
  57. </view>
  58. <view class="item-button">
  59. <view v-if="data.viewMode==='3' && data.hasBuy" class="item-button-yiGouMai">已购买
  60. </view>
  61. <view v-else-if="data.viewMode==='3' && !data.hasBuy" class="item-button-goumai">
  62. 点击购买</view>
  63. <view v-else-if="data.viewMode==='2'" class="item-button-huiyuan">
  64. 会员免费
  65. </view>
  66. </view>
  67. </view>
  68. </view>
  69. </view>
  70. <u-empty text="暂无内容" mode="data" v-else></u-empty>
  71. </template>
  72. </u-card>
  73. </view>
  74. <u-modal v-model="loginModal" mask-close-able class="modal" show-cancel-button
  75. :title-style="{fontWeight: 'bold'}" @confirm="confirmModal">
  76. <view class="modal-content">
  77. <text>请登录后使用该功能</text>
  78. </view>
  79. </u-modal>
  80. </view>
  81. </template>
  82. <script setup>
  83. import lgSwiper from '@/components/lgSwiper.vue'
  84. import {
  85. onMounted,
  86. ref
  87. } from 'vue'
  88. import {
  89. onReady,
  90. onLoad,
  91. onShow
  92. } from '@dcloudio/uni-app'
  93. import {
  94. useAuthStore
  95. } from '@/store/authStore'
  96. import {
  97. count
  98. } from '@/api/chat.js'
  99. import {
  100. homeCourseList,
  101. homeReportList,
  102. homeSetting,
  103. homeSwiperList
  104. } from '@/api/home.js'
  105. import {
  106. me
  107. } from '@/api/user.js'
  108. const authStore = useAuthStore()
  109. // 屏幕状态栏高度
  110. const statusBarHeight = ref(0)
  111. // 顶部导航栏高度
  112. const navBarHeight = ref(0)
  113. // 是否登录
  114. const loginModal = ref(false)
  115. // 是否为会员,从缓存里拿取用户信息
  116. // const userInfo = uni.getStorageSync("userinfo") || {}
  117. const isMemberMap = {
  118. 0: true,
  119. 1: false
  120. }
  121. const isMember = ref(false)
  122. // 首页-轮播图
  123. const swiperList = ref([{
  124. imgUrl: 'https://tse3-mm.cn.bing.net/th/id/OIP-C.YKoZzgmubNBxQ8j-mmoTKAHaEK?rs=1&pid=ImgDetMain',
  125. id: 1
  126. },
  127. {
  128. imgUrl: 'https://pic3.zhimg.com/v2-e52354ffdbd94a8e0a7649eacd34a788_r.jpg?source=1940ef5c',
  129. id: 2
  130. },
  131. {
  132. imgUrl: 'https://desk-fd.zol-img.com.cn/t_s960x600c5/g4/M03/00/0C/Cg-4zFS8bC-Ie9zBADCvovJAqiEAATJ8wDX__cAMK-6184.jpg',
  133. id: 3
  134. },
  135. ])
  136. const courseList = ref([{
  137. courseImg: 'https://tse3-mm.cn.bing.net/th/id/OIP-C.YKoZzgmubNBxQ8j-mmoTKAHaEK?rs=1&pid=ImgDetMain',
  138. id: 1,
  139. courseName: '【8月8日】房地产经纪进阶培训班'
  140. },
  141. {
  142. courseImg: 'https://pic3.zhimg.com/v2-e52354ffdbd94a8e0a7649eacd34a788_r.jpg?source=1940ef5c',
  143. id: 2,
  144. courseName: '【8月9日】《房地产中介服务规范》培训'
  145. },
  146. {
  147. courseImg: 'https://desk-fd.zol-img.com.cn/t_s960x600c5/g4/M03/00/0C/Cg-4zFS8bC-Ie9zBADCvovJAqiEAATJ8wDX__cAMK-6184.jpg',
  148. id: 3,
  149. courseName: '【已结束】《广州市房屋租赁管理规定》'
  150. },
  151. ])
  152. // 首页-导航栏
  153. const navList = ref([{
  154. id: 'notice',
  155. title: '通知公告',
  156. image: 'notice',
  157. url: '/pages/notice/notice/notice',
  158. toOtherApp: false,
  159. otherAppId: '其他小程序的appid'
  160. },
  161. {
  162. id: 'dynamic',
  163. title: '协会动态',
  164. image: 'dynamic',
  165. url: '/pages/dynamic/dynamic/dynamic',
  166. toOtherApp: false,
  167. otherAppId: '其他小程序的appid'
  168. },
  169. {
  170. id: 'guide',
  171. title: '办事指引',
  172. image: 'guide',
  173. url: '/pages/guide/guide/guide',
  174. toOtherApp: false,
  175. otherAppId: '其他小程序的appid'
  176. },
  177. {
  178. id: 'edu',
  179. title: '继续教育',
  180. image: 'edu',
  181. url: '/pages/goOnEdu/index',
  182. toOtherApp: false,
  183. otherAppId: '其他小程序的appid'
  184. },
  185. {
  186. id: 'level',
  187. title: '水平认证',
  188. image: 'level',
  189. url: '跳转页面的路径',
  190. toOtherApp: true,
  191. otherAppId: '其他小程序的appid'
  192. },
  193. {
  194. id: 'report',
  195. title: '研究报告',
  196. image: 'report',
  197. url: '/pages/researchReport/reportHome/reportHome',
  198. toOtherApp: false,
  199. otherAppId: '其他小程序的appid'
  200. },
  201. {
  202. id: 'index',
  203. title: '经理人指数',
  204. image: 'index',
  205. url: '跳转页面的路径',
  206. toOtherApp: true,
  207. otherAppId: '其他小程序的appid'
  208. },
  209. {
  210. id: 'pay',
  211. title: '会费缴交',
  212. image: 'pay',
  213. url: '跳转页面的路径',
  214. toOtherApp: true,
  215. otherAppId: '其他小程序的appid'
  216. }
  217. ])
  218. const reportList = ref(
  219. [{
  220. "id": 1,
  221. "title": "2023年7月广州市中介促成二手住宅市场交易简报",
  222. "imgUrl": "https://tse3-mm.cn.bing.net/th/id/OIP-C.YKoZzgmubNBxQ8j-mmoTKAHaEK?rs=1&pid=ImgDetMain",
  223. "type": "月度成交简报",
  224. "price": 150.80,
  225. "hasBuy": true,
  226. "memberFree": false
  227. },
  228. {
  229. "id": 2,
  230. "title": "成交有望稳中微升——2023年8月中介协会经理人指数报告经理人指数报告经理人指数报告",
  231. "imgUrl": "https://pic3.zhimg.com/v2-e52354ffdbd94a8e0a7649eacd34a788_r.jpg?source=1940ef5c",
  232. "type": "经理人指数报告",
  233. "price": 200.88,
  234. "hasBuy": false,
  235. "memberFree": false
  236. },
  237. {
  238. "id": 3,
  239. "title": "2023年6月广州市住宅租金动态监测报告",
  240. "imgUrl": "https://desk-fd.zol-img.com.cn/t_s960x600c5/g4/M03/00/0C/Cg-4zFS8bC-Ie9zBADCvovJAqiEAATJ8wDX__cAMK-6184.jpg",
  241. "type": "月度租赁简报",
  242. "price": 300.00,
  243. "hasBuy": true,
  244. "memberFree": true
  245. }
  246. ])
  247. // 跳转页面
  248. const jumpToPage = (data) => {
  249. if (data.toOtherApp) {
  250. // 跳转其他小程序
  251. console.log("跳转至其他小程序", data.otherAppId)
  252. return
  253. }
  254. if (!authStore.isAuthenticated) {
  255. loginModal.value = true
  256. return
  257. }
  258. uni.navigateTo({
  259. url: data.url
  260. })
  261. }
  262. // 确认跳转至登录
  263. const confirmModal = () => {
  264. uni.navigateTo({
  265. url: "/pages/initial/initial"
  266. })
  267. }
  268. const toPage = () => {
  269. if (!authStore.isAuthenticated) {
  270. uni.navigateTo({
  271. url: "/pages/initial/initial"
  272. })
  273. return
  274. }
  275. }
  276. const itemClick = (data) =>{
  277. console.log("swiper", data)
  278. }
  279. const swiperClick = (data) => {
  280. console.log(data, "课程预告数据")
  281. }
  282. function initUser() {
  283. me().then(res => {
  284. if (res?.data) {
  285. authStore.setUserInfo(res.data);
  286. isMember.value = res.data.isMember;
  287. }
  288. })
  289. }
  290. function init() {
  291. homeSwiperList().then(res => {
  292. if (res?.data) {
  293. swiperList.value = res.data
  294. }
  295. })
  296. homeCourseList().then(res => {
  297. // console.log(1000, res.data)
  298. if (res?.data) {
  299. courseList.value = res.data
  300. console.log(courseList.value)
  301. }
  302. })
  303. homeReportList().then(res => {
  304. if (res?.data) {
  305. reportList.value = res.data
  306. }
  307. })
  308. // homeSetting().then(res=>{
  309. // console.log(res)
  310. // })
  311. }
  312. function getCharCount() {
  313. count().then(res => {
  314. if (res && res.message === 'success') {
  315. uni.setTabBarBadge({ //显示数字
  316. index: 1, //tabbar下标
  317. text: `${res.data.amount}` ?? '0' //数字
  318. })
  319. }
  320. })
  321. }
  322. onReady(() => {
  323. uni.getSystemInfo({
  324. success(e) {
  325. statusBarHeight.value = e.statusBarHeight;
  326. let custom = uni.getMenuButtonBoundingClientRect();
  327. navBarHeight.value = custom.height + (custom.top - e.statusBarHeight) * 2;
  328. }
  329. })
  330. })
  331. onLoad(() => {
  332. init()
  333. // initUser()
  334. })
  335. onShow(() => {
  336. const isLogin = authStore.isAuthenticated;
  337. const isUserInfo = authStore.isUserInfo;
  338. if (isLogin) {
  339. // 登录后才请求消息数量
  340. getCharCount()
  341. // 没有用户信息就加载一边
  342. if (!isUserInfo) {
  343. initUser();
  344. } else {
  345. isMember.value = authStore.userInfo.isMember;
  346. }
  347. }
  348. })
  349. </script>
  350. <style lang="scss" scoped>
  351. .container {
  352. width: 100vw;
  353. background-color: $uni-bg-color;
  354. padding: 0 20rpx 5rpx;
  355. }
  356. .slot-wrap {
  357. padding-left: 20rpx;
  358. }
  359. .grid-text {
  360. font-size: 28rpx;
  361. margin-top: 4rpx;
  362. color: $uni-text-color;
  363. }
  364. .u-card-wrap {
  365. background-color: $u-bg-color;
  366. padding: 1px;
  367. }
  368. .u-body-item {
  369. font-size: 32rpx;
  370. color: #333;
  371. margin-bottom: 30rpx;
  372. height: 140rpx;
  373. &:last-of-type {
  374. margin-bottom: 0;
  375. }
  376. .u-body-item-content {
  377. position: relative;
  378. flex: 1;
  379. /* 剩余空间占用 Flex 规则 */
  380. min-width: 0;
  381. // width: 100%;
  382. height: inherit;
  383. .item-content text {
  384. width: inherit;
  385. font-size: $uni-font-size-2;
  386. display: block;
  387. margin: 10rpx;
  388. color: $uni-text-color;
  389. }
  390. .item-content .item-content-title {
  391. font-size: $uni-title-font-size-2;
  392. }
  393. .item-content .item-content-price {
  394. color: $uni-color-error;
  395. // font-weight: bold;
  396. }
  397. .item-button {
  398. position: absolute;
  399. right: 0;
  400. bottom: 0;
  401. font-size: 22rpx;
  402. .item-button-huiyuan {
  403. padding: 15rpx 0 5rpx;
  404. text-align: center;
  405. width: 150rpx;
  406. background-image: url('https://sylwt.top/api/visitor/resources/image?name=/ydl/menber-center/bg-label.png');
  407. background-size: cover;
  408. background-repeat: no-repeat;
  409. // background-position: center;
  410. }
  411. .item-button-goumai {
  412. padding: 5rpx 0;
  413. text-align: center;
  414. width: 150rpx;
  415. background-color: #fe0000;
  416. border-radius: 30rpx;
  417. color: #fff;
  418. }
  419. .item-button-yiGouMai {
  420. text-align: center;
  421. width: 150rpx;
  422. padding: 5rpx 0;
  423. background-color: #006af4;
  424. border-radius: 30rpx;
  425. color: #fff;
  426. }
  427. }
  428. }
  429. image {
  430. width: 200rpx;
  431. flex: 0 0 200rpx;
  432. height: 100%;
  433. border-radius: 20rpx;
  434. margin-right: 12rpx;
  435. }
  436. }
  437. .course-swiper {
  438. height: 200px;
  439. .swiper-item {
  440. width: 33.33%;
  441. height: 200px;
  442. /* 三个一排,宽度为三分之一 */
  443. transition: transform 0.3s ease;
  444. /* 加入过渡效果 */
  445. display: flex;
  446. flex-direction: column;
  447. align-items: center;
  448. justify-content: center;
  449. }
  450. .swiper-item.active {
  451. transform: scale(2);
  452. /* 主项放大 */
  453. }
  454. image {
  455. width: 80%;
  456. /* 图片宽度 */
  457. height: auto;
  458. }
  459. text {
  460. margin-top: 10px;
  461. }
  462. }
  463. .text-ellipsis {
  464. overflow: hidden;
  465. /* 隐藏超出内容 */
  466. white-space: nowrap;
  467. /* 禁止换行 */
  468. text-overflow: ellipsis;
  469. }
  470. .swiper-container {
  471. perspective: 1000px;
  472. }
  473. .swiper-item {
  474. transition: transform 0.5s;
  475. transform-style: preserve-3d;
  476. /* 其他样式 */
  477. }
  478. .content {
  479. backface-visibility: hidden;
  480. /* 确保背面不可见 */
  481. display: flex;
  482. justify-content: center;
  483. align-items: center;
  484. height: 200px;
  485. /* 设置高度 */
  486. font-size: 24px;
  487. color: white;
  488. background: linear-gradient(45deg, #ff5858, #f09819);
  489. /* 示例背景 */
  490. }
  491. // 登录模拟态
  492. .modal {
  493. .modal-content {
  494. padding: 50rpx;
  495. .content-a {
  496. color: #2979ff;
  497. }
  498. }
  499. }
  500. </style>