|
|
@@ -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; |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
}); |