Explorar el Código

支付修改

dev
HolyKnightIX hace 2 años
padre
commit
83350700b2
Se han modificado 3 ficheros con 334 adiciones y 287 borrados
  1. +4
    -4
      ext.json
  2. +219
    -204
      pages/coupon/confirmation/confirmation.js
  3. +111
    -79
      pages/order/detail/index.js

+ 4
- 4
ext.json Ver fichero

@@ -1,17 +1,17 @@
{
"ext": {
"attr": {
"configUrl": "https://c.malls.iformall.com/C/api"
"configUrl": "https://ctest.malls.iformall.com/C/api"
},
"name": "创美优团",
"weappId": "tt15d463698aebb83b01"
"name": "富茂券券",
"weappId": "ttef6599d8705b49b101"
},
"window": {
"backgroundTextStyle": "light",
"navigationBarTextStyle": "black",
"navigationBarBackgroundColor": "#fff"
},
"extAppid": "tt15d463698aebb83b01",
"extAppid": "ttef6599d8705b49b101",
"extEnable": true,
"directCommit": false,
"networkTimeout": {


+ 219
- 204
pages/coupon/confirmation/confirmation.js Ver fichero

@@ -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({


+ 111
- 79
pages/order/detail/index.js Ver fichero

@@ -12,10 +12,10 @@ Page({
data: {
curHtml: '',
showIdFalg: false,
outOrderNo: '',//支付2.0继续支付id
payOrderNo: "",//评价订单id
evaluateFlag: false,//控制评价显隐藏
serviceUrl: '',//客服外部链接
outOrderNo: '', //支付2.0继续支付id
payOrderNo: "", //评价订单id
evaluateFlag: false, //控制评价显隐藏
serviceUrl: '', //客服外部链接
dynamicRq: "",
expiredSeconds: 0,
showhieRq: false,
@@ -52,18 +52,30 @@ Page({
orderFlag: false, //判断是不是线上配送
},
handleRefund(event) {
const { status, result } = event.detail;
const {
status,
result
} = event.detail;
if (status === 'success') {
const { refundId, outRefundNo } = result;
console.log(refundId, outRefundNo );
const {
refundId,
outRefundNo
} = result;
console.log(refundId, outRefundNo);
} else {
const { errMsg } = result;
const {
errMsg
} = result;
console.log(errMsg);
}
},
applyRefund(event) {
const { orderId } = event.detail;
const extra = { orderId }; // 开发者需要透传的参数,可自定义内容
const {
orderId
} = event.detail;
const extra = {
orderId
}; // 开发者需要透传的参数,可自定义内容
return new Promise(resolve => {
resolve(extra);
});
@@ -141,7 +153,7 @@ Page({
},
});
},
refund() {//退款
refund() { //退款
Http.post({
url: config.api.refund,
data: {
@@ -186,7 +198,7 @@ Page({
console.log(`showModal调用失败`);
},
});
} else if (this_.data.order.couponOrderStatus == 3) {//退款中
} else if (this_.data.order.couponOrderStatus == 3) { //退款中
tt.navigateTo({
url: `/pages/refund/refund?id=${this.data.order.id}`,
success: (res) => {
@@ -294,7 +306,7 @@ Page({
createDate: createDate,
composeOrderType: tempData.composeOrderType,
contentType: tempData.contentType ? tempData.contentType : 0,
orderFlag: tempData.type == 11 ? true : false,//判断是不是线上配送
orderFlag: tempData.type == 11 ? true : false, //判断是不是线上配送
})
if (tempData.couponOrderId) { //0未付款 1已支付 2已取消 3退款中 4已退款
that.setRq()
@@ -302,29 +314,29 @@ Page({
let setInter = setInterval(() => {
if (tempData.couponOrderStatus == 0) {
Http.get({
url: config.api.getStatus,
data: {
couponOrderId: tempData.couponOrderId
}
}).then(res => {
console.log(res);
that.setData({
couponOrderStatus: res.data.CouponOrderStatus
});
if (res.data.CouponOrderStatus == 1 || res.data.CouponOrderStatus == 3) {
/**
* 动态改变上一级页面的核销状态
*/
// that.getStaticGame()
//直接调用上一个页面的setData()方法,把数据存到上一个页面中去
clearInterval(that.data.setInter);
clearInterval(that.data.templTiem);
that.updetail()
url: config.api.getStatus,
data: {
couponOrderId: tempData.couponOrderId
}
}).then(res => {
console.log(res);
that.setData({
mystatus: res.data.CouponOrderStatus
couponOrderStatus: res.data.CouponOrderStatus
});
}
})
if (res.data.CouponOrderStatus == 1 || res.data.CouponOrderStatus == 3) {
/**
* 动态改变上一级页面的核销状态
*/
// that.getStaticGame()
//直接调用上一个页面的setData()方法,把数据存到上一个页面中去
clearInterval(that.data.setInter);
clearInterval(that.data.templTiem);
that.updetail()
that.setData({
mystatus: res.data.CouponOrderStatus
});
}
})
.catch(err => {
tt.showToast({
title: err.errMsg,
@@ -339,8 +351,8 @@ Page({
setInter: setInter
})
}
if (tempData.couponOrderStatus && tempData.couponOrderStatus == 1) {//核销后
that.goIfEvaluate()//判断订单是否能评价
if (tempData.couponOrderStatus && tempData.couponOrderStatus == 1) { //核销后
that.goIfEvaluate() //判断订单是否能评价
}
}).catch(error => {
console.log(error, "error");
@@ -392,9 +404,9 @@ Page({
let that = this;
// 获取用户信息
Http.get({
url: config.api.getScore,
data: {}
})
url: config.api.getScore,
data: {}
})
.then(res => {
console.log(res)
that.setData({
@@ -440,7 +452,7 @@ Page({
_this.setData({
showhieRq: false,
})
Http.get({//获取动态二维码
Http.get({ //获取动态二维码
url: config.api.dynamicId,
data: {
couponOrderId: _this.data.order.couponOrderId
@@ -541,20 +553,20 @@ Page({
getStaticGame(token) {
let _this = this;
Http.get({
url: config.api.getGame,
data: {
triggleAction: 3 // 购买触发
}
}).then(res => {
if (res.data.id) {
url: config.api.getGame,
data: {
triggleAction: 3 // 购买触发
}
}).then(res => {
if (res.data.id) {
_this.setData({
showIf: true
})
}
_this.setData({
showIf: true
staticGamedata: res.data
})
}
_this.setData({
staticGamedata: res.data
})
})
.catch(err => {
console.log(err);
})
@@ -563,7 +575,9 @@ Page({
let _this = this
tt.rateAwemeOrder({
orderId: _this.data.payOrderNo,
success({ result }) {
success({
result
}) {
console.log(result);
if (result) {
tt.navigateBack({
@@ -596,7 +610,9 @@ Page({
}).then(res => {
tt.canRateAwemeOrders({
orderIds: [res.data.payOrderNo],
success({ result }) {
success({
result
}) {
console.log("result", result);
_this.setData({
evaluateFlag: result[0],
@@ -631,7 +647,7 @@ Page({

});
tt.hideShareMenu()
if (options.cardIf) {//转赠 展示不需
if (options.cardIf) { //转赠 展示不需
that.setData({
cardIf: true
})
@@ -650,7 +666,7 @@ Page({
})
that.updetail()
},
getSeUrl() {//获取客服链接
getSeUrl() { //获取客服链接
const openId = tt.getStorageSync('openId');
Http.post({
url: config.api.getServiceUrl,
@@ -686,13 +702,13 @@ Page({
let that = this;
// 支付成功
Http.post({
url: config.api.toOrderGroup,
data: {
id: orderGroupId,
orderId,
couponId: _this.data.order.productId
}
})
url: config.api.toOrderGroup,
data: {
id: orderGroupId,
orderId,
couponId: _this.data.order.productId
}
})
.then(res => {
tt.redirectTo({
url: `/pages/spellDetail/index?orderId=${orderId}&couponId=${_this.data.order.productId}&orderGroupId=${res.data.orderGroupId}`
@@ -719,7 +735,7 @@ Page({
// if (true) {//兼容不支持支付2.0 js-api !tt.canIUse('createOrder')
if (that.data.order.payment > 0) {

if (tt.canIUse('createOrder')) {//支付2.0 js-api
if (tt.canIUse('createOrder')) { //支付2.0 js-api
const outOrderNo = that.data.outOrderNo
console.log(outOrderNo, "outOrderNo");
Http.post({
@@ -731,7 +747,9 @@ Page({
}
}).then(res => {
if (res.data.createPay) {
let tempCallbackData = res.data.callbackData
let tempCallbackData = {
composeOrderId: res.data.outOrderNo
}
// tempCallbackData[that.data.data.couponChannel.ttSpuId] = that.data.data.couponChannel.id
let options = {
callbackData: tempCallbackData,
@@ -742,12 +760,21 @@ Page({
that.setData({
showbutton: false,
})
const { orderId, outOrderNo } = res;
const {
orderId,
outOrderNo
} = res;
// that.setData({ orderId, outOrderNo });
that.payOrderUpdate(outOrderNo, outOrderNo, 1, '', '', that, '');
},
fail: res => {
const { orderId, outOrderNo, errNo, errMsg, errLogId } = res;
const {
orderId,
outOrderNo,
errNo,
errMsg,
errLogId
} = res;
if (errLogId) {
tt.hideLoading();
that.setData({
@@ -795,7 +822,13 @@ Page({
that.payOrderUpdate(outOrderNo, outOrderNo, 1, '', '', that); // 支付成功
},
fail: res => {
const { orderId, outOrderNo, errNo, errMsg, errLogId } = res;
const {
orderId,
outOrderNo,
errNo,
errMsg,
errLogId
} = res;
if (errLogId) {
console.log('查询订单信息失败', errNo, errMsg, errLogId);
that.setData({
@@ -833,11 +866,11 @@ Page({
icon: "none"
});
})
} else {//不支持支付2.0 js-api
} else { //不支持支付2.0 js-api
tt.showToast({
title: '请升级抖音', // 内容
icon: "none"
});
});
return
// 支付金额不为0
Http.post({
@@ -979,14 +1012,14 @@ Page({
payOrderUpdate: (orderId, payOrderId, status, reason, type, _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();
_this.setData({
@@ -1045,5 +1078,4 @@ Page({
clearInterval(that.data.setInter);
clearInterval(that.data.templTiem);
},
});

});

Cargando…
Cancelar
Guardar