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

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