暂存code

This commit is contained in:
hejiangming
2025-05-07 09:54:33 +08:00
parent 78270eeda0
commit 007b002b81
403 changed files with 14507 additions and 6320 deletions
+167 -179
View File
@@ -2,55 +2,34 @@
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 api_order = require("../../api/order.js");
const utils_index = require("../../utils/index.js");
const utils_payUtils = require("../../utils/payUtils.js");
const Address = () => "../../components/address.js";
const Header = () => "../../components/header.js";
const _sfc_main = {
computed: {
PAYMENT_WAY_() {
return utils_enumUtils.PAYMENT_WAY_;
},
PRODUCT_DELIVERY_TIME() {
return utils_enumUtils.PRODUCT_DELIVERY_TIME;
}
},
components: {
Address
},
onLoad(option) {
const ids = option.ids;
if (ids) {
this.ids = ids;
this.getOrder();
}
Address,
Header
},
data() {
return {
ids: 0,
orderInfo: {
// coupon:2,//优惠卷
paymentMethod: null,
// 支付方式
paymentMethod: utils_enumUtils.PAYMENT_WAY.ALIPAY,
// 支付方式,暂时默认用支付宝
total: 4e3,
// 需要支付的总金额
address: {},
// 选中的地址
store: []
},
wayList: [
{
disabled: false,
id: utils_enumUtils.PAYMENT_WAY.WECHAT,
name: "微信支付",
path: "/static/product/way_wx.png"
},
{
disabled: false,
id: utils_enumUtils.PAYMENT_WAY.ALIPAY,
name: "支付宝支付",
path: "/static/product/way_zfb.png"
}
],
wayShow: false,
addressShow: false,
// 收件地址选择
@@ -60,13 +39,44 @@ const _sfc_main = {
// 收件地址数据类型
shopsIndex: 0,
// 收件地址数据类型
selectAddress: {}
selectAddress: {},
// 收件地址选择
wayOption: []
// leftPath:'',
// leftPathType:'',
};
},
onLoad(option) {
const ids = option.ids;
common_vendor.index.__f__("log", "at pages/order_submit/order_submit.vue:202", "ids", ids);
if (ids && ids !== "null") {
this.ids = ids;
this.getOrder();
}
const addressShow = option.addressShow;
if (addressShow && addressShow !== "null") {
this.addressShow = addressShow;
}
},
mounted() {
this.getWayOption();
},
methods: {
getValue: utils_enumUtils.getValue,
assembleAddress: utils_index.assembleAddress,
// 增加收货地址
addAdress() {
const ids = this.ids;
common_vendor.index.navigateTo({
url: "/pages/mine_address_add/mine_address_add?ids=" + ids
});
},
async getWayOption() {
const result = await api_order.getSupportPay();
if (result && result.bizcode === 100) {
this.wayOption = result.data;
}
},
async getOrder() {
const ids = this.ids;
if (!ids || ids === 0) {
@@ -107,26 +117,42 @@ const _sfc_main = {
* @param {Object} addIndex 需要修改店铺的数据节点
* @param {Object} index 需要修改的数据节点
*/
quantityFun(type, index, addIndex, pIndex) {
let currentQuantity = this.orderInfo.shops[index].addrTimes[addIndex].goods[pIndex].num;
async quantityFun(type, index, addIndex, pIndex) {
const data = this.orderInfo.shops[index].addrTimes[addIndex].goods[pIndex];
let currentQuantity = Number(data.num);
let currentTotalPrice = Number(data.totalPrice);
let currentAmount = Number(this.orderInfo.amount);
if (type === "minus") {
if (currentQuantity === 1) {
this.$refs.uToastRef.show({
type: "error",
message: "不能再减拉,不能小于最低购买数量~"
});
x3;
} else {
currentQuantity = currentQuantity - 1;
currentAmount = currentAmount - data.unitPrice;
currentTotalPrice = currentTotalPrice - data.unitPrice;
}
} else if (type === "add") {
currentQuantity = currentQuantity + 1;
currentAmount = currentAmount + data.unitPrice;
currentTotalPrice = currentTotalPrice + data.unitPrice;
}
const params = {
id: data.id,
goodsNum: currentQuantity
};
const result = await api_cart.updateGoodsNum(params);
if (result && result.bizcode === 100) {
this.orderInfo.shops[index].addrTimes[addIndex].goods[pIndex].num = currentQuantity;
this.orderInfo.shops[index].addrTimes[addIndex].goods[pIndex].totalPrice = currentTotalPrice.toFixed(2);
this.orderInfo.amount = currentAmount.toFixed(2);
}
this.orderInfo.shops[index].addrTimes[addIndex].goods[pIndex].num = currentQuantity;
},
// 获取备注
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) {
const remarObj = {};
@@ -144,7 +170,6 @@ const _sfc_main = {
}
remarkArr.push(remarObj);
}
common_vendor.index.__f__("log", "at pages/order_submit/order_submit.vue:295", "remarkArr", remarkArr);
return remarkArr;
},
/**
@@ -152,6 +177,13 @@ const _sfc_main = {
*/
async goPay() {
const orderInfo = this.orderInfo;
if (!orderInfo.address || Object.keys(orderInfo.address).length === 0) {
this.$refs.uToastRef.show({
type: "error",
message: "请选择收货地址"
});
return;
}
const way = orderInfo.paymentMethod;
if (!way || way === 0) {
this.$refs.uToastRef.show({
@@ -170,104 +202,48 @@ const _sfc_main = {
remark: JSON.stringify(this.getRemark())
//备注信息'[{"sid":"店铺ID","rmk":"备注内容"},{"sid":"店铺ID","rmk":"备注内容"}]'
};
common_vendor.index.__f__("log", "at pages/order_submit/order_submit.vue:317", "params", params);
common_vendor.index.__f__("log", "at pages/order_submit/order_submit.vue:366", "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: "订单支付失败"
});
}
if (item.status === 1) {
utils_payUtils.jumpWayOk();
return;
}
if (item.wechat && Object.keys(item.wechat).length !== 0) {
this.appWxpay(item.wechat, item.orderId, item.orderNum);
} else if (item.alipay && Object.keys(item.alipay).length !== 0 && item.alipay) {
this.zfbPay(item.alipay, item.orderId, item.orderNum);
} else {
this.$refs.uToastRef.show({
type: "error",
message: "订单支付失败"
});
setTimeout(() => {
utils_payUtils.jumpWayError();
}, 2e3);
}
} else {
this.getOrder();
}
},
// 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: "支付失败"
});
}
});
async appWxpay(alipay, orderId, orderNum) {
try {
const result = await utils_payUtils.appWxpayFun(alipay, orderId, orderNum);
common_vendor.index.__f__("log", "at pages/order_submit/order_submit.vue:396", "支付成功", result);
} catch (error) {
common_vendor.index.__f__("error", "at pages/order_submit/order_submit.vue:399", "支付失败", error);
}
},
// 支付宝支付
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);
async zfbPay(alipay, orderId, orderNum) {
try {
const result = await utils_payUtils.zfbPayFun(alipay, orderId, orderNum);
common_vendor.index.__f__("log", "at pages/order_submit/order_submit.vue:407", "支付成功", result);
} catch (error) {
common_vendor.index.__f__("error", "at pages/order_submit/order_submit.vue:410", "支付失败", error);
}
},
// 地址选中
getAddressValueFunc(item) {
@@ -293,10 +269,17 @@ const _sfc_main = {
this.addressType = type;
this.addressIndex = addIndex;
this.shopsIndex = index;
},
jumpProductInfo(item) {
common_vendor.index.__f__("log", "at pages/order_submit/order_submit.vue:440", "item", item);
common_vendor.index.navigateTo({
url: "/pages/productInfo/productInfo?id=" + item.goodsId
});
}
}
};
if (!Array) {
const _component_Header = common_vendor.resolveComponent("Header");
const _easycom_up_image2 = common_vendor.resolveComponent("up-image");
const _easycom_up_input2 = common_vendor.resolveComponent("up-input");
const _easycom_up_radio2 = common_vendor.resolveComponent("up-radio");
@@ -304,7 +287,7 @@ if (!Array) {
const _easycom_up_popup2 = common_vendor.resolveComponent("up-popup");
const _component_Address = common_vendor.resolveComponent("Address");
const _easycom_up_toast2 = common_vendor.resolveComponent("up-toast");
(_easycom_up_image2 + _easycom_up_input2 + _easycom_up_radio2 + _easycom_up_radio_group2 + _easycom_up_popup2 + _component_Address + _easycom_up_toast2)();
(_component_Header + _easycom_up_image2 + _easycom_up_input2 + _easycom_up_radio2 + _easycom_up_radio_group2 + _easycom_up_popup2 + _component_Address + _easycom_up_toast2)();
}
const _easycom_up_image = () => "../../uni_modules/uview-plus/components/u-image/u-image.js";
const _easycom_up_input = () => "../../uni_modules/uview-plus/components/u-input/u-input.js";
@@ -317,38 +300,44 @@ if (!Math) {
}
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return common_vendor.e({
a: $data.orderInfo.address && Object.keys($data.orderInfo.address).length !== 0
a: common_vendor.p({
leftTitle: _ctx.$t("order.submit.title"),
leftPathType: "switchTab",
leftPath: "/pages/shopping_cart/shopping_cart"
}),
b: $data.orderInfo.address && Object.keys($data.orderInfo.address).length !== 0
}, $data.orderInfo.address && Object.keys($data.orderInfo.address).length !== 0 ? common_vendor.e({
b: $data.orderInfo.address.isDefault
c: $data.orderInfo.address.isDefault
}, $data.orderInfo.address.isDefault ? {} : {}, {
c: common_vendor.t($options.assembleAddress($data.orderInfo.address).names),
d: common_vendor.t($data.orderInfo.address.address),
e: common_vendor.p({
d: common_vendor.t($options.assembleAddress($data.orderInfo.address).names),
e: common_vendor.t($data.orderInfo.address.address),
f: common_vendor.p({
src: "/static/common/right.png",
width: "20",
height: "20",
bgColor: "#f1f6ff00"
}),
f: common_vendor.t($data.orderInfo.address.name),
g: common_vendor.t($data.orderInfo.address.phone),
h: common_vendor.o(($event) => $options.checkAddressShow(true, "data"))
g: common_vendor.t($data.orderInfo.address.name),
h: common_vendor.t($data.orderInfo.address.phone),
i: common_vendor.o(($event) => $options.checkAddressShow(true, "data"))
}) : {
i: common_vendor.p({
j: common_vendor.p({
src: "/static/common/right.png",
width: "14",
height: "14",
bgColor: "#f1f6ff00"
}),
j: common_vendor.o(($event) => $options.checkAddressShow(true, "data"))
k: common_vendor.o(($event) => $options.checkAddressShow(true, "data"))
}, {
k: common_vendor.f($data.orderInfo.shops, (item, index, i0) => {
l: common_vendor.f($data.orderInfo.shops, (item, index, i0) => {
return {
a: "dc7219ba-2-" + i0,
a: "dc7219ba-3-" + i0,
b: common_vendor.p({
src: item.logo,
width: "22",
height: "22",
bgColor: "#f1f6ff00"
bgColor: "#f1f6ff00",
shape: "circle"
}),
c: common_vendor.t(item.name),
d: common_vendor.f(item.addrTimes, (addItem, addIndex, i1) => {
@@ -357,7 +346,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
}, addItem.address ? {
b: common_vendor.t(addItem.address.name),
c: common_vendor.t(addItem.address.address),
d: "dc7219ba-3-" + i0 + "-" + i1,
d: "dc7219ba-4-" + i0 + "-" + i1,
e: common_vendor.p({
src: "/static/common/right.png",
width: "16",
@@ -368,24 +357,26 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
} : {}, {
g: common_vendor.f(addItem.goods, (pItem, pIndex, i2) => {
return {
a: "dc7219ba-4-" + i0 + "-" + i1 + "-" + i2,
b: common_vendor.p({
a: common_vendor.o(($event) => $options.jumpProductInfo(pItem), pItem.id),
b: "dc7219ba-5-" + i0 + "-" + i1 + "-" + i2,
c: common_vendor.p({
src: pItem.img,
width: "80",
height: "80",
bgColor: "#f1f6ff00"
}),
c: common_vendor.t(pItem.title),
d: common_vendor.t(pItem.specs),
e: common_vendor.t(pItem.totalPrice),
f: common_vendor.t(pItem.unitPrice),
g: common_vendor.o(($event) => $options.quantityFun("minus", index, addIndex, pIndex), pItem.id),
h: common_vendor.t(pItem.num),
i: common_vendor.o(($event) => $options.quantityFun("add", index, addIndex, pIndex), pItem.id),
j: pItem.id
d: common_vendor.t(pItem.title),
e: common_vendor.t(pItem.specs),
f: common_vendor.o(($event) => $options.jumpProductInfo(pItem), pItem.id),
g: common_vendor.t(pItem.totalPrice),
h: common_vendor.t(pItem.unitPrice),
i: common_vendor.o(($event) => $options.quantityFun("minus", index, addIndex, pIndex), pItem.id),
j: common_vendor.t(pItem.num),
k: common_vendor.o(($event) => $options.quantityFun("add", index, addIndex, pIndex), pItem.id),
l: pItem.id
};
}),
h: "dc7219ba-5-" + i0 + "-" + i1,
h: "dc7219ba-6-" + i0 + "-" + i1,
i: common_vendor.o(($event) => addItem.remark = $event, addIndex),
j: common_vendor.p({
placeholder: "建议留言前先与商家沟通确认",
@@ -403,65 +394,62 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
e: item.id
};
}),
l: common_vendor.t($options.getValue($options.PAYMENT_WAY_, $data.orderInfo.paymentMethod)),
m: common_vendor.p({
m: common_vendor.t($options.getValue($data.wayOption, $data.orderInfo.paymentMethod)),
n: common_vendor.p({
src: "/static/common/right.png",
width: "20",
height: "20",
bgColor: "#f1f6ff00"
}),
n: common_vendor.o(($event) => {
o: common_vendor.o(($event) => {
$data.wayShow = true;
}),
o: common_vendor.t($data.orderInfo.amount),
p: common_vendor.o((...args) => $options.goPay && $options.goPay(...args)),
q: common_vendor.f($data.wayList, (item, k0, i0) => {
return {
a: "dc7219ba-9-" + i0 + ",dc7219ba-8",
b: common_vendor.p({
src: item.path,
width: "20",
height: "20",
bgColor: "#f1f6ff00"
}),
c: common_vendor.t(item.name),
d: "dc7219ba-10-" + i0 + ",dc7219ba-8",
p: common_vendor.t($data.orderInfo.amount),
q: common_vendor.o((...args) => $options.goPay && $options.goPay(...args)),
r: common_vendor.f($data.wayOption, (item, k0, i0) => {
return common_vendor.e({
a: common_vendor.t(item.name),
b: item.balance
}, item.balance ? {
c: common_vendor.t(item.balance)
} : {}, {
d: "dc7219ba-10-" + i0 + ",dc7219ba-9",
e: common_vendor.p({
name: item.id,
disabled: item.disabled,
name: item.type,
activeColor: "#FF7C41"
}),
f: item.id
};
});
}),
r: common_vendor.o(($event) => $data.orderInfo.paymentMethod = $event),
s: common_vendor.p({
s: common_vendor.o(($event) => $data.orderInfo.paymentMethod = $event),
t: common_vendor.p({
placement: "column",
modelValue: $data.orderInfo.paymentMethod
}),
t: common_vendor.o(($event) => {
v: common_vendor.o(($event) => {
$data.wayShow = false;
}),
v: common_vendor.o(($event) => $data.wayShow = $event),
w: common_vendor.p({
w: common_vendor.o(($event) => $data.wayShow = $event),
x: common_vendor.p({
round: 10,
closeOnClickOverlay: false,
closeable: true,
safeAreaInsetBottom: false,
show: $data.wayShow
}),
x: common_vendor.o($options.getAddressValueFunc),
y: common_vendor.o((...args) => $options.addressOk && $options.addressOk(...args)),
z: common_vendor.o(($event) => $options.checkAddressShow(false, null, 0, 0)),
A: common_vendor.o(($event) => $data.addressShow = $event),
B: common_vendor.p({
y: common_vendor.o((...args) => $options.addAdress && $options.addAdress(...args)),
z: common_vendor.o($options.getAddressValueFunc),
A: common_vendor.o((...args) => $options.addressOk && $options.addressOk(...args)),
B: common_vendor.o(($event) => $options.checkAddressShow(false, null, 0, 0)),
C: common_vendor.o(($event) => $data.addressShow = $event),
D: common_vendor.p({
round: 10,
closeOnClickOverlay: false,
closeable: true,
safeAreaInsetBottom: false,
show: $data.addressShow
}),
C: common_vendor.sr("uToastRef", "dc7219ba-13")
E: common_vendor.sr("uToastRef", "dc7219ba-13")
});
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-dc7219ba"]]);
@@ -1,11 +1,8 @@
{
"navigationBarTitleText": "提交订单",
"navigationBarBackgroundColor": "#F5F5F5",
"navigationBarTextStyle": "black",
"enablePullDownRefresh": false,
"navigationStyle": "default",
"navigationStyle": "custom",
"usingComponents": {
"address": "../../components/address",
"header": "../../components/header",
"up-image": "../../uni_modules/uview-plus/components/u-image/u-image",
"up-input": "../../uni_modules/uview-plus/components/u-input/u-input",
"up-radio": "../../uni_modules/uview-plus/components/u-radio/u-radio",
File diff suppressed because one or more lines are too long
@@ -119,13 +119,15 @@
}
.order_product_warp .order_item_content.data-v-dc7219ba {
display: flex;
margin-top: 20rpx;
}
.order_product_warp .order_item_content .content_info_right.data-v-dc7219ba {
margin-left: 20rpx;
display: grid;
width: calc(100% - 160rpx);
}
.order_product_warp .order_item_content .content_info_title.data-v-dc7219ba {
width: 266px;
width: 460rpx;
}
.order_product_warp .order_item_content .content_info_tag.data-v-dc7219ba {
font-size: 20rpx;
@@ -174,21 +176,6 @@
color: #FF7C41;
padding: 0rpx 6rpx;
}
.order_way_warp.data-v-dc7219ba {
display: flex;
justify-content: space-between;
align-items: center;
background: #FFFFFF;
border-radius: 24rpx;
margin-top: 30rpx;
padding: 30rpx;
font-weight: 500;
font-size: 26rpx;
color: #222222;
}
.order_way_warp .order_way_right.data-v-dc7219ba {
display: flex;
}
.order_pay_but.data-v-dc7219ba {
position: fixed;
bottom: 0;
@@ -211,51 +198,4 @@
font-weight: bold;
font-size: 36rpx;
color: #FF7C41;
}
.way_popup_warp.data-v-dc7219ba {
padding: 30rpx;
min-height: 800rpx;
width: calc(100% - 60rpx);
}
.way_popup_warp .way_popup_title.data-v-dc7219ba {
text-align: center;
margin-bottom: 60rpx;
}
.way_popup_warp .way_item.data-v-dc7219ba {
display: flex;
justify-content: space-between;
line-height: 82rpx;
}
.way_popup_warp .way_item .way_item_.data-v-dc7219ba {
display: flex;
align-items: center;
}
.way_popup_warp .way_item .way_item_val.data-v-dc7219ba {
font-weight: bold;
font-size: 30rpx;
color: #222222;
margin-left: 20rpx;
}
.popup_but.data-v-dc7219ba {
position: fixed;
bottom: 64rpx;
background: #FF7C41;
border-radius: 16rpx;
color: #FFFFFF;
text-align: center;
padding: 20rpx 0;
width: calc(100% - 60rpx);
}
.address_popup_warp.data-v-dc7219ba {
padding: 30rpx;
height: 1200rpx;
overflow-y: hidden;
}
.address_popup_warp .address_popup_title.data-v-dc7219ba {
text-align: center;
margin-bottom: 20rpx;
}
.address_popup_warp .address_popup_content.data-v-dc7219ba {
height: calc(100% - 180rpx);
overflow-y: auto;
}