index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709
  1. <template>
  2. <view class="container" :style="{backgroundColor: `${backgroundColor}`}">
  3. <u-navbar :is-back="false" title="" :style="{backgroundColor: `${backgroundColor}`}" :border-bottom="false">
  4. <view class="slot-wrap">
  5. <image :src="`${FILE_URL}/login-icon.png`" mode="aspectFit" style="width: 300rpx;"></image>
  6. </view>
  7. </u-navbar>
  8. <!-- <u-link href="http://www.uviewui.com">蜀道难,难于上青天</u-link> -->
  9. <view class="page-content">
  10. <swiper class="swiper"
  11. autoplay
  12. :interval="5000"
  13. :duration="500"
  14. circular indicator-dots style="border-radius: 20rpx;overflow: hidden;height: 200px">
  15. <swiper-item v-for="(data, index) in swiperList"
  16. style="width: 100%;height: 100%;" :key="index">
  17. <view class="swiper-item" style="width: 100%;height: 100%;" @click="itemClick(data)">
  18. <image :src="data.imgUrl" mode="aspectFill" style="width: 100%;height: 100%;"></image>
  19. </view>
  20. </swiper-item>
  21. </swiper>
  22. <u-grid :col="4" :border="false" style="margin: 10rpx 0 ;">
  23. <template v-for="(item,index) in navList" :key="index">
  24. <u-grid-item bg-color="none" @click="jumpToPage(item)" class="menu-item">
  25. <i :class="['iconfont', `${item.icon}`]" :style="{ color: `${tabbarActiveColor}` }"></i>
  26. <view class="grid-text">{{item.title}}</view>
  27. </u-grid-item>
  28. </template>
  29. </u-grid>
  30. <u-card padding="20" margin="0rpx 0rpx 30rpx" border-radius="20"
  31. box-shadow="0px 2px 5px rgba(0, 0, 0, 0.1)">
  32. <template v-slot:head>
  33. <u-section title="课程预告" sub-title="查看更多" sub-color="#000000"
  34. @click="toPage('/pages/goOnEdu/index')"></u-section>
  35. </template>
  36. <template v-slot:body>
  37. <lg-swiper v-if="courseList.length!=0" :sildeItems="courseList" @swiperClick="swiperClick"
  38. image="thumImg" title="title"></lg-swiper>
  39. <u-empty text="暂无内容" mode="data" v-else></u-empty>
  40. </template>
  41. </u-card>
  42. <u-card padding="30" margin="0rpx 0rpx 30rpx" border-radius="20"
  43. box-shadow="0px 2px 5px rgba(0, 0, 0, 0.1)">
  44. <template v-slot:head>
  45. <u-section title="研究报告" sub-title="查看更多" sub-color="#000000"
  46. @click="toPage('/pages/researchReport/reportHome/reportHome')"></u-section>
  47. </template>
  48. <template v-slot:body>
  49. <view v-if="reportList.length!=0">
  50. <view v-for="(data,index) in reportList" :key="index" class="u-body-item u-flex u-p-t-0 "
  51. style="align-items: inherit;" @click="toReport(data.id, data.title)">
  52. <image :src="data.cover" mode="aspectFill"></image>
  53. <view class="u-body-item-content">
  54. <view class="item-content">
  55. <text class="item-content-title text-ellipsis">{{data.title}}</text>
  56. <text class="item-content-type">{{data.type}}</text>
  57. </view>
  58. <view class="item-button">
  59. <view v-if="data.viewMode==='1'" class="func-box"
  60. style="justify-content: flex-end;">
  61. <view class="button free">免费</view>
  62. </view>
  63. <view v-else-if="data.viewMode==='2' && isMember" class="func-box">
  64. <view class="price">¥{{ data.price }}元</view>
  65. <view class="button member-free">会员免费</view>
  66. </view>
  67. <view v-else-if="data.viewMode==='2' && !isMember" class="func-box">
  68. <view style="flex: 0 0 auto;display: flex;align-items: center;">
  69. <view class="member-free">
  70. 会员免费
  71. </view>
  72. <view class="not-member-price">
  73. 非会员:¥{{data.price}}元
  74. </view>
  75. </view>
  76. <view :class="['button', data.hasBuy ? 'free' : 'buy']">
  77. {{data.hasBuy ? '已购买' : '立即购买'}}
  78. </view>
  79. </view>
  80. <view v-else-if="data.viewMode==='3' && data.price===data.priceMember"
  81. class="func-box">
  82. <view class="price">¥{{ data.price }}元</view>
  83. <view :class="['button', data.hasBuy ? 'free' : 'buy']">
  84. {{data.hasBuy ? '已购买' : '立即购买'}}
  85. </view>
  86. </view>
  87. <view v-else-if="data.viewMode==='3' && data.price!==data.priceMember"
  88. class="func-box">
  89. <view style="flex: 0 0 auto;display: flex;align-items: center;">
  90. <view class="member-free">
  91. {{`会员:${data.priceMember}元`}}
  92. </view>
  93. <view class="not-member-price">
  94. 非会员:¥{{data.price}}元
  95. </view>
  96. </view>
  97. <view :class="['button', data.hasBuy ? 'free' : 'buy']">
  98. {{data.hasBuy ? '已购买' : '立即购买'}}
  99. </view>
  100. </view>
  101. </view>
  102. </view>
  103. </view>
  104. </view>
  105. <u-empty text="暂无内容" mode="data" v-else></u-empty>
  106. </template>
  107. </u-card>
  108. </view>
  109. <u-modal v-model="loginModal" mask-close-able class="modal" show-cancel-button
  110. :title-style="{fontWeight: 'bold'}" @confirm="confirmModal">
  111. <view class="modal-content">
  112. <text>请登录后使用该功能</text>
  113. </view>
  114. </u-modal>
  115. <!-- 与包裹页面所有内容的元素u-page同级,且在它的下方 -->
  116. <u-tabbar v-model="tabbarCurrentIndex" :list="tabbarList" icon-size="50" :active-color="tabbarActiveColor"
  117. :inactive-color="tabbarInactiveColor"></u-tabbar>
  118. </view>
  119. </template>
  120. <script setup>
  121. import lgSwiper from '@/components/lgSwiper.vue'
  122. import {
  123. onMounted,
  124. ref,
  125. computed
  126. } from 'vue'
  127. import {
  128. onReady,
  129. onLoad,
  130. onShow,
  131. onShareAppMessage
  132. } from '@dcloudio/uni-app'
  133. import {
  134. useAuthStore
  135. } from '@/store/authStore'
  136. import {
  137. count
  138. } from '@/api/chat.js'
  139. import {
  140. homeCourseList,
  141. homeReportList,
  142. homeSetting,
  143. homeSwiperList,
  144. loadJlrzsUrl
  145. } from '@/api/home.js'
  146. import {
  147. me
  148. } from '@/api/user.js'
  149. import configService from '@/utils/baseurl.js'
  150. const FILE_URL = configService.FILE_URL;
  151. import {
  152. useTabbarStore
  153. } from '@/store/tabbarStore.js'
  154. import { msg, msgSuccess } from '../../utils/common'
  155. const tabbarStore = useTabbarStore()
  156. // 底部导航栏数据
  157. const tabbarList = computed(() => {
  158. return tabbarStore.list
  159. })
  160. // 底部导航栏选中颜色
  161. const tabbarActiveColor = computed(() => {
  162. return tabbarStore.activeColor
  163. })
  164. const backgroundColor = computed(() => {
  165. return tabbarStore.backgroundColor
  166. })
  167. // 底部导航栏未选中颜色
  168. const tabbarInactiveColor = computed(() => {
  169. return tabbarStore.inactiveColor
  170. })
  171. const tabbarCurrentIndex = 0
  172. const jlrzsUrl = ref(null)
  173. const authStore = useAuthStore()
  174. // 屏幕状态栏高度
  175. const statusBarHeight = ref(0)
  176. // 顶部导航栏高度
  177. const navBarHeight = ref(0)
  178. // 是否登录
  179. const loginModal = ref(false)
  180. // 是否为会员,从缓存里拿取用户信息
  181. // const userInfo = uni.getStorageSync("userinfo") || {}
  182. const isMemberMap = {
  183. 0: true,
  184. 1: false
  185. }
  186. const isMember = ref(false)
  187. // 首页-轮播图
  188. const swiperList = ref([])
  189. const courseList = ref([{
  190. courseImg: 'https://tse3-mm.cn.bing.net/th/id/OIP-C.YKoZzgmubNBxQ8j-mmoTKAHaEK?rs=1&pid=ImgDetMain',
  191. id: 1,
  192. courseName: '【8月8日】房地产经纪进阶培训班'
  193. },
  194. {
  195. courseImg: 'https://pic3.zhimg.com/v2-e52354ffdbd94a8e0a7649eacd34a788_r.jpg?source=1940ef5c',
  196. id: 2,
  197. courseName: '【8月9日】《房地产中介服务规范》培训'
  198. },
  199. {
  200. courseImg: 'https://desk-fd.zol-img.com.cn/t_s960x600c5/g4/M03/00/0C/Cg-4zFS8bC-Ie9zBADCvovJAqiEAATJ8wDX__cAMK-6184.jpg',
  201. id: 3,
  202. courseName: '【已结束】《广州市房屋租赁管理规定》'
  203. },
  204. ])
  205. // 首页-导航栏
  206. const navList = ref([{
  207. id: 'notice',
  208. isLogin: false,
  209. title: '通知公告',
  210. icon: 'icon-xiaoxitongzhi',
  211. url: '/pages/notice/notice/notice',
  212. toOtherApp: false,
  213. otherAppId: '其他小程序的appid'
  214. },
  215. {
  216. id: 'dynamic',
  217. title: '协会动态',
  218. isLogin: false,
  219. icon: 'icon-xinxisousuo-01',
  220. url: '/pages/dynamic/dynamic/dynamic',
  221. toOtherApp: false,
  222. otherAppId: '其他小程序的appid'
  223. },
  224. {
  225. id: 'guide',
  226. title: '办事指引',
  227. isLogin: false,
  228. icon: 'icon-caidanguanli',
  229. url: '/pages/guide/guide/guide',
  230. toOtherApp: false,
  231. otherAppId: '其他小程序的appid'
  232. },
  233. {
  234. id: 'edu',
  235. title: '行业培训',
  236. isLogin: true,
  237. icon: 'icon-xueshimao1',
  238. url: '/pages/goOnEdu/index',
  239. toOtherApp: false,
  240. otherAppId: '其他小程序的appid'
  241. },
  242. {
  243. id: 'level',
  244. isLogin: true,
  245. title: '水平认证',
  246. icon: 'icon-zhengshu-copy',
  247. url: 'pages/index/index',
  248. toOtherApp: true,
  249. otherAppId: 'wx050c17d8b239da86'
  250. },
  251. {
  252. id: 'report',
  253. title: '研究报告',
  254. isLogin: true,
  255. icon: 'icon-circular',
  256. url: '/pages/researchReport/reportHome/reportHome',
  257. toOtherApp: false,
  258. otherAppId: '其他小程序的appid'
  259. },
  260. {
  261. id: 'index',
  262. isLogin: true,
  263. title: '经理人指数',
  264. icon: 'icon-zhishu',
  265. url: '跳转页面的路径',
  266. toOtherApp: false,
  267. otherAppId: '其他小程序的appid'
  268. },
  269. {
  270. id: 'pay',
  271. isLogin: true,
  272. title: '会费缴交',
  273. icon: 'icon-shangchuanchenggong',
  274. url: '/pages/huifeijiaojiaoRukou/huifeijiaojiaoRukou',
  275. toOtherApp: false,
  276. otherAppId: '其他小程序的appid'
  277. }
  278. ])
  279. const reportList = ref([])
  280. // 跳转页面
  281. const jumpToPage = (data) => {
  282. if (data.toOtherApp) {
  283. // 跳转其他小程序
  284. wx.navigateToMiniProgram({
  285. appId: data.otherAppId, // 例如:wx1234567890abcdef
  286. path: data.url, // 跳转路径
  287. envVersion: 'release', // 版本(develop/trial/release)
  288. success(res) {
  289. console.log('跳转成功');
  290. },
  291. fail(err) {
  292. console.error('跳转失败', err);
  293. }
  294. });
  295. return
  296. }
  297. if (data.isLogin) {
  298. if (!authStore.isAuthenticated) {
  299. loginModal.value = true
  300. return
  301. }
  302. }
  303. if (data.id === 'index') {
  304. // jlrzsUrl.value = 'https://www.gzrea.cn:8089/start/534C6DA13FDBAD13479F099E9FC873DF/4D3433353936/'
  305. const src = encodeURIComponent(jlrzsUrl.value);
  306. uni.navigateTo({
  307. url: `/pages/webview/webview?url=${src}`
  308. });
  309. // uni.setClipboardData({
  310. // data: jlrzsUrl.value,
  311. // success: function () {
  312. // msg("链接已复制,请在浏览器中打开")
  313. // }
  314. // });
  315. return
  316. }
  317. uni.navigateTo({
  318. url: data.url
  319. })
  320. }
  321. // 确认跳转至登录
  322. const confirmModal = () => {
  323. uni.navigateTo({
  324. url: "/pages/initial/initial"
  325. })
  326. }
  327. const toPage = (url) => {
  328. if (!authStore.isAuthenticated) {
  329. loginModal.value = true
  330. return
  331. }
  332. uni.navigateTo({
  333. url: url
  334. })
  335. }
  336. const itemClick = (data) => {
  337. // console.log("轮播图swiper", data)
  338. if (!authStore.isAuthenticated) {
  339. loginModal.value = true
  340. return
  341. }
  342. uni.navigateTo({
  343. url: "/pages/swiperDetail/swiperDetail?id=" + data.id
  344. })
  345. }
  346. const swiperClick = (data) => {
  347. // console.log(data, "课程预告数据")
  348. if (!authStore.isAuthenticated) {
  349. loginModal.value = true
  350. return
  351. }
  352. uni.navigateTo({
  353. url: `/pages/goOnEdu/course/courseDetail/courseDetail?id=${data.id}&title=${data.title}`
  354. });
  355. }
  356. function initUser() {
  357. me().then(res => {
  358. if (res?.data) {
  359. authStore.setUserInfo(res.data);
  360. isMember.value = res.data.isMember;
  361. }
  362. })
  363. }
  364. function init() {
  365. homeSwiperList().then(res => {
  366. if (res?.data) {
  367. swiperList.value = res.data
  368. }
  369. })
  370. homeCourseList().then(res => {
  371. // console.log(1000, res.data)
  372. if (res?.data) {
  373. courseList.value = res.data
  374. }
  375. })
  376. initReport()
  377. // homeSetting().then(res=>{
  378. // console.log(res)
  379. // })
  380. }
  381. function initReport() {
  382. homeReportList().then(res => {
  383. if (res?.data) {
  384. reportList.value = res.data
  385. }
  386. })
  387. }
  388. function getCharCount() {
  389. count().then(res => {
  390. if (res && res.code === 0) {
  391. tabbarStore.setMessageCount(res.data.amount)
  392. uni.setTabBarBadge({ //显示数字
  393. index: 1, //tabbar下标
  394. text: `${res.data.amount}` ?? '0' //数字
  395. })
  396. }
  397. })
  398. }
  399. function toReport(id, title) {
  400. if (!authStore.isAuthenticated) {
  401. loginModal.value = true
  402. return
  403. }
  404. uni.navigateTo({
  405. url: "/pages/reportDetail/reportDetail?id=" + id + "&title=" + title
  406. })
  407. }
  408. function loadUrl() {
  409. loadJlrzsUrl().then(res => {
  410. if (res && res.code === 0) {
  411. jlrzsUrl.value = res.data.url
  412. }
  413. })
  414. }
  415. onReady(() => {
  416. uni.getSystemInfo({
  417. success(e) {
  418. statusBarHeight.value = e.statusBarHeight;
  419. let custom = uni.getMenuButtonBoundingClientRect();
  420. navBarHeight.value = custom.height + (custom.top - e.statusBarHeight) * 2;
  421. }
  422. })
  423. })
  424. // 测试
  425. // onShareAppMessage(async (res) => {
  426. // // console.log(processedImage)
  427. // return {
  428. // title: 'fenxiang',
  429. // path: `/pages/index/index`,
  430. // imageUrl: 'https://www.gzrea.org.cn/upload/news/2025/07/08b94d42b95bed40c987fe252852ba348ace99348105088a.jpg'
  431. // };
  432. // })
  433. onLoad(() => {
  434. init()
  435. // uni.setBackgroundColor({
  436. // backgroundColor: '#ffff7f',
  437. // });
  438. // initUser()
  439. })
  440. onShow(() => {
  441. const isLogin = authStore.isAuthenticated;
  442. const isUserInfo = authStore.isUserInfo;
  443. if (isLogin) {
  444. // 登录后才请求消息数量
  445. getCharCount()
  446. initReport()
  447. if(!jlrzsUrl.value){
  448. loadUrl()
  449. }
  450. // 没有用户信息就加载一边
  451. if (!isUserInfo) {
  452. initUser();
  453. } else {
  454. isMember.value = authStore.userInfo.isMember === '0' ? false : true;
  455. }
  456. }
  457. })
  458. </script>
  459. <style lang="scss" scoped>
  460. .container {
  461. width: 100vw;
  462. // background-color: $uni-bg-color;
  463. padding: 0 20rpx 5rpx;
  464. }
  465. .slot-wrap {
  466. padding-left: 20rpx;
  467. }
  468. .menu-item {
  469. .iconfont {
  470. font-size: 60rpx;
  471. }
  472. }
  473. .grid-text {
  474. font-size: 28rpx;
  475. margin-top: 4rpx;
  476. color: $uni-text-color;
  477. }
  478. .u-card-wrap {
  479. background-color: $u-bg-color;
  480. padding: 1px;
  481. }
  482. .u-body-item {
  483. font-size: 32rpx;
  484. color: #333;
  485. margin-bottom: 30rpx;
  486. height: 140rpx;
  487. &:last-of-type {
  488. margin-bottom: 0;
  489. }
  490. .u-body-item-content {
  491. position: relative;
  492. flex: 1;
  493. /* 剩余空间占用 Flex 规则 */
  494. min-width: 0;
  495. // width: 100%;
  496. height: inherit;
  497. .item-content text {
  498. width: inherit;
  499. font-size: $uni-font-size-2;
  500. display: block;
  501. margin: 10rpx;
  502. color: $uni-text-color;
  503. }
  504. .item-content .item-content-title {
  505. font-size: $uni-title-font-size-2;
  506. }
  507. .item-content .item-content-price {
  508. color: $uni-color-error;
  509. // font-weight: bold;
  510. }
  511. .item-button {
  512. width: 100%;
  513. .item-button-huiyuan {
  514. padding: 15rpx 0 5rpx;
  515. text-align: center;
  516. width: 150rpx;
  517. background-image: url('http://www.gzrea.org.cn:8543/icon/wxmp/bg-label.png');
  518. background-size: cover;
  519. background-repeat: no-repeat;
  520. // background-position: center;
  521. }
  522. .item-button-goumai {
  523. padding: 5rpx 0;
  524. text-align: center;
  525. width: 150rpx;
  526. background-color: #fe0000;
  527. border-radius: 30rpx;
  528. color: #fff;
  529. }
  530. .item-button-yiGouMai {
  531. text-align: center;
  532. width: 150rpx;
  533. padding: 5rpx 0;
  534. background-color: #006af4;
  535. border-radius: 30rpx;
  536. color: #fff;
  537. }
  538. }
  539. }
  540. image {
  541. width: 200rpx;
  542. flex: 0 0 200rpx;
  543. height: 100%;
  544. border-radius: 20rpx;
  545. margin-right: 12rpx;
  546. }
  547. }
  548. .course-swiper {
  549. height: 200px;
  550. .swiper-item {
  551. width: 33.33%;
  552. height: 200px;
  553. /* 三个一排,宽度为三分之一 */
  554. transition: transform 0.3s ease;
  555. /* 加入过渡效果 */
  556. display: flex;
  557. flex-direction: column;
  558. align-items: center;
  559. justify-content: center;
  560. }
  561. .swiper-item.active {
  562. transform: scale(2);
  563. /* 主项放大 */
  564. }
  565. image {
  566. width: 80%;
  567. /* 图片宽度 */
  568. height: auto;
  569. }
  570. text {
  571. margin-top: 10px;
  572. }
  573. }
  574. .text-ellipsis {
  575. overflow: hidden;
  576. /* 隐藏超出内容 */
  577. white-space: nowrap;
  578. /* 禁止换行 */
  579. text-overflow: ellipsis;
  580. }
  581. .swiper-container {
  582. perspective: 1000px;
  583. }
  584. .swiper-item {
  585. transition: transform 0.5s;
  586. transform-style: preserve-3d;
  587. /* 其他样式 */
  588. }
  589. .content {
  590. backface-visibility: hidden;
  591. /* 确保背面不可见 */
  592. display: flex;
  593. justify-content: center;
  594. align-items: center;
  595. height: 200px;
  596. /* 设置高度 */
  597. font-size: 24px;
  598. color: white;
  599. background: linear-gradient(45deg, #ff5858, #f09819);
  600. /* 示例背景 */
  601. }
  602. // 登录模拟态
  603. .modal {
  604. .modal-content {
  605. padding: 50rpx;
  606. .content-a {
  607. color: #2979ff;
  608. }
  609. }
  610. }
  611. .item-button {
  612. display: flex;
  613. justify-content: space-between;
  614. align-items: flex-end;
  615. font-size: $uni-font-size-2;
  616. font-weight: bold;
  617. margin-top: 10rpx;
  618. .func-box {
  619. display: flex;
  620. justify-content: space-between;
  621. width: 100%;
  622. align-items: center;
  623. }
  624. .button {
  625. text-align: center;
  626. width: 130rpx;
  627. }
  628. .price {
  629. color: $uni-color-error;
  630. font-size: $uni-title-font-size-3;
  631. }
  632. .not-member-price {
  633. font-size: $uni-font-size-4;
  634. color: $uni-text-color-grey;
  635. text-align: end;
  636. }
  637. .buy {
  638. padding: 6rpx 25rpx;
  639. background-color: $uni-color-error;
  640. border-radius: $uni-card-border-radius;
  641. color: $uni-text-color-inverse;
  642. }
  643. .free {
  644. padding: 6rpx 25rpx;
  645. background-color: $uni-color-primary;
  646. border-radius: $uni-card-border-radius;
  647. color: $uni-text-color-inverse;
  648. }
  649. .member-free {
  650. padding: 10rpx 20rpx;
  651. @include backgroundImg('http://www.gzrea.org.cn:8543/icon/wxmp/bg-label.png');
  652. color: $uni-text-color;
  653. }
  654. }
  655. </style>