index.vue 17 KB

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