index.tsx 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. import ColHeader from '@/components/col-header'
  2. import { postMessage } from '@/helpers/native-message'
  3. import request from '@/helpers/request'
  4. import { numberFormat } from '@/helpers/utils'
  5. import { orderStatus } from '@/views/order-detail/orderStatus'
  6. import { useEventListener, useWindowScroll } from '@vueuse/core'
  7. import { Button } from 'vant'
  8. import { defineComponent } from 'vue'
  9. import styles from './index.module.less'
  10. export const getAssetsHomeFile = (fileName: string) => {
  11. const path = `../images/${fileName}`
  12. const modules = import.meta.globEager('../images/*')
  13. return modules[path].default
  14. }
  15. export default defineComponent({
  16. name: 'accountRechargeTimer',
  17. data() {
  18. return {
  19. list: [],
  20. selectItem: {} as any,
  21. remain: {
  22. frozenTime: 0,
  23. remainTime: 0,
  24. studentCount: 0
  25. },
  26. background: 'transparent',
  27. color: '#fff'
  28. }
  29. },
  30. async mounted() {
  31. try {
  32. await this._init()
  33. const res = await request.post('/api-teacher/pianoRoomSettings/list', {
  34. data: {}
  35. })
  36. this.list = res.data || []
  37. if (this.list.length > 0) {
  38. const item: any = this.list[0]
  39. this.selectItem = item
  40. }
  41. document.addEventListener('scroll', this.scrollInit, false)
  42. } catch {}
  43. },
  44. unmounted() {
  45. this.background = '#fff'
  46. this.color = '#333'
  47. // this.documentDom = document.body as any
  48. postMessage({
  49. api: 'backIconChange',
  50. content: { iconStyle: 'black' }
  51. })
  52. document.removeEventListener('scroll', this.scrollInit)
  53. },
  54. methods: {
  55. scrollInit() {
  56. const { y } = useWindowScroll()
  57. if (y.value > 30) {
  58. this.background = '#fff'
  59. this.color = '#333'
  60. postMessage({
  61. api: 'backIconChange',
  62. content: { iconStyle: 'black' }
  63. })
  64. } else {
  65. this.background = 'transparent'
  66. this.color = '#fff'
  67. postMessage({
  68. api: 'backIconChange',
  69. content: { iconStyle: 'white' }
  70. })
  71. }
  72. },
  73. async _init() {
  74. try {
  75. const res = await request.get(
  76. '/api-teacher/courseSchedule/selectRemainTime'
  77. )
  78. const { frozenTime, remainTime, studentCount } = res.data || {}
  79. this.remain = {
  80. frozenTime: frozenTime || 0,
  81. remainTime: remainTime || 0,
  82. studentCount: studentCount || 0
  83. }
  84. } catch {}
  85. },
  86. async onSubmit() {
  87. const selectItem = this.selectItem
  88. orderStatus.orderObject.orderType = 'PIANO_ROOM'
  89. orderStatus.orderObject.orderName = selectItem.times + '分钟琴房时长充值'
  90. orderStatus.orderObject.orderDesc = selectItem.times + '分钟琴房时长充值'
  91. orderStatus.orderObject.actualPrice = selectItem.salePrice
  92. orderStatus.orderObject.orderNo = ''
  93. orderStatus.orderObject.orderList = [
  94. {
  95. orderType: 'PIANO_ROOM',
  96. goodsName: selectItem.times + '分钟琴房时长充值',
  97. ...selectItem
  98. }
  99. ]
  100. this.$router.push({
  101. path: '/orderDetail',
  102. query: {
  103. orderType: 'PIANO_ROOM',
  104. pinaoId: selectItem.id
  105. }
  106. })
  107. }
  108. },
  109. render() {
  110. return (
  111. <div class={styles.accountRechargeTimer}>
  112. <ColHeader
  113. // rightText="充值记录"
  114. backIconColor="white"
  115. border={false}
  116. background={this.background}
  117. color={this.color}
  118. // onClickRight={() => {
  119. // this.$router.push('/rechargeRecord')
  120. // }}
  121. />
  122. <div class={styles.userMins}>
  123. <p class={styles.userLastMins}>
  124. {numberFormat(this.remain.remainTime)}
  125. <span>分钟</span>
  126. </p>
  127. <p class={styles.userTips}>
  128. <img src={getAssetsHomeFile('icon_timers.png')} />
  129. 您的琴房剩余时长
  130. </p>
  131. </div>
  132. <div class={styles.selectTimers}>
  133. <img
  134. src={getAssetsHomeFile('title_timers.png')}
  135. class={styles.selectTitle}
  136. alt=""
  137. />
  138. <div class={styles.lastMin}>
  139. <img src={getAssetsHomeFile('icon_music_account.png')} />
  140. <p>
  141. {this.selectItem.times && (
  142. <b>已选{numberFormat(this.selectItem.times)}分钟</b>
  143. )}{' '}
  144. {this.selectItem.description}
  145. </p>
  146. </div>
  147. <div class={styles.memberItem}>
  148. {/* <div class={styles.rTitle}>
  149. <span>选择时长</span>
  150. </div> */}
  151. <div class={styles['system-list']}>
  152. {this.list.map((item: any) => (
  153. <div
  154. class={[
  155. styles['system-item'],
  156. item.id === this.selectItem.id && styles.active
  157. ]}
  158. style={{ borderRadius: '11px' }}
  159. onClick={() => {
  160. this.selectItem = item
  161. }}
  162. >
  163. <p class={styles.price}>
  164. <span>¥</span>
  165. {item.salePrice}
  166. </p>
  167. <del class={styles.originalPrice}>¥{item.originalPrice}</del>
  168. <p class={styles.title}>{item.times}分钟</p>
  169. {/* <p class={styles.tips}>{item.description}</p> */}
  170. </div>
  171. ))}
  172. </div>
  173. </div>
  174. </div>
  175. <div class={styles.reminder}>
  176. <div class={styles.h2}>
  177. <img src={getAssetsHomeFile('icon_tips.png')} />
  178. <span>温馨提醒</span>
  179. </div>
  180. <p>
  181. 1、云酷琴房时长按课程学生人数扣减,以45分钟1对2课程为例,课程结束后将消耗时长:2人*45分钟=90分钟;
  182. </p>
  183. <p>
  184. 2、每节线上课平台赠送10分钟免费时长,分别为课前5分钟及课后5分钟,赠送时长不计算费用;
  185. </p>
  186. <p>
  187. 3、课程消耗时长按排课人数计算,无论实际到课人数是否为排课人数,都会按照排课人数扣费;
  188. </p>
  189. <p>4、课程结束后费用立即结算;</p>
  190. <p>5、琴房时长不足时,您将无法排课,请确保琴房剩 余时长充足;</p>
  191. <p>6、琴房时长一经购买不予退费。</p>
  192. </div>
  193. <div class={styles.btnGroup}>
  194. <div class={styles.priceSection}>
  195. 支付金额:
  196. <div class={styles.price}>
  197. <span class={styles.priceUnit}>¥</span>
  198. <span class={styles.priceNum}>{this.selectItem.salePrice}</span>
  199. </div>
  200. </div>
  201. <Button
  202. color="linear-gradient(360deg, #FF0909 0%, #FF4D4D 69%, #FF7B7B 100%)"
  203. round
  204. class={styles.btn}
  205. onClick={this.onSubmit}
  206. >
  207. 立即支付
  208. </Button>
  209. </div>
  210. </div>
  211. )
  212. }
  213. })