index.tsx 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. import ColHeader from '@/components/col-header'
  2. import { Button, Cell, Dialog, Icon, Image, Popup, Toast } from 'vant'
  3. import { defineComponent } from 'vue'
  4. import styles from './index.module.less'
  5. import request from '@/helpers/request'
  6. import { state } from '@/state'
  7. import shareBanner from '../images/share-banner.png'
  8. import wxImage from '../images/wx_bg.png'
  9. import { shareCall, initJumpNativePage } from '../share'
  10. import { browser } from '@/helpers/utils'
  11. import { postMessage } from '@/helpers/native-message'
  12. import qs from 'query-string'
  13. import iconTitle from './images/icon-title-3.png'
  14. import equityBg from './images/icon-equity-bg.png'
  15. import ColSticky from '@/components/col-sticky'
  16. export const getAssetsHomeFile = (fileName: string) => {
  17. const path = `../../../views/member-center/images/${fileName}`
  18. const modules = import.meta.globEager('../../../views/member-center/images/*')
  19. return modules[path].default
  20. }
  21. export default defineComponent({
  22. name: 'MemberCenter',
  23. data() {
  24. const query = this.$route.query
  25. query.recomUserId =
  26. query.userType && query.userType == 'STUDENT' ? '' : query.recomUserId
  27. const tmpUrl = `${location.origin}/student/#/memberCenter?${qs.stringify(
  28. query
  29. )}`
  30. return {
  31. activityId: query.activityId,
  32. recomUserId: query.recomUserId,
  33. discount: 0,
  34. functionList: [],
  35. wxStatus: false,
  36. jumpUrl: tmpUrl
  37. }
  38. },
  39. computed: {
  40. userInfo() {
  41. const users = state.user.data
  42. return {
  43. username: users?.username,
  44. phone: users?.phone,
  45. avatar: users?.heardUrl,
  46. id: users?.userId,
  47. memberRankSettingId: users?.memberRankSettingId,
  48. membershipDays: users?.membershipDays,
  49. membershipEndTime: users?.membershipEndTime
  50. }
  51. }
  52. },
  53. created() {
  54. initJumpNativePage(this.jumpUrl)
  55. },
  56. async mounted() {
  57. try {
  58. // const res = await request.post(
  59. // `/api-teacher/open/memberPriceSettings/vipPermissions`
  60. // )
  61. // const result = res.data || []
  62. // this.functionList = result.map((item: any) => {
  63. // return {
  64. // title: item.paramName,
  65. // icon: getAssetsHomeFile(`${item.paramValue}.png`)
  66. // }
  67. // })
  68. if (this.activityId) {
  69. const active = await request.post(
  70. `/api-teacher/open/activity/state/${this.activityId}`
  71. )
  72. this.discount = active.data.check || 0
  73. }
  74. } catch {
  75. //
  76. }
  77. },
  78. methods: {
  79. onShare() {
  80. if (browser().weixin) {
  81. this.wxStatus = true
  82. return
  83. }
  84. // 尝试拉起app
  85. shareCall(this.jumpUrl)
  86. // 不管有没有拉起app则都跳转到下载app
  87. setTimeout(() => {
  88. window.location.href = location.origin + '/student/#/download'
  89. }, 3000)
  90. }
  91. },
  92. render() {
  93. return (
  94. <div class={styles['member-center']}>
  95. <Image src={shareBanner} class={styles.shareBanner} />
  96. <div class={styles.memberContainer}>
  97. {/* <div class={[styles.intro]}>
  98. <p>
  99. 酷乐秀会员可使用包括平台提供的所有训练乐谱,并专享“
  100. <b>小酷Ai</b>
  101. ”八大核心功能,孩子在家就能轻松完成乐器自主规范练习。
  102. </p>
  103. </div>
  104. {this.functionList.length > 0 && (
  105. <div class={styles.memberItem}>
  106. <div class={styles.title}>会员功能</div>
  107. <div class={styles.member_function}>
  108. {this.functionList.map((item: any) => (
  109. <div class={styles.function_item}>
  110. <Icon name={item.icon} size={34} />
  111. <div class={styles.function_text} v-html={item.title}></div>
  112. </div>
  113. ))}
  114. </div>
  115. </div>
  116. )} */}
  117. <img src={iconTitle} class={styles.iconTitle} />
  118. <img src={equityBg} class={styles.iconEquity} />
  119. </div>
  120. <ColSticky position="bottom">
  121. <div class={['btnGroup', styles.btnGroup]}>
  122. {this.discount === 1 && (
  123. <div class={styles.tagDiscount}>专属优惠</div>
  124. )}
  125. <Button
  126. block
  127. round
  128. type="primary"
  129. onClick={this.onShare}
  130. color="linear-gradient(220deg, #DFA164 0%, #FAC87E 100%)"
  131. >
  132. 下载酷乐秀开始练习吧!
  133. </Button>
  134. </div>
  135. </ColSticky>
  136. {this.wxStatus && (
  137. <div
  138. class={styles.wxpopup}
  139. onClick={() => {
  140. this.wxStatus = false
  141. }}
  142. >
  143. <img src={wxImage} alt="" />
  144. </div>
  145. )}
  146. </div>
  147. )
  148. }
  149. })