增加新功能
This commit is contained in:
+131
-8
@@ -2,6 +2,7 @@
|
||||
const common_vendor = require("../../common/vendor.js");
|
||||
const utils_enumUtils = require("../../utils/enumUtils.js");
|
||||
const api_cart = require("../../api/cart.js");
|
||||
const api_payment = require("../../api/payment.js");
|
||||
const utils_index = require("../../utils/index.js");
|
||||
const Address = () => "../../components/address.js";
|
||||
const _sfc_main = {
|
||||
@@ -96,7 +97,6 @@ const _sfc_main = {
|
||||
}
|
||||
data.shops = shops;
|
||||
data.paymentMethod = null;
|
||||
common_vendor.index.__f__("log", "at pages/order_submit/order_submit.vue:245", "data", data);
|
||||
this.orderInfo = data;
|
||||
}
|
||||
},
|
||||
@@ -126,26 +126,148 @@ const _sfc_main = {
|
||||
// 获取备注
|
||||
getRemark() {
|
||||
const orderInfo = this.orderInfo;
|
||||
common_vendor.index.__f__("log", "at pages/order_submit/order_submit.vue:277", "orderInfo", orderInfo);
|
||||
const remarkArr = [];
|
||||
if (orderInfo && Object.keys(orderInfo).length !== 0)
|
||||
;
|
||||
if (orderInfo && Object.keys(orderInfo).length !== 0) {
|
||||
const remarObj = {};
|
||||
if (orderInfo.shops && orderInfo.shops.length !== 0) {
|
||||
orderInfo.shops.map((sItem) => {
|
||||
if (sItem.addrTimes && sItem.addrTimes.length !== 0) {
|
||||
sItem.addrTimes.map((addItem) => {
|
||||
if (addItem.remark) {
|
||||
remarObj.gkey = addItem.groupKey;
|
||||
remarObj.rmk = addItem.remark;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
remarkArr.push(remarObj);
|
||||
}
|
||||
common_vendor.index.__f__("log", "at pages/order_submit/order_submit.vue:295", "remarkArr", remarkArr);
|
||||
return remarkArr;
|
||||
},
|
||||
/**
|
||||
* 去支付
|
||||
*/
|
||||
goPay() {
|
||||
async goPay() {
|
||||
const orderInfo = this.orderInfo;
|
||||
const way = orderInfo.paymentMethod;
|
||||
if (!way || way === 0) {
|
||||
this.$refs.uToastRef.show({
|
||||
type: "error",
|
||||
message: "请先选择支付方式"
|
||||
});
|
||||
return;
|
||||
}
|
||||
const params = {
|
||||
addrId: this.orderInfo.address.id,
|
||||
addrId: orderInfo.address.id,
|
||||
// 收货地址ID
|
||||
cartIds: this.ids,
|
||||
//结算的购物车ID,多个以逗号分割,ALL表示全选
|
||||
payway: 0,
|
||||
payway: way,
|
||||
// 支付方式:1-微信,2-支付宝
|
||||
remark: null
|
||||
remark: JSON.stringify(this.getRemark())
|
||||
//备注信息'[{"sid":"店铺ID","rmk":"备注内容"},{"sid":"店铺ID","rmk":"备注内容"}]'
|
||||
};
|
||||
common_vendor.index.__f__("log", "at pages/order_submit/order_submit.vue:294", "params", params);
|
||||
common_vendor.index.__f__("log", "at pages/order_submit/order_submit.vue:317", "params", params);
|
||||
const resp = await api_cart.settle(params);
|
||||
if (resp && resp.bizcode === 100) {
|
||||
const item = resp.data;
|
||||
if (params.payway === utils_enumUtils.PAYMENT_WAY.WECHAT) {
|
||||
if (item.wechat && Object.keys(item.wechat).length !== 0) {
|
||||
this.appWxpay(item.wechat);
|
||||
} else {
|
||||
this.$refs.uToastRef.show({
|
||||
type: "error",
|
||||
message: "订单支付失败"
|
||||
});
|
||||
}
|
||||
} else if (params.payway === utils_enumUtils.PAYMENT_WAY.ALIPAY) {
|
||||
if (item.alipay && Object.keys(item.alipay).length !== 0) {
|
||||
this.zfbPay(item.alipay);
|
||||
} else {
|
||||
this.$refs.uToastRef.show({
|
||||
type: "error",
|
||||
message: "订单支付失败"
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
// app 微信支付
|
||||
appWxpay(item) {
|
||||
const newThis = this;
|
||||
const orderInfo = {
|
||||
"appid": item.appId,
|
||||
// 微信开放平台 - 应用 - AppId,注意和微信小程序、公众号 AppId 可能不一致
|
||||
"noncestr": item.nonceStr,
|
||||
// 随机字符串
|
||||
"package": "Sign=WXPay",
|
||||
// 固定值
|
||||
"partnerid": item.partnerId,
|
||||
// 微信支付商户号
|
||||
"prepayid": item.prepayId,
|
||||
// 统一下单订单号
|
||||
"timestamp": item.timeStamp,
|
||||
// 时间戳(单位:秒)
|
||||
"sign": item.sign
|
||||
// 签名,这里用的 MD5/RSA 签名
|
||||
};
|
||||
common_vendor.index.requestPayment({
|
||||
provider: "wxpay",
|
||||
orderInfo,
|
||||
success: function(res) {
|
||||
common_vendor.index.__f__("log", "at pages/order_submit/order_submit.vue:359", "success:" + res);
|
||||
newThis.payFeedbackFun(item.orderId, res.orderNum, 1);
|
||||
newThis.jumpWayOk();
|
||||
},
|
||||
fail: function(err) {
|
||||
common_vendor.index.__f__("log", "at pages/order_submit/order_submit.vue:364", "fail:", err);
|
||||
this.$refs.uToastRef.show({
|
||||
type: "error",
|
||||
message: "支付失败"
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
// 支付宝支付
|
||||
zfbPay(item) {
|
||||
const that = this;
|
||||
common_vendor.index.requestPayment({
|
||||
provider: "alipay",
|
||||
orderInfo: item.orderStr,
|
||||
success(res) {
|
||||
common_vendor.index.__f__("log", "at pages/order_submit/order_submit.vue:379", "res", res);
|
||||
that.payFeedbackFun(item.orderId, item.orderNum, 1);
|
||||
that.jumpWayOk();
|
||||
},
|
||||
//调用失败的回调
|
||||
fail(err) {
|
||||
common_vendor.index.__f__("log", "at pages/order_submit/order_submit.vue:385", "fail:", err);
|
||||
this.$refs.uToastRef.show({
|
||||
type: "error",
|
||||
message: "支付失败"
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
// 跳转到支付成功页面
|
||||
jumpWayOk() {
|
||||
common_vendor.index.navigateTo({
|
||||
url: "/pages/order_submit_ok/order_submit_ok"
|
||||
});
|
||||
},
|
||||
// 支付结果回调
|
||||
async payFeedbackFun(orderId, orderNum, status) {
|
||||
const params = {
|
||||
orderId,
|
||||
orderNum,
|
||||
status
|
||||
};
|
||||
common_vendor.index.__f__("log", "at pages/order_submit/order_submit.vue:406", "params", params);
|
||||
const response = await api_payment.feedback(params);
|
||||
common_vendor.index.__f__("log", "at pages/order_submit/order_submit.vue:408", "反馈结果", response);
|
||||
},
|
||||
// 地址选中
|
||||
getAddressValueFunc(item) {
|
||||
@@ -153,6 +275,7 @@ const _sfc_main = {
|
||||
addressObj.addressStr = utils_index.assembleAddress(addressObj).names;
|
||||
this.selectAddress = addressObj;
|
||||
},
|
||||
// 地址选中OK
|
||||
addressOk() {
|
||||
const type = this.addressType;
|
||||
const addressIndex = this.addressIndex;
|
||||
|
||||
Reference in New Issue
Block a user