index.tsx 4.3 KB

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