Commit b23bfd53 by 胡悦

提交领取优惠券

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