index.e25098df.js 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. import {
  2. d as l,
  3. i as o,
  4. w as a,
  5. F as c,
  6. C as r,
  7. aP as d,
  8. B as h,
  9. e as C,
  10. s as f,
  11. aQ as m
  12. } from './index.9a31d746.js'
  13. import { C as L } from './index.b1685363.js'
  14. import { u as g } from './hooks.e9646728.js'
  15. import { I as S } from './item.04350235.js'
  16. const y = '_useCoupon_dzp2v_1',
  17. b = '_couponCount_dzp2v_5',
  18. A = '_choiceCoupon_dzp2v_14',
  19. I = '_couponTitle_dzp2v_20',
  20. _ = '_iconClose_dzp2v_32',
  21. E = '_couponContent_dzp2v_39',
  22. v = '_couponFooter_dzp2v_46',
  23. N = '_couponSelectText_dzp2v_53'
  24. var i = {
  25. useCoupon: y,
  26. couponCount: b,
  27. choiceCoupon: A,
  28. couponTitle: I,
  29. iconClose: _,
  30. couponContent: E,
  31. couponFooter: v,
  32. couponSelectText: N
  33. },
  34. U = l({
  35. name: 'choice-coupon',
  36. props: {
  37. orderAmount: { type: Number, default: 0 },
  38. useCoupon: { type: Array, default: () => [] },
  39. couponCategory: { type: String, default: 'UNIVERSAL' },
  40. couponList: { type: Array, default: () => [] }
  41. },
  42. emits: ['close', 'submit'],
  43. data() {
  44. return { list: [], dataLoading: !1 }
  45. },
  46. computed: {
  47. useLength() {
  48. return this.list.filter(t => t.checked).length || 0
  49. }
  50. },
  51. async mounted() {
  52. this.couponList.forEach(e => {
  53. this.useCoupon.forEach(s => {
  54. e.couponIssueId === s.couponIssueId && (e.checked = !0)
  55. })
  56. })
  57. const t = this.couponList.filter(e => !e.disabled),
  58. u = this.couponList.filter(e => e.disabled)
  59. ;(this.list = [...t, ...u]), this.calcCoupon(), g('\u4F18\u60E0\u5238')
  60. },
  61. methods: {
  62. onSubmit() {
  63. this.$emit(
  64. 'submit',
  65. this.list.filter(t => t.checked)
  66. ),
  67. this.list.forEach(t => {
  68. t.checked = !1
  69. })
  70. },
  71. onSelect(t) {
  72. ;(t.checked = !t.checked), this.calcCoupon()
  73. },
  74. calcCoupon() {
  75. const u = this.list
  76. .filter(n => n.checked)
  77. .map(n => Number(n.useLimit || 0)),
  78. e = u.length > 0 ? u.reduce((n, p) => n + p) : 0,
  79. s = this.orderAmount - e
  80. this.list.forEach(n => {
  81. Number(n.useLimit) > s && !n.checked
  82. ? (n.disabled = !0)
  83. : (n.disabled = !1)
  84. })
  85. }
  86. },
  87. render() {
  88. return o('div', { class: i.choiceCoupon }, [
  89. o('div', { class: i.couponTitle }, [
  90. o('span', null, [a('\u4F18\u60E0\u5238')]),
  91. o(
  92. 'i',
  93. { class: i.iconClose, onClick: () => this.$emit('close') },
  94. null
  95. )
  96. ]),
  97. o('div', { class: i.couponContent }, [
  98. this.dataLoading
  99. ? o(
  100. d,
  101. {
  102. size: 48,
  103. color: '#2dc7aa',
  104. vertical: !0,
  105. style: { height: '100%', justifyContent: 'center' }
  106. },
  107. { default: () => [a('\u52A0\u8F7D\u4E2D...')] }
  108. )
  109. : o(c, null, [
  110. this.list.length > 0
  111. ? o(c, null, [
  112. this.list.map(t =>
  113. o(
  114. S,
  115. { item: t, isSelect: !0, onClick: this.onSelect },
  116. null
  117. )
  118. )
  119. ])
  120. : o(
  121. r,
  122. {
  123. btnStatus: !1,
  124. tips: '\u6682\u65E0\u4F18\u60E0\u5238',
  125. classImgSize: 'SMALL'
  126. },
  127. null
  128. )
  129. ])
  130. ]),
  131. o('div', { class: [i.couponFooter, 'van-hairline--top'] }, [
  132. o('div', { class: i.couponSelectText }, [
  133. a('\u5DF2\u9009'),
  134. o('span', null, [this.useLength]),
  135. a('\u5F20')
  136. ]),
  137. o(
  138. h,
  139. {
  140. type: 'primary',
  141. round: !0,
  142. style: { minWidth: '105px', fontSize: '16px' },
  143. onClick: this.onSubmit
  144. },
  145. { default: () => [a('\u786E\u5B9A')] }
  146. )
  147. ])
  148. ])
  149. }
  150. })
  151. const k = {
  152. UNIVERSAL: 'UNIVERSAL',
  153. VIP: 'VIP',
  154. PIANO_ROOM: 'PIANO',
  155. GOODS: 'MALL',
  156. MUSIC: 'MUSIC',
  157. PRACTICE: 'SPARRING',
  158. LIVE: 'LIVE',
  159. VIDEO: 'VIDEO',
  160. ALBUM: 'ALBUM'
  161. }
  162. var z = l({
  163. name: 'use-conpon',
  164. props: {
  165. disabled: { type: Boolean, default: !1 },
  166. orderAmount: { type: Number, default: 0 },
  167. orderType: { type: String, default: '' },
  168. discountPrice: { type: Number, default: 0 }
  169. },
  170. emits: ['couponSelect'],
  171. data() {
  172. return {
  173. popupStatus: !1,
  174. popupLoading: !1,
  175. useCouponList: [],
  176. useCouponLoading: !1,
  177. useCouponCount: 0,
  178. dataLoading: !1,
  179. list: []
  180. }
  181. },
  182. computed: {
  183. couponCount() {
  184. const t = this.useCouponList.map(e => Number(e.discountPrice || 0))
  185. let u = 0
  186. return (
  187. this.disabled
  188. ? (u = this.discountPrice)
  189. : (u = t.length > 0 ? t.reduce((e, s) => e + s) : 0),
  190. u
  191. )
  192. },
  193. couponCategory() {
  194. return k[this.orderType] || 'UNIVERSAL'
  195. }
  196. },
  197. mounted() {
  198. this.getList()
  199. },
  200. methods: {
  201. async getList() {
  202. if (!this.dataLoading) {
  203. this.dataLoading = !0
  204. try {
  205. const t = await C.post(`${f.platformApi}/couponInfo/page`, {
  206. data: {
  207. couponCategory: this.couponCategory,
  208. couponType: 'FULL_DISCOUNT',
  209. useState: 'USABLE',
  210. orderUse: 1,
  211. page: 1,
  212. rows: 100
  213. }
  214. })
  215. this.dataLoading = !1
  216. const u = t.data || {}
  217. if (this.list.length > 0 && u.pageNo === 1) return
  218. ;(this.list = u.rows || []),
  219. this.list.forEach(s => {
  220. ;(s.checked = !1),
  221. s.useLimit > this.orderAmount
  222. ? (s.disabled = !0)
  223. : (s.disabled = !1)
  224. })
  225. let e = 0
  226. this.list.forEach(s => {
  227. s.disabled || e++
  228. }),
  229. console.log(this.list, 'list'),
  230. (this.useCouponCount = e)
  231. } catch {}
  232. }
  233. },
  234. onSubmit(t) {
  235. ;(this.useCouponList = t),
  236. this.$emit('couponSelect', t),
  237. (this.popupStatus = !1),
  238. (this.popupLoading = !1)
  239. }
  240. },
  241. render() {
  242. return o(c, null, [
  243. o(
  244. L,
  245. {
  246. title: '\u4F18\u60E0\u5238',
  247. class: i.useCoupon,
  248. style: { borderRadius: '8px' },
  249. isLink: !this.disabled,
  250. clickable: !1,
  251. onClick: () => {
  252. this.disabled || ((this.popupStatus = !0), (this.popupLoading = !0))
  253. }
  254. },
  255. {
  256. value: () =>
  257. !this.useCouponLoading &&
  258. o(c, null, [
  259. this.couponCount > 0
  260. ? o('span', { class: i.couponCount }, [
  261. o('i', null, [a('-\uFFE5')]),
  262. this.couponCount
  263. ])
  264. : o(c, null, [
  265. this.useCouponCount > 0
  266. ? `${this.useCouponCount}\u5F20\u53EF\u4F7F\u7528`
  267. : '\u6682\u65E0\u53EF\u4F7F\u7528\u4F18\u60E0\u5238'
  268. ])
  269. ])
  270. }
  271. ),
  272. o(
  273. m,
  274. {
  275. show: this.popupStatus,
  276. 'onUpdate:show': t => (this.popupStatus = t),
  277. position: 'bottom',
  278. round: !0,
  279. safeAreaInsetBottom: !0,
  280. style: { height: '75%' },
  281. onClosed: () => {
  282. this.popupLoading = !1
  283. }
  284. },
  285. {
  286. default: () => [
  287. this.popupLoading &&
  288. o(
  289. U,
  290. {
  291. couponCategory: this.couponCategory,
  292. useCoupon: this.useCouponList,
  293. orderAmount: this.orderAmount,
  294. couponList: this.list,
  295. onClose: () => (this.popupStatus = !1),
  296. onSubmit: t => this.onSubmit(t)
  297. },
  298. null
  299. )
  300. ]
  301. }
  302. )
  303. ])
  304. }
  305. })
  306. export { z as U }