Commit db351fea by 李嘉林

支付功能

parent bd5297f9
......@@ -4,6 +4,6 @@ import { requestPOST, requestGET } from "@/utils/request.js";
export default {
//登录
orderDetail(options) {
return requestGET(`${process.env.OLSHOP_URL}/order/detail`, options);
return requestPOST(`${process.env.OLSHOP_URL}/order/detail?orderSn=${options}`);
}
};
......@@ -6,10 +6,10 @@
<div class="btn-wrap">
<button open-type="contact">
<div class="btn-main">
<div class="main-img">
<div class="main-img" v-if="!isTT">
<img src="../../../static/images/wx.png" alt="">
</div>
<div class="main-text">官方微信客服</div>
<div class="main-text">官方{{!isTT?'微信':''}}客服</div>
</div>
<img class="btn-next" src="../../../static/images/next.png" alt="">
</button>
......@@ -19,7 +19,11 @@
<script>
export default {
data(){
return {
isTT:MINI_ENV=='tt',
}
}
}
</script>
......
......@@ -155,6 +155,7 @@ export default {
},
// 头条支付
toTtPay(orderInfo){
let _this=this;
console.log(orderInfo,'---orderInfo')
tt.pay({
orderInfo,
......@@ -163,6 +164,7 @@ export default {
default_pay_channel: "wx", // wx || alipay
},
getOrderStatus(res) {
console.log(res,'------------------------167')
let { out_order_no } = res;
return new Promise(function (resolve, reject) {
// 商户前端根据 out_order_no 请求商户后端查询微信支付订单状态
......@@ -170,8 +172,20 @@ export default {
orderSn:out_order_no,
}
order.orderDetail(query).then(res=>{
console.log(res.data,"------------------------174")
if(res.data.code==200){
console.log(res.data.data,'------------------订单信息')
let code="";
if(res.data.data){
let {paymentStatus}=res.data.data;
if(paymentStatus==2){
code=0;
}else if(paymentStatus-0==0){
code=4;
}else {
code=9;
}
}
// 商户后端查询的微信支付状态,通知收银台支付结果
// 0:支付成功
// 1:支付超时
......@@ -179,7 +193,7 @@ export default {
// 3:支付关闭
// 4:支付取消
// 9:订单状态未知/未支付
// resolve({ code: 0 | 1 | 2 | 3 | 9 });
resolve({ code });
}else {
console.log(res.data.msg,'------查询订单详情失败');
reject(res.data.msg);
......@@ -188,14 +202,53 @@ export default {
});
},
success(res) {
console.log(res,'--------------ttpay')
if (res.code == 0) {
console.log("支付成功处理逻辑,只有res.code=0时,才表示支付成功")
// 支付成功处理逻辑,只有res.code=0时,才表示支付成功
// 但是最终状态要以商户后端结果为准
}
order.orderDetail(_this.options.orderSn).then(res=>{
if(res.data.code==200){
console.log(res.data.data,'------------------订单信息')
if(res.data.data){
let {paymentStatus}=res.data.data;
if(paymentStatus==2){
wx.hideLoading();
wx.showToast({ title: '支付成功', icon: "none" });
if(!_this.options_isCard){
let query = {
orderSn: _this.options.orderSn
};
wx.redirectTo({
url: `../index/main?from=wxPay&backpath=/pay/paySuccess&params=${JSON.stringify(
query
)}`
});
}else{
let query = {
cardTitle: _this.options_isCardTitle
};
wx.redirectTo({
url: `../index/main?from=wxPay&backpath=/pay/payCardSuccess&params=${JSON.stringify(
query
)}`
});
}
}else if(paymentStatus-0==0){
wx.hideLoading();
wx.showToast({ title: '支付失败', icon: "none" });
_this.toPage();
}else {
wx.hideLoading();
wx.showToast({ title: '支付失败', icon: "none" });
_this.toPage();
}
}
}else {
console.log(res.data.msg,'------查询订单详情失败');
reject(res.data.msg);
}
})
},
fail(res) {
wx.hideLoading();
wx.showToast({ title: '支付失败', icon: "none" });
_this.toPage();
console.log(res,'-----------------------201--res')
// 调起收银台失败处理逻辑
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment