Przeglądaj źródła

[支付状态的更新][修改]:支付状态的更新

tags/2.3.0
meo 6 lat temu
rodzic
commit
e82d76eca6
5 zmienionych plików z 91 dodań i 81 usunięć
  1. +73
    -73
      pages/coupon/detail/index.js
  2. +1
    -0
      pages/index/rushToBuy/index.js
  3. +7
    -4
      pages/order/detail/index.js
  4. +9
    -1
      pages/passCar/passCar.js
  5. +1
    -3
      utils/util.js

+ 73
- 73
pages/coupon/detail/index.js Wyświetl plik

@@ -6,11 +6,11 @@ const util = require("../../../utils/util");
Page({ Page({
data: { data: {
data: { data: {
title:null
title: null
}, },
questions1:null,
questions2:null,
display:"none",
questions1: null,
questions2: null,
display: "none",
carList: [], carList: [],
couponChannelId: null, couponChannelId: null,
couponId: null, couponId: null,
@@ -26,11 +26,11 @@ Page({
end_time: null, end_time: null,
clock: "已经截止", clock: "已经截止",
questionnaire: {}, questionnaire: {},
questionId:null
questionId: null
}, },
onShow:function(){
onShow: function () {
this.setData({ this.setData({
display:"none",
display: "none",
}) })
}, },
phone: function () { phone: function () {
@@ -50,59 +50,59 @@ Page({
let that = this; let that = this;
that.setData({ that.setData({
questions1: e.detail, questions1: e.detail,
display:"none"
display: "none"
}) })
}, },
formSubmit:function(e){
formSubmit: function (e) {
let that = this; let that = this;
that.setData({ that.setData({
questions2: e.detail, questions2: e.detail,
display:"none"
display: "none"
}) })
}, },
/** /**
* gotopay * gotopay
*/ */
gotopay:function(){
gotopay: function () {
let that = this; let that = this;
if (that.data.questions1 || that.data.questions2){
if (that.data.questions1 || that.data.questions2) {
that.setData({ that.setData({
display: "none", display: "none",
}) })
that.orderFunc(); that.orderFunc();
}else{
} else {
Http.get({ Http.get({
url: config.api.getQuestion, url: config.api.getQuestion,
data: { data: {
couponType: JSON.stringify(that.data.data.type) couponType: JSON.stringify(that.data.data.type)
} }
}) })
.then(res => {
if (res.data == undefined) {
.then(res => {
if (res.data == undefined) {
that.setData({ that.setData({
display: "none", display: "none",
}) })
that.orderFunc(); that.orderFunc();
} }
else if (res.data) {
that.setData({
display: "block",
questionnaire: JSON.parse(res.data.content),
questionId:res.data.id
else if (res.data) {
that.setData({
display: "block",
questionnaire: JSON.parse(res.data.content),
questionId: res.data.id
});
}
})
.catch(err => {
wx.showToast({
title: err.errMsg,
icon: 'none',
duration: 2000,
mask: false
}); });
}
})
.catch(err => {
wx.showToast({
title: err.errMsg,
icon: 'none',
duration: 2000,
mask: false
});
})
})
} }
}, },

countdown(end_time) { countdown(end_time) {
let that = this; let that = this;
var EndTime = end_time; var EndTime = end_time;
@@ -110,8 +110,8 @@ Page({
var total_micro_second = EndTime - NowTime || []; var total_micro_second = EndTime - NowTime || [];
// 渲染倒计时时钟 // 渲染倒计时时钟
let obj = that.dateformat(total_micro_second); let obj = that.dateformat(total_micro_second);
if (total_micro_second>0){
if (total_micro_second > 0) {
that.setData({ that.setData({
clock: obj, clock: obj,
day: obj.a1, day: obj.a1,
@@ -119,7 +119,7 @@ Page({
min: obj.c1, min: obj.c1,
sec: obj.d1, sec: obj.d1,
}) })
}else{
} else {
that.setData({ that.setData({
clock: "00", clock: "00",
day: "00", day: "00",
@@ -145,10 +145,10 @@ Page({
// 分钟 // 分钟
var min = Math.floor(second / 60 % 60) < 10 ? "0" + Math.floor(second / 60 % 60) : Math.floor(second / 60 % 60); var min = Math.floor(second / 60 % 60) < 10 ? "0" + Math.floor(second / 60 % 60) : Math.floor(second / 60 % 60);
// 秒 // 秒
var sec = Math.floor(second % 60) < 10 ? "0" + Math.floor(second % 60): Math.floor(second % 60);
var sec = Math.floor(second % 60) < 10 ? "0" + Math.floor(second % 60) : Math.floor(second % 60);
// return day + "天" + hr + "小时" + min + "分钟" + sec + "秒"; // return day + "天" + hr + "小时" + min + "分钟" + sec + "秒";
return { a1: day, b1: hr, c1: min, d1: sec}
return { a1: day, b1: hr, c1: min, d1: sec }
}, },
onLoad(options) { onLoad(options) {
let that = this; let that = this;
@@ -171,7 +171,7 @@ Page({
} }
}; };
Http.get(parmer).then(res => { Http.get(parmer).then(res => {
if (res.data.endTime){
if (res.data.endTime) {
that.countdown(res.data.endTime); that.countdown(res.data.endTime);
//当前时间与优惠券下架时间做计算 //当前时间与优惠券下架时间做计算
var endTime = util.formatTime(res.data.endTime, "yyyy-MM-dd hh:mm:ss"); var endTime = util.formatTime(res.data.endTime, "yyyy-MM-dd hh:mm:ss");
@@ -185,7 +185,7 @@ Page({
}); });
} }
} }
wx.hideLoading(); wx.hideLoading();
that.setData({ that.setData({
data: res.data data: res.data
@@ -212,8 +212,8 @@ Page({
/** /**
* 支付订单更新 * 支付订单更新
*/ */
payOrderUpdate: (orderId, payOrderId, status, reason,type,_this) => {
let that=this;
payOrderUpdate: (orderId, payOrderId, status, reason, type, _this) => {
let that = this;
// 支付成功 // 支付成功
Http.post({ Http.post({
url: config.api.payOrderUpdate, url: config.api.payOrderUpdate,
@@ -225,21 +225,25 @@ Page({
} }
}) })
.then(res => { .then(res => {
if(!type){
setTimeout(() => {
wx.navigateTo({
url: `/pages/order/detail/index?orderId=${
orderId
}`
});
console.log(res);
if (!type) {
setTimeout(() => {
wx.navigateTo({
url: `/pages/order/detail/index?orderId=${
orderId
}`
});
}, 1000) }, 1000)
}
}
})
.catch(err => {
console.log(err);
if (!type) {
setTimeout(function () {
_this.payOrderUpdate(orderId, payOrderId, status, reason, type, _this);
}, 2000)
}
}) })
.catch(err => {
setTimeout(function(){
_this.payOrderUpdate(orderId, payOrderId, status, reason, type, _this);
},2000)
});
}, },
/** /**
* 发起支付 * 发起支付
@@ -330,7 +334,6 @@ Page({
mask: false mask: false
}); });
} else if (err.code == 11005) { } else if (err.code == 11005) {
// 用户手机未授权
/** /**
* 将值传到用户手机号授权的页面 * 将值传到用户手机号授权的页面
* *
@@ -402,33 +405,30 @@ Page({
wx.switchTab({ wx.switchTab({
url: '/pages/passCar/passCar' url: '/pages/passCar/passCar'
}); });
}, 1600);
}, 1600);
} }
} }
}, },

fail: res => { fail: res => {
that.payOrderUpdate(that.data.orderId, payOrderId, 2,'','fail'); // 支付失败
/**
* 支付失败,需要更新订单的状态
*/
that.payOrderUpdate(that.data.orderId, payOrderId, 2, '', 'fail',that);
return; return;
}, },
complete: res => { complete: res => {
} }
}); });
/// End payment -------- /// End payment --------

///// virtual pay
//var payOrderId = "" + res.data.out_trade_no;
//that.payOrderUpdate(that.data.orderId, payOrderId, 1); // 支付成功
///// end virtual pay
})
.catch(err => {
wx.showToast({
title: err.errMsg,
icon: 'none',
duration: 2000,
mask: false
});
}) })
.catch(err => {
wx.showToast({
title: err.errMsg,
icon: 'none',
duration: 2000,
mask: false
});
})
} else { } else {
// 免费券 // 免费券
that.payOrderUpdate(orderId, "0", 1, '', 'fail'); that.payOrderUpdate(orderId, "0", 1, '', 'fail');
@@ -482,10 +482,10 @@ Page({
if (options.from == 'button') { if (options.from == 'button') {
var eData = options.target.dataset.id; var eData = options.target.dataset.id;
var couponId = options.target.dataset.couponid; var couponId = options.target.dataset.couponid;
// shareObj.path = `/pages/index/index?couponChannelId=${eData}&couponId=${couponId}`;
shareObj.path = `/pages/index/index?couponChannelId=${eData}&couponId=${couponId}`; shareObj.path = `/pages/index/index?couponChannelId=${eData}&couponId=${couponId}`;
} }
// 返回shareObj // 返回shareObj
return shareObj; return shareObj;
}
},

}); });

+ 1
- 0
pages/index/rushToBuy/index.js Wyświetl plik

@@ -55,6 +55,7 @@ Component({
}); });
}) })
.catch(err => { .catch(err => {
console.log(err)
wx.showToast({ wx.showToast({
title: err.errMsg, title: err.errMsg,
icon: 'none', icon: 'none',


+ 7
- 4
pages/order/detail/index.js Wyświetl plik

@@ -144,7 +144,7 @@ Page({
that.payOrderUpdate(that.data.orderId, payOrderId, 1,'','',that); // 支付成功 that.payOrderUpdate(that.data.orderId, payOrderId, 1,'','',that); // 支付成功
}, },
fail: res => { fail: res => {
that.payOrderUpdate(that.data.orderId, payOrderId, 2,'','fail');
that.payOrderUpdate(that.data.orderId, payOrderId, 2,'','fail',that);
return; return;
}, },
}); });
@@ -198,9 +198,12 @@ Page({
} }
}) })
.catch(err => { .catch(err => {
setTimeout(function () {
_this.payOrderUpdate(orderId, payOrderId, status, reason, type, _this);
}, 1500)
console.log(err)
if (!type) {
setTimeout(function () {
_this.payOrderUpdate(orderId, payOrderId, status, reason, type, _this);
}, 1500)
}
}); });
}, },




+ 9
- 1
pages/passCar/passCar.js Wyświetl plik

@@ -199,6 +199,7 @@ Page({
url: "/pages/getuserinfo/index" url: "/pages/getuserinfo/index"
}); });
}else{ }else{
console.log(err)
wx.showToast({ wx.showToast({
title: err.errMsg, title: err.errMsg,
icon: 'none', icon: 'none',
@@ -228,6 +229,7 @@ Page({
} }
}) })
.catch(err => { .catch(err => {
console.log(err)
wx.showToast({ wx.showToast({
title: err.errMsg, title: err.errMsg,
icon: 'none', icon: 'none',
@@ -294,6 +296,7 @@ Page({
that.initUsrCarList(); that.initUsrCarList();
}) })
.catch(err => { .catch(err => {
console.log(err)
wx.showToast({ wx.showToast({
title: err.errMsg, title: err.errMsg,
icon: 'none', icon: 'none',
@@ -335,6 +338,7 @@ Page({
}); });
}) })
.catch(err => { .catch(err => {
console.log(err)
wx.showToast({ wx.showToast({
title: err.errMsg, title: err.errMsg,
icon: 'none', icon: 'none',
@@ -395,6 +399,7 @@ Page({
url: "/pages/phoneinput/phoneinput" url: "/pages/phoneinput/phoneinput"
}); });
}else{ }else{
console.log(err)
wx.showToast({ wx.showToast({
title: err.errMsg, title: err.errMsg,
icon: 'none', icon: 'none',
@@ -438,6 +443,7 @@ Page({
}); });
}) })
.catch(error => { .catch(error => {
console.log(error)
wx.showModal({ wx.showModal({
title: "提示", title: "提示",
showCancel: false, showCancel: false,
@@ -461,6 +467,7 @@ Page({
}) })
}) })
.catch(err => { .catch(err => {
console.log(err)
wx.showToast({ wx.showToast({
title: err.errMsg, title: err.errMsg,
icon: 'none', icon: 'none',
@@ -481,8 +488,9 @@ Page({
.then(res => { .then(res => {
}) })
.catch(err => { .catch(err => {
console.log(err)
wx.showToast({ wx.showToast({
title: err.errMsg,
title: err.message,
icon: 'none', icon: 'none',
duration: 2000, duration: 2000,
mask: false mask: false


+ 1
- 3
utils/util.js Wyświetl plik

@@ -92,7 +92,6 @@ function timechuo(startTime) {
var minute = Math.floor(runTime / 60); var minute = Math.floor(runTime / 60);
var runTime = runTime % 60; var runTime = runTime % 60;
var second = runTime; var second = runTime;
console.log(month, day, hour, minute, second);
return (day+"天"+hour+"小时"+minute+"分钟") return (day+"天"+hour+"小时"+minute+"分钟")
} }


@@ -113,8 +112,7 @@ function timecha(endTime,startTime) {
var minute = Math.floor(runTime / 60); var minute = Math.floor(runTime / 60);
var runTime = runTime % 60; var runTime = runTime % 60;
var second = runTime; var second = runTime;
console.log(month, day, hour, minute, second);
return (day+"天"+hour+"小时"+minute+"分钟")
return (month+"月"+day+"天"+hour+"小时"+minute+"分钟")
} }


module.exports = { module.exports = {


Ładowanie…
Anuluj
Zapisz