index.tsx 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. import ColProtocol from '@/components/col-protocol'
  2. import { Button, Icon, Popup, Sticky, Toast } from 'vant'
  3. import ColPopup from '@/components/col-popup'
  4. import { defineComponent } from 'vue'
  5. import { postMessage } from '@/helpers/native-message'
  6. import styles from './index.module.less'
  7. import OrderVideo from './order-video'
  8. import OrderLive from './order-live'
  9. import UserAuth from './userAuth'
  10. // 调用原生支付
  11. // postMessage({ api: 'paymentOrder', content: { orderNo: 0 } })
  12. // listenerMessage({ api: 'paymentResult', callback: (res: any) => {
  13. // status: 'success | fail'
  14. // }})
  15. import iconTips from '@common/images/icon_tips.png'
  16. import Payment from './payment'
  17. import ColHeader from '@/components/col-header'
  18. import { state } from '@/state'
  19. export default defineComponent({
  20. name: 'order-detail',
  21. data() {
  22. const query = this.$route.query
  23. console.log(query)
  24. return {
  25. orderType: query.orderType,
  26. agreeStatus: false,
  27. popupShow: false,
  28. paymentStatus: false,
  29. orderPrice: 0, // 支付金额
  30. orderInfo: {
  31. orderNo: '',
  32. actualPrice: 0
  33. }
  34. }
  35. },
  36. methods: {
  37. onAuthSuccess() {
  38. console.log('auth success')
  39. this.popupShow = false
  40. this.onSubmit() // 实名成功后自动支付
  41. },
  42. async onSubmit() {
  43. if (!this.agreeStatus) {
  44. Toast('请先阅读并同意《酷乐秀平台服务协议》')
  45. return
  46. }
  47. const users = state.user.data
  48. // 判断是否需要实名认证
  49. if (!users?.realName || !users?.idCard) {
  50. this.popupShow = true
  51. return
  52. }
  53. // return
  54. let result: any
  55. if (this.$refs.orderVideo && this.orderType == 'VIDEO') {
  56. result = await (this as any).$refs.orderVideo.onSubmit()
  57. console.log(result)
  58. } else if (this.$refs.orderLive && this.orderType == 'LIVE') {
  59. result = await (this as any).$refs.orderLive.onSubmit()
  60. }
  61. if (result) {
  62. this.orderInfo = {
  63. orderNo: result.orderNo,
  64. actualPrice: result.actualPrice
  65. }
  66. this.paymentStatus = true
  67. }
  68. }
  69. },
  70. render() {
  71. return (
  72. <div class={styles['order-detail']}>
  73. <ColHeader />
  74. {this.orderType === 'LIVE' && (
  75. <OrderLive ref="orderLive" v-model={this.orderPrice} />
  76. )}
  77. {this.orderType === 'VIDEO' && (
  78. <OrderVideo ref="orderVideo" v-model={this.orderPrice} />
  79. )}
  80. <div class={styles.tips}>
  81. <h3>
  82. <Icon name={iconTips} size={15} />
  83. 温馨提示
  84. </h3>
  85. <p>
  86. 1、您支付的课程费用将由平台收取; <br />
  87. 2、陪练课、直播课课程结束后,平台将单课时费用向老师结算;
  88. <br />
  89. 3、除直播课未达到开课人数外,其他服务一经购买不予退费。
  90. </p>
  91. </div>
  92. <div class={styles.paymentInfo}>
  93. <div class={styles.protocol}>
  94. <ColProtocol
  95. v-model={this.agreeStatus}
  96. showHeader
  97. style={{ paddingLeft: 0, paddingRight: 0 }}
  98. />
  99. </div>
  100. <div class={styles.btnGroup}>
  101. <div class={styles.priceSection}>
  102. 支付金额:
  103. <div class={styles.price}>
  104. <span class={styles.priceUnit}>¥</span>
  105. <span class={styles.priceNum}>
  106. {(this as any).$filters.moneyFormat(this.orderPrice)}
  107. </span>
  108. </div>
  109. </div>
  110. <Button
  111. type="primary"
  112. round
  113. class={styles.btn}
  114. onClick={this.onSubmit}
  115. >
  116. 立即支付
  117. </Button>
  118. </div>
  119. </div>
  120. <ColPopup v-model={this.popupShow}>
  121. <UserAuth onSuccess={this.onAuthSuccess} />
  122. </ColPopup>
  123. <Popup
  124. show={this.paymentStatus}
  125. closeOnClickOverlay={false}
  126. position="bottom"
  127. round
  128. closeOnPopstate
  129. safeAreaInsetBottom
  130. style={{ minHeight: '30%' }}
  131. >
  132. <Payment v-model={this.paymentStatus} orderInfo={this.orderInfo} />
  133. </Popup>
  134. </div>
  135. )
  136. }
  137. })