|
@@ -1,3 +1,5 @@
|
|
|
+import request from '@/helpers/request'
|
|
|
+import { state } from '@/state'
|
|
|
import { Cell, Popup } from 'vant'
|
|
|
import { defineComponent } from 'vue'
|
|
|
import ChoiceCoupon from './choice-coupon'
|
|
@@ -21,7 +23,8 @@ export default defineComponent({
|
|
|
popupStatus: false,
|
|
|
popupLoading: false,
|
|
|
useCouponList: [] as any,
|
|
|
- useCouponCount: 1
|
|
|
+ useCouponLoading: false,
|
|
|
+ useCouponCount: 0
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
@@ -36,7 +39,26 @@ export default defineComponent({
|
|
|
: 0
|
|
|
}
|
|
|
},
|
|
|
+ mounted() {
|
|
|
+ this.getUseableCoupon()
|
|
|
+ },
|
|
|
methods: {
|
|
|
+ async getUseableCoupon() {
|
|
|
+ try {
|
|
|
+ this.useCouponLoading = true
|
|
|
+ // 判断是哪个端
|
|
|
+ const url =
|
|
|
+ state.platformType === 'STUDENT' ? '/api-student' : '/api-teacher'
|
|
|
+ const res = await request.get(`${url}/couponInfo/statInfo`)
|
|
|
+ this.useCouponLoading = false
|
|
|
+ const result = (res.data || []).find(
|
|
|
+ result => result.useState === 'USABLE'
|
|
|
+ )
|
|
|
+ this.useCouponCount = result.total || 0
|
|
|
+ } catch {
|
|
|
+ // TODO: handle
|
|
|
+ }
|
|
|
+ },
|
|
|
onSubmit(item: any) {
|
|
|
// useCouponList
|
|
|
this.useCouponList = item
|
|
@@ -55,24 +77,25 @@ export default defineComponent({
|
|
|
isLink={!this.disabled}
|
|
|
clickable={false}
|
|
|
v-slots={{
|
|
|
- value: () => (
|
|
|
- <>
|
|
|
- {/* 判断是否有选择优惠券 */}
|
|
|
- {this.couponCount > 0 ? (
|
|
|
- <span class={styles.couponCount}>
|
|
|
- <i>-¥</i>
|
|
|
- {this.couponCount}
|
|
|
- </span>
|
|
|
- ) : (
|
|
|
- <>
|
|
|
- {/* 判断是否有可以的优惠券 */}
|
|
|
- {this.useCouponCount > 0
|
|
|
- ? `${this.useCouponCount}张可使用`
|
|
|
- : '暂无可使用优惠券'}
|
|
|
- </>
|
|
|
- )}
|
|
|
- </>
|
|
|
- )
|
|
|
+ value: () =>
|
|
|
+ !this.useCouponLoading && (
|
|
|
+ <>
|
|
|
+ {/* 判断是否有选择优惠券 */}
|
|
|
+ {this.couponCount > 0 ? (
|
|
|
+ <span class={styles.couponCount}>
|
|
|
+ <i>-¥</i>
|
|
|
+ {this.couponCount}
|
|
|
+ </span>
|
|
|
+ ) : (
|
|
|
+ <>
|
|
|
+ {/* 判断是否有可以的优惠券 */}
|
|
|
+ {this.useCouponCount > 0
|
|
|
+ ? `${this.useCouponCount}张可使用`
|
|
|
+ : '暂无可使用优惠券'}
|
|
|
+ </>
|
|
|
+ )}
|
|
|
+ </>
|
|
|
+ )
|
|
|
}}
|
|
|
onClick={() => {
|
|
|
if (this.disabled) return
|