Browse Source

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

tags/2.3.0
meo 6 years ago
parent
commit
e82d76eca6
5 changed files with 91 additions and 81 deletions
  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 View File

@@ -6,11 +6,11 @@ const util = require("../../../utils/util");
Page({
data: {
data: {
title:null
title: null
},
questions1:null,
questions2:null,
display:"none",
questions1: null,
questions2: null,
display: "none",
carList: [],
couponChannelId: null,
couponId: null,
@@ -26,11 +26,11 @@ Page({
end_time: null,
clock: "已经截止",
questionnaire: {},
questionId:null
questionId: null
},
onShow:function(){
onShow: function () {
this.setData({
display:"none",
display: "none",
})
},
phone: function () {
@@ -50,59 +50,59 @@ Page({
let that = this;
that.setData({
questions1: e.detail,
display:"none"
display: "none"
})
},
formSubmit:function(e){
formSubmit: function (e) {
let that = this;
that.setData({
questions2: e.detail,
display:"none"
display: "none"
})
},
/**
* gotopay
*/
gotopay:function(){
gotopay: function () {
let that = this;
if (that.data.questions1 || that.data.questions2){
if (that.data.questions1 || that.data.questions2) {
that.setData({
display: "none",
})
that.orderFunc();
}else{
} else {
Http.get({
url: config.api.getQuestion,
data: {
couponType: JSON.stringify(that.data.data.type)
}
})
.then(res => {
if (res.data == undefined) {
.then(res => {
if (res.data == undefined) {
that.setData({
display: "none",
})
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) {
let that = this;
var EndTime = end_time;
@@ -110,8 +110,8 @@ Page({
var total_micro_second = EndTime - NowTime || [];
// 渲染倒计时时钟
let obj = that.dateformat(total_micro_second);
if (total_micro_second>0){
if (total_micro_second > 0) {
that.setData({
clock: obj,
day: obj.a1,
@@ -119,7 +119,7 @@ Page({
min: obj.c1,
sec: obj.d1,
})
}else{
} else {
that.setData({
clock: "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 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 { a1: day, b1: hr, c1: min, d1: sec}
return { a1: day, b1: hr, c1: min, d1: sec }
},
onLoad(options) {
let that = this;
@@ -171,7 +171,7 @@ Page({
}
};
Http.get(parmer).then(res => {
if (res.data.endTime){
if (res.data.endTime) {
that.countdown(res.data.endTime);
//当前时间与优惠券下架时间做计算
var endTime = util.formatTime(res.data.endTime, "yyyy-MM-dd hh:mm:ss");
@@ -185,7 +185,7 @@ Page({
});
}
}
wx.hideLoading();
that.setData({
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({
url: config.api.payOrderUpdate,
@@ -225,21 +225,25 @@ Page({
}
})
.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)
}
}
})
.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
});
} else if (err.code == 11005) {
// 用户手机未授权
/**
* 将值传到用户手机号授权的页面
*
@@ -402,33 +405,30 @@ Page({
wx.switchTab({
url: '/pages/passCar/passCar'
});
}, 1600);
}, 1600);
}
}
},

fail: res => {
that.payOrderUpdate(that.data.orderId, payOrderId, 2,'','fail'); // 支付失败
/**
* 支付失败,需要更新订单的状态
*/
that.payOrderUpdate(that.data.orderId, payOrderId, 2, '', 'fail',that);
return;
},
complete: res => {
}
});
/// 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 {
// 免费券
that.payOrderUpdate(orderId, "0", 1, '', 'fail');
@@ -482,10 +482,10 @@ Page({
if (options.from == 'button') {
var eData = options.target.dataset.id;
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
return shareObj;
}
},

});

+ 1
- 0
pages/index/rushToBuy/index.js View File

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


+ 7
- 4
pages/order/detail/index.js View File

@@ -144,7 +144,7 @@ Page({
that.payOrderUpdate(that.data.orderId, payOrderId, 1,'','',that); // 支付成功
},
fail: res => {
that.payOrderUpdate(that.data.orderId, payOrderId, 2,'','fail');
that.payOrderUpdate(that.data.orderId, payOrderId, 2,'','fail',that);
return;
},
});
@@ -198,9 +198,12 @@ Page({
}
})
.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 View File

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


+ 1
- 3
utils/util.js View File

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

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

module.exports = {


Loading…
Cancel
Save