index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539
  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. uni.navigateTo({
  279. url: "/pages/swiperDetail/swiperDetail?id=" + data.id
  280. })
  281. }
  282. const swiperClick = (data) => {
  283. console.log(data, "课程预告数据")
  284. }
  285. function initUser() {
  286. me().then(res => {
  287. if (res?.data) {
  288. authStore.setUserInfo(res.data);
  289. isMember.value = res.data.isMember;
  290. }
  291. })
  292. }
  293. function init() {
  294. homeSwiperList().then(res => {
  295. if (res?.data) {
  296. swiperList.value = res.data
  297. }
  298. })
  299. homeCourseList().then(res => {
  300. // console.log(1000, res.data)
  301. if (res?.data) {
  302. courseList.value = res.data
  303. console.log(courseList.value)
  304. }
  305. })
  306. homeReportList().then(res => {
  307. if (res?.data) {
  308. reportList.value = res.data
  309. }
  310. })
  311. // homeSetting().then(res=>{
  312. // console.log(res)
  313. // })
  314. }
  315. function getCharCount() {
  316. count().then(res => {
  317. if (res && res.message === 'success') {
  318. uni.setTabBarBadge({ //显示数字
  319. index: 1, //tabbar下标
  320. text: `${res.data.amount}` ?? '0' //数字
  321. })
  322. }
  323. })
  324. }
  325. onReady(() => {
  326. uni.getSystemInfo({
  327. success(e) {
  328. statusBarHeight.value = e.statusBarHeight;
  329. let custom = uni.getMenuButtonBoundingClientRect();
  330. navBarHeight.value = custom.height + (custom.top - e.statusBarHeight) * 2;
  331. }
  332. })
  333. })
  334. onLoad(() => {
  335. init()
  336. // initUser()
  337. })
  338. onShow(() => {
  339. const isLogin = authStore.isAuthenticated;
  340. const isUserInfo = authStore.isUserInfo;
  341. if (isLogin) {
  342. // 登录后才请求消息数量
  343. getCharCount()
  344. // 没有用户信息就加载一边
  345. if (!isUserInfo) {
  346. initUser();
  347. } else {
  348. isMember.value = authStore.userInfo.isMember;
  349. }
  350. }
  351. })
  352. </script>
  353. <style lang="scss" scoped>
  354. .container {
  355. width: 100vw;
  356. background-color: $uni-bg-color;
  357. padding: 0 20rpx 5rpx;
  358. }
  359. .slot-wrap {
  360. padding-left: 20rpx;
  361. }
  362. .grid-text {
  363. font-size: 28rpx;
  364. margin-top: 4rpx;
  365. color: $uni-text-color;
  366. }
  367. .u-card-wrap {
  368. background-color: $u-bg-color;
  369. padding: 1px;
  370. }
  371. .u-body-item {
  372. font-size: 32rpx;
  373. color: #333;
  374. margin-bottom: 30rpx;
  375. height: 140rpx;
  376. &:last-of-type {
  377. margin-bottom: 0;
  378. }
  379. .u-body-item-content {
  380. position: relative;
  381. flex: 1;
  382. /* 剩余空间占用 Flex 规则 */
  383. min-width: 0;
  384. // width: 100%;
  385. height: inherit;
  386. .item-content text {
  387. width: inherit;
  388. font-size: $uni-font-size-2;
  389. display: block;
  390. margin: 10rpx;
  391. color: $uni-text-color;
  392. }
  393. .item-content .item-content-title {
  394. font-size: $uni-title-font-size-2;
  395. }
  396. .item-content .item-content-price {
  397. color: $uni-color-error;
  398. // font-weight: bold;
  399. }
  400. .item-button {
  401. position: absolute;
  402. right: 0;
  403. bottom: 0;
  404. font-size: 22rpx;
  405. .item-button-huiyuan {
  406. padding: 15rpx 0 5rpx;
  407. text-align: center;
  408. width: 150rpx;
  409. background-image: url('https://sylwt.top/api/visitor/resources/image?name=/ydl/menber-center/bg-label.png');
  410. background-size: cover;
  411. background-repeat: no-repeat;
  412. // background-position: center;
  413. }
  414. .item-button-goumai {
  415. padding: 5rpx 0;
  416. text-align: center;
  417. width: 150rpx;
  418. background-color: #fe0000;
  419. border-radius: 30rpx;
  420. color: #fff;
  421. }
  422. .item-button-yiGouMai {
  423. text-align: center;
  424. width: 150rpx;
  425. padding: 5rpx 0;
  426. background-color: #006af4;
  427. border-radius: 30rpx;
  428. color: #fff;
  429. }
  430. }
  431. }
  432. image {
  433. width: 200rpx;
  434. flex: 0 0 200rpx;
  435. height: 100%;
  436. border-radius: 20rpx;
  437. margin-right: 12rpx;
  438. }
  439. }
  440. .course-swiper {
  441. height: 200px;
  442. .swiper-item {
  443. width: 33.33%;
  444. height: 200px;
  445. /* 三个一排,宽度为三分之一 */
  446. transition: transform 0.3s ease;
  447. /* 加入过渡效果 */
  448. display: flex;
  449. flex-direction: column;
  450. align-items: center;
  451. justify-content: center;
  452. }
  453. .swiper-item.active {
  454. transform: scale(2);
  455. /* 主项放大 */
  456. }
  457. image {
  458. width: 80%;
  459. /* 图片宽度 */
  460. height: auto;
  461. }
  462. text {
  463. margin-top: 10px;
  464. }
  465. }
  466. .text-ellipsis {
  467. overflow: hidden;
  468. /* 隐藏超出内容 */
  469. white-space: nowrap;
  470. /* 禁止换行 */
  471. text-overflow: ellipsis;
  472. }
  473. .swiper-container {
  474. perspective: 1000px;
  475. }
  476. .swiper-item {
  477. transition: transform 0.5s;
  478. transform-style: preserve-3d;
  479. /* 其他样式 */
  480. }
  481. .content {
  482. backface-visibility: hidden;
  483. /* 确保背面不可见 */
  484. display: flex;
  485. justify-content: center;
  486. align-items: center;
  487. height: 200px;
  488. /* 设置高度 */
  489. font-size: 24px;
  490. color: white;
  491. background: linear-gradient(45deg, #ff5858, #f09819);
  492. /* 示例背景 */
  493. }
  494. // 登录模拟态
  495. .modal {
  496. .modal-content {
  497. padding: 50rpx;
  498. .content-a {
  499. color: #2979ff;
  500. }
  501. }
  502. }
  503. </style>