1.18整合
This commit is contained in:
99
unpackage/dist/dev/mp-weixin/pages/login/login.js
vendored
Normal file
99
unpackage/dist/dev/mp-weixin/pages/login/login.js
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../common/vendor.js");
|
||||
const common_assets = require("../../common/assets.js");
|
||||
const request_api = require("../../request/api.js");
|
||||
const _sfc_main = {
|
||||
__name: "login",
|
||||
setup(__props) {
|
||||
const username = common_vendor.ref("");
|
||||
const password = common_vendor.ref("");
|
||||
const showPassword = common_vendor.ref(true);
|
||||
const changePassword = () => {
|
||||
showPassword.value = !showPassword.value;
|
||||
};
|
||||
const handleLogin = async () => {
|
||||
console.log("点击登录按钮");
|
||||
console.log("用户名:", username.value);
|
||||
console.log("密码:", password.value);
|
||||
if (!username.value) {
|
||||
common_vendor.index.showToast({
|
||||
icon: "none",
|
||||
title: "请输入用户名"
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (!password.value) {
|
||||
common_vendor.index.showToast({
|
||||
icon: "none",
|
||||
title: "请输入密码"
|
||||
});
|
||||
return;
|
||||
}
|
||||
try {
|
||||
console.log("开始调用登录接口...");
|
||||
const res = await request_api.login({
|
||||
username: username.value,
|
||||
password: password.value
|
||||
});
|
||||
console.log("登录接口返回:", res);
|
||||
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
|
||||
};
|
||||
common_vendor.index.setStorageSync("userInfo", JSON.stringify(userInfo));
|
||||
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) {
|
||||
console.error("登录失败:", error);
|
||||
common_vendor.index.showToast({
|
||||
title: "网络请求失败",
|
||||
icon: "none"
|
||||
});
|
||||
}
|
||||
};
|
||||
const goToReport = () => {
|
||||
common_vendor.index.navigateTo({
|
||||
url: "/subpackages/suishoupai/pages/index/index"
|
||||
});
|
||||
};
|
||||
return (_ctx, _cache) => {
|
||||
return {
|
||||
a: common_assets._imports_0$3,
|
||||
b: common_assets._imports_0$4,
|
||||
c: username.value,
|
||||
d: common_vendor.o(($event) => username.value = $event.detail.value),
|
||||
e: common_assets._imports_1$2,
|
||||
f: showPassword.value,
|
||||
g: password.value,
|
||||
h: common_vendor.o(($event) => password.value = $event.detail.value),
|
||||
i: showPassword.value ? "/static/index/cl.png" : "/static/index/op.png",
|
||||
j: common_vendor.o(changePassword),
|
||||
k: common_vendor.o(handleLogin),
|
||||
l: common_assets._imports_3$1,
|
||||
m: common_vendor.o(goToReport)
|
||||
};
|
||||
};
|
||||
}
|
||||
};
|
||||
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-e4e4508d"]]);
|
||||
wx.createPage(MiniProgramPage);
|
||||
Reference in New Issue
Block a user