|
|
|
|
@ -43,13 +43,13 @@ |
|
|
|
|
</view> |
|
|
|
|
<view class="m-botom"> |
|
|
|
|
<button class="m-btn m-btn-line" @click="cancelOrder">取消订单</button> |
|
|
|
|
<button class="m-btn" @click="resvcePrice">确认收款</button> |
|
|
|
|
<button class="m-btn" @click="resvcePrice(choose)">确认收款</button> |
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
<script> |
|
|
|
|
import { paymentOrder,printTicket,cancelOrder } from '@/api/seal/seal.js'; |
|
|
|
|
import { paymentOrder, printTicket, cancelOrder, submitOrder, getOrder } from '@/api/seal/seal.js'; |
|
|
|
|
export default { |
|
|
|
|
data() { |
|
|
|
|
return { |
|
|
|
|
@ -57,17 +57,18 @@ export default { |
|
|
|
|
orderPrice: 0.0, |
|
|
|
|
cashValue: 0, |
|
|
|
|
choose: 'cash', |
|
|
|
|
interval: undefined, |
|
|
|
|
way: [ |
|
|
|
|
// { |
|
|
|
|
// id: 1, |
|
|
|
|
// title: '微信支付', |
|
|
|
|
// imgPath: '/static/images/index/icon_wechat.png' |
|
|
|
|
// }, |
|
|
|
|
// { |
|
|
|
|
// id: 2, |
|
|
|
|
// title: '支付宝支付', |
|
|
|
|
// imgPath: '/static/images/index/icon_alipay.png' |
|
|
|
|
// }, |
|
|
|
|
{ |
|
|
|
|
id: 1, |
|
|
|
|
title: '微信支付', |
|
|
|
|
imgPath: '/static/images/index/icon_wechat.png' |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
id: 2, |
|
|
|
|
title: '支付宝支付', |
|
|
|
|
imgPath: '/static/images/index/icon_alipay.png' |
|
|
|
|
}, |
|
|
|
|
// { |
|
|
|
|
// id: 3, |
|
|
|
|
// title: '银联支付', |
|
|
|
|
@ -82,20 +83,22 @@ export default { |
|
|
|
|
}; |
|
|
|
|
}, |
|
|
|
|
onLoad(params) { |
|
|
|
|
uni.removeStorageSync('ALL_TICKET') |
|
|
|
|
uni.removeStorageSync('EVENT') |
|
|
|
|
uni.removeStorageSync('ALL_TICKET'); |
|
|
|
|
uni.removeStorageSync('EVENT'); |
|
|
|
|
if (params.order) { |
|
|
|
|
uni.setStorageSync('payOrder', params.order); |
|
|
|
|
this.orderDetail = null; |
|
|
|
|
this.orderDetail = JSON.parse(params.order); |
|
|
|
|
console.log('this.orderDetail', this.orderDetail); |
|
|
|
|
this.orderPrice = this.orderDetail.orderInfo.settlementAmount; |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
onUnload() { |
|
|
|
|
this.back() |
|
|
|
|
this.back(); |
|
|
|
|
}, |
|
|
|
|
methods: { |
|
|
|
|
cancelOrder(){ |
|
|
|
|
const that = this |
|
|
|
|
cancelOrder() { |
|
|
|
|
const that = this; |
|
|
|
|
uni.showModal({ |
|
|
|
|
title: '提示', |
|
|
|
|
content: '确定放弃支付吗', |
|
|
|
|
@ -103,68 +106,246 @@ export default { |
|
|
|
|
if (res.confirm) { |
|
|
|
|
uni.showLoading({ |
|
|
|
|
title: '请稍后...' |
|
|
|
|
}) |
|
|
|
|
cancelOrder(that.orderDetail.orderInfo.orderNumber).then(res=>{ |
|
|
|
|
uni.hideLoading(); |
|
|
|
|
uni.showToast({ |
|
|
|
|
icon:'none', |
|
|
|
|
title:'已取消' |
|
|
|
|
}); |
|
|
|
|
cancelOrder(that.orderDetail.orderInfo.orderNumber) |
|
|
|
|
.then((res) => { |
|
|
|
|
uni.hideLoading(); |
|
|
|
|
uni.showToast({ |
|
|
|
|
icon: 'none', |
|
|
|
|
title: '已取消' |
|
|
|
|
}); |
|
|
|
|
setTimeout(() => { |
|
|
|
|
uni.reLaunch({ |
|
|
|
|
url: '/pages/index' |
|
|
|
|
}); |
|
|
|
|
}, 2100); |
|
|
|
|
}) |
|
|
|
|
setTimeout(()=>{ |
|
|
|
|
uni.reLaunch({ |
|
|
|
|
url:'/pages/index' |
|
|
|
|
}) |
|
|
|
|
},2100) |
|
|
|
|
}).catch(err=>{ |
|
|
|
|
uni.hideLoading(); |
|
|
|
|
console.log(err) |
|
|
|
|
}) |
|
|
|
|
.catch((err) => { |
|
|
|
|
uni.hideLoading(); |
|
|
|
|
console.log(err); |
|
|
|
|
}); |
|
|
|
|
} else if (res.cancel) { |
|
|
|
|
console.log('用户点击取消'); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
resvcePrice() { |
|
|
|
|
const obj = { |
|
|
|
|
orderNumber: this.orderDetail.orderInfo.orderNumber, |
|
|
|
|
settlementAmount: Number(this.orderPrice), |
|
|
|
|
payMethod: 'cash', |
|
|
|
|
actualAmount: this.cashValue, |
|
|
|
|
changeAmount: this.cashValue - Number(this.orderPrice) |
|
|
|
|
}; |
|
|
|
|
paymentOrder(obj).then(res=>{ |
|
|
|
|
console.log(res) |
|
|
|
|
const ob = { |
|
|
|
|
orderNumber:this.orderDetail.orderInfo.orderNumber |
|
|
|
|
} |
|
|
|
|
printTicket(ob).then(ress=>{ |
|
|
|
|
const datas = JSON.stringify(this.orderDetail.orderInfo.ticketList) |
|
|
|
|
// console.log(data) |
|
|
|
|
uni.navigateTo({ |
|
|
|
|
url:'/pages/payResult/payResult?status=success&detail='+datas+'&tickets='+ress.data |
|
|
|
|
createQueryInterval() { |
|
|
|
|
let that = this |
|
|
|
|
if (this.interval) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
this.interval = setInterval(() => { |
|
|
|
|
getOrder(that.orderDetail.orderInfo.belongingPayOrderId).then((response) => { |
|
|
|
|
// 已支付 |
|
|
|
|
if (response.data.status === 10) { |
|
|
|
|
that.clearQueryInterval(); |
|
|
|
|
uni.hideLoading(); |
|
|
|
|
uni.showToast({ |
|
|
|
|
icon: 'none', |
|
|
|
|
title: '支付成功!', |
|
|
|
|
duration: 1000 |
|
|
|
|
}); |
|
|
|
|
const ob = { |
|
|
|
|
orderNumber: that.orderDetail.orderInfo.orderNumber |
|
|
|
|
}; |
|
|
|
|
printTicket(ob) |
|
|
|
|
.then((ress) => { |
|
|
|
|
const datas = JSON.stringify(that.orderDetail.orderInfo.ticketList); |
|
|
|
|
// console.log(data) |
|
|
|
|
uni.navigateTo({ |
|
|
|
|
url: '/pages/payResult/payResult?status=success&detail=' + datas + '&tickets=' + ress.data |
|
|
|
|
}); |
|
|
|
|
}) |
|
|
|
|
.catch((err) => { |
|
|
|
|
console.log(err); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
// 已取消 |
|
|
|
|
if (response.data.status === 20) { |
|
|
|
|
that.clearQueryInterval(); |
|
|
|
|
uni.hideLoading(); |
|
|
|
|
uni.showToast({ |
|
|
|
|
icon: 'none', |
|
|
|
|
title: '支付已关闭!', |
|
|
|
|
duration: 1000 |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}, 1000 * 2); |
|
|
|
|
}, |
|
|
|
|
/** 清空查询任务 */ |
|
|
|
|
clearQueryInterval() { |
|
|
|
|
// 清空任务 |
|
|
|
|
clearInterval(this.interval); |
|
|
|
|
this.interval = undefined; |
|
|
|
|
}, |
|
|
|
|
resvcePrice(val) { |
|
|
|
|
let that = this |
|
|
|
|
console.log(val); |
|
|
|
|
if (val == 1) { |
|
|
|
|
uni.hideLoading(); |
|
|
|
|
uni.scanCode({ |
|
|
|
|
scanType: ['barCode','qrCode'], |
|
|
|
|
success: function (resposon) { |
|
|
|
|
console.log('条码内容:' + resposon.result); |
|
|
|
|
// console.log('this.orderDetail', this.orderDetail); |
|
|
|
|
const obj = { |
|
|
|
|
channelCode: 'wx_bar', |
|
|
|
|
channelExtras: { |
|
|
|
|
auth_code: resposon.result |
|
|
|
|
}, |
|
|
|
|
id: that.orderDetail.orderInfo.belongingPayOrderId, |
|
|
|
|
returnUrl: '' |
|
|
|
|
}; |
|
|
|
|
debugger |
|
|
|
|
submitOrder(obj).then((res) => { |
|
|
|
|
console.log('支付结果',res) |
|
|
|
|
const data = res.data; |
|
|
|
|
if (data.status === 10) { |
|
|
|
|
that.clearQueryInterval(); |
|
|
|
|
uni.showToast({ |
|
|
|
|
icon: 'none', |
|
|
|
|
title: '支付成功!', |
|
|
|
|
duration: 1000 |
|
|
|
|
}); |
|
|
|
|
const ob = { |
|
|
|
|
orderNumber: that.orderDetail.orderInfo.orderNumber |
|
|
|
|
}; |
|
|
|
|
printTicket(ob) |
|
|
|
|
.then((ress) => { |
|
|
|
|
const datas = JSON.stringify(that.orderDetail.orderInfo.ticketList); |
|
|
|
|
// console.log(data) |
|
|
|
|
uni.navigateTo({ |
|
|
|
|
url: '/pages/payResult/payResult?status=success&detail=' + datas + '&tickets=' + ress.data |
|
|
|
|
}); |
|
|
|
|
}) |
|
|
|
|
.catch((err) => { |
|
|
|
|
console.log(err); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
// 打开轮询任务 |
|
|
|
|
uni.showLoading({ |
|
|
|
|
title: '支付中...', |
|
|
|
|
mask:true |
|
|
|
|
}); |
|
|
|
|
this.createQueryInterval(); |
|
|
|
|
}).catch(err=>{ |
|
|
|
|
// uni.showLoading({ |
|
|
|
|
// title: '支付中...' |
|
|
|
|
// }); |
|
|
|
|
// this.createQueryInterval(); |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
if (val == 2) { |
|
|
|
|
// 调起条码扫描 |
|
|
|
|
uni.hideLoading(); |
|
|
|
|
uni.scanCode({ |
|
|
|
|
scanType: ['barCode','qrCode'], |
|
|
|
|
success: function (resposon) { |
|
|
|
|
console.log('条码内容:' + resposon.result); |
|
|
|
|
// console.log('this.orderDetail', this.orderDetail); |
|
|
|
|
const obj = { |
|
|
|
|
channelCode: 'alipay_bar', |
|
|
|
|
channelExtras: { |
|
|
|
|
auth_code: resposon.result |
|
|
|
|
}, |
|
|
|
|
id: that.orderDetail.orderInfo.belongingPayOrderId, |
|
|
|
|
returnUrl: '' |
|
|
|
|
}; |
|
|
|
|
debugger |
|
|
|
|
submitOrder(obj).then((res) => { |
|
|
|
|
console.log('支付结果',res) |
|
|
|
|
const data = res.data; |
|
|
|
|
if (data.status === 10) { |
|
|
|
|
that.clearQueryInterval(); |
|
|
|
|
uni.showToast({ |
|
|
|
|
icon: 'none', |
|
|
|
|
title: '支付成功!', |
|
|
|
|
duration: 1000 |
|
|
|
|
}); |
|
|
|
|
const ob = { |
|
|
|
|
orderNumber: that.orderDetail.orderInfo.orderNumber |
|
|
|
|
}; |
|
|
|
|
printTicket(ob) |
|
|
|
|
.then((ress) => { |
|
|
|
|
const datas = JSON.stringify(that.orderDetail.orderInfo.ticketList); |
|
|
|
|
// console.log(data) |
|
|
|
|
uni.navigateTo({ |
|
|
|
|
url: '/pages/payResult/payResult?status=success&detail=' + datas + '&tickets=' + ress.data |
|
|
|
|
}); |
|
|
|
|
}) |
|
|
|
|
.catch((err) => { |
|
|
|
|
console.log(err); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
// 打开轮询任务 |
|
|
|
|
uni.showLoading({ |
|
|
|
|
title: '支付中...', |
|
|
|
|
mask:true |
|
|
|
|
}); |
|
|
|
|
this.createQueryInterval(); |
|
|
|
|
}).catch(err=>{ |
|
|
|
|
// uni.showLoading({ |
|
|
|
|
// title: '支付中...' |
|
|
|
|
// }); |
|
|
|
|
// this.createQueryInterval(); |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
if (val == 'cash') { |
|
|
|
|
const obj = { |
|
|
|
|
orderNumber: this.orderDetail.orderInfo.orderNumber, |
|
|
|
|
settlementAmount: Number(this.orderPrice), |
|
|
|
|
payMethod: 'cash', |
|
|
|
|
actualAmount: this.cashValue, |
|
|
|
|
changeAmount: this.cashValue - Number(this.orderPrice) |
|
|
|
|
}; |
|
|
|
|
paymentOrder(obj) |
|
|
|
|
.then((res) => { |
|
|
|
|
console.log(res); |
|
|
|
|
const ob = { |
|
|
|
|
orderNumber: this.orderDetail.orderInfo.orderNumber |
|
|
|
|
}; |
|
|
|
|
printTicket(ob) |
|
|
|
|
.then((ress) => { |
|
|
|
|
const datas = JSON.stringify(this.orderDetail.orderInfo.ticketList); |
|
|
|
|
// console.log(data) |
|
|
|
|
uni.navigateTo({ |
|
|
|
|
url: '/pages/payResult/payResult?status=success&detail=' + datas + '&tickets=' + ress.data |
|
|
|
|
}); |
|
|
|
|
}) |
|
|
|
|
.catch((err) => { |
|
|
|
|
console.log(err); |
|
|
|
|
}); |
|
|
|
|
}) |
|
|
|
|
}).catch(err=>{ |
|
|
|
|
console.log(err) |
|
|
|
|
}) |
|
|
|
|
}).catch(err=>{ |
|
|
|
|
console.log(err) |
|
|
|
|
// uni.navigateTo({ |
|
|
|
|
// url:'/pages/payResult/payResult?status=fail' |
|
|
|
|
// }) |
|
|
|
|
}) |
|
|
|
|
.catch((err) => { |
|
|
|
|
console.log(err); |
|
|
|
|
// uni.navigateTo({ |
|
|
|
|
// url:'/pages/payResult/payResult?status=fail' |
|
|
|
|
// }) |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
back() { |
|
|
|
|
let that = this |
|
|
|
|
cancelOrder(that.orderDetail.orderInfo.orderNumber).then(res=>{ |
|
|
|
|
console.log(res) |
|
|
|
|
}).catch(err=>{ |
|
|
|
|
console.log(err) |
|
|
|
|
}) |
|
|
|
|
let that = this; |
|
|
|
|
cancelOrder(that.orderDetail.orderInfo.orderNumber) |
|
|
|
|
.then((res) => { |
|
|
|
|
console.log(res); |
|
|
|
|
}) |
|
|
|
|
.catch((err) => { |
|
|
|
|
console.log(err); |
|
|
|
|
}); |
|
|
|
|
uni.navigateBack({ |
|
|
|
|
delta:1, |
|
|
|
|
}) |
|
|
|
|
delta: 1 |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|