index.vue 12 KB

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