546 lines
17 KiB
JavaScript
546 lines
17 KiB
JavaScript
"use strict";
|
|
const common_vendor = require("../../common/vendor.js");
|
|
const api_shop_order_index = require("../../api/shop/order/index.js");
|
|
const api_booking_course_index = require("../../api/booking/course/index.js");
|
|
const api_booking_student_index = require("../../api/booking/student/index.js");
|
|
const api_system_payment_index = require("../../api/system/payment/index.js");
|
|
const api_passport_login_index = require("../../api/passport/login/index.js");
|
|
const utils_common = require("../../utils/common.js");
|
|
const store_modules_car = require("../../store/modules/car.js");
|
|
const store_modules_user = require("../../store/modules/user.js");
|
|
const userStore = store_modules_user.useUserStore();
|
|
const carStore = store_modules_car.useCarStore();
|
|
const { goodsList, totalPrice, carNum, merchantId, merchantName, merchantCode, type, dateTime } = common_vendor.storeToRefs(carStore);
|
|
const _sfc_main = {
|
|
data() {
|
|
return {
|
|
courseId: 0,
|
|
form: {},
|
|
orderId: 0,
|
|
goodsId: 0,
|
|
userInfo: {},
|
|
student: {},
|
|
studentList: [],
|
|
week: 0,
|
|
goodsList,
|
|
// 骨架屏
|
|
hideTools: true,
|
|
// 订单总金额
|
|
totalPrice,
|
|
reducePrice: 0,
|
|
merchantId,
|
|
merchantName,
|
|
merchantCode,
|
|
getWeek: utils_common.getWeek,
|
|
payType: 1,
|
|
payment: [],
|
|
isLogin: false,
|
|
disabled: false,
|
|
// 支付密码是否正确
|
|
isPayPasswordCorrect: false,
|
|
disabledPayPayPassword: false,
|
|
payPassword: ""
|
|
};
|
|
},
|
|
onLoad(option) {
|
|
this.courseId = option.id;
|
|
this.reload();
|
|
},
|
|
onShow() {
|
|
if (common_vendor.index.getStorageSync("user_id") && common_vendor.index.getStorageSync("access_token")) {
|
|
this.isLogin = true;
|
|
}
|
|
this.openLogin();
|
|
},
|
|
methods: {
|
|
async reload() {
|
|
const app = this;
|
|
const userInfo = await userStore.fetchUserInfo();
|
|
app.userInfo = userInfo;
|
|
api_booking_student_index.pageStudent({ userId: common_vendor.index.getStorageSync("user_id") }).then((res) => {
|
|
app.studentList = res.list;
|
|
const arr = res.list.filter((d) => d.isDefault === true);
|
|
app.student = arr[0];
|
|
});
|
|
api_system_payment_index.select({ status: true }).then((list) => {
|
|
app.payment = list.filter((d) => d.type < 2).map((d) => {
|
|
if (d.code == "balancePay") {
|
|
d.name = `${d.name} (¥${userInfo.balance})`;
|
|
}
|
|
return d;
|
|
});
|
|
});
|
|
api_booking_course_index.getCourse(app.courseId).then((data) => {
|
|
this.form = data;
|
|
});
|
|
},
|
|
onDisabled() {
|
|
this.disabled = !this.disabled;
|
|
},
|
|
navTo(url) {
|
|
common_vendor.index.navigateTo({
|
|
url
|
|
});
|
|
},
|
|
openUrl(url) {
|
|
if (!this.isLogin) {
|
|
this.$refs.login.open("bottom");
|
|
return false;
|
|
} else {
|
|
common_vendor.index.navigateTo({
|
|
url
|
|
});
|
|
}
|
|
},
|
|
onAddress(item) {
|
|
this.address = item;
|
|
this.$refs.addForm.close();
|
|
},
|
|
// 切换支付方式
|
|
onPayType(index) {
|
|
this.payType = index;
|
|
},
|
|
openStudentList() {
|
|
this.$refs.addForm.open("center");
|
|
},
|
|
// 弹出登录提示框
|
|
openLogin() {
|
|
if (!this.isLogin) {
|
|
this.$refs.login.open("bottom");
|
|
return false;
|
|
}
|
|
},
|
|
// 验证支付密码
|
|
onPayPassword() {
|
|
if (this.payPassword == "" || !this.payPassword) {
|
|
common_vendor.index.showToast({
|
|
title: "请输入支付密码",
|
|
icon: "none"
|
|
});
|
|
return false;
|
|
}
|
|
this.disabledPayPayPassword = true;
|
|
const { payPassword } = this;
|
|
api_passport_login_index.checkPayPassword({ payPassword }).then((res) => {
|
|
this.disabledPayPayPassword = false;
|
|
this.isPayPasswordCorrect = true;
|
|
this.save();
|
|
}).catch((err) => {
|
|
common_vendor.index.showToast({
|
|
title: err.message,
|
|
icon: "none"
|
|
});
|
|
this.disabledPayPayPassword = false;
|
|
});
|
|
},
|
|
save() {
|
|
const app = this;
|
|
if (!this.disabled) {
|
|
common_vendor.index.showToast({
|
|
title: "请先阅读并同意服务协议",
|
|
icon: "none"
|
|
});
|
|
return false;
|
|
}
|
|
if (carStore.goodsList.length == 0) {
|
|
common_vendor.index.showToast({
|
|
title: "订单信息不存在",
|
|
icon: "none"
|
|
});
|
|
return false;
|
|
}
|
|
if (app.payType == 0 && !this.isPayPasswordCorrect) {
|
|
this.$refs.payPasswordForm.open("center");
|
|
return false;
|
|
}
|
|
common_vendor.index.showLoading({
|
|
title: "订单提交中."
|
|
});
|
|
api_shop_order_index.addOrder({
|
|
type: 0,
|
|
// 0商城订单
|
|
orderId: this.orderId,
|
|
merchantId: this.merchantId,
|
|
merchantCode: this.merchantCode,
|
|
merchantName: this.merchantName,
|
|
totalPrice: this.totalPrice,
|
|
payPrice: this.totalPrice - this.reducePrice,
|
|
goodsList: this.goodsList,
|
|
comments: this.goodsList[0].goodsName,
|
|
// 微信支付
|
|
payType: this.payType,
|
|
// 下单日期
|
|
dateTime: this.dateTime
|
|
}).then((data) => {
|
|
const orderInfo = data;
|
|
common_vendor.index.requestPayment({
|
|
provider: orderInfo.provider,
|
|
// 服务提供商
|
|
timeStamp: orderInfo.timeStamp,
|
|
// 时间戳
|
|
nonceStr: orderInfo.nonceStr,
|
|
// 随机字符串
|
|
package: orderInfo.package,
|
|
signType: orderInfo.signType,
|
|
// 签名算法
|
|
paySign: orderInfo.paySign,
|
|
// 签名
|
|
success: function(res) {
|
|
common_vendor.index.showToast({
|
|
title: "支付成功",
|
|
icon: "success"
|
|
});
|
|
setTimeout(function() {
|
|
app.disabled = false;
|
|
common_vendor.index.navigateTo({
|
|
url: "/package/goods/order"
|
|
});
|
|
}, 500);
|
|
},
|
|
fail: function(err) {
|
|
console.log("支付失败", err);
|
|
app.disabled = false;
|
|
common_vendor.index.navigateTo({
|
|
url: "/package/goods/order"
|
|
});
|
|
}
|
|
});
|
|
common_vendor.index.hideLoading();
|
|
}).catch((res) => {
|
|
common_vendor.index.showToast({
|
|
title: res.message || "请检查您的网络.",
|
|
icon: "none"
|
|
});
|
|
common_vendor.index.hideLoading();
|
|
});
|
|
}
|
|
}
|
|
};
|
|
if (!Array) {
|
|
const _easycom_uv_cell2 = common_vendor.resolveComponent("uv-cell");
|
|
const _easycom_uv_cell_group2 = common_vendor.resolveComponent("uv-cell-group");
|
|
const _easycom_uni_card2 = common_vendor.resolveComponent("uni-card");
|
|
const _easycom_uv_icon2 = common_vendor.resolveComponent("uv-icon");
|
|
const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons");
|
|
const _easycom_uv_gap2 = common_vendor.resolveComponent("uv-gap");
|
|
const _easycom_uv_count_to2 = common_vendor.resolveComponent("uv-count-to");
|
|
const _easycom_uv_button2 = common_vendor.resolveComponent("uv-button");
|
|
const _easycom_uv_avatar2 = common_vendor.resolveComponent("uv-avatar");
|
|
const _easycom_uni_tag2 = common_vendor.resolveComponent("uni-tag");
|
|
const _easycom_uni_popup2 = common_vendor.resolveComponent("uni-popup");
|
|
const _easycom_uv_code_input2 = common_vendor.resolveComponent("uv-code-input");
|
|
const _easycom_uni_forms_item2 = common_vendor.resolveComponent("uni-forms-item");
|
|
const _easycom_uni_forms2 = common_vendor.resolveComponent("uni-forms");
|
|
const _easycom_ws_login2 = common_vendor.resolveComponent("ws-login");
|
|
(_easycom_uv_cell2 + _easycom_uv_cell_group2 + _easycom_uni_card2 + _easycom_uv_icon2 + _easycom_uni_icons2 + _easycom_uv_gap2 + _easycom_uv_count_to2 + _easycom_uv_button2 + _easycom_uv_avatar2 + _easycom_uni_tag2 + _easycom_uni_popup2 + _easycom_uv_code_input2 + _easycom_uni_forms_item2 + _easycom_uni_forms2 + _easycom_ws_login2)();
|
|
}
|
|
const _easycom_uv_cell = () => "../../uni_modules/uv-cell/components/uv-cell/uv-cell.js";
|
|
const _easycom_uv_cell_group = () => "../../uni_modules/uv-cell/components/uv-cell-group/uv-cell-group.js";
|
|
const _easycom_uni_card = () => "../../uni_modules/uni-card/components/uni-card/uni-card.js";
|
|
const _easycom_uv_icon = () => "../../uni_modules/uv-icon/components/uv-icon/uv-icon.js";
|
|
const _easycom_uni_icons = () => "../../uni_modules/uni-icons/components/uni-icons/uni-icons.js";
|
|
const _easycom_uv_gap = () => "../../uni_modules/uv-gap/components/uv-gap/uv-gap.js";
|
|
const _easycom_uv_count_to = () => "../../uni_modules/uv-count-to/components/uv-count-to/uv-count-to.js";
|
|
const _easycom_uv_button = () => "../../uni_modules/uv-button/components/uv-button/uv-button.js";
|
|
const _easycom_uv_avatar = () => "../../uni_modules/uv-avatar/components/uv-avatar/uv-avatar.js";
|
|
const _easycom_uni_tag = () => "../../uni_modules/uni-tag/components/uni-tag/uni-tag.js";
|
|
const _easycom_uni_popup = () => "../../uni_modules/uni-popup/components/uni-popup/uni-popup.js";
|
|
const _easycom_uv_code_input = () => "../../uni_modules/uv-code-input/components/uv-code-input/uv-code-input.js";
|
|
const _easycom_uni_forms_item = () => "../../uni_modules/uni-forms/components/uni-forms-item/uni-forms-item.js";
|
|
const _easycom_uni_forms = () => "../../uni_modules/uni-forms/components/uni-forms/uni-forms.js";
|
|
const _easycom_ws_login = () => "../../uni_modules/ws-login/components/ws-login/ws-login.js";
|
|
if (!Math) {
|
|
(_easycom_uv_cell + _easycom_uv_cell_group + _easycom_uni_card + _easycom_uv_icon + _easycom_uni_icons + _easycom_uv_gap + _easycom_uv_count_to + _easycom_uv_button + _easycom_uv_avatar + _easycom_uni_tag + _easycom_uni_popup + _easycom_uv_code_input + _easycom_uni_forms_item + _easycom_uni_forms + _easycom_ws_login)();
|
|
}
|
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
return common_vendor.e({
|
|
a: common_vendor.t($data.merchantId),
|
|
b: common_vendor.t($data.merchantCode),
|
|
c: common_vendor.t($data.merchantName),
|
|
d: common_vendor.t(_ctx.dateTime),
|
|
e: common_vendor.t($data.week),
|
|
f: common_vendor.t($data.totalPrice),
|
|
g: common_vendor.t(_ctx.type),
|
|
h: common_vendor.t($data.goodsList),
|
|
i: common_vendor.p({
|
|
title: `课程名称`,
|
|
label: $data.form.courseName,
|
|
cellStyle: {
|
|
padding: "10px 0"
|
|
},
|
|
border: false
|
|
}),
|
|
j: common_vendor.p({
|
|
title: `上课课时`,
|
|
label: $data.form.classPeriod,
|
|
cellStyle: {
|
|
padding: "10px 0"
|
|
},
|
|
border: false
|
|
}),
|
|
k: common_vendor.p({
|
|
title: `年龄限制`,
|
|
label: $data.form.ageLimit,
|
|
cellStyle: {
|
|
padding: "10px 0"
|
|
},
|
|
border: false
|
|
}),
|
|
l: common_vendor.p({
|
|
title: `培训费用`,
|
|
label: `¥${$data.form.price}`,
|
|
cellStyle: {
|
|
padding: "10px 0"
|
|
},
|
|
border: false
|
|
}),
|
|
m: common_vendor.p({
|
|
title: `上课时间`,
|
|
label: `${$data.form.startTime}`,
|
|
cellStyle: {
|
|
padding: "10px 0"
|
|
},
|
|
border: false
|
|
}),
|
|
n: common_vendor.p({
|
|
title: `上课地点`,
|
|
label: `${$data.form.address}`,
|
|
cellStyle: {
|
|
padding: "10px 0"
|
|
},
|
|
border: false
|
|
}),
|
|
o: common_vendor.p({
|
|
customStyle: {
|
|
backgroundColor: "#ffffff"
|
|
},
|
|
border: false
|
|
}),
|
|
p: common_vendor.p({
|
|
title: "课程信息",
|
|
border: false,
|
|
["is-shadow"]: false
|
|
}),
|
|
q: $data.student
|
|
}, $data.student ? {
|
|
r: common_vendor.p({
|
|
name: "arrow-right"
|
|
}),
|
|
s: common_vendor.o($options.openStudentList),
|
|
t: common_vendor.p({
|
|
title: `${$data.student.name}`,
|
|
icon: "account",
|
|
cellStyle: {
|
|
padding: "5px 0"
|
|
},
|
|
border: false
|
|
})
|
|
} : {
|
|
v: common_vendor.p({
|
|
name: "arrow-right"
|
|
}),
|
|
w: common_vendor.o($options.openStudentList),
|
|
x: common_vendor.p({
|
|
title: `选择学员`,
|
|
icon: "account",
|
|
cellStyle: {
|
|
padding: "5px 0"
|
|
},
|
|
border: false
|
|
})
|
|
}, {
|
|
y: common_vendor.p({
|
|
title: "报名学员",
|
|
border: false,
|
|
["is-shadow"]: false
|
|
}),
|
|
z: common_vendor.f($data.payment, (item, index, i0) => {
|
|
return common_vendor.e({
|
|
a: item.type == $data.payType
|
|
}, item.type == $data.payType ? {
|
|
b: "15db4f87-16-" + i0 + "," + ("15db4f87-15-" + i0),
|
|
c: common_vendor.p({
|
|
size: "30rpx",
|
|
name: "checkbox-mark"
|
|
})
|
|
} : {}, {
|
|
d: common_vendor.o(($event) => $options.onPayType(item.type), index),
|
|
e: "15db4f87-15-" + i0 + ",15db4f87-14",
|
|
f: common_vendor.p({
|
|
title: `${item.name}`,
|
|
icon: `${item.image}`,
|
|
cellStyle: {
|
|
padding: "20rpx 10rpx",
|
|
borderRadius: "8rpx",
|
|
backgroundColor: item.type == $data.payType ? "#f6fff1" : ""
|
|
},
|
|
border: false
|
|
}),
|
|
g: index
|
|
});
|
|
}),
|
|
A: common_vendor.p({
|
|
customStyle: {
|
|
backgroundColor: "#ffffff"
|
|
},
|
|
border: false
|
|
}),
|
|
B: common_vendor.t($data.totalPrice || 0),
|
|
C: common_vendor.o(($event) => _ctx.actionsClick("分享")),
|
|
D: common_vendor.p({
|
|
title: "选择支付方式",
|
|
border: false,
|
|
["is-shadow"]: false
|
|
}),
|
|
E: !$data.disabled
|
|
}, !$data.disabled ? {
|
|
F: common_vendor.o($options.onDisabled),
|
|
G: common_vendor.p({
|
|
type: "circle",
|
|
size: "20",
|
|
color: "#a4a5a7"
|
|
})
|
|
} : {
|
|
H: common_vendor.o($options.onDisabled),
|
|
I: common_vendor.p({
|
|
type: "checkbox",
|
|
size: "20",
|
|
color: "#11a954"
|
|
})
|
|
}, {
|
|
J: common_vendor.o(($event) => $options.navTo("/package/article/detail?articleId=501")),
|
|
K: common_vendor.o(($event) => $options.navTo("/package/article/detail?articleId=502")),
|
|
L: common_vendor.o((...args) => $options.onDisabled && $options.onDisabled(...args)),
|
|
M: common_vendor.p({
|
|
height: "50"
|
|
}),
|
|
N: common_vendor.p({
|
|
startVal: 0,
|
|
decimals: "2",
|
|
duration: "100",
|
|
color: "#ebcf00",
|
|
bold: true,
|
|
endVal: $data.totalPrice
|
|
}),
|
|
O: common_vendor.o($options.save),
|
|
P: common_vendor.p({
|
|
disabled: !$data.disabled || $data.goodsList.length == 0,
|
|
customStyle: {
|
|
background: "linear-gradient(to right, #70b915, #008e04)",
|
|
borderRadius: "0 30px 30px 0",
|
|
color: "#ffffff",
|
|
border: "none",
|
|
padding: "22px 30px"
|
|
},
|
|
text: "提交订单"
|
|
}),
|
|
Q: common_vendor.f($data.studentList, (item, index, i0) => {
|
|
return common_vendor.e({
|
|
a: "15db4f87-26-" + i0 + "," + ("15db4f87-25-" + i0),
|
|
b: common_vendor.p({
|
|
text: item.type,
|
|
fontSize: "12",
|
|
size: "32",
|
|
randomBgColor: true
|
|
}),
|
|
c: common_vendor.t(item.name),
|
|
d: common_vendor.t(item.phone),
|
|
e: item.isDefault
|
|
}, item.isDefault ? {
|
|
f: "15db4f87-27-" + i0 + "," + ("15db4f87-25-" + i0),
|
|
g: common_vendor.p({
|
|
text: "默认",
|
|
size: "mini",
|
|
inverted: true,
|
|
type: "success"
|
|
})
|
|
} : {}, {
|
|
h: "15db4f87-28-" + i0 + "," + ("15db4f87-25-" + i0),
|
|
i: common_vendor.o(($event) => $options.onAddress(item), index),
|
|
j: "15db4f87-25-" + i0 + ",15db4f87-24",
|
|
k: common_vendor.p({
|
|
cellStyle: {
|
|
padding: "10px 0"
|
|
},
|
|
label: item.address
|
|
}),
|
|
l: index
|
|
});
|
|
}),
|
|
R: common_vendor.p({
|
|
type: "right"
|
|
}),
|
|
S: common_vendor.o(($event) => $options.navTo("/package/course/student")),
|
|
T: common_vendor.p({
|
|
customStyle: {
|
|
borderRadius: "30px"
|
|
},
|
|
text: "学员管理"
|
|
}),
|
|
U: common_vendor.p({
|
|
customStyle: {
|
|
backgroundColor: "#ffffff"
|
|
},
|
|
border: false
|
|
}),
|
|
V: common_vendor.p({
|
|
title: "选择学员",
|
|
border: false,
|
|
["is-shadow"]: false,
|
|
padding: 0
|
|
}),
|
|
W: common_vendor.sr("addForm", "15db4f87-22"),
|
|
X: common_vendor.p({
|
|
type: "center",
|
|
["border-radius"]: "10px 10px 0 0"
|
|
}),
|
|
Y: common_vendor.o(($event) => $data.payPassword = $event),
|
|
Z: common_vendor.p({
|
|
mode: "box",
|
|
dot: true,
|
|
space: 0,
|
|
maxlength: 6,
|
|
hairline: true,
|
|
modelValue: $data.payPassword
|
|
}),
|
|
aa: common_vendor.p({
|
|
label: "支付密码",
|
|
name: "payPassword",
|
|
required: true
|
|
}),
|
|
ab: common_vendor.o($options.onPayPassword),
|
|
ac: common_vendor.p({
|
|
customStyle: {
|
|
background: "linear-gradient(to right, #70b915, #008e04)",
|
|
borderRadius: "30px",
|
|
color: "#ffffff"
|
|
},
|
|
text: "确定支付",
|
|
disabled: $data.disabledPayPayPassword
|
|
}),
|
|
ad: common_vendor.sr("form", "15db4f87-32,15db4f87-31"),
|
|
ae: common_vendor.p({
|
|
["label-width"]: 80
|
|
}),
|
|
af: common_vendor.o(($event) => $options.navTo(`/package/user/pay-password`)),
|
|
ag: common_vendor.p({
|
|
title: "请输入支付密码",
|
|
border: false,
|
|
["is-shadow"]: false,
|
|
padding: 0
|
|
}),
|
|
ah: common_vendor.sr("payPasswordForm", "15db4f87-30"),
|
|
ai: common_vendor.p({
|
|
type: "center",
|
|
["border-radius"]: "10px 10px 0 0"
|
|
}),
|
|
aj: common_vendor.sr("login", "15db4f87-36"),
|
|
ak: common_vendor.o($options.reload),
|
|
al: common_vendor.p({
|
|
logo: _ctx.logo
|
|
})
|
|
});
|
|
}
|
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-15db4f87"], ["__file", "/Users/gxwebsoft/APP/gxtyzx-uniapp-cli/src/package/course/checkout.vue"]]);
|
|
wx.createPage(MiniProgramPage);
|