|
|
@@ -54,7 +54,9 @@ Page({ |
|
|
|
getSupId(id) { |
|
|
|
Http.get({ |
|
|
|
url: config.api.getSpuid, |
|
|
|
data: { id: id } |
|
|
|
data: { |
|
|
|
id: id |
|
|
|
} |
|
|
|
}).then(res => { |
|
|
|
if (res.data) { |
|
|
|
this.setData({ |
|
|
@@ -98,15 +100,15 @@ Page({ |
|
|
|
success: (res) => { |
|
|
|
tt.reLaunch({ |
|
|
|
url: "/index/index", |
|
|
|
success(res) { |
|
|
|
console.log(`${res}`); |
|
|
|
app.globalData.selected = 0 |
|
|
|
}, |
|
|
|
fail(err) { |
|
|
|
console.log(`navigateTo调用失败`,err); |
|
|
|
}, |
|
|
|
success(res) { |
|
|
|
console.log(`${res}`); |
|
|
|
app.globalData.selected = 0 |
|
|
|
}, |
|
|
|
fail(err) { |
|
|
|
console.log(`navigateTo调用失败`, err); |
|
|
|
}, |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
}, |
|
|
|
fail: (res) => { |
|
|
|
|
|
|
@@ -114,7 +116,7 @@ Page({ |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
getCouponPriceAndStock(couponChannelId) {//获取券价格与库存 |
|
|
|
getCouponPriceAndStock(couponChannelId) { //获取券价格与库存 |
|
|
|
Http.get({ |
|
|
|
url: config.api.couponPriceAndStock, |
|
|
|
data: { |
|
|
@@ -132,7 +134,7 @@ Page({ |
|
|
|
let that = this; |
|
|
|
let data = {}; |
|
|
|
|
|
|
|
that.getCouponPriceAndStock(couponChannelId);//获取券价格和库存 |
|
|
|
that.getCouponPriceAndStock(couponChannelId); //获取券价格和库存 |
|
|
|
if (that.data.couponIds) { |
|
|
|
data.couponId = couponChannelId |
|
|
|
} else { |
|
|
@@ -285,20 +287,20 @@ Page({ |
|
|
|
}) |
|
|
|
}, |
|
|
|
/** |
|
|
|
* 支付订单更新 |
|
|
|
*/ |
|
|
|
* 支付订单更新 |
|
|
|
*/ |
|
|
|
payOrderUpdate: (orderId, payOrderId, status, reason, type, _this, composeOrderType) => { |
|
|
|
let that = this; |
|
|
|
// 支付成功 |
|
|
|
Http.post({ |
|
|
|
url: config.api.payOrderUpdate, |
|
|
|
data: { |
|
|
|
payOrderId: payOrderId, |
|
|
|
composeOrderId: orderId, |
|
|
|
status: status, |
|
|
|
reason: reason |
|
|
|
} |
|
|
|
}) |
|
|
|
url: config.api.payOrderUpdate, |
|
|
|
data: { |
|
|
|
payOrderId: payOrderId, |
|
|
|
composeOrderId: orderId, |
|
|
|
status: status, |
|
|
|
reason: reason |
|
|
|
} |
|
|
|
}) |
|
|
|
.then(res => { |
|
|
|
tt.hideLoading() |
|
|
|
// 有价券 |
|
|
@@ -368,7 +370,7 @@ Page({ |
|
|
|
success: function (res1) { |
|
|
|
if (res1.confirm) { |
|
|
|
|
|
|
|
if (that.data.composeOrderType > 0) {//券包 |
|
|
|
if (that.data.composeOrderType > 0) { //券包 |
|
|
|
tt.navigateTo({ |
|
|
|
url: `/pages/order/detail/index?orderId=${res.data.composeOrderId}`, |
|
|
|
}) |
|
|
@@ -417,139 +419,153 @@ Page({ |
|
|
|
}).then(res => { |
|
|
|
// |
|
|
|
// if (!tt.canIUse('createOrder') || that.data.data.type == 50 || that.data.priceAndStockObj.salePrice == 0) { |
|
|
|
//积分券和免费券 |
|
|
|
// 发起砍价 |
|
|
|
if (discount == 'discount') { |
|
|
|
var data = { |
|
|
|
couponChannelId: "" + that.data.couponChannelId, |
|
|
|
couponId: "" + that.data.couponId, |
|
|
|
formId: "" + that.data.formId, |
|
|
|
press: true |
|
|
|
} |
|
|
|
} else if (discount == 'discount1') { |
|
|
|
var data = { |
|
|
|
couponChannelId: "" + that.data.couponChannelId, |
|
|
|
couponId: "" + that.data.couponId, |
|
|
|
formId: "" + that.data.formId, |
|
|
|
press: false |
|
|
|
} |
|
|
|
} else if (that.data.couponChannelId == null) { |
|
|
|
var data = { |
|
|
|
couponId: "" + that.data.couponId, |
|
|
|
formId: "" + that.data.formId, |
|
|
|
}; |
|
|
|
} else { |
|
|
|
var data = { |
|
|
|
//积分券和免费券 |
|
|
|
// 发起砍价 |
|
|
|
if (discount == 'discount') { |
|
|
|
var data = { |
|
|
|
couponChannelId: "" + that.data.couponChannelId, |
|
|
|
couponId: "" + that.data.couponId, |
|
|
|
formId: "" + that.data.formId, |
|
|
|
press: true |
|
|
|
} |
|
|
|
} else if (discount == 'discount1') { |
|
|
|
var data = { |
|
|
|
couponChannelId: "" + that.data.couponChannelId, |
|
|
|
couponId: "" + that.data.couponId, |
|
|
|
formId: "" + that.data.formId, |
|
|
|
press: false |
|
|
|
} |
|
|
|
} else if (that.data.couponChannelId == null) { |
|
|
|
var data = { |
|
|
|
couponId: "" + that.data.couponId, |
|
|
|
formId: "" + that.data.formId, |
|
|
|
}; |
|
|
|
} else { |
|
|
|
var data = { |
|
|
|
couponChannelId: "" + that.data.couponChannelId, |
|
|
|
couponId: "" + that.data.couponId, |
|
|
|
formId: "" + that.data.formId, |
|
|
|
} |
|
|
|
} |
|
|
|
console.log(data, "data") |
|
|
|
let url = "" |
|
|
|
let tempObj; |
|
|
|
let tempArr = [] |
|
|
|
if (that.data.data.type == 12) { |
|
|
|
url = config.api.couponPackageSave |
|
|
|
tempObj = { |
|
|
|
signleOrder: { |
|
|
|
couponChannelId: "" + that.data.couponChannelId, |
|
|
|
couponId: "" + that.data.couponId, |
|
|
|
formId: "" + that.data.formId, |
|
|
|
} |
|
|
|
} |
|
|
|
console.log(data, "data") |
|
|
|
let url = "" |
|
|
|
let tempObj; |
|
|
|
let tempArr = [] |
|
|
|
if (that.data.data.type == 12) { |
|
|
|
url = config.api.couponPackageSave |
|
|
|
tempObj = { |
|
|
|
signleOrder: { |
|
|
|
couponChannelId: "" + that.data.couponChannelId, |
|
|
|
couponId: "" + that.data.couponId, |
|
|
|
formId: "" + that.data.formId, |
|
|
|
}, |
|
|
|
count: "1" |
|
|
|
} |
|
|
|
tempArr.push(tempObj) |
|
|
|
} else { |
|
|
|
url = config.api.orderSave |
|
|
|
}, |
|
|
|
count: "1" |
|
|
|
} |
|
|
|
/** |
|
|
|
* orderSave 下单 |
|
|
|
*/ |
|
|
|
Http.post({ |
|
|
|
url: url, |
|
|
|
data: that.data.data.type == 12 ? JSON.stringify(tempArr) : data |
|
|
|
}).then(res => { |
|
|
|
if (discount != 'discount') { |
|
|
|
if (typeof (res) != "undefined") { |
|
|
|
let orderId = "" + res.data.mainOrderId; |
|
|
|
that.setData({ |
|
|
|
orderId: orderId, |
|
|
|
composeOrderType: res.data.composeOrderType |
|
|
|
}); |
|
|
|
if (res.data.payment > 0) { |
|
|
|
// 支付金额不为0 |
|
|
|
if (tt.canIUse('createOrder')) { |
|
|
|
Http.post({ |
|
|
|
url: config.api.payOrderCreate_2, |
|
|
|
data: { |
|
|
|
orderId: orderId, |
|
|
|
composeOrderType: res.data.composeOrderType |
|
|
|
} |
|
|
|
}).then(res => { |
|
|
|
console.log(res,"789789"); |
|
|
|
let tempCallbackData = res.data.callbackData |
|
|
|
// tempCallbackData[that.data.data.couponChannel.ttSpuId] = that.data.data.couponChannel.id |
|
|
|
let options = { |
|
|
|
callbackData: tempCallbackData, |
|
|
|
goodsList: res.data.goodsList, |
|
|
|
payment: res.data.payment, |
|
|
|
success: res => { |
|
|
|
tempArr.push(tempObj) |
|
|
|
} else { |
|
|
|
url = config.api.orderSave |
|
|
|
} |
|
|
|
/** |
|
|
|
* orderSave 下单 |
|
|
|
*/ |
|
|
|
Http.post({ |
|
|
|
url: url, |
|
|
|
data: that.data.data.type == 12 ? JSON.stringify(tempArr) : data |
|
|
|
}).then(res => { |
|
|
|
if (discount != 'discount') { |
|
|
|
if (typeof (res) != "undefined") { |
|
|
|
let orderId = "" + res.data.mainOrderId; |
|
|
|
that.setData({ |
|
|
|
orderId: orderId, |
|
|
|
composeOrderType: res.data.composeOrderType |
|
|
|
}); |
|
|
|
if (res.data.payment > 0) { |
|
|
|
// 支付金额不为0 |
|
|
|
if (tt.canIUse('createOrder')) { |
|
|
|
Http.post({ |
|
|
|
url: config.api.payOrderCreate_2, |
|
|
|
data: { |
|
|
|
orderId: orderId, |
|
|
|
composeOrderType: res.data.composeOrderType |
|
|
|
} |
|
|
|
}).then(res => { |
|
|
|
console.log(res, "789789"); |
|
|
|
let tempCallbackData = { |
|
|
|
composeOrderId: res.data.outOrderNo |
|
|
|
} |
|
|
|
// tempCallbackData[that.data.data.couponChannel.ttSpuId] = that.data.data.couponChannel.id |
|
|
|
let options = { |
|
|
|
callbackData: tempCallbackData, |
|
|
|
goodsList: res.data.goodsList, |
|
|
|
payment: res.data.payment, |
|
|
|
success: res => { |
|
|
|
tt.hideLoading(); |
|
|
|
that.setData({ |
|
|
|
showbutton: false, |
|
|
|
}) |
|
|
|
const { |
|
|
|
orderId, |
|
|
|
outOrderNo |
|
|
|
} = res; |
|
|
|
that.setData({ |
|
|
|
orderId, |
|
|
|
outOrderNo |
|
|
|
}); |
|
|
|
that.payOrderUpdate(outOrderNo, outOrderNo, 1, '', '', that, ''); |
|
|
|
}, |
|
|
|
fail: res => { |
|
|
|
const { |
|
|
|
orderId, |
|
|
|
outOrderNo, |
|
|
|
errNo, |
|
|
|
errMsg, |
|
|
|
errLogId |
|
|
|
} = res; |
|
|
|
if (errLogId) { |
|
|
|
tt.hideLoading(); |
|
|
|
that.setData({ |
|
|
|
showbutton: false, |
|
|
|
}) |
|
|
|
const { orderId, outOrderNo } = res; |
|
|
|
that.setData({ orderId, outOrderNo }); |
|
|
|
that.payOrderUpdate(outOrderNo, outOrderNo, 1, '', '', that, ''); |
|
|
|
}, |
|
|
|
fail: res => { |
|
|
|
const { orderId, outOrderNo, errNo, errMsg, errLogId } = res; |
|
|
|
if (errLogId) { |
|
|
|
tt.hideLoading(); |
|
|
|
that.setData({ |
|
|
|
showbutton: false, |
|
|
|
}) |
|
|
|
console.log('预下单失败', errNo, errMsg, errLogId); |
|
|
|
let tempErrmsg = errMsg.split('开发者拒绝交易:'); |
|
|
|
tt.showToast({ |
|
|
|
title: tempErrmsg[tempErrmsg.length - 1], |
|
|
|
icon: 'none', |
|
|
|
duration: 2000, |
|
|
|
mask: false |
|
|
|
}); |
|
|
|
} |
|
|
|
if (orderId || outOrderNo) { |
|
|
|
tt.hideLoading(); |
|
|
|
that.setData({ |
|
|
|
showbutton: false, |
|
|
|
}) |
|
|
|
console.log('支付失败', errNo, errMsg, orderId, outOrderNo); |
|
|
|
console.log(that.payOrderUpdate, "payOrderUpdate"); |
|
|
|
tt.showToast({ |
|
|
|
title: "取消支付", |
|
|
|
icon: 'none', |
|
|
|
duration: 2000, |
|
|
|
mask: false |
|
|
|
}); |
|
|
|
that.payOrderUpdate(outOrderNo, outOrderNo, 2, '', 'fail') |
|
|
|
} |
|
|
|
}, |
|
|
|
} |
|
|
|
console.log(options, "options"); |
|
|
|
tt.createOrder(options) |
|
|
|
}) |
|
|
|
|
|
|
|
} else {//不支持2.0支付 |
|
|
|
/** |
|
|
|
console.log('预下单失败', errNo, errMsg, errLogId); |
|
|
|
let tempErrmsg = errMsg.split('开发者拒绝交易:'); |
|
|
|
tt.showToast({ |
|
|
|
title: tempErrmsg[tempErrmsg.length - 1], |
|
|
|
icon: 'none', |
|
|
|
duration: 2000, |
|
|
|
mask: false |
|
|
|
}); |
|
|
|
} |
|
|
|
if (orderId || outOrderNo) { |
|
|
|
tt.hideLoading(); |
|
|
|
that.setData({ |
|
|
|
showbutton: false, |
|
|
|
}) |
|
|
|
console.log('支付失败', errNo, errMsg, orderId, outOrderNo); |
|
|
|
console.log(that.payOrderUpdate, "payOrderUpdate"); |
|
|
|
tt.showToast({ |
|
|
|
title: "取消支付", |
|
|
|
icon: 'none', |
|
|
|
duration: 2000, |
|
|
|
mask: false |
|
|
|
}); |
|
|
|
that.payOrderUpdate(outOrderNo, outOrderNo, 2, '', 'fail') |
|
|
|
} |
|
|
|
}, |
|
|
|
} |
|
|
|
console.log(options, "options"); |
|
|
|
tt.createOrder(options) |
|
|
|
}) |
|
|
|
|
|
|
|
} else { //不支持2.0支付 |
|
|
|
/** |
|
|
|
* 支付订单创建 |
|
|
|
*/ |
|
|
|
tt.showToast({ |
|
|
|
title: '请升级抖音', // 内容 |
|
|
|
icon: "none" |
|
|
|
}); |
|
|
|
return |
|
|
|
Http.post({ |
|
|
|
tt.showToast({ |
|
|
|
title: '请升级抖音', // 内容 |
|
|
|
icon: "none" |
|
|
|
}); |
|
|
|
return |
|
|
|
Http.post({ |
|
|
|
url: config.api.payOrderCreate, |
|
|
|
data: { |
|
|
|
orderId: orderId, |
|
|
@@ -586,8 +602,7 @@ Page({ |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else if (res.code === 1) { |
|
|
|
} else if (res.code === 1) { |
|
|
|
that.setData({ |
|
|
|
showbutton: false |
|
|
|
}) |
|
|
@@ -647,66 +662,66 @@ Page({ |
|
|
|
}) |
|
|
|
return; |
|
|
|
}, |
|
|
|
complete: res => { } |
|
|
|
complete: res => {} |
|
|
|
}); |
|
|
|
/// End payment -------- |
|
|
|
}) |
|
|
|
.catch(err => { |
|
|
|
tt.hideLoading(); |
|
|
|
tt.showToast({ |
|
|
|
title: err.message, |
|
|
|
icon: 'none', |
|
|
|
duration: 2000, |
|
|
|
mask: false |
|
|
|
}); |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
// 免费券 |
|
|
|
that.payOrderUpdate(orderId, "0", 1, '', 'free', that, that.data.composeOrderType); |
|
|
|
if (that.data.cardType == 100) { |
|
|
|
tt.setStorage({ |
|
|
|
key: 'couponNum2', |
|
|
|
data: "couponNum2" |
|
|
|
}) |
|
|
|
} else if (that.data.data.type != "5" && that.data.cardType != 100) { |
|
|
|
tt.setStorage({ |
|
|
|
key: 'couponNum', |
|
|
|
data: "couponNum" |
|
|
|
.catch(err => { |
|
|
|
tt.hideLoading(); |
|
|
|
tt.showToast({ |
|
|
|
title: err.message, |
|
|
|
icon: 'none', |
|
|
|
duration: 2000, |
|
|
|
mask: false |
|
|
|
}); |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
if (res) { |
|
|
|
tt.navigateTo({ |
|
|
|
url: `/pages/bargain/bargainDatail/bargainDatail?orderId=${res.data.mainOrderId}&composeOrderType=${res.data.composeOrderType}`, |
|
|
|
}) |
|
|
|
|
|
|
|
} else { |
|
|
|
// 免费券 |
|
|
|
that.payOrderUpdate(orderId, "0", 1, '', 'free', that, that.data.composeOrderType); |
|
|
|
if (that.data.cardType == 100) { |
|
|
|
tt.setStorage({ |
|
|
|
key: 'couponNum2', |
|
|
|
data: "couponNum2" |
|
|
|
}) |
|
|
|
} else if (that.data.data.type != "5" && that.data.cardType != 100) { |
|
|
|
tt.setStorage({ |
|
|
|
key: 'couponNum', |
|
|
|
data: "couponNum" |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}).catch(err => { |
|
|
|
tt.hideLoading(); |
|
|
|
that.setData({ |
|
|
|
showbutton: false, |
|
|
|
}) |
|
|
|
if (err.code == 3012) { |
|
|
|
that.getUnPaidOrder(that.data.couponId); |
|
|
|
} else { |
|
|
|
tt.showToast({ |
|
|
|
title: err.message ? err.message : err.data, |
|
|
|
icon: 'none', |
|
|
|
duration: 2000, |
|
|
|
success(res) { |
|
|
|
console.log(res); |
|
|
|
}, |
|
|
|
fail(res) { |
|
|
|
console.log("showToast 调用失败", res); |
|
|
|
}, |
|
|
|
}); |
|
|
|
} else { |
|
|
|
if (res) { |
|
|
|
tt.navigateTo({ |
|
|
|
url: `/pages/bargain/bargainDatail/bargainDatail?orderId=${res.data.mainOrderId}&composeOrderType=${res.data.composeOrderType}`, |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
}).catch(err => { |
|
|
|
tt.hideLoading(); |
|
|
|
that.setData({ |
|
|
|
showbutton: false, |
|
|
|
}) |
|
|
|
if (err.code == 3012) { |
|
|
|
that.getUnPaidOrder(that.data.couponId); |
|
|
|
} else { |
|
|
|
tt.showToast({ |
|
|
|
title: err.message ? err.message : err.data, |
|
|
|
icon: 'none', |
|
|
|
duration: 2000, |
|
|
|
success(res) { |
|
|
|
console.log(res); |
|
|
|
}, |
|
|
|
fail(res) { |
|
|
|
console.log("showToast 调用失败", res); |
|
|
|
}, |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
// } else { |
|
|
|
// //有价券 |
|
|
|
// console.log(tt.canIUse('createOrder'), "是否支持2.0js-api"); |
|
|
@@ -851,12 +866,12 @@ Page({ |
|
|
|
* 将值传到用户手机号授权的页面 |
|
|
|
* |
|
|
|
*/ |
|
|
|
// tt.navigateTo({ |
|
|
|
// url: `/pages/getPhone/getPhone?couponChannelId=${that.data.couponChannelId}&path=qr` |
|
|
|
// }); |
|
|
|
this.setData({ |
|
|
|
showPhoem:true |
|
|
|
}) |
|
|
|
tt.navigateTo({ |
|
|
|
url: `/pages/getPhone/getPhone?couponChannelId=${that.data.couponChannelId}&path=qr` |
|
|
|
}); |
|
|
|
// this.setData({ |
|
|
|
// showPhoem: true |
|
|
|
// }) |
|
|
|
} else if (err.code == 11006) { |
|
|
|
// 用户手机已加密 |
|
|
|
tt.navigateTo({ |
|
|
|