|
@@ -45,6 +45,7 @@ Page({ |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
canBuyIf: false |
|
|
canBuyIf: false |
|
|
}) |
|
|
}) |
|
|
|
|
|
this.orderFunc() |
|
|
}, |
|
|
}, |
|
|
/** |
|
|
/** |
|
|
* 发起拼团 |
|
|
* 发起拼团 |
|
@@ -54,7 +55,7 @@ Page({ |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
canSpell:false |
|
|
canSpell:false |
|
|
}) |
|
|
}) |
|
|
this.orderFunc() |
|
|
|
|
|
|
|
|
this.orderFunc(0) |
|
|
}, |
|
|
}, |
|
|
/** |
|
|
/** |
|
|
* 获取一个拼团信息 |
|
|
* 获取一个拼团信息 |
|
@@ -74,6 +75,35 @@ Page({ |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
}, |
|
|
}, |
|
|
|
|
|
countdown(end_time) { |
|
|
|
|
|
let that = this; |
|
|
|
|
|
var EndTime = end_time; |
|
|
|
|
|
var NowTime = new Date().getTime(); |
|
|
|
|
|
var total_micro_second = EndTime - NowTime || []; |
|
|
|
|
|
// 渲染倒计时时钟 |
|
|
|
|
|
let obj = that.dateformat(total_micro_second); |
|
|
|
|
|
if (total_micro_second > 0) { |
|
|
|
|
|
that.setData({ |
|
|
|
|
|
clock: obj, |
|
|
|
|
|
day: obj.a1, |
|
|
|
|
|
hour: obj.b1, |
|
|
|
|
|
min: obj.c1, |
|
|
|
|
|
sec: obj.d1, |
|
|
|
|
|
}) |
|
|
|
|
|
} else { |
|
|
|
|
|
that.setData({ |
|
|
|
|
|
clock: "00", |
|
|
|
|
|
day: "00", |
|
|
|
|
|
hour: "00", |
|
|
|
|
|
min: "00", |
|
|
|
|
|
sec: "00", |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
setTimeout(function () { |
|
|
|
|
|
total_micro_second -= 1000; |
|
|
|
|
|
that.countdown(end_time); |
|
|
|
|
|
}, 1000) |
|
|
|
|
|
}, |
|
|
/** |
|
|
/** |
|
|
* 获取券详情信息 |
|
|
* 获取券详情信息 |
|
|
*/ |
|
|
*/ |
|
@@ -93,10 +123,72 @@ Page({ |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}, |
|
|
}, |
|
|
|
|
|
/** |
|
|
|
|
|
* 去拼团 |
|
|
|
|
|
*/ |
|
|
|
|
|
goToOrderGroup(orderId, orderGroupId, _this){ |
|
|
|
|
|
console.log(22222222) |
|
|
|
|
|
let that = this; |
|
|
|
|
|
// 支付成功 |
|
|
|
|
|
Http.post({ |
|
|
|
|
|
url: config.api.toOrderGroup, |
|
|
|
|
|
data: { |
|
|
|
|
|
id: orderGroupId, |
|
|
|
|
|
orderId, |
|
|
|
|
|
couponId: _this.data.data.couponId |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
.then(res => { |
|
|
|
|
|
|
|
|
|
|
|
}) |
|
|
|
|
|
.catch(err => { |
|
|
|
|
|
console.log(err); |
|
|
|
|
|
}) |
|
|
|
|
|
// return; |
|
|
|
|
|
// wx.navigateTo({ |
|
|
|
|
|
// url: `/pages/spellDetail/index?orderId=${orderId}&couponId=${_this.data.data.couponId}` |
|
|
|
|
|
// }); |
|
|
|
|
|
}, |
|
|
|
|
|
/** |
|
|
|
|
|
* 支付订单更新 |
|
|
|
|
|
*/ |
|
|
|
|
|
payOrderUpdate: (orderId, payOrderId, status, reason, _this, orderGroupId) => { |
|
|
|
|
|
let that = this; |
|
|
|
|
|
// 支付成功 |
|
|
|
|
|
Http.post({ |
|
|
|
|
|
url: config.api.payOrderUpdate, |
|
|
|
|
|
data: { |
|
|
|
|
|
payOrderId: payOrderId, |
|
|
|
|
|
orderId: orderId, |
|
|
|
|
|
status: status, |
|
|
|
|
|
reason: reason |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
.then(res => { |
|
|
|
|
|
wx.hideLoading() |
|
|
|
|
|
_this.goToOrderGroup(orderId, res.data.orderGroupId, _this) |
|
|
|
|
|
}) |
|
|
|
|
|
.catch(err => { |
|
|
|
|
|
console.log(err); |
|
|
|
|
|
setTimeout(function () { |
|
|
|
|
|
_this.payOrderUpdate(orderId, payOrderId, status, reason, _this, orderGroupId); |
|
|
|
|
|
}, 2000) |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
/** |
|
|
/** |
|
|
* 发起支付 |
|
|
* 发起支付 |
|
|
*/ |
|
|
*/ |
|
|
orderFunc(discount) { |
|
|
|
|
|
|
|
|
orderFunc(orderGroupId) { |
|
|
|
|
|
let data = { |
|
|
|
|
|
couponChannelId: this.data.data.id, |
|
|
|
|
|
couponId: this.data.data.couponId |
|
|
|
|
|
} |
|
|
|
|
|
/** |
|
|
|
|
|
* 拼团订单 |
|
|
|
|
|
*/ |
|
|
|
|
|
if (orderGroupId==0){ |
|
|
|
|
|
data.orderGroupId = orderGroupId |
|
|
|
|
|
} |
|
|
var that = this; |
|
|
var that = this; |
|
|
Http.post({ |
|
|
Http.post({ |
|
|
url: config.api.checkPhoneStatus, |
|
|
url: config.api.checkPhoneStatus, |
|
@@ -106,11 +198,10 @@ Page({ |
|
|
/** |
|
|
/** |
|
|
* orderSave 下单 |
|
|
* orderSave 下单 |
|
|
*/ |
|
|
*/ |
|
|
debugger |
|
|
|
|
|
// return Http.post({ |
|
|
|
|
|
// url: config.api.orderSave, |
|
|
|
|
|
// data: data |
|
|
|
|
|
// }); |
|
|
|
|
|
|
|
|
return Http.post({ |
|
|
|
|
|
url: config.api.orderSave, |
|
|
|
|
|
data: data |
|
|
|
|
|
}); |
|
|
}) |
|
|
}) |
|
|
.catch(err => { |
|
|
.catch(err => { |
|
|
console.log(err); |
|
|
console.log(err); |
|
@@ -200,106 +291,82 @@ Page({ |
|
|
}) |
|
|
}) |
|
|
.then(res => { |
|
|
.then(res => { |
|
|
console.log(res) |
|
|
console.log(res) |
|
|
if (discount != 'discount') { |
|
|
|
|
|
if (typeof (res) != "undefined") { |
|
|
|
|
|
let orderId = "" + res.data.id; |
|
|
|
|
|
that.setData({ |
|
|
|
|
|
|
|
|
if (typeof (res) != "undefined") { |
|
|
|
|
|
let orderId = "" + res.data.id; |
|
|
|
|
|
that.setData({ |
|
|
|
|
|
orderId: orderId |
|
|
|
|
|
}); |
|
|
|
|
|
// 支付金额不为0 |
|
|
|
|
|
/** |
|
|
|
|
|
* 支付订单创建 |
|
|
|
|
|
*/ |
|
|
|
|
|
Http.post({ |
|
|
|
|
|
url: config.api.payOrderCreate, |
|
|
|
|
|
data: { |
|
|
orderId: orderId |
|
|
orderId: orderId |
|
|
}); |
|
|
|
|
|
if (res.data.payment > 0) { |
|
|
|
|
|
// 支付金额不为0 |
|
|
|
|
|
/** |
|
|
|
|
|
* 支付订单创建 |
|
|
|
|
|
*/ |
|
|
|
|
|
Http.post({ |
|
|
|
|
|
url: config.api.payOrderCreate, |
|
|
|
|
|
data: { |
|
|
|
|
|
orderId: orderId |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
.then(res => { |
|
|
|
|
|
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 => { |
|
|
|
|
|
wx.showLoading({ |
|
|
|
|
|
title: '订单正在处理中...', |
|
|
|
|
|
}) |
|
|
|
|
|
setTimeout(function () { |
|
|
|
|
|
wx.hideLoading() |
|
|
|
|
|
}, 5000) |
|
|
|
|
|
that.payOrderUpdate(that.data.orderId, payOrderId, 1, '', '', that); |
|
|
|
|
|
if (res.errMsg == "requestPayment:ok") { |
|
|
|
|
|
setTimeout(function () { |
|
|
|
|
|
wx.hideLoading(); |
|
|
|
|
|
}, 2000); |
|
|
|
|
|
/** |
|
|
|
|
|
* 用户支付成功以后跳转到券包列表 |
|
|
|
|
|
*/ |
|
|
|
|
|
if (that.data.cardType == 100) { |
|
|
|
|
|
wx.setStorage({ |
|
|
|
|
|
key: 'couponNum2', |
|
|
|
|
|
data: "couponNum2" |
|
|
|
|
|
}) |
|
|
|
|
|
} else if (that.data.data.type != 5) { |
|
|
|
|
|
wx.setStorage({ |
|
|
|
|
|
key: 'couponNum', |
|
|
|
|
|
data: "couponNum" |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
fail: res => { |
|
|
|
|
|
/** |
|
|
|
|
|
* 支付失败,需要更新订单的状态 |
|
|
|
|
|
*/ |
|
|
|
|
|
that.payOrderUpdate(that.data.orderId, payOrderId, 2, '', 'fail', that); |
|
|
|
|
|
that.setData({ |
|
|
|
|
|
showbutton: false |
|
|
|
|
|
}) |
|
|
|
|
|
return; |
|
|
|
|
|
}, |
|
|
|
|
|
complete: res => { } |
|
|
|
|
|
}); |
|
|
|
|
|
/// End payment -------- |
|
|
|
|
|
}) |
|
|
|
|
|
.catch(err => { |
|
|
|
|
|
wx.showToast({ |
|
|
|
|
|
title: err.message, |
|
|
|
|
|
icon: 'none', |
|
|
|
|
|
duration: 2000, |
|
|
|
|
|
mask: false |
|
|
|
|
|
}); |
|
|
|
|
|
}) |
|
|
|
|
|
} else { |
|
|
|
|
|
console.log(that.data.type) |
|
|
|
|
|
// 免费券 |
|
|
|
|
|
that.payOrderUpdate(orderId, "0", 1, '', 'free'); |
|
|
|
|
|
if (that.data.cardType == 100) { |
|
|
|
|
|
wx.setStorage({ |
|
|
|
|
|
key: 'couponNum2', |
|
|
|
|
|
data: "couponNum2" |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
.then(res => { |
|
|
|
|
|
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 => { |
|
|
|
|
|
wx.showLoading({ |
|
|
|
|
|
title: '订单正在处理中...', |
|
|
}) |
|
|
}) |
|
|
} else if (that.data.data.type != "5") { |
|
|
|
|
|
wx.setStorage({ |
|
|
|
|
|
key: 'couponNum', |
|
|
|
|
|
data: "couponNum" |
|
|
|
|
|
|
|
|
setTimeout(function () { |
|
|
|
|
|
wx.hideLoading() |
|
|
|
|
|
}, 5000) |
|
|
|
|
|
that.payOrderUpdate(that.data.orderId, payOrderId, 1, '', that, orderGroupId); |
|
|
|
|
|
if (res.errMsg == "requestPayment:ok") { |
|
|
|
|
|
setTimeout(function () { |
|
|
|
|
|
wx.hideLoading(); |
|
|
|
|
|
}, 2000); |
|
|
|
|
|
/** |
|
|
|
|
|
* 用户支付成功以后跳转到券包列表 |
|
|
|
|
|
*/ |
|
|
|
|
|
if (that.data.cardType == 100) { |
|
|
|
|
|
wx.setStorage({ |
|
|
|
|
|
key: 'couponNum2', |
|
|
|
|
|
data: "couponNum2" |
|
|
|
|
|
}) |
|
|
|
|
|
} else if (that.data.data.type != 5) { |
|
|
|
|
|
wx.setStorage({ |
|
|
|
|
|
key: 'couponNum', |
|
|
|
|
|
data: "couponNum" |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
fail: res => { |
|
|
|
|
|
/** |
|
|
|
|
|
* 支付失败,需要更新订单的状态 |
|
|
|
|
|
*/ |
|
|
|
|
|
that.payOrderUpdate(that.data.orderId, payOrderId, 2, '', that, orderGroupId); |
|
|
|
|
|
that.setData({ |
|
|
|
|
|
showbutton: false |
|
|
}) |
|
|
}) |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
if (res) { |
|
|
|
|
|
wx.navigateTo({ |
|
|
|
|
|
url: `/pages/bargain/bargainDatail/bargainDatail?orderId=${res.data.id}`, |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return; |
|
|
|
|
|
}, |
|
|
|
|
|
complete: res => { } |
|
|
|
|
|
}); |
|
|
|
|
|
/// End payment -------- |
|
|
|
|
|
}) |
|
|
|
|
|
.catch(err => { |
|
|
|
|
|
wx.showToast({ |
|
|
|
|
|
title: err.message, |
|
|
|
|
|
icon: 'none', |
|
|
|
|
|
duration: 2000, |
|
|
|
|
|
mask: false |
|
|
|
|
|
}); |
|
|
|
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
/** |
|
|
/** |
|
|