Commit b23bfd53 by 胡悦

提交领取优惠券

1 parent de2d9489
......@@ -3,7 +3,7 @@
* @Author: huyue
* @Date: 2024-09-06 10:11:03
* @LastEditors: huyue
* @LastEditTime: 2024-09-06 17:14:39
* @LastEditTime: 2024-09-12 10:15:21
-->
<template>
<view>
......@@ -92,21 +92,23 @@
<view>客户领券成功</view>
</view>
</template>
<template v-if="!pageParams.received && pageParams.QRURL">
<image
class="qr-code-img"
:src="pageParams.QRURL"
/>
</template>
<template v-else>
<view class="no-data">
<template v-if="pageParams.QRURL">
<image
src="@/assets/images/boutique/no-data.webp"
class="no-data-img"
class="qr-code-img"
:src="pageParams.QRURL"
/>
<view>填写客户信息后点击</view>
<view>生成专属二维码」生成券码</view>
</view>
</template>
<tempalate v-else>
<view class="no-data">
<image
src="@/assets/images/boutique/no-data.webp"
class="no-data-img"
/>
<view>填写客户信息后点击</view>
<view>生成专属二维码」生成券码</view>
</view>
</tempalate>
</template>
</template>
<template v-else>
......@@ -180,6 +182,7 @@
import Employee from '@/components/Employee.vue'
import qrcode from '@/utils/qrcode.js'
const phoneRex = /^[1]([3-9])[0-9]{9}$/;
import dayjs from 'dayjs'
const formObject_boutique = [{
label: "车主姓名",
key: "customerName",
......@@ -227,13 +230,18 @@ export default {
customerType: {
type: Number,
default: 1
},
carInfo: {
type: Object,
default: () => ({})
}
},
components: { Employee },
watch: {
watchCustomerInfo: {
immediate: true,
handler (newval) {
handler(newval) {
console.log(newval, 'carModel')
this.customerInfo = newval
this.pageParams.showDetail = false
}
......@@ -257,13 +265,13 @@ export default {
QRURL: '',
showDetail: false,
clickFlag: false,
customerCouponId: 'id=1'
customerCouponId: ''
},
isCheck: false
}
},
mounted () {
this.init()
console.log(qrcode.createQrCodeImg('id=10086', {
size: 200
}))
......@@ -294,6 +302,7 @@ export default {
let item = arr.find(e => e.couponType == 1),
item2 = arr.find(e => e.couponType == 18)
if (!this.pageParams.couponId) {
console.log(1111111111111)
if (item) this.chooseCoupon(item) //默认填入类型为「太阳膜」类型
else if (item2) this.chooseCoupon(item2) //次选填入「精品」类型
else this.chooseCoupon(arr[0]) // 无此两种类型情况默认带入任意类型礼券
......@@ -308,7 +317,8 @@ export default {
const { customerName, phoneNumber, staffName } = this.customerInfo
this.isCheck = customerName && phoneNumber && staffName
},
chooseCoupon (item) {
chooseCoupon(item) {
console.log(item, '----------')
this.pageParams.couponId = item.id
this.customerInfo.couponTypeName = item.couponTypeName
this.$refs.couponBoxVisible.close()
......@@ -325,6 +335,7 @@ export default {
},
open () {
this.$refs.couponPopup.open()
this.init()
},
close () {
this.$refs.couponPopup.close()
......@@ -363,12 +374,13 @@ export default {
})
flag = false
}
console.log(flag, this.customerInfo, this.pageParams)
return flag
},
async createCoupon () {
try {
console.log(this.pageParams)
const { pageParams: { clickFlag, couponId, carInfo }, customerInfo } = this, {
const { pageParams: { clickFlag, couponId }, carInfo, customerInfo } = this, {
shopMerchantId } = uni.$storage.get("userInfo"),
validateStatus = await this.validate(),
checkCouponAmount = await this.checkCouponAmount(couponId, [shopMerchantId])
......@@ -398,7 +410,6 @@ export default {
if (data) {
this.pageParams.QRURL = data
this.checkCustomerReceivedStatus(dayjs().format("YYYY-MM-DD HH:mm:ss"))
this.$refs.qrbox.open()
uni.hideLoading()
this.pageParams.clickFlag = false
}
......@@ -412,6 +423,13 @@ export default {
}
}
},
async checkCouponAmount (merchantCouponId, merchantIdList) {
const { list } = await uni.$api.boutiqueApi.findCouponList({
merchantCouponId,
merchantIdList
})
return list || []
},
checkCustomerReceivedStatus (receiveCouponStartTime) {
if (this.pageParams.qrTimer) return
try {
......@@ -425,7 +443,6 @@ export default {
})
if (res && res.total) {
this.pageParams.received = true
this.closeQr()
this.$emit('reception', {
item: {
customerName: customerInfo.customerName,
......@@ -436,9 +453,6 @@ export default {
receiveCouponDate: Date.now()
}
})
setTimeout(() => {
this.$refs.qrbox.close()
}, 3e3)
}
}, 2e3)
} catch (error) {
......@@ -483,8 +497,8 @@ export default {
background-color: #f9f9f9;
}
&-img {
width: 343rpx;
height: 343rpx;
width: 400rpx;
height: 400rpx;
}
}
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!