439 lines
14 KiB
JavaScript
439 lines
14 KiB
JavaScript
"use strict";
|
|
const common_vendor = require("../../common/vendor.js");
|
|
const api_shop_userAddress_index = require("../../api/shop/userAddress/index.js");
|
|
require("../../utils/request.js");
|
|
const regionsData = require("../../regions-data.js");
|
|
const utils_common = require("../../utils/common.js");
|
|
const store_modules_user = require("../../store/modules/user.js");
|
|
const store_modules_car = require("../../store/modules/car.js");
|
|
const userStore = store_modules_user.useUserStore();
|
|
const carStore = store_modules_car.useCarStore();
|
|
const _sfc_main = {
|
|
data() {
|
|
return {
|
|
list: [],
|
|
statusBarHeight: 104,
|
|
isLogin: false,
|
|
form: {
|
|
name: "",
|
|
phone: ""
|
|
},
|
|
// 表单数据
|
|
formData: {},
|
|
fields: {},
|
|
logo: "",
|
|
bookingUser: {},
|
|
server: [],
|
|
order: [],
|
|
defaultData: [{
|
|
text: "默认学员",
|
|
value: true
|
|
}],
|
|
typeData: [
|
|
{
|
|
text: "家",
|
|
value: "家"
|
|
},
|
|
{
|
|
text: "公司",
|
|
value: "公司"
|
|
},
|
|
{
|
|
text: "学校",
|
|
value: "学校"
|
|
}
|
|
],
|
|
regions: regionsData.regions,
|
|
dataTree: [
|
|
{
|
|
text: "一年级",
|
|
value: "1-0",
|
|
children: [
|
|
{
|
|
text: "1.1班",
|
|
value: "1-1"
|
|
},
|
|
{
|
|
text: "1.2班",
|
|
value: "1-2"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
text: "二年级",
|
|
value: "2-0",
|
|
children: [
|
|
{
|
|
text: "2.1班",
|
|
value: "2-1"
|
|
},
|
|
{
|
|
text: "2.2班",
|
|
value: "2-2"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
text: "三年级",
|
|
value: "3-0",
|
|
disable: true
|
|
}
|
|
],
|
|
rules: {
|
|
// 对name字段进行必填验证
|
|
name: {
|
|
rules: [{
|
|
required: true,
|
|
errorMessage: "请输入收件人名称"
|
|
}]
|
|
},
|
|
phone: {
|
|
rules: [{
|
|
required: true,
|
|
format: "number",
|
|
errorMessage: "请输入正确的手机号码"
|
|
}]
|
|
},
|
|
address: {
|
|
rules: [{
|
|
required: true,
|
|
errorMessage: "请输入详情地址"
|
|
}]
|
|
},
|
|
region: {
|
|
rules: [{
|
|
required: true,
|
|
errorMessage: "请选择所在地区"
|
|
}, {
|
|
validateFunction: function(rule, value, data, callback) {
|
|
console.log("value: ", value);
|
|
if (value.length < 2) {
|
|
callback("请至少勾选两个兴趣爱好");
|
|
}
|
|
return true;
|
|
}
|
|
}]
|
|
}
|
|
}
|
|
};
|
|
},
|
|
onLoad() {
|
|
this.reload();
|
|
},
|
|
methods: {
|
|
async reload(e) {
|
|
const app = this;
|
|
const userInfo = await userStore.fetchUserInfo();
|
|
if (Object.keys(userInfo).length > 0) {
|
|
app.isLogin = true;
|
|
app.userInfo = userInfo;
|
|
} else {
|
|
app.isLogin = false;
|
|
}
|
|
api_shop_userAddress_index.pageUserAddress({
|
|
userId: userInfo.userId
|
|
}).then((res) => {
|
|
app.list = res.list;
|
|
});
|
|
},
|
|
navTo(item) {
|
|
if (!this.isLogin) {
|
|
this.$refs.login.open("bottom");
|
|
return false;
|
|
}
|
|
utils_common.openUrl(item);
|
|
},
|
|
// 弹出登录提示框
|
|
openLogin() {
|
|
if (!this.isLogin) {
|
|
this.$refs.login.open("bottom");
|
|
return false;
|
|
}
|
|
},
|
|
onType(e) {
|
|
this.formData.type = e.detail.value;
|
|
},
|
|
onIsDefault() {
|
|
this.formData.isDefault = !this.formData.isDefault;
|
|
},
|
|
// 选用该地址
|
|
onAddres(item) {
|
|
carStore.setAddress(item);
|
|
common_vendor.index.navigateBack();
|
|
},
|
|
add() {
|
|
this.formData = {};
|
|
this.$refs.addForm.open("center");
|
|
},
|
|
openEdit(item) {
|
|
this.formData = item;
|
|
this.$refs.addForm.open("center");
|
|
},
|
|
remove(item) {
|
|
const app = this;
|
|
common_vendor.index.showModal({
|
|
title: "确定要删除吗?",
|
|
success(o) {
|
|
if (o.confirm) {
|
|
common_vendor.index.showLoading({
|
|
title: "请求中."
|
|
});
|
|
api_shop_userAddress_index.removeUserAddress(item.id).then((res) => {
|
|
common_vendor.index.showToast({
|
|
title: "操作成功",
|
|
icon: "none"
|
|
});
|
|
app.$refs.addForm.close();
|
|
app.reload();
|
|
});
|
|
app.reload();
|
|
}
|
|
}
|
|
});
|
|
},
|
|
// 触发提交表单
|
|
submit() {
|
|
this.$refs.form.validate().then((res) => {
|
|
const saveOrUpdate = this.formData.id ? api_shop_userAddress_index.updateUserAddress : api_shop_userAddress_index.addUserAddress;
|
|
saveOrUpdate(this.formData).then((message) => {
|
|
common_vendor.index.showToast({
|
|
title: "保存成功",
|
|
icon: "success"
|
|
});
|
|
this.$refs.addForm.close();
|
|
this.reload();
|
|
}).catch((err) => {
|
|
console.log(err);
|
|
});
|
|
console.log("表单数据信息:", res);
|
|
}).catch((err) => {
|
|
console.log("表单错误信息:", err);
|
|
});
|
|
},
|
|
save() {
|
|
api_shop_userAddress_index.addUserAddress(this.form).then((msg) => {
|
|
common_vendor.index.showToast({
|
|
title: msg,
|
|
icon: "none"
|
|
});
|
|
this.$refs.addForm.close();
|
|
this.reload();
|
|
}).catch(() => {
|
|
common_vendor.index.showToast({
|
|
title: "请检查您的网络.",
|
|
icon: "none"
|
|
});
|
|
common_vendor.index.hideLoading();
|
|
this.$refs.addForm.close();
|
|
this.reload();
|
|
});
|
|
}
|
|
}
|
|
};
|
|
if (!Array) {
|
|
const _easycom_uv_avatar2 = common_vendor.resolveComponent("uv-avatar");
|
|
const _easycom_uni_tag2 = common_vendor.resolveComponent("uni-tag");
|
|
const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons");
|
|
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_button2 = common_vendor.resolveComponent("uv-button");
|
|
const _easycom_ws_login2 = common_vendor.resolveComponent("ws-login");
|
|
const _easycom_uv_input2 = common_vendor.resolveComponent("uv-input");
|
|
const _easycom_uni_forms_item2 = common_vendor.resolveComponent("uni-forms-item");
|
|
const _easycom_uni_data_picker2 = common_vendor.resolveComponent("uni-data-picker");
|
|
const _easycom_uni_data_checkbox2 = common_vendor.resolveComponent("uni-data-checkbox");
|
|
const _easycom_uni_forms2 = common_vendor.resolveComponent("uni-forms");
|
|
const _easycom_uni_popup2 = common_vendor.resolveComponent("uni-popup");
|
|
(_easycom_uv_avatar2 + _easycom_uni_tag2 + _easycom_uni_icons2 + _easycom_uv_cell2 + _easycom_uv_cell_group2 + _easycom_uni_card2 + _easycom_uv_button2 + _easycom_ws_login2 + _easycom_uv_input2 + _easycom_uni_forms_item2 + _easycom_uni_data_picker2 + _easycom_uni_data_checkbox2 + _easycom_uni_forms2 + _easycom_uni_popup2)();
|
|
}
|
|
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_icons = () => "../../uni_modules/uni-icons/components/uni-icons/uni-icons.js";
|
|
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_button = () => "../../uni_modules/uv-button/components/uv-button/uv-button.js";
|
|
const _easycom_ws_login = () => "../../uni_modules/ws-login/components/ws-login/ws-login.js";
|
|
const _easycom_uv_input = () => "../../uni_modules/uv-input/components/uv-input/uv-input.js";
|
|
const _easycom_uni_forms_item = () => "../../uni_modules/uni-forms/components/uni-forms-item/uni-forms-item.js";
|
|
const _easycom_uni_data_picker = () => "../../uni_modules/uni-data-picker/components/uni-data-picker/uni-data-picker.js";
|
|
const _easycom_uni_data_checkbox = () => "../../uni_modules/uni-data-checkbox/components/uni-data-checkbox/uni-data-checkbox.js";
|
|
const _easycom_uni_forms = () => "../../uni_modules/uni-forms/components/uni-forms/uni-forms.js";
|
|
const _easycom_uni_popup = () => "../../uni_modules/uni-popup/components/uni-popup/uni-popup.js";
|
|
if (!Math) {
|
|
(_easycom_uv_avatar + _easycom_uni_tag + _easycom_uni_icons + _easycom_uv_cell + _easycom_uv_cell_group + _easycom_uni_card + _easycom_uv_button + _easycom_ws_login + _easycom_uv_input + _easycom_uni_forms_item + _easycom_uni_data_picker + _easycom_uni_data_checkbox + _easycom_uni_forms + _easycom_uni_popup)();
|
|
}
|
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
return common_vendor.e({
|
|
a: common_vendor.f($data.list, (item, index, i0) => {
|
|
return common_vendor.e({
|
|
a: "0e16bb55-3-" + i0 + "," + ("0e16bb55-2-" + 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: "0e16bb55-4-" + i0 + "," + ("0e16bb55-2-" + i0),
|
|
g: common_vendor.p({
|
|
text: "默认",
|
|
size: "mini",
|
|
inverted: true,
|
|
type: "success"
|
|
})
|
|
} : {}, {
|
|
h: common_vendor.o(($event) => $options.openEdit(item), index),
|
|
i: "0e16bb55-5-" + i0 + "," + ("0e16bb55-2-" + i0),
|
|
j: "0e16bb55-2-" + i0 + ",0e16bb55-1",
|
|
k: index
|
|
});
|
|
}),
|
|
b: common_vendor.p({
|
|
type: "compose",
|
|
size: "18"
|
|
}),
|
|
c: common_vendor.p({
|
|
cellStyle: {
|
|
padding: "10px 0"
|
|
}
|
|
}),
|
|
d: common_vendor.p({
|
|
customStyle: {
|
|
backgroundColor: "#ffffff"
|
|
},
|
|
border: false
|
|
}),
|
|
e: common_vendor.p({
|
|
border: false,
|
|
["is-shadow"]: false,
|
|
padding: 0
|
|
}),
|
|
f: common_vendor.o($options.add),
|
|
g: common_vendor.p({
|
|
customStyle: {
|
|
background: "linear-gradient(to right, #70b915, #008e04)",
|
|
borderRadius: "30px",
|
|
color: "#ffffff"
|
|
},
|
|
text: "添加学员"
|
|
}),
|
|
h: common_vendor.sr("login", "0e16bb55-7"),
|
|
i: common_vendor.o($options.reload),
|
|
j: common_vendor.p({
|
|
logo: $data.logo
|
|
}),
|
|
k: common_vendor.o(($event) => $data.formData.name = $event),
|
|
l: common_vendor.p({
|
|
placeholder: "收件人姓名",
|
|
maxlength: "5",
|
|
modelValue: $data.formData.name
|
|
}),
|
|
m: common_vendor.p({
|
|
label: "收件人",
|
|
name: "name",
|
|
required: true
|
|
}),
|
|
n: common_vendor.o(($event) => $data.formData.phone = $event),
|
|
o: common_vendor.p({
|
|
placeholder: "收件人手机号码",
|
|
maxlength: "11",
|
|
modelValue: $data.formData.phone
|
|
}),
|
|
p: common_vendor.p({
|
|
label: "手机号码",
|
|
name: "phone",
|
|
required: true
|
|
}),
|
|
q: common_vendor.o(_ctx.onchange),
|
|
r: common_vendor.o(_ctx.onnodeclick),
|
|
s: common_vendor.o(_ctx.onpopupopened),
|
|
t: common_vendor.o(_ctx.onpopupclosed),
|
|
v: common_vendor.o(($event) => $data.formData.region = $event),
|
|
w: common_vendor.p({
|
|
placeholder: "省、市、区、街道",
|
|
["popup-title"]: "请选择所在地区",
|
|
localdata: $data.regions,
|
|
map: {
|
|
text: "label",
|
|
value: "value"
|
|
},
|
|
modelValue: $data.formData.region
|
|
}),
|
|
x: common_vendor.p({
|
|
label: "所在地区",
|
|
name: "region",
|
|
required: true
|
|
}),
|
|
y: common_vendor.o(($event) => $data.formData.address = $event),
|
|
z: common_vendor.p({
|
|
placeholder: "小区、写字楼、门牌号等",
|
|
modelValue: $data.formData.address
|
|
}),
|
|
A: common_vendor.p({
|
|
label: "详细地址",
|
|
name: "address",
|
|
required: true
|
|
}),
|
|
B: common_vendor.o($options.onType),
|
|
C: common_vendor.o(($event) => $data.formData.type = $event),
|
|
D: common_vendor.p({
|
|
mode: "tag",
|
|
localdata: $data.typeData,
|
|
modelValue: $data.formData.type
|
|
}),
|
|
E: common_vendor.p({
|
|
label: "标签",
|
|
name: "type"
|
|
}),
|
|
F: common_vendor.o($options.onIsDefault),
|
|
G: common_vendor.o(($event) => $data.formData.isDefault = $event),
|
|
H: common_vendor.p({
|
|
localdata: $data.defaultData,
|
|
modelValue: $data.formData.isDefault
|
|
}),
|
|
I: $data.formData.id
|
|
}, $data.formData.id ? {
|
|
J: common_vendor.p({
|
|
type: "trash"
|
|
}),
|
|
K: common_vendor.o(($event) => $options.remove($data.formData))
|
|
} : {}, {
|
|
L: common_vendor.p({
|
|
name: "isDefault"
|
|
}),
|
|
M: common_vendor.o($options.submit),
|
|
N: common_vendor.p({
|
|
customStyle: {
|
|
background: "linear-gradient(to right, #70b915, #008e04)",
|
|
borderRadius: "30px",
|
|
color: "#ffffff"
|
|
},
|
|
text: "保存"
|
|
}),
|
|
O: common_vendor.sr("form", "0e16bb55-10,0e16bb55-9"),
|
|
P: common_vendor.p({
|
|
modelValue: $data.formData,
|
|
rules: $data.rules,
|
|
["label-width"]: 80
|
|
}),
|
|
Q: common_vendor.p({
|
|
title: "添加学员",
|
|
border: false,
|
|
["is-shadow"]: false,
|
|
padding: "10px 6px"
|
|
}),
|
|
R: common_vendor.sr("addForm", "0e16bb55-8"),
|
|
S: common_vendor.p({
|
|
type: "center",
|
|
["border-radius"]: "10px 10px 0 0"
|
|
})
|
|
});
|
|
}
|
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "/Users/gxwebsoft/APP/gxtyzx-uniapp-cli/src/package/course/student.vue"]]);
|
|
wx.createPage(MiniProgramPage);
|