|
|
@ -63,43 +63,78 @@ export default { |
|
|
|
this.ticketNumber--; |
|
|
|
} |
|
|
|
}, |
|
|
|
confirm(){ |
|
|
|
let { ticketNumber, orderInfo } = this; |
|
|
|
confirm: util.debounce(async function(){ |
|
|
|
let { ticketNumber, orderInfo, orderIndex } = this; |
|
|
|
let { available_num, id } = orderInfo; |
|
|
|
if(+available_num === 0)return; |
|
|
|
if(+ticketNumber > +available_num)return util.showNone('核销次数不能大于剩余次数'); |
|
|
|
try{ |
|
|
|
util.showLoad(); |
|
|
|
let _verifyInfo = await this.sessionVerify({ |
|
|
|
brand_id: orderInfo.brand_id || '', |
|
|
|
nums: ticketNumber, |
|
|
|
order_no: orderInfo.order_no || '' |
|
|
|
}); |
|
|
|
util.hideLoad(); |
|
|
|
util.showNone('核销成功!'); |
|
|
|
await new Promise(resolve => setTimeout(resolve, 1200)); |
|
|
|
|
|
|
|
if(orderIndex>=0){ // 列表刷新 |
|
|
|
try{ |
|
|
|
let _orderInfo = await this.getOrderInfo({ |
|
|
|
order_no: orderInfo.order_no, |
|
|
|
stadium_id: orderInfo.stadium_id |
|
|
|
}); |
|
|
|
if(!_orderInfo.order_no)return util.showNone('加载订单信息失败!'); |
|
|
|
this.$emit('confirm', { orderInfo: _orderInfo || {}, orderIndex }); |
|
|
|
}catch(err){ |
|
|
|
console.warn('加载订单信息失败!', err); |
|
|
|
} |
|
|
|
this.getOrderInfo({ |
|
|
|
order_no: orderInfo.order_no, |
|
|
|
stadium_id: orderInfo.stadium_id |
|
|
|
}) |
|
|
|
}else{ // 详情页直接调用详情方法 |
|
|
|
this.$emit('confirm'); |
|
|
|
} |
|
|
|
|
|
|
|
this.hide(); |
|
|
|
}, |
|
|
|
}catch(err){ |
|
|
|
util.hideLoad(); |
|
|
|
console.warn('核销失败', err); |
|
|
|
} |
|
|
|
|
|
|
|
}, 300, true), |
|
|
|
getOrderInfo({ |
|
|
|
order_no, |
|
|
|
stadium_id |
|
|
|
}){ |
|
|
|
let { orderIndex } = this; |
|
|
|
util.showLoad(); |
|
|
|
servers.get({ |
|
|
|
return servers.get({ |
|
|
|
url: API.order.reservationDetail, |
|
|
|
data: { order_no, stadium_id }, |
|
|
|
failMsg: '加载订单信息失败!' |
|
|
|
}) |
|
|
|
.then(res => { |
|
|
|
util.hideLoad(); |
|
|
|
this.$emit('confirm', { orderInfo: res || {}, orderIndex }); |
|
|
|
return this.orderInfo = res || {}; |
|
|
|
|
|
|
|
}) |
|
|
|
}, |
|
|
|
show({ info, index }) { |
|
|
|
let { orderInfo } = this; |
|
|
|
this.orderInfo = info || {}; |
|
|
|
this.orderIndex = index; |
|
|
|
sessionVerify({ brand_id, nums, order_no }){ |
|
|
|
return servers.post({ |
|
|
|
url: API.order.sessionVerify, |
|
|
|
data: { brand_id, nums, order_no }, |
|
|
|
failMsg: '核销失败!' |
|
|
|
}) |
|
|
|
}, |
|
|
|
show({ order_no, stadium_id, index }) { |
|
|
|
this.ticketNumber = 1; |
|
|
|
this.orderIndex = isNaN(index) || index < 0 ? -1 : index; |
|
|
|
this.isShow = true; |
|
|
|
this.$emit('show'); |
|
|
|
if(orderInfo?.id !== info?.id){ |
|
|
|
this.ticketNumber = 1; |
|
|
|
} |
|
|
|
this.getOrderInfo({ order_no, stadium_id }); |
|
|
|
}, |
|
|
|
hide() { |
|
|
|
this.isShow = false; |
|
|
|