ts_aimz_uni/unpackage/dist/dev/mp-baidu/pages/login/login.js

358 lines
12 KiB
JavaScript
Raw Normal View History

2025-05-28 16:22:03 +08:00
"use strict";
const common_vendor = require("../../common/vendor.js");
const common_js_net_UserApi = require("../../common/js/net/UserApi.js");
const common_js_cache_storage = require("../../common/js/cache/storage.js");
const common_js_validator = require("../../common/js/validator.js");
const common_assets = require("../../common/assets.js");
const _sfc_main = {
data() {
return {
isActive: true,
verifyBtnTxt: "获取验证码",
phoneNumber: "",
//手机号
verifyCode: "",
//验证码
msgType: "error",
msgHint: "",
countNumber: 120,
isVerifyActive: false,
timer: null,
isRememberPhone: false,
contactPhone: "",
contactName: "",
contactEmail: "",
contactCompany: "",
csaNo: ""
};
},
onLoad() {
this.isRememberPhone = common_js_cache_storage.get("isRemember", false);
this.phoneNumber = common_js_cache_storage.get("loginPhone", "");
},
onUnload() {
2025-05-30 17:38:28 +08:00
common_vendor.index.__f__("log", "at pages/login/login.vue:131", "页面卸载");
2025-05-28 16:22:03 +08:00
if (this.timer != null) {
clearInterval(this.timer);
}
},
methods: {
closeDialog() {
2025-05-30 17:38:28 +08:00
common_vendor.index.showModal({
title: "警告",
content: "如不创建联系人,将无法使用本程序,您确定要关闭吗?",
success: (res) => {
if (res.confirm) {
this.$refs.contactDialog.close();
}
}
});
2025-05-28 16:22:03 +08:00
},
inputPhone(e) {
this.phoneNumber = e.detail.value;
if (this.timer != null) {
clearInterval(this.timer);
this.timer = null;
this.verifyBtnTxt = "获取验证码";
this.isVerifyActive = false;
this.countNumber = 120;
}
},
inputVerifyCode(e) {
this.verifyCode = e.detail.value;
},
inputContactName(e) {
this.contactName = e.detail.value;
},
inputContactPhone(e) {
this.contactPhone = e.detail.value;
},
inputContactCompany(e) {
this.contactCompany = e.detail.value;
},
inputContactEmail(e) {
this.contactEmail = e.detail.value;
},
rememberPhone(e) {
this.isRememberPhone = !this.isRememberPhone;
},
//是否勾选服务协议
changeAgree(e) {
this.isActive = !this.isActive;
},
getVerifyCode() {
if (this.isVerifyActive) {
return;
}
const _self = this;
if (_self.phoneNumber == "" || !common_js_validator.isMobilePhone(_self.phoneNumber)) {
_self.msgHint = "请输入有效的手机号码";
_self.msgType = "error";
_self.$refs.msg.open();
return;
}
common_vendor.index.showLoading({
title: "获取中..."
});
common_js_net_UserApi.UserApi.doGetVerifyCode(_self.phoneNumber).then((res) => {
common_vendor.index.hideLoading();
_self.msgHint = "获取成功";
_self.msgType = "success";
_self.$refs.msg.open();
_self.timer = setInterval(_self.startCountDown, 1e3);
2025-05-30 17:38:28 +08:00
common_vendor.index.__f__("log", "at pages/login/login.vue:202", res);
2025-05-28 16:22:03 +08:00
}).catch((err) => {
2025-05-30 17:38:28 +08:00
common_vendor.index.__f__("log", "at pages/login/login.vue:205", err);
2025-05-28 16:22:03 +08:00
common_vendor.index.hideLoading();
_self.msgHint = err.msg ? err.msg : "获取验证码失败,请稍后重试";
_self.msgType = "error";
_self.$refs.msg.open();
});
},
startCountDown() {
const _self = this;
if (_self.countNumber <= 0) {
_self.verifyBtnTxt = "获取验证码";
_self.isVerifyActive = false;
if (_self.timer != null) {
clearInterval(_self.timer);
_self.timer = null;
}
_self.countNumber = 20;
return;
}
_self.isVerifyActive = true;
_self.verifyBtnTxt = `重新发送(${_self.countNumber}s)`;
_self.countNumber = --_self.countNumber;
},
//用户服务协议
showServiceDeal() {
common_vendor.index.navigateTo({
url: "/pages/common/rule/rule?id=68eee8f5-33d3-4246-aeee-a33956677101"
});
},
//隐私条款
showPrivacyDeal() {
common_vendor.index.navigateTo({
url: "/pages/common/rule/rule?id=93679af4-e264-4d1c-bd49-538028daa95d"
});
},
//创建联系人
showCreateContactDialog() {
this.contactPhone = this.phoneNumber;
this.$refs.contactDialog.open();
},
doLogin() {
2025-05-30 17:38:28 +08:00
const _self = this;
if (_self.phoneNumber == "" || !common_js_validator.isMobilePhone(_self.phoneNumber)) {
_self.msgHint = "请输入正确的手机号码";
_self.msgType = "error";
_self.$refs.msg.open();
return;
}
if (_self.verifyCode == "") {
_self.msgHint = "请输入验证码";
_self.msgType = "error";
_self.$refs.msg.open();
return;
}
if (_self.isActive) {
_self.msgHint = "请勾选阅读与同意用户服务协议与隐私条款";
_self.msgType = "error";
_self.$refs.msg.open();
return;
}
common_vendor.index.showLoading({
title: "登录中..."
});
const data = {
phone: _self.phoneNumber,
verifyCode: _self.verifyCode
};
common_js_cache_storage.set("isRemember", this.isRememberPhone);
common_js_cache_storage.set("loginPhone", this.isRememberPhone ? this.phoneNumber : "");
common_js_net_UserApi.UserApi.doLoginVerifyCode(data).then((res) => {
common_vendor.index.hideLoading();
if (res.data && res.data != "") {
common_js_cache_storage.set("token", res.data);
_self.doGetMineContactList();
} else {
_self.msgHint = "登录失败,请稍后重试";
_self.msgType = "error";
_self.$refs.msg.open();
}
}).catch((err) => {
common_vendor.index.hideLoading();
common_vendor.index.__f__("log", "at pages/login/login.vue:291", err);
self.msgHint = err.msg ? err.msg : "登录失败,请稍后重试";
_self.msgType = "error";
_self.$refs.msg.open();
2025-05-28 16:22:03 +08:00
});
},
2025-05-30 17:38:28 +08:00
//判断是否创建过联系人
2025-05-28 16:22:03 +08:00
doGetMineContactList() {
common_vendor.index.showLoading({
title: "登录中..."
});
const data = {
page: 1,
rows: 2
};
const _self = this;
common_js_net_UserApi.UserApi.doGetMineContactList(data).then((res) => {
common_vendor.index.hideLoading();
if (res.rows && res.rows.length <= 0) {
_self.doGetCsaNo();
} else {
common_vendor.index.switchTab({
url: "/pages/index/home"
});
}
}).catch((err) => {
common_vendor.index.hideLoading();
_self.msgHint = "登录失败,请稍后重试";
_self.msgType = "error";
_self.$refs.msg.open();
});
},
//获取客服id
doGetCsaNo() {
const _self = this;
common_vendor.index.showLoading({
title: "加载中..."
});
common_js_net_UserApi.UserApi.doGetCsaNo().then((res) => {
common_vendor.index.hideLoading();
if (res.csaNo && res.csaNo != "") {
_self.csaNo = res.csaNo;
_self.showCreateContactDialog();
} else {
_self.msgHint = "登录失败,请稍后重试";
_self.msgType = "error";
_self.$refs.msg.open();
}
}).catch((err) => {
common_vendor.index.hideLoading();
_self.msgHint = "登录失败,请稍后重试";
_self.msgType = "error";
_self.$refs.msg.open();
});
},
checkParams() {
if (this.contactName == "") {
this.msgHint = "请输入联系人姓名";
this.msgType = "error";
this.$refs.msg.open();
return false;
}
if (this.contactPhone == "" || !common_js_validator.isMobilePhone(this.contactPhone)) {
this.msgHint = "请输入正确的联系电话";
this.msgType = "error";
this.$refs.msg.open();
return false;
}
return true;
},
//去创建联系人
doCreateContact() {
const isLegal = this.checkParams();
if (isLegal) {
common_vendor.index.showLoading({
title: "创建中..."
});
const _self = this;
const userInfo = {
userInfoName: _self.contactName != "" ? _self.contactName : "新用户",
contactPhone: _self.contactPhone,
idCardType: "ID_CARD",
userInfoType: "PERSONAL"
};
const contactData = {
company: _self.contactCompany,
csaNo: _self.csaNo,
email: _self.contactEmail,
name: _self.contactName,
phone: _self.contactPhone
};
const user = common_js_net_UserApi.UserApi.doUpdateUserInfo(userInfo);
const contact = common_js_net_UserApi.UserApi.doCreateContact(contactData);
const list = [user, contact];
Promise.all(list).then((res) => {
common_vendor.index.hideLoading();
_self.msgHint = "创建成功";
_self.msgType = "success";
_self.$refs.msg.open();
setTimeout(() => {
common_vendor.index.switchTab({
url: "/pages/index/home"
});
}, 1500);
}).catch((err) => {
common_vendor.index.hideLoading();
_self.msgHint = "创建失败,请稍后重试";
_self.msgType = "error";
_self.$refs.msg.open();
});
}
}
}
};
if (!Array) {
const _easycom_uni_popup2 = common_vendor.resolveComponent("uni-popup");
const _easycom_uni_popup_message2 = common_vendor.resolveComponent("uni-popup-message");
(_easycom_uni_popup2 + _easycom_uni_popup_message2)();
}
const _easycom_uni_popup = () => "../../uni_modules/uni-popup/components/uni-popup/uni-popup.js";
const _easycom_uni_popup_message = () => "../../uni_modules/uni-popup/components/uni-popup-message/uni-popup-message.js";
if (!Math) {
(_easycom_uni_popup + _easycom_uni_popup_message)();
}
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return {
a: common_assets._imports_0,
b: $data.phoneNumber,
c: common_vendor.o((...args) => $options.inputPhone && $options.inputPhone(...args)),
d: $data.verifyCode,
e: common_vendor.o((...args) => $options.inputVerifyCode && $options.inputVerifyCode(...args)),
f: common_vendor.t($data.verifyBtnTxt),
g: common_vendor.n($data.isVerifyActive ? "verify-btn-disable" : "verify-btn"),
h: common_vendor.o((...args) => $options.getVerifyCode && $options.getVerifyCode(...args)),
i: $data.isRememberPhone,
j: common_vendor.o((...args) => $options.rememberPhone && $options.rememberPhone(...args)),
k: common_vendor.o((...args) => $options.changeAgree && $options.changeAgree(...args)),
l: common_vendor.o((...args) => $options.showServiceDeal && $options.showServiceDeal(...args)),
m: common_vendor.o((...args) => $options.showPrivacyDeal && $options.showPrivacyDeal(...args)),
n: common_vendor.o((...args) => $options.doLogin && $options.doLogin(...args)),
o: common_vendor.n($data.isActive ? "btn-login-disable" : "btn-login"),
p: common_vendor.o((...args) => $options.closeDialog && $options.closeDialog(...args)),
q: $data.contactName,
r: common_vendor.o((...args) => $options.inputContactName && $options.inputContactName(...args)),
s: $data.contactPhone,
t: common_vendor.o((...args) => $options.inputContactPhone && $options.inputContactPhone(...args)),
v: $data.contactEmail,
w: common_vendor.o((...args) => $options.inputContactEmail && $options.inputContactEmail(...args)),
x: $data.contactCompany,
y: common_vendor.o((...args) => $options.inputContactCompany && $options.inputContactCompany(...args)),
z: common_vendor.o((...args) => $options.doCreateContact && $options.doCreateContact(...args)),
A: common_vendor.sr("contactDialog", "18f427ba-0"),
B: common_vendor.p({
["is-mask-click"]: false,
type: "bottom",
["background-color"]: "#fff",
["border-radius"]: "15rpx 15rpx 0rpx 0rpx"
}),
C: common_vendor.p({
type: $data.msgType,
message: $data.msgHint,
duration: 2e3
}),
D: common_vendor.sr("msg", "18f427ba-1"),
E: common_vendor.p({
type: "message"
})
};
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
swan.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-baidu/pages/login/login.js.map