Commit 0a66a129 by 李伟康

commit

1 parent 0cb2063a
...@@ -15,6 +15,8 @@ module.exports = { ...@@ -15,6 +15,8 @@ module.exports = {
method: 'dj.api.smartcarlife.merchantCoupon.pageForZYApp', method: 'dj.api.smartcarlife.merchantCoupon.pageForZYApp',
projectName: "boutique", projectName: "boutique",
onlyUsable: true, onlyUsable: true,
currentPage: 1,
pageSize: 99999,
...data, ...data,
},false,'ip'); },false,'ip');
}, },
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<view class="box"> <view class="box">
<view <view
class="icon-close-box flex" class="icon-close-box flex"
@click="$refs.qr.close()" @click="close"
> >
<uni-icons <uni-icons
class="icon-close" class="icon-close"
......
...@@ -107,7 +107,7 @@ ...@@ -107,7 +107,7 @@
<view class="select-box"> <view class="select-box">
<view <view
class="select-item" class="select-item"
:class="{ checked: couponId == item.id }" :class="{ checked: pageParams.couponId == item.id }"
@click="chooseCoupon(item)" @click="chooseCoupon(item)"
v-for="(item, index) in couponList" v-for="(item, index) in couponList"
:key="index" :key="index"
...@@ -117,9 +117,9 @@ ...@@ -117,9 +117,9 @@
</view> </view>
</MessageBox> </MessageBox>
<qr-box <qr-box
:url="QRURL" :url="pageParams.QRURL"
ref="qrbox" ref="qrbox"
:received="received" :received="pageParams.received"
@close="closeQr" @close="closeQr"
/> />
</view> </view>
...@@ -174,11 +174,13 @@ export default { ...@@ -174,11 +174,13 @@ export default {
couponList: [], couponList: [],
couponTypeName: '', couponTypeName: '',
focusIndex: -1, focusIndex: -1,
pageParams: {
qrTimer: null,
received: false,
couponId: '', couponId: '',
carInfo: {}, carInfo: {},
QRURL: '', QRURL: '',
received: false, }
qrTimer: null
} }
}, },
watch: { watch: {
...@@ -190,6 +192,13 @@ export default { ...@@ -190,6 +192,13 @@ export default {
}, },
show (n) { show (n) {
if (n && this.customerType == 1) this.init() if (n && this.customerType == 1) this.init()
},
watchStatus: {
immediate: true,
handler (newval) {
this.pageParams = this.$options.data.call(this).pageParams
this.resetFocusIndex()
}
} }
}, },
computed: { computed: {
...@@ -203,8 +212,6 @@ export default { ...@@ -203,8 +212,6 @@ export default {
methods: { methods: {
init () { init () {
this.qrTimer = null
this.resetFocusIndex()
this.findCouponList() this.findCouponList()
}, },
async findCouponList () { async findCouponList () {
...@@ -214,8 +221,26 @@ export default { ...@@ -214,8 +221,26 @@ export default {
merchantIdList: [shopMerchantId] merchantIdList: [shopMerchantId]
}) })
if (list && list.length) { if (list && list.length) {
let item = list.find(e => e.couponType == 1) let couponTypeList = Array.from(new Set([...list.map((e) => e.couponType)]))
if (item && !this.couponId) this.chooseCoupon(item) let arr = []
couponTypeList.map((i) => {
let item = []
list.map((e) => {
if (i == e.couponType) item.push(e)
})
arr.push({
couponType: i,
list: item
})
})
console.log(arr)
let item = list.find(e => e.couponType == 1),
item2 = list.find(e => e.couponType == 18)
if (!this.pageParams.couponId) {
if (item) this.chooseCoupon(item) //默认填入类型为「太阳膜」类型
else if (item2) this.chooseCoupon(item) //次选填入「精品」类型
else this.chooseCoupon(list[0]) // 无此两种类型情况默认带入任意类型礼券
}
} }
this.couponList = list || [] this.couponList = list || []
}, },
...@@ -230,7 +255,7 @@ export default { ...@@ -230,7 +255,7 @@ export default {
} else { } else {
this.$refs.carBrandListVisible.close() this.$refs.carBrandListVisible.close()
this.customerInfo.carModel = item.name this.customerInfo.carModel = item.name
this.carInfo = item this.pageParams.carInfo = item
} }
this.resetFocusIndex() this.resetFocusIndex()
this.$store.dispatch('setCustomerInfo', this.customerInfo) this.$store.dispatch('setCustomerInfo', this.customerInfo)
...@@ -247,7 +272,7 @@ export default { ...@@ -247,7 +272,7 @@ export default {
this.closeQr() this.closeQr()
}, },
chooseCoupon (item) { chooseCoupon (item) {
this.couponId = item.id this.pageParams.couponId = item.id
this.couponTypeName = item.couponTypeName this.couponTypeName = item.couponTypeName
this.$refs.couponBoxVisible.close() this.$refs.couponBoxVisible.close()
}, },
...@@ -256,7 +281,7 @@ export default { ...@@ -256,7 +281,7 @@ export default {
}, },
async createCoupon () { async createCoupon () {
try { try {
const { couponId, customerInfo, carInfo } = this const { pageParams: { couponId, carInfo }, customerInfo } = this
await this.validate() await this.validate()
uni.showLoading() uni.showLoading()
const { const {
...@@ -281,13 +306,12 @@ export default { ...@@ -281,13 +306,12 @@ export default {
uni.hideLoading() uni.hideLoading()
if (code == 0) { if (code == 0) {
if (data) { if (data) {
this.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() this.$refs.qrbox.open()
} }
else throw '生成小程序码失败,请重试!' else throw '生成小程序码失败,请重试!'
} else throw message } else throw message
console.log(data)
} catch (error) { } catch (error) {
console.log(error) console.log(error)
uni.showToast({ uni.showToast({
...@@ -298,7 +322,7 @@ export default { ...@@ -298,7 +322,7 @@ export default {
}, },
async validate () { async validate () {
const { customerName, phoneNumber, carModel, staffName } = this.customerInfo, const { customerName, phoneNumber, carModel, staffName } = this.customerInfo,
{ couponId } = this { couponId } = this.pageParams
// 检查车主姓名 // 检查车主姓名
if (!customerName) throw '请输入车主姓名' if (!customerName) throw '请输入车主姓名'
// 检查车主手机 // 检查车主手机
...@@ -312,15 +336,16 @@ export default { ...@@ -312,15 +336,16 @@ export default {
if (!couponId) throw '请选择礼券类型' if (!couponId) throw '请选择礼券类型'
}, },
checkCustomerReceivedStatus (receiveCouponStartTime) { checkCustomerReceivedStatus (receiveCouponStartTime) {
this.qrTimer = setInterval(async () => { this.pageParams.received = false
const { couponId, customerInfo } = this, this.pageParams.qrTimer = setInterval(async () => {
const { pageParams: { couponId }, customerInfo } = this,
res = await uni.$api.boutiqueApi.findCustomerReceivedStatus({ res = await uni.$api.boutiqueApi.findCustomerReceivedStatus({
merchantCouponId: couponId, merchantCouponId: couponId,
customerPhone: customerInfo.phoneNumber, customerPhone: customerInfo.phoneNumber,
receiveCouponStartTime receiveCouponStartTime
}) })
if (res.total) { if (res.total) {
this.received = true this.pageParams.received = true
this.closeQr() this.closeQr()
setTimeout(() => { setTimeout(() => {
this.$refs.qrbox.close() this.$refs.qrbox.close()
...@@ -329,9 +354,8 @@ export default { ...@@ -329,9 +354,8 @@ export default {
}, 1e3) }, 1e3)
}, },
closeQr () { closeQr () {
console.log(this.qrTimer) clearInterval(this.pageParams.qrTimer)
clearInterval(this.qrTimer) this.pageParams.qrTimer = null
this.qrTimer = null
}, },
resetFocusIndex () { resetFocusIndex () {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!