123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302 |
- import { C as r, r as d, s as h } from './index.9e4b607f.js'
- import {
- d as l,
- a as o,
- j as a,
- F as c,
- L as C,
- B as f,
- C as m,
- P as L
- } from './vendor.3506a68e.js'
- /* empty css */ import { I as g } from './item.c80360f7.js'
- const S = '_useCoupon_dzp2v_1',
- b = '_couponCount_dzp2v_5',
- y = '_choiceCoupon_dzp2v_14',
- I = '_couponTitle_dzp2v_20',
- _ = '_iconClose_dzp2v_32',
- A = '_couponContent_dzp2v_39',
- E = '_couponFooter_dzp2v_46',
- v = '_couponSelectText_dzp2v_53'
- var i = {
- useCoupon: S,
- couponCount: b,
- choiceCoupon: y,
- couponTitle: I,
- iconClose: _,
- couponContent: A,
- couponFooter: E,
- couponSelectText: v
- },
- N = l({
- name: 'choice-coupon',
- props: {
- orderAmount: { type: Number, default: 0 },
- useCoupon: { type: Array, default: () => [] },
- couponCategory: { type: String, default: 'UNIVERSAL' },
- couponList: { type: Array, default: () => [] }
- },
- emits: ['close', 'submit'],
- data() {
- return { list: [], dataLoading: !1 }
- },
- computed: {
- useLength() {
- return this.list.filter(t => t.checked).length || 0
- }
- },
- async mounted() {
- this.couponList.forEach(e => {
- this.useCoupon.forEach(s => {
- e.couponIssueId === s.couponIssueId && (e.checked = !0)
- })
- })
- const t = this.couponList.filter(e => !e.disabled),
- u = this.couponList.filter(e => e.disabled)
- ;(this.list = [...t, ...u]), this.calcCoupon()
- },
- methods: {
- onSubmit() {
- this.$emit(
- 'submit',
- this.list.filter(t => t.checked)
- ),
- this.list.forEach(t => {
- t.checked = !1
- })
- },
- onSelect(t) {
- ;(t.checked = !t.checked), this.calcCoupon()
- },
- calcCoupon() {
- const u = this.list
- .filter(n => n.checked)
- .map(n => Number(n.useLimit || 0)),
- e = u.length > 0 ? u.reduce((n, p) => n + p) : 0,
- s = this.orderAmount - e
- this.list.forEach(n => {
- Number(n.useLimit) > s && !n.checked
- ? (n.disabled = !0)
- : (n.disabled = !1)
- })
- }
- },
- render() {
- return o('div', { class: i.choiceCoupon }, [
- o('div', { class: i.couponTitle }, [
- o('span', null, [a('\u4F18\u60E0\u5238')]),
- o(
- 'i',
- { class: i.iconClose, onClick: () => this.$emit('close') },
- null
- )
- ]),
- o('div', { class: i.couponContent }, [
- this.dataLoading
- ? o(
- C,
- {
- size: 48,
- color: '#01C1B5',
- vertical: !0,
- style: { height: '100%', justifyContent: 'center' }
- },
- { default: () => [a('\u52A0\u8F7D\u4E2D...')] }
- )
- : o(c, null, [
- this.list.length > 0
- ? o(c, null, [
- this.list.map(t =>
- o(
- g,
- { item: t, isSelect: !0, onClick: this.onSelect },
- null
- )
- )
- ])
- : o(
- r,
- {
- btnStatus: !1,
- tips: '\u6682\u65E0\u4F18\u60E0\u5238',
- classImgSize: 'SMALL'
- },
- null
- )
- ])
- ]),
- o('div', { class: [i.couponFooter, 'van-hairline--top'] }, [
- o('div', { class: i.couponSelectText }, [
- a('\u5DF2\u9009'),
- o('span', null, [this.useLength]),
- a('\u5F20')
- ]),
- o(
- f,
- {
- type: 'primary',
- round: !0,
- style: { minWidth: '105px', fontSize: '16px' },
- onClick: this.onSubmit
- },
- { default: () => [a('\u786E\u5B9A')] }
- )
- ])
- ])
- }
- })
- const k = {
- UNIVERSAL: 'UNIVERSAL',
- VIP: 'VIP',
- PINAO_ROOM: 'PIANO',
- GOODS: 'MALL',
- MUSIC: 'MUSIC',
- PRACTICE: 'SPARRING',
- LIVE: 'LIVE',
- VIDEO: 'VIDEO'
- }
- var V = l({
- name: 'use-conpon',
- props: {
- disabled: { type: Boolean, default: !1 },
- orderAmount: { type: Number, default: 0 },
- orderType: { type: String, default: '' },
- discountPrice: { type: Number, default: 0 }
- },
- emits: ['couponSelect'],
- data() {
- return {
- popupStatus: !1,
- popupLoading: !1,
- useCouponList: [],
- useCouponLoading: !1,
- useCouponCount: 0,
- dataLoading: !1,
- list: []
- }
- },
- computed: {
- couponCount() {
- const t = this.useCouponList.map(e => Number(e.discountPrice || 0))
- let u = 0
- return (
- this.disabled
- ? (u = this.discountPrice)
- : (u = t.length > 0 ? t.reduce((e, s) => e + s) : 0),
- u
- )
- },
- couponCategory() {
- return k[this.orderType] || 'UNIVERSAL'
- }
- },
- mounted() {
- this.getList()
- },
- methods: {
- async getList() {
- if (!this.dataLoading) {
- this.dataLoading = !0
- try {
- const t = await d.post(`${h.platformApi}/couponInfo/page`, {
- data: {
- couponCategory: this.couponCategory,
- couponType: 'FULL_DISCOUNT',
- useState: 'USABLE',
- orderUse: 1,
- page: 1,
- rows: 100
- }
- })
- this.dataLoading = !1
- const u = t.data || {}
- if (this.list.length > 0 && u.pageNo === 1) return
- ;(this.list = u.rows || []),
- this.list.forEach(s => {
- ;(s.checked = !1),
- s.useLimit > this.orderAmount
- ? (s.disabled = !0)
- : (s.disabled = !1)
- })
- let e = 0
- this.list.forEach(s => {
- s.disabled || e++
- }),
- console.log(this.list, 'list'),
- (this.useCouponCount = e)
- } catch {}
- }
- },
- onSubmit(t) {
- ;(this.useCouponList = t),
- this.$emit('couponSelect', t),
- (this.popupStatus = !1),
- (this.popupLoading = !1)
- }
- },
- render() {
- return o(c, null, [
- o(
- m,
- {
- title: '\u4F18\u60E0\u5238',
- class: i.useCoupon,
- style: { borderRadius: '8px' },
- isLink: !this.disabled,
- clickable: !1,
- onClick: () => {
- this.disabled || ((this.popupStatus = !0), (this.popupLoading = !0))
- }
- },
- {
- value: () =>
- !this.useCouponLoading &&
- o(c, null, [
- this.couponCount > 0
- ? o('span', { class: i.couponCount }, [
- o('i', null, [a('-\uFFE5')]),
- this.couponCount
- ])
- : o(c, null, [
- this.useCouponCount > 0
- ? `${this.useCouponCount}\u5F20\u53EF\u4F7F\u7528`
- : '\u6682\u65E0\u53EF\u4F7F\u7528\u4F18\u60E0\u5238'
- ])
- ])
- }
- ),
- o(
- L,
- {
- show: this.popupStatus,
- 'onUpdate:show': t => (this.popupStatus = t),
- position: 'bottom',
- round: !0,
- safeAreaInsetBottom: !0,
- style: { height: '75%' },
- onClosed: () => {
- this.popupLoading = !1
- }
- },
- {
- default: () => [
- this.popupLoading &&
- o(
- N,
- {
- couponCategory: this.couponCategory,
- useCoupon: this.useCouponList,
- orderAmount: this.orderAmount,
- couponList: this.list,
- onClose: () => (this.popupStatus = !1),
- onSubmit: t => this.onSubmit(t)
- },
- null
- )
- ]
- }
- )
- ])
- }
- })
- export { V as U }
|