index.tsx 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. import { Cell, CellGroup, Icon, Image, Stepper } from 'vant'
  2. import { defineComponent } from 'vue'
  3. import styles from './index.module.less'
  4. // import { orderStatus } from '../orderStatus'
  5. import iconDiscount from '@common/images/icon_discount.png'
  6. import dayjs from 'dayjs'
  7. import { numberToTwoUp } from '..'
  8. export default defineComponent({
  9. name: 'OrderVideo',
  10. props: {
  11. item: {
  12. type: Object,
  13. default: () => ({})
  14. },
  15. disabled: {
  16. type: Boolean,
  17. default: false
  18. }
  19. },
  20. emits: ['priceChange'],
  21. computed: {
  22. startTime() {
  23. const item = this.item
  24. return item.startTime
  25. }
  26. },
  27. render() {
  28. const item = this.item
  29. return (
  30. <div class={styles.videoOrder}>
  31. <CellGroup class={['mb12', styles.cellGroup]} border={false}>
  32. <Cell
  33. // center
  34. titleClass={styles.titleClass}
  35. v-slots={{
  36. icon: () => (
  37. <Image class={styles.memberLogo} src={iconDiscount} />
  38. ),
  39. title: () => (
  40. <>
  41. <div class={styles.container}>
  42. <div class={styles.title}>
  43. {item.goodsName || item.goodName}
  44. </div>
  45. <div class={styles.price}>
  46. <i>¥ </i>
  47. {(this as any).$filters.moneyFormat(item.price)}
  48. </div>
  49. </div>
  50. <div class={styles.addNum}>
  51. <Stepper
  52. disableInput
  53. disabled={item.period === 'PERPETUAL' || this.disabled}
  54. v-model={item.num}
  55. theme="round"
  56. min={1}
  57. max={99}
  58. onChange={() => {
  59. let endTime = new Date()
  60. if (item.period === 'MONTH') {
  61. endTime = dayjs(item.startTime)
  62. .add(1 * item.num, 'month')
  63. .toDate()
  64. } else if (item.period === 'QUARTERLY') {
  65. endTime = dayjs(item.startTime)
  66. .add(3 * item.num, 'month')
  67. .toDate()
  68. } else if (item.period === 'YEAR_HALF') {
  69. endTime = dayjs(item.startTime)
  70. .add(6 * item.num, 'month')
  71. .toDate()
  72. } else if (item.period === 'YEAR') {
  73. endTime = dayjs(item.startTime)
  74. .add(1 * item.num, 'year')
  75. .toDate()
  76. }
  77. item.endTime = dayjs(endTime).format('YYYY-MM-DD')
  78. // 价格变化
  79. this.$emit(
  80. 'priceChange',
  81. numberToTwoUp(item.price * item.num)
  82. )
  83. }}
  84. ></Stepper>
  85. </div>
  86. </>
  87. )
  88. }}
  89. />
  90. </CellGroup>
  91. <CellGroup
  92. class={['mb12', styles.cellGroup, styles.cellGroupTimer]}
  93. border={false}
  94. >
  95. <Cell
  96. center
  97. v-slots={{
  98. title: () => (
  99. <div class={styles.timerCell}>
  100. <div class={styles.timerTitle}>
  101. <span>畅学卡生效时间</span>
  102. </div>
  103. <div class={styles.timer}>
  104. {this.startTime} 至 {item.endTime}
  105. </div>
  106. </div>
  107. )
  108. }}
  109. />
  110. </CellGroup>
  111. {/* {item.discountPrice && item.discountPrice > 0 ? <CellGroup class={['mb12', styles.cellGroup]} border={false}>
  112. <Cell
  113. center
  114. v-slots={{
  115. title: () => (
  116. <div class={styles.timerCell}>
  117. <div class={styles.timerTitle}>
  118. <span>畅学卡优惠</span>
  119. </div>
  120. <div class={styles.timer}>-¥{(this as any).$filters.moneyFormat(item.discountPrice)}</div>
  121. </div>
  122. )
  123. }}
  124. />
  125. </CellGroup> : ''} */}
  126. </div>
  127. // 视频课
  128. )
  129. }
  130. })