|
|
|
@@ -26,12 +26,15 @@ Page({ |
|
|
|
end_time: null, |
|
|
|
clock: "已经截止", |
|
|
|
questionnaire: {}, |
|
|
|
questionId: null |
|
|
|
}, |
|
|
|
onShow: function () { |
|
|
|
this.setData({ |
|
|
|
display: "none", |
|
|
|
}) |
|
|
|
questionId: null, |
|
|
|
widthScreen: null, |
|
|
|
moveData: null, |
|
|
|
rotateData: null, |
|
|
|
alphaData: null, |
|
|
|
scaleData: null, |
|
|
|
skewData: null, |
|
|
|
matrixData: null, |
|
|
|
flag: false |
|
|
|
}, |
|
|
|
phone: function () { |
|
|
|
let that = this; |
|
|
|
@@ -41,68 +44,106 @@ Page({ |
|
|
|
}); |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* @Meo |
|
|
|
* 问卷调查组件传递的值 |
|
|
|
* 点击提交问题单选 |
|
|
|
*/ |
|
|
|
close: function (e) { |
|
|
|
formSubmit: function (e) { |
|
|
|
let that = this; |
|
|
|
that.setData({ |
|
|
|
questions1: e.detail, |
|
|
|
display: "none" |
|
|
|
/** |
|
|
|
* 多选 |
|
|
|
*/ |
|
|
|
console.log(e); |
|
|
|
if (e.currentTarget.dataset.flags == 'multi') { |
|
|
|
if (that.data.anwserId.length == 0) { |
|
|
|
var answserIs = "" |
|
|
|
} else { |
|
|
|
var answserIs = that.data.anwserId.join(","); |
|
|
|
} |
|
|
|
} else { |
|
|
|
var answserIs = e.target.dataset.answerid; |
|
|
|
} |
|
|
|
Http.post({ |
|
|
|
url: config.api.answerQuestion, |
|
|
|
data: { |
|
|
|
answer: answserIs, |
|
|
|
questionId: e.currentTarget.dataset.questionid |
|
|
|
} |
|
|
|
}) |
|
|
|
.then(res => { |
|
|
|
that.closeQuestion(); |
|
|
|
}) |
|
|
|
.catch(err => { |
|
|
|
wx.showToast({ |
|
|
|
title: err.message, |
|
|
|
icon: 'none', |
|
|
|
duration: 2000, |
|
|
|
mask: false |
|
|
|
}); |
|
|
|
}) |
|
|
|
}, |
|
|
|
/** |
|
|
|
* 多选 |
|
|
|
*/ |
|
|
|
checkboxChange: function (e) { |
|
|
|
this.setData({ |
|
|
|
anwserId: e.detail.value |
|
|
|
}) |
|
|
|
}, |
|
|
|
formSubmit: function (e) { |
|
|
|
|
|
|
|
closeQuestion: function () { |
|
|
|
let that = this; |
|
|
|
that.setData({ |
|
|
|
questions2: e.detail, |
|
|
|
display: "none" |
|
|
|
var animation = wx.createAnimation({}) |
|
|
|
setTimeout(function () { |
|
|
|
that.setData({ |
|
|
|
flag: false |
|
|
|
}) |
|
|
|
}, 1000) |
|
|
|
animation.translate((this.data.widthScreen - 0), 0).scale(0).opacity(0.5).step({ |
|
|
|
duration: 1000 |
|
|
|
}) |
|
|
|
that.setData({ |
|
|
|
alphaData: animation.export() |
|
|
|
}); |
|
|
|
setTimeout(function () { |
|
|
|
that.orderFunc(); |
|
|
|
}, 1100) |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* gotopay |
|
|
|
*/ |
|
|
|
gotopay: function () { |
|
|
|
let that = this; |
|
|
|
if (that.data.questions1 || that.data.questions2) { |
|
|
|
that.setData({ |
|
|
|
display: "none", |
|
|
|
}) |
|
|
|
that.orderFunc(); |
|
|
|
} else { |
|
|
|
Http.get({ |
|
|
|
that.setData({ |
|
|
|
alphaData: null |
|
|
|
}) |
|
|
|
Http.get({ |
|
|
|
url: config.api.getQuestion, |
|
|
|
data: { |
|
|
|
couponType: JSON.stringify(that.data.data.type) |
|
|
|
} |
|
|
|
}) |
|
|
|
.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 |
|
|
|
}); |
|
|
|
} |
|
|
|
}) |
|
|
|
.catch(err => { |
|
|
|
wx.showToast({ |
|
|
|
title: err.errMsg, |
|
|
|
icon: 'none', |
|
|
|
duration: 2000, |
|
|
|
mask: false |
|
|
|
.then(res => { |
|
|
|
console.log(res); |
|
|
|
if (res.data == undefined) { |
|
|
|
that.orderFunc(); |
|
|
|
} else if (res.data) { |
|
|
|
that.setData({ |
|
|
|
flag: true, |
|
|
|
questionnaire: JSON.parse(res.data.content), |
|
|
|
questionId: res.data.id |
|
|
|
}); |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
.catch(err => { |
|
|
|
wx.showToast({ |
|
|
|
title: err.message, |
|
|
|
icon: 'none', |
|
|
|
duration: 2000, |
|
|
|
mask: false |
|
|
|
}); |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
countdown(end_time) { |
|
|
|
let that = this; |
|
|
|
var EndTime = end_time; |
|
|
|
@@ -110,7 +151,6 @@ Page({ |
|
|
|
var total_micro_second = EndTime - NowTime || []; |
|
|
|
// 渲染倒计时时钟 |
|
|
|
let obj = that.dateformat(total_micro_second); |
|
|
|
|
|
|
|
if (total_micro_second > 0) { |
|
|
|
that.setData({ |
|
|
|
clock: obj, |
|
|
|
@@ -148,21 +188,22 @@ Page({ |
|
|
|
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; |
|
|
|
wx.showLoading({ |
|
|
|
title: "加载中..." |
|
|
|
}); |
|
|
|
/** |
|
|
|
* 暂时注销 |
|
|
|
* this.orderFunc() |
|
|
|
*/ |
|
|
|
that.setData({ |
|
|
|
couponChannelId: options.couponChannelId, |
|
|
|
couponId: options.couponId, |
|
|
|
title: that.data.data.title, |
|
|
|
title: that.data.data.title ? that.data.data.title : '', |
|
|
|
}); |
|
|
|
var parmer = { |
|
|
|
url: config.api.couponDetail, |
|
|
|
@@ -202,7 +243,7 @@ Page({ |
|
|
|
} |
|
|
|
}).catch(err => { |
|
|
|
wx.showToast({ |
|
|
|
title: err.errMsg, |
|
|
|
title: err.message, |
|
|
|
icon: 'none', |
|
|
|
duration: 2000, |
|
|
|
mask: false |
|
|
|
@@ -216,14 +257,14 @@ Page({ |
|
|
|
let that = this; |
|
|
|
// 支付成功 |
|
|
|
Http.post({ |
|
|
|
url: config.api.payOrderUpdate, |
|
|
|
data: { |
|
|
|
payOrderId: payOrderId, |
|
|
|
orderId: orderId, |
|
|
|
status: status, |
|
|
|
reason: reason |
|
|
|
} |
|
|
|
}) |
|
|
|
url: config.api.payOrderUpdate, |
|
|
|
data: { |
|
|
|
payOrderId: payOrderId, |
|
|
|
orderId: orderId, |
|
|
|
status: status, |
|
|
|
reason: reason |
|
|
|
} |
|
|
|
}) |
|
|
|
.then(res => { |
|
|
|
console.log(res); |
|
|
|
if (!type) { |
|
|
|
@@ -253,11 +294,11 @@ Page({ |
|
|
|
wx.showLoading({ |
|
|
|
title: "加载中..." |
|
|
|
}); |
|
|
|
if (that.data.data.type == 6) { } else { |
|
|
|
if (that.data.data.type == 6) {} else { |
|
|
|
Http.post({ |
|
|
|
url: config.api.checkPhoneStatus, |
|
|
|
data: {} |
|
|
|
}) |
|
|
|
url: config.api.checkPhoneStatus, |
|
|
|
data: {} |
|
|
|
}) |
|
|
|
.then(res => { |
|
|
|
var data = { |
|
|
|
couponChannelId: "" + that.data.couponChannelId, |
|
|
|
@@ -354,7 +395,7 @@ Page({ |
|
|
|
}); |
|
|
|
} else { |
|
|
|
wx.showToast({ |
|
|
|
title: err.errMsg, |
|
|
|
title: err.message, |
|
|
|
icon: 'none', |
|
|
|
duration: 2000, |
|
|
|
mask: false |
|
|
|
@@ -373,57 +414,56 @@ Page({ |
|
|
|
* 支付订单创建 |
|
|
|
*/ |
|
|
|
Http.post({ |
|
|
|
url: config.api.payOrderCreate, |
|
|
|
data: { |
|
|
|
orderId: orderId |
|
|
|
} |
|
|
|
}).then(res => { |
|
|
|
/// Begin payment ---- |
|
|
|
var payOrderId = "" + res.data.payOrderId; |
|
|
|
wx.hideLoading(); |
|
|
|
wx.requestPayment({ |
|
|
|
timeStamp: res.data.timeStamp, |
|
|
|
nonceStr: res.data.nonceStr, |
|
|
|
package: res.data.package, |
|
|
|
signType: (res.data.signType) ? res.data.signType : "MD5", |
|
|
|
paySign: res.data.paySign, |
|
|
|
success: res => { |
|
|
|
that.payOrderUpdate(that.data.orderId, payOrderId, 1, '', '', that); |
|
|
|
if (res.errMsg == "requestPayment:ok") { |
|
|
|
setTimeout(function () { |
|
|
|
wx.hideLoading(); |
|
|
|
}, 2000); |
|
|
|
url: config.api.payOrderCreate, |
|
|
|
data: { |
|
|
|
orderId: orderId |
|
|
|
} |
|
|
|
}).then(res => { |
|
|
|
/// Begin payment ---- |
|
|
|
var payOrderId = "" + res.data.payOrderId; |
|
|
|
wx.hideLoading(); |
|
|
|
wx.requestPayment({ |
|
|
|
timeStamp: res.data.timeStamp, |
|
|
|
nonceStr: res.data.nonceStr, |
|
|
|
package: res.data.package, |
|
|
|
signType: (res.data.signType) ? res.data.signType : "MD5", |
|
|
|
paySign: res.data.paySign, |
|
|
|
success: res => { |
|
|
|
that.payOrderUpdate(that.data.orderId, payOrderId, 1, '', '', that); |
|
|
|
if (res.errMsg == "requestPayment:ok") { |
|
|
|
setTimeout(function () { |
|
|
|
wx.hideLoading(); |
|
|
|
}, 2000); |
|
|
|
/** |
|
|
|
* 用户支付成功以后跳转到券包列表 |
|
|
|
*/ |
|
|
|
wx.setStorage({ |
|
|
|
key: 'couponNum', |
|
|
|
data: "couponNum", |
|
|
|
}) |
|
|
|
if (that.data.data.type == 5) { |
|
|
|
setTimeout(() => { |
|
|
|
wx.switchTab({ |
|
|
|
url: '/pages/passCar/passCar' |
|
|
|
}); |
|
|
|
}, 1600); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
fail: res => { |
|
|
|
/** |
|
|
|
* 用户支付成功以后跳转到券包列表 |
|
|
|
* 支付失败,需要更新订单的状态 |
|
|
|
*/ |
|
|
|
wx.setStorage({ |
|
|
|
key: 'couponNum', |
|
|
|
data: "couponNum", |
|
|
|
}) |
|
|
|
if (that.data.data.type == 5) { |
|
|
|
setTimeout(() => { |
|
|
|
wx.switchTab({ |
|
|
|
url: '/pages/passCar/passCar' |
|
|
|
}); |
|
|
|
}, 1600); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
fail: res => { |
|
|
|
/** |
|
|
|
* 支付失败,需要更新订单的状态 |
|
|
|
*/ |
|
|
|
that.payOrderUpdate(that.data.orderId, payOrderId, 2, '', 'fail',that); |
|
|
|
return; |
|
|
|
}, |
|
|
|
complete: res => { |
|
|
|
} |
|
|
|
}); |
|
|
|
/// End payment -------- |
|
|
|
}) |
|
|
|
that.payOrderUpdate(that.data.orderId, payOrderId, 2, '', 'fail', that); |
|
|
|
return; |
|
|
|
}, |
|
|
|
complete: res => {} |
|
|
|
}); |
|
|
|
/// End payment -------- |
|
|
|
}) |
|
|
|
.catch(err => { |
|
|
|
wx.showToast({ |
|
|
|
title: err.errMsg, |
|
|
|
title: err.message, |
|
|
|
icon: 'none', |
|
|
|
duration: 2000, |
|
|
|
mask: false |
|
|
|
@@ -455,7 +495,7 @@ Page({ |
|
|
|
}) |
|
|
|
.catch(err => { |
|
|
|
wx.showToast({ |
|
|
|
title: err.errMsg, |
|
|
|
title: err.message, |
|
|
|
icon: 'none', |
|
|
|
duration: 2000, |
|
|
|
mask: false |
|
|
|
@@ -469,13 +509,10 @@ Page({ |
|
|
|
title: that.data.data.title, |
|
|
|
path: `/pages/index/index?couponChannelId=${that.data.couponChannelId}&couponId=${that.data.couponId}`, |
|
|
|
success: function (res) { |
|
|
|
if (res.errMsg == 'shareAppMessage:ok') { |
|
|
|
} |
|
|
|
if (res.errMsg == 'shareAppMessage:ok') {} |
|
|
|
}, |
|
|
|
fail: function (error) { |
|
|
|
if (res.errMsg == 'shareAppMessage:fail cancel') { |
|
|
|
} else if (res.errMsg == 'shareAppMessage:fail') { |
|
|
|
} |
|
|
|
if (res.errMsg == 'shareAppMessage:fail cancel') {} else if (res.errMsg == 'shareAppMessage:fail') {} |
|
|
|
} |
|
|
|
}; |
|
|
|
// 来自页面内的按钮的转发 |
|
|
|
|