checkPayMode.js
4.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
"use strict";
var common_vendor = require("../common/vendor.js");
var api_index = require("../api/index.js");
require("../utils/request.js");
if (!Array) {
const _easycom_u_popup2 = common_vendor.resolveComponent("u-popup");
_easycom_u_popup2();
}
const _easycom_u_popup = () => "../uni_modules/uview-plus/components/u-popup/u-popup.js";
if (!Math) {
_easycom_u_popup();
}
const _sfc_main = {
props: {
payParams: {
type: Object,
default: {}
},
modeShow: {
type: Boolean,
default: false
},
adressId: {
type: String,
default: ""
},
totalPrice: {
type: String,
default: 0
},
balance: {
type: String,
default: 0
},
isOrderPay: {
type: Boolean,
default: false
},
orderId: {
type: String,
default: ""
},
carId: {
type: String,
default: ""
}
},
emits: ["canclePop"],
setup(__props, { emit }) {
const props = __props;
common_vendor.onMounted(() => {
setTimeout(() => {
if (props.totalPrice > props.balance) {
payMode[1].shows = false;
}
}, 100);
});
common_vendor.watchEffect(() => {
if (props.totalPrice < props.balance) {
payMode[1].shows = true;
}
});
const payMode = common_vendor.reactive([
{ id: 1, name: "\u5FAE\u4FE1\u652F\u4ED8", check: true, modeUrl: "/static/shopCarIc/weCaat.png", shows: true },
{ id: 2, name: "\u4F59\u989D\u652F\u4ED8", check: false, modeUrl: "/static/shopCarIc/yue.png", shows: true }
]);
common_vendor.ref(0);
let defaultMode = common_vendor.ref(0);
let checkPay = (index) => {
defaultMode.value = index;
};
const subOrder = () => {
if (props.car_Id) {
console.log("\u8D2D\u7269\u8F66\u652F\u4ED8", props.car_Id);
getCarPays();
} else {
console.log("dindan\u652F\u4ED8", props.car_Id);
props.isOrderPay ? getOrderPays() : getPays();
}
};
const goRecharge = () => {
common_vendor.index.navigateTo({ url: "/pages/mine/recharge" });
};
const canclePop = () => {
emit("canclePop");
};
const { proxy } = common_vendor.getCurrentInstance();
const getPays = async () => {
try {
let { id, num, specId } = props.payParams;
let params = {
goods_id: id,
num,
goods_spec_id: specId,
address_id: props.adressId,
fangs: defaultMode.value == 0 ? 1 : 2,
remark: ""
};
const res = await api_index.getPay(params);
proxy.$methods.pay(res);
canclePop();
} catch (err) {
common_vendor.index.showToast({ title: err, icon: "none" });
console.log("getPay", err);
}
};
const getCarPays = async () => {
try {
let params = {
cart_ids: props.car_Id,
address_id: props.adressId,
remark: "",
fangs: defaultMode.value == 0 ? 1 : 2
};
const res = await api_index.getCarPay(params);
proxy.$methods.showTN("\u4F59\u989D\u652F\u4ED8\u6210\u529F~");
canclePop();
console.log("getCarPay", res);
} catch (err) {
common_vendor.index.showToast({ title: err, icon: "none" });
console.log("getCarPay", err);
}
};
const getOrderPays = async () => {
try {
const res = await api_index.getOrderPay(props.orderId, defaultMode.value == 0 ? 1 : 2);
proxy.$methods.pay(res);
canclePop();
console.log("getOrderPay", res);
} catch (err) {
common_vendor.index.showToast({ title: err, icon: "none" });
console.log("getOrderPay", err);
}
};
return (_ctx, _cache) => {
return {
a: common_vendor.f(common_vendor.unref(payMode), (item, index, i0) => {
return common_vendor.e({
a: item.modeUrl,
b: common_vendor.t(item.name),
c: item.shows
}, item.shows ? {
d: common_vendor.unref(defaultMode) == index ? "/static/shopCarIc/modeCheck.png" : "/static/shopCarIc/checks.png"
} : {
e: common_vendor.o(goRecharge)
}, {
f: item.id,
g: common_vendor.o(($event) => common_vendor.unref(checkPay)(index), item.id)
});
}),
b: common_vendor.o(subOrder),
c: common_vendor.o(canclePop),
d: common_vendor.p({
show: __props.modeShow,
bgColor: "#F6F8FA",
closeable: true,
round: "12"
})
};
};
}
};
var Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "D:/vue/\u5927\u5065\u5EB7\u5546\u57CE/healthMall/componets/checkPayMode.vue"]]);
wx.createComponent(Component);