index.vue 17 KB

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