四零语境前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

711 lines
16 KiB

1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
  1. <template>
  2. <view class="container">
  3. <view class="header">
  4. <!-- #ifndef H5 -->
  5. <view class="header-bg">
  6. <image
  7. src="/static/会员背景.png"
  8. class="header-img"
  9. mode="scaleToFill"
  10. />
  11. <text class="header-title">会员中心</text>
  12. </view>
  13. <!-- #endif -->
  14. <view class="header-content">
  15. <view class="zuanshi">
  16. <image
  17. src="/static/会员钻石.png"
  18. mode="scaleToFill"
  19. class="zuanshi-img"
  20. />
  21. </view>
  22. <view v-if="!isMember" class="noVip-container">
  23. <image
  24. src="/static/VIP.png"
  25. mode="aspectFit"
  26. class="VIP-img"
  27. />
  28. <text class="intro" >共19项会员特权 | 3 项年VIP专属特权</text>
  29. <view class="border" ></view>
  30. <view class="info" >
  31. <view class="avatar-box">
  32. <image
  33. :src="userInfo.avatar"
  34. mode="aspectFill"
  35. class="avatar"
  36. />
  37. <text class="name">{{userInfo.name}}</text>
  38. </view>
  39. <uv-button :text="isLogin ? '立即开通' : '前往登陆'"
  40. @click="goRecharge"
  41. type="primary"
  42. :customStyle="{
  43. width: '160rpx',
  44. height: '60rpx',
  45. borderRadius: '198rpx',
  46. backgroundColor: '#06DADC',
  47. color: '#fff',
  48. fontSize: '28rpx',
  49. fontWeight: '500',
  50. lineHeight: '60rpx',
  51. letterSpacing: '0%',
  52. verticalAlign: 'middle',
  53. }" />
  54. </view>
  55. </view>
  56. <view v-else>
  57. <!-- 代码加在这里 -->
  58. <view class="vip-container " >
  59. <view class="avatar-box ">
  60. <image
  61. :src="userInfo.avatar"
  62. mode="aspectFill"
  63. class="avatar"
  64. />
  65. <text class="name">{{userInfo.name}}</text>
  66. <text class="time">{{memberInfo[0].endTime.split(' ')[0]}}</text>
  67. </view>
  68. <view class="border" ></view>
  69. <view class="project">{{ memberInfo[0].memberTitle }}</view>
  70. <text class="res-time">{{ '预计剩余学习' + $utils.calculateDateDifference(memberInfo[0].endTime.split(' ')[0]) + '天'}}</text>
  71. </view>
  72. </view>
  73. </view>
  74. </view>
  75. <!-- 会员权益 -->
  76. <view class="benefits-section" v-if="!isMember">
  77. <view class="benefits-title">会员权益</view>
  78. <view class="benefits-list">
  79. <!-- 碎片学习 系统掌握 -->
  80. <view class="benefit-item" v-for="(item, index) in memberBenefits" :key="index">
  81. <uv-parse :content="item"></uv-parse>
  82. </view>
  83. <!-- 匹配水平 -->
  84. <!-- <view class="benefit-item">
  85. <view class="benefit-content">
  86. <view class="benefit-title">匹配水平</view>
  87. <view class="benefit-desc">依据水平精准推课不做无用功快速提升</view>
  88. </view>
  89. <view class="benefit-icon">
  90. <image src="/static/会员图片2.png" mode="aspectFit"></image>
  91. </view>
  92. </view> -->
  93. <!-- 科学闭环测 讲练结合 -->
  94. <!-- <view class="benefit-item">
  95. <view class="benefit-content">
  96. <view class="benefit-title">科学闭环测 讲练结合</view>
  97. <view class="benefit-desc">精心设计科学的学习流程 测试-讲解-练习-检验知识掌握更牢固</view>
  98. </view>
  99. <view class="benefit-icon">
  100. <image src="/static/会员图片3.png" mode="aspectFit"></image>
  101. </view>
  102. </view> -->
  103. </view>
  104. </view>
  105. <!-- 以下内容为成为会员才能看到的 -->
  106. <!-- 学习计划 -->
  107. <view class="study-plan-section" v-else>
  108. <view class="section-title">学习计划</view>
  109. <view class="plan-books">
  110. <view
  111. v-for="(book, index) in studyPlanBooks"
  112. :key="index"
  113. class="plan-book-item"
  114. @click="goBookDetail(book.book.id)"
  115. :class="{ 'active-book': index === 1 }"
  116. >
  117. <view class="plan-book-cover">
  118. <image :src="book.book.booksImg" mode="aspectFill"></image>
  119. <!-- 学习中标识 -->
  120. <view v-if="index === 1" class="studying-badge">
  121. <view class="studying-icon"/>
  122. <text>学习中</text>
  123. </view>
  124. </view>
  125. <view class="plan-book-info">
  126. <text class="plan-book-title" :class="{ 'highlight-title': index === 1 }">{{ book.book.booksName || '暂无课程' }}</text>
  127. <view class="plan-book-meta" >
  128. <text class="plan-book-grade" :class="{ 'highlight-title': index === 1 }">{{ book.book.categoryName || '--' }}/</text>
  129. <image v-if="index !== 1" src="/static/播放图标.png" class="plan-book-duration-icon" />
  130. <image v-else src="/static/播放图标高亮.png" class="plan-book-duration-icon" />
  131. <text class="plan-book-duration" :class="{ 'highlight-title': index === 1 }">{{ book.book.duration }}</text>
  132. </view>
  133. </view>
  134. </view>
  135. </view>
  136. </view>
  137. <!-- 学习推荐 -->
  138. <view class="study-recommend-section" v-if="isMember">
  139. <view class="section-header" @click="goRecommend">
  140. <text class="section-title">学习推荐</text>
  141. <view class="section-more">
  142. <text>更多</text>
  143. <uv-icon name="arrow-right" size="14" color="#8B8B8B"></uv-icon>
  144. </view>
  145. </view>
  146. <view class="recommend-grid">
  147. <view
  148. v-for="(book, index) in recommendBooks"
  149. :key="index"
  150. @click="goBookDetail(book.id)"
  151. class="recommend-grid-item"
  152. >
  153. <view class="recommend-grid-cover">
  154. <image :src="book.booksImg" mode="aspectFill"></image>
  155. </view>
  156. <view class="recommend-grid-info">
  157. <text class="recommend-grid-title">{{ book.booksName }}</text>
  158. <view class="recommend-grid-meta">
  159. <text class="recommend-grid-grade">{{ book.categoryName }}/</text>
  160. <image src="/static/播放图标.png" class="recommend-grid-duration-icon" />
  161. <text class="recommend-grid-duration">{{ book.duration }}</text>
  162. </view>
  163. </view>
  164. </view>
  165. </view>
  166. </view>
  167. </view>
  168. </template>
  169. <script>
  170. export default{
  171. data() {
  172. return {
  173. isLogin: uni.getStorageSync('token') ? true : false,
  174. memberInfo: [],
  175. memberBenefits: [],
  176. userInfo: {
  177. name: '战斗世界',
  178. avatar: '/static/默认头像.png'
  179. },
  180. // 学习计划书籍数据
  181. studyPlanBooks: [
  182. ],
  183. // 学习推荐书籍数据
  184. recommendBooks: [
  185. ]
  186. }
  187. },
  188. computed: {
  189. isMember() {
  190. return this.memberInfo.length > 0
  191. }
  192. },
  193. methods: {
  194. // 跳转学习推荐
  195. goRecommend() {
  196. uni.navigateTo({
  197. url: '/subPages/home/search'
  198. })
  199. },
  200. // 跳转书籍详情
  201. goBookDetail(bookId) {
  202. uni.navigateTo({
  203. url: `/subPages/home/directory?id=${bookId}`
  204. })
  205. },
  206. goRecharge() {
  207. if (!this.isLogin) {
  208. uni.navigateTo({
  209. url: '/subPages/login/login'
  210. })
  211. return
  212. }
  213. uni.navigateTo({
  214. url: '/subPages/member/recharge'
  215. })
  216. },
  217. // 获取会员信息
  218. async getUserMemberInfo() {
  219. const memberRes = await this.$api.member.getUserMemberInfo()
  220. if (memberRes.code === 200) {
  221. this.memberInfo = [...memberRes.result]
  222. }
  223. if(!this.memberInfo.length){
  224. // 如果不是会员 获取会员部分信息
  225. this.getMemberBenefits()
  226. }
  227. },
  228. // 获取会员权益
  229. async getMemberBenefits() {
  230. const benefitsRes = await this.$api.member.getMemberList()
  231. if (benefitsRes.code === 200) {
  232. this.memberBenefits = benefitsRes.result.map(item => item.content)
  233. }
  234. },
  235. // 获取用户信息
  236. async getUserInfo() {
  237. const userRes = await this.$api.login.getUserInfo()
  238. if (userRes.code === 200) {
  239. this.userInfo = userRes.result
  240. }
  241. },
  242. // 获取3个学习计划书籍
  243. async getStudyPlanBook() {
  244. const bookRes = await this.$api.book.stand({
  245. pageNo: 1,
  246. pageSize: 3
  247. })
  248. if (bookRes.code === 200) {
  249. const oneBook = bookRes.result.records[1]
  250. const twoBook = bookRes.result.records[0]
  251. const threeBook = bookRes.result.records[2]
  252. this.studyPlanBooks = [oneBook, twoBook, threeBook]
  253. }
  254. },
  255. async getRecommendBook() {
  256. const bookRes = await this.$api.book.list({
  257. pageNo: 1,
  258. pageSize: 6,
  259. member: 1
  260. }, false)
  261. if (bookRes.code === 200) {
  262. this.recommendBooks = bookRes.result.records
  263. }
  264. },
  265. },
  266. async onShow() {
  267. // 如果登录了就查询会员情况 如果没有登录就不查询
  268. if (uni.getStorageSync('token')) {
  269. this.isLogin = true
  270. Promise.all([this.getUserMemberInfo(), this.getUserInfo(), this.getStudyPlanBook(), this.getRecommendBook()])
  271. }else {
  272. this.isLogin = false
  273. this.userInfo = {
  274. name: '登录后查看会员情况',
  275. avatar: '/static/默认头像.png'
  276. }
  277. }
  278. }
  279. }
  280. </script>
  281. <style lang="scss" scoped>
  282. .container {
  283. min-height: 100%;
  284. padding-bottom: 50rpx;
  285. }
  286. .header{
  287. width: 100%;
  288. .header-bg{
  289. position: relative;
  290. width: 100%;
  291. height: 400rpx;
  292. // background: red;
  293. .header-img{
  294. width: 100%;
  295. height: 400rpx;
  296. }
  297. .header-title{
  298. font-size: 32rpx;
  299. color: black;
  300. position: absolute;
  301. top: 100rpx;
  302. font-weight: 500;
  303. left: 50%;
  304. transform: translateX(-50%);
  305. }
  306. }
  307. .header-content{
  308. margin: 0 18rpx;
  309. /* #ifndef H5 */
  310. margin-top: -150rpx;
  311. /* #endif */
  312. /* #ifdef H5 */
  313. margin-top: 100rpx;
  314. /* #endif */
  315. // height: 256rpx;
  316. border-radius: 32rpx;
  317. border-width: 2rpx;
  318. padding: 40rpx;
  319. background: linear-gradient(180deg, #DEFFFF 0%, #FBFEFF 22.65%, #F0FBFF 100%);
  320. border: 2rpx solid #06DADC12;
  321. display: flex;
  322. flex-direction: column;
  323. gap: 28rpx;
  324. position: relative;
  325. .vip-container{
  326. padding: 20rpx 0;
  327. display: flex;
  328. flex-direction: column;
  329. gap: 18rpx;
  330. .project{
  331. font-size: 36rpx;
  332. color: #191919;
  333. line-height: 1.4;
  334. font-weight: 500;
  335. }
  336. .res-time{
  337. color: $primary-color;
  338. font-size: 24rpx;
  339. line-height: 36rpx;
  340. }
  341. }
  342. .noVip-container{
  343. display: flex;
  344. flex-direction: column;
  345. // align-items: center;
  346. // justify-content: center;
  347. gap: 28rpx;
  348. }
  349. .zuanshi{
  350. position: absolute;
  351. width: 190rpx;
  352. height: 190rpx;
  353. top: -80rpx;
  354. right: 0;
  355. .zuanshi-img{
  356. width: 190rpx;
  357. height: 190rpx;
  358. }
  359. }
  360. .VIP-img{
  361. width: 80rpx;
  362. height: 50rpx;
  363. }
  364. .border{
  365. width: 100%;
  366. // height: 2rpx;
  367. border: 2rpx solid;
  368. border-image-source: linear-gradient(90deg, rgba(228, 255, 255, 0) 0%, #C3EFEF 50.48%, rgba(228, 255, 255, 0) 100%);
  369. border-image-slice: 1;
  370. }
  371. .intro{
  372. font-size: 28rpx;
  373. line-height: 36rpx;
  374. letter-spacing: 0%;
  375. vertical-align: middle;
  376. color: #09B1B3;
  377. }
  378. .info{
  379. display: flex;
  380. justify-content: space-between;
  381. align-items: center;
  382. }
  383. .avatar-box{
  384. display: flex;
  385. align-items: center;
  386. gap: 16rpx;
  387. .name{
  388. font-weight: 600;
  389. font-size: 36rpx;
  390. line-height: 44rpx;
  391. letter-spacing: 0%;
  392. vertical-align: middle;
  393. color: #252545;
  394. }
  395. .avatar{
  396. width: 60rpx;
  397. height: 60rpx;
  398. border-radius: 50%;
  399. }
  400. .time{
  401. font-size: 30rpx;
  402. color: #8B8B8B;
  403. line-height: 36rpx;
  404. }
  405. }
  406. }
  407. }
  408. /* 立即开通会员按钮样式 */
  409. .member-button-section {
  410. margin: 40rpx 50rpx;
  411. }
  412. /* 会员权益样式 */
  413. .benefits-section {
  414. margin-top: 40rpx;
  415. padding: 0 30rpx;
  416. }
  417. .benefits-title {
  418. font-size: 36rpx;
  419. font-weight: bold;
  420. color: #191919;
  421. margin-bottom: 32rpx;
  422. }
  423. .benefits-list {
  424. display: flex;
  425. flex-direction: column;
  426. gap: 32rpx;
  427. }
  428. .benefit-item {
  429. background: #F8F8F8;
  430. border: 1px solid #FFFFFF;
  431. border-radius: 48rpx;
  432. padding: 27rpx 40rpx;
  433. display: flex;
  434. align-items: center;
  435. justify-content: space-between;
  436. }
  437. .benefit-content {
  438. flex: 1;
  439. margin-right: 40rpx;
  440. }
  441. .benefit-title {
  442. font-size: 32rpx;
  443. font-weight: 600;
  444. color: #333;
  445. margin-bottom: 16rpx;
  446. }
  447. .benefit-desc {
  448. font-size: 24rpx;
  449. color: #09B1B3;
  450. line-height: 36rpx;
  451. }
  452. .benefit-icon {
  453. width: 152rpx;
  454. height: 152rpx;
  455. // flex-shrink: 0;
  456. }
  457. .benefit-icon image {
  458. width: 100%;
  459. height: 100%;
  460. }
  461. /* 学习计划样式 */
  462. .study-plan-section {
  463. margin-top: 40rpx;
  464. padding: 0 30rpx;
  465. }
  466. .section-title {
  467. font-size: 36rpx;
  468. font-weight: 500;
  469. color: #191919;
  470. margin-bottom: 32rpx;
  471. }
  472. .plan-books {
  473. display: flex;
  474. justify-content: center;
  475. align-items: flex-end;
  476. gap: 78rpx;
  477. padding: 20rpx 0;
  478. }
  479. .plan-book-item {
  480. display: flex;
  481. flex-direction: column;
  482. align-items: center;
  483. transition: all 0.3s ease;
  484. &.active-book {
  485. transform: scale(1.15);
  486. .plan-book-cover {
  487. // box-shadow: 0 8rpx 24rpx rgba(6, 218, 220, 0.3);
  488. }
  489. }
  490. }
  491. .plan-book-cover {
  492. width: 172rpx;
  493. height: 230rpx;
  494. border-radius: 16rpx;
  495. overflow: hidden;
  496. margin-bottom: 16rpx;
  497. position: relative;
  498. box-shadow: 0px 4px 4px 0px #C0BCBA75;
  499. image {
  500. width: 100%;
  501. height: 100%;
  502. }
  503. .studying-badge {
  504. position: absolute;
  505. bottom: 0rpx;
  506. right: 0rpx;
  507. background: #00000099;
  508. color: #fff;
  509. padding: 6rpx 10rpx;
  510. border-radius: 20rpx;
  511. font-size: 18rpx;
  512. display: flex;
  513. align-items: center;
  514. justify-content: center;
  515. gap: 6rpx;
  516. .studying-icon{
  517. width: 10rpx;
  518. height: 10rpx;
  519. background: $primary-color;
  520. border-radius: 50%;
  521. }
  522. }
  523. }
  524. .plan-book-info {
  525. text-align: center;
  526. width: 180rpx;
  527. .plan-book-title {
  528. // width: 100%;
  529. font-size: 28rpx;
  530. font-weight: 700;
  531. color: #333;
  532. margin-bottom: 8rpx;
  533. display: block;
  534. overflow: hidden;
  535. text-overflow: ellipsis;
  536. white-space: nowrap;
  537. &.highlight-title {
  538. color: $primary-color;
  539. }
  540. }
  541. .plan-book-meta {
  542. display: flex;
  543. align-items: center;
  544. justify-content: center;
  545. gap: 8rpx;
  546. .plan-book-duration-icon {
  547. width: 20rpx;
  548. height: 20rpx;
  549. }
  550. .plan-book-grade {
  551. font-size: 24rpx;
  552. color: #999;
  553. &.highlight-title {
  554. color: $primary-color;
  555. }
  556. }
  557. .plan-book-duration {
  558. font-size: 24rpx;
  559. color: #999;
  560. &.highlight-title {
  561. color: $primary-color;
  562. }
  563. }
  564. }
  565. }
  566. /* 学习推荐样式 */
  567. .study-recommend-section {
  568. margin-top: 40rpx;
  569. padding: 0 30rpx;
  570. }
  571. .section-header {
  572. display: flex;
  573. align-items: center;
  574. justify-content: space-between;
  575. margin-bottom: 24rpx;
  576. .section-more {
  577. display: flex;
  578. align-items: center;
  579. gap: 4rpx;
  580. text {
  581. font-size: 24rpx;
  582. color: #8B8B8B;
  583. }
  584. }
  585. }
  586. .recommend-grid {
  587. display: flex;
  588. flex-wrap: wrap;
  589. gap: 32rpx;
  590. .recommend-grid-item {
  591. width: 208rpx;
  592. display: flex;
  593. flex-direction: column;
  594. .recommend-grid-cover {
  595. box-shadow: 0px 4px 4px 0px #C0BCBA75;
  596. width: 100%;
  597. height: 278rpx;
  598. border-radius: 16rpx;
  599. overflow: hidden;
  600. margin-bottom: 16rpx;
  601. image {
  602. width: 100%;
  603. height: 100%;
  604. }
  605. }
  606. .recommend-grid-info {
  607. padding: 6rpx;
  608. .recommend-grid-title {
  609. font-size: 28rpx;
  610. font-weight: 700;
  611. color: #333;
  612. margin-bottom: 14rpx;
  613. overflow: hidden;
  614. text-overflow: ellipsis;
  615. white-space: nowrap;
  616. }
  617. .recommend-grid-meta {
  618. display: flex;
  619. align-items: center;
  620. .recommend-grid-duration-icon {
  621. width: 24rpx;
  622. height: 24rpx;
  623. margin-right: 12rpx;
  624. }
  625. .recommend-grid-grade {
  626. font-size: 24rpx;
  627. color: #999;
  628. margin-right: 8rpx;
  629. }
  630. .recommend-grid-duration {
  631. font-size: 24rpx;
  632. color: #999;
  633. }
  634. }
  635. }
  636. }
  637. }
  638. </style>