上传代码
This commit is contained in:
278
distribution/unpackage/dist/dev/mp-alipay/pages/register/register.js
vendored
Normal file
278
distribution/unpackage/dist/dev/mp-alipay/pages/register/register.js
vendored
Normal file
@ -0,0 +1,278 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../common/vendor.js");
|
||||
const API_api = require("../../API/api.js");
|
||||
const _sfc_main = {
|
||||
data() {
|
||||
return {
|
||||
formData: {
|
||||
checkPassword: "",
|
||||
distributionScope: "",
|
||||
errandName: "",
|
||||
errandPhone: "",
|
||||
gender: "",
|
||||
userAccount: "",
|
||||
userPassword: ""
|
||||
},
|
||||
range: [
|
||||
{
|
||||
value: "1公寓",
|
||||
text: "1公寓"
|
||||
},
|
||||
{
|
||||
value: "2公寓",
|
||||
text: "2公寓"
|
||||
},
|
||||
{
|
||||
value: "3公寓",
|
||||
text: "3公寓"
|
||||
},
|
||||
{
|
||||
value: "4公寓",
|
||||
text: "4公寓"
|
||||
},
|
||||
{
|
||||
value: "5公寓",
|
||||
text: "5公寓"
|
||||
},
|
||||
{
|
||||
value: "6公寓",
|
||||
text: "6公寓"
|
||||
},
|
||||
{
|
||||
value: "7公寓",
|
||||
text: "7公寓"
|
||||
},
|
||||
{
|
||||
value: "8公寓",
|
||||
text: "8公寓"
|
||||
},
|
||||
{
|
||||
value: "9公寓",
|
||||
text: "9公寓"
|
||||
},
|
||||
{
|
||||
value: "10公寓",
|
||||
text: "10公寓"
|
||||
},
|
||||
{
|
||||
value: "11公寓",
|
||||
text: "11公寓"
|
||||
},
|
||||
{
|
||||
value: "12公寓",
|
||||
text: "12公寓"
|
||||
},
|
||||
{
|
||||
value: "育才大厦",
|
||||
text: "育才大厦"
|
||||
}
|
||||
],
|
||||
fields: [
|
||||
{
|
||||
label: "账户",
|
||||
model: "userAccount",
|
||||
placeholder: "请输入账户"
|
||||
},
|
||||
{
|
||||
label: "密码",
|
||||
model: "userPassword",
|
||||
placeholder: "请输入密码"
|
||||
},
|
||||
{
|
||||
label: "确认密码",
|
||||
model: "checkPassword",
|
||||
placeholder: "请再次输入密码"
|
||||
},
|
||||
{
|
||||
label: "用户名称",
|
||||
model: "errandName",
|
||||
placeholder: "请输入用户名称"
|
||||
},
|
||||
{
|
||||
label: "手机号",
|
||||
model: "errandPhone",
|
||||
placeholder: "请输入手机号"
|
||||
},
|
||||
{
|
||||
label: "性别",
|
||||
model: "gender",
|
||||
placeholder: "请选择性别"
|
||||
},
|
||||
{
|
||||
label: "配送范围",
|
||||
model: "distributionScope",
|
||||
placeholder: "请选择配送范围"
|
||||
}
|
||||
]
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
handleGenderChange(e) {
|
||||
this.formData.gender = e.detail.value === "男" ? 0 : 1;
|
||||
},
|
||||
saveAddress() {
|
||||
if (!this.validateForm()) {
|
||||
return;
|
||||
}
|
||||
const url = API_api.apiImageUrl + "/api/errand/add";
|
||||
const data = {
|
||||
checkPassword: this.formData.checkPassword,
|
||||
distributionScope: this.formData.distributionScope,
|
||||
errandName: this.formData.errandName,
|
||||
errandPhone: this.formData.errandPhone,
|
||||
gender: this.formData.gender,
|
||||
userAccount: this.formData.userAccount,
|
||||
userPassword: this.formData.userPassword
|
||||
};
|
||||
common_vendor.index.request({
|
||||
url,
|
||||
method: "POST",
|
||||
data,
|
||||
header: {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
success(res) {
|
||||
console.log(res.data);
|
||||
if (res.data.code === 0) {
|
||||
common_vendor.index.showToast({
|
||||
title: "注册成功!",
|
||||
duration: 2e3,
|
||||
icon: "success"
|
||||
});
|
||||
common_vendor.index.reLaunch({
|
||||
url: "/pages/login/login"
|
||||
});
|
||||
} else if (res.data.code === 4e4) {
|
||||
common_vendor.index.showToast({
|
||||
title: res.data.description,
|
||||
duration: 2e3,
|
||||
icon: "fail"
|
||||
});
|
||||
}
|
||||
},
|
||||
fail(err) {
|
||||
console.error(err);
|
||||
common_vendor.index.showModal({
|
||||
title: "注册失败",
|
||||
//提示标题
|
||||
content: "请重新输入"
|
||||
//提示内容
|
||||
//showCancel: true, //是否显示取消按钮
|
||||
// success: function (res) {
|
||||
// if (res.confirm) { //confirm为ture,代表用户点击确定
|
||||
// console.log('点击了确定按钮');
|
||||
// } else if (res.cancel) { //cancel为ture,代表用户点击取消
|
||||
// console.log('点击了取消按钮');
|
||||
// }
|
||||
// }
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
validateForm() {
|
||||
if (!this.formData.userAccount) {
|
||||
common_vendor.index.showToast({
|
||||
title: "请输入账户",
|
||||
icon: "none"
|
||||
});
|
||||
return false;
|
||||
}
|
||||
if (!this.formData.userPassword) {
|
||||
common_vendor.index.showToast({
|
||||
title: "请输入密码",
|
||||
icon: "none"
|
||||
});
|
||||
return false;
|
||||
}
|
||||
if (this.formData.userPassword.length < 8) {
|
||||
common_vendor.index.showToast({
|
||||
title: "密码过短,至少8位",
|
||||
icon: "none"
|
||||
});
|
||||
return false;
|
||||
}
|
||||
if (!this.formData.checkPassword) {
|
||||
common_vendor.index.showToast({
|
||||
title: "请输入确认密码",
|
||||
icon: "none"
|
||||
});
|
||||
return false;
|
||||
}
|
||||
if (this.formData.userPassword !== this.formData.checkPassword) {
|
||||
common_vendor.index.showToast({
|
||||
title: "两次密码不一致",
|
||||
icon: "none"
|
||||
});
|
||||
return false;
|
||||
}
|
||||
if (!this.formData.errandName) {
|
||||
common_vendor.index.showToast({
|
||||
title: "请输入用户名称",
|
||||
icon: "none"
|
||||
});
|
||||
return false;
|
||||
}
|
||||
if (!this.formData.errandPhone) {
|
||||
common_vendor.index.showToast({
|
||||
title: "请输入手机号",
|
||||
icon: "none"
|
||||
});
|
||||
return false;
|
||||
}
|
||||
if (!this.formData.gender) {
|
||||
common_vendor.index.showToast({
|
||||
title: "请选择性别",
|
||||
icon: "none"
|
||||
});
|
||||
return false;
|
||||
}
|
||||
if (!this.formData.distributionScope) {
|
||||
common_vendor.index.showToast({
|
||||
title: "请选择配送范围",
|
||||
icon: "none"
|
||||
});
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
};
|
||||
if (!Array) {
|
||||
const _easycom_uni_data_select2 = common_vendor.resolveComponent("uni-data-select");
|
||||
_easycom_uni_data_select2();
|
||||
}
|
||||
const _easycom_uni_data_select = () => "../../uni_modules/uni-data-select/components/uni-data-select/uni-data-select.js";
|
||||
if (!Math) {
|
||||
_easycom_uni_data_select();
|
||||
}
|
||||
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||||
return {
|
||||
a: common_vendor.f($data.fields, (field, index, i0) => {
|
||||
return common_vendor.e({
|
||||
a: common_vendor.t(field.label),
|
||||
b: field.model === "gender"
|
||||
}, field.model === "gender" ? {
|
||||
c: $data.formData.gender,
|
||||
d: common_vendor.o((...args) => $options.handleGenderChange && $options.handleGenderChange(...args))
|
||||
} : field.model === "distributionScope" ? {
|
||||
f: "bac4a35d-0-" + i0,
|
||||
g: common_vendor.o(($event) => $data.formData.distributionScope = $event),
|
||||
h: common_vendor.p({
|
||||
localdata: $data.range,
|
||||
clear: false,
|
||||
modelValue: $data.formData.distributionScope
|
||||
})
|
||||
} : {
|
||||
i: field.placeholder,
|
||||
j: $data.formData[field.model],
|
||||
k: common_vendor.o(($event) => $data.formData[field.model] = $event.detail.value)
|
||||
}, {
|
||||
e: field.model === "distributionScope",
|
||||
l: index
|
||||
});
|
||||
}),
|
||||
b: common_vendor.o((...args) => $options.saveAddress && $options.saveAddress(...args))
|
||||
};
|
||||
}
|
||||
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-bac4a35d"]]);
|
||||
my.createPage(MiniProgramPage);
|
Reference in New Issue
Block a user