Files
threeonecheck_web/unpackage/dist/dev/mp-weixin/pages/login/login.js

160 lines
5.6 KiB
JavaScript

"use strict";
const common_vendor = require("../../common/vendor.js");
const common_assets = require("../../common/assets.js");
const request_api = require("../../request/api.js");
if (!Array) {
const _easycom_u_icon2 = common_vendor.resolveComponent("u-icon");
_easycom_u_icon2();
}
const _easycom_u_icon = () => "../../uni_modules/uview-plus/components/u-icon/u-icon.js";
if (!Math) {
_easycom_u_icon();
}
const _sfc_main = {
__name: "login",
setup(__props) {
const statusBarHeight = common_vendor.index.getSystemInfoSync().statusBarHeight || 0;
const SUPERVISION_MINI_PROGRAM = {
appId: "wxe3533791db8a8734",
path: "pages/index/index",
// develop=开发版 trial=体验版 release=正式版
envVersion: "release"
};
const roleList = [
{ id: "enterprise", name: "企业", icon: "home-fill" },
{ id: "personal", name: "个人", icon: "account-fill" },
{ id: "supervision", name: "督导组", icon: "man-add-fill" },
{ id: "government", name: "政务", icon: "order" }
// { id: 'family', name: '家庭', icon: 'home' }
];
const selectedRole = common_vendor.ref("enterprise");
const username = common_vendor.ref("");
const password = common_vendor.ref("");
const showPassword = common_vendor.ref(true);
const selectRole = (roleId) => {
if (roleId === "supervision") {
navigateToSupervisionMiniProgram();
return;
}
selectedRole.value = roleId;
};
const navigateToSupervisionMiniProgram = () => {
common_vendor.index.navigateToMiniProgram({
appId: SUPERVISION_MINI_PROGRAM.appId,
path: SUPERVISION_MINI_PROGRAM.path,
extraData: {
from: "threeonecheck",
role: "supervision"
},
envVersion: SUPERVISION_MINI_PROGRAM.envVersion,
success() {
common_vendor.index.__f__("log", "at pages/login/login.vue:103", "跳转督导组小程序成功");
},
fail(err) {
common_vendor.index.__f__("error", "at pages/login/login.vue:106", "跳转督导组小程序失败:", err);
common_vendor.index.showModal({
title: "跳转失败",
content: "请确认两个小程序已关联,且目标小程序已添加您为开发者。开发阶段可在微信开发者工具中测试。",
showCancel: false
});
}
});
};
const changePassword = () => {
showPassword.value = !showPassword.value;
};
const handleLogin = async () => {
if (!username.value) {
common_vendor.index.showToast({
icon: "none",
title: "请输入用户名"
});
return;
}
if (!password.value) {
common_vendor.index.showToast({
icon: "none",
title: "请输入密码"
});
return;
}
try {
const res = await request_api.login({
username: username.value,
password: password.value
});
if (res.code === 0) {
if (res.data.token) {
common_vendor.index.setStorageSync("token", res.data.token);
}
const userInfo = {
userId: res.data.userId,
username: res.data.username,
nickName: res.data.nickName,
deptId: res.data.deptId,
deptName: res.data.deptName,
role: res.data.role,
isDept: res.data.isDept
};
common_vendor.index.setStorageSync("userInfo", JSON.stringify(userInfo));
common_vendor.index.setStorageSync("loginRole", selectedRole.value);
common_vendor.index.showToast({
title: "登录成功",
icon: "success"
});
setTimeout(() => {
common_vendor.index.reLaunch({
url: "/pages/index/index"
});
}, 1500);
} else {
common_vendor.index.showToast({
title: res.msg || "登录失败",
icon: "none"
});
}
} catch (error) {
common_vendor.index.__f__("error", "at pages/login/login.vue:185", "登录失败:", error);
common_vendor.index.showToast({
title: "网络请求失败",
icon: "none"
});
}
};
return (_ctx, _cache) => {
return {
a: common_vendor.unref(statusBarHeight) + "px",
b: common_assets._imports_0$6,
c: common_vendor.f(roleList, (item, k0, i0) => {
return {
a: "e4e4508d-0-" + i0,
b: common_vendor.p({
name: item.icon,
size: 22,
color: selectedRole.value === item.id ? "#ffffff" : "#b0b8c8"
}),
c: common_vendor.t(item.name),
d: item.id,
e: selectedRole.value === item.id ? 1 : "",
f: common_vendor.o(($event) => selectRole(item.id), item.id)
};
}),
d: common_assets._imports_0$7,
e: username.value,
f: common_vendor.o(($event) => username.value = $event.detail.value),
g: common_assets._imports_1$4,
h: showPassword.value,
i: password.value,
j: common_vendor.o(($event) => password.value = $event.detail.value),
k: showPassword.value ? "/static/index/cl.png" : "/static/index/op.png",
l: common_vendor.o(changePassword),
m: common_vendor.o(handleLogin),
n: common_vendor.gei(_ctx, "")
};
};
}
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-e4e4508d"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/login/login.js.map