四零语境前端代码仓库
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.

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