index.e1414f64.js 8.0 KB

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