82 lines
2.8 KiB
JavaScript
82 lines
2.8 KiB
JavaScript
"use strict";
|
|
const common_vendor = require("../../common/vendor.js");
|
|
const api_index = require("../../api/index.js");
|
|
if (!Array) {
|
|
const _easycom_nut_input2 = common_vendor.resolveComponent("nut-input");
|
|
const _easycom_nut_button2 = common_vendor.resolveComponent("nut-button");
|
|
(_easycom_nut_input2 + _easycom_nut_button2)();
|
|
}
|
|
const _easycom_nut_input = () => "../../uni_modules/nutui-uni/components/input/input.js";
|
|
const _easycom_nut_button = () => "../../uni_modules/nutui-uni/components/button/button.js";
|
|
if (!Math) {
|
|
(_easycom_nut_input + _easycom_nut_button)();
|
|
}
|
|
const _sfc_main = {
|
|
__name: "index",
|
|
setup(__props) {
|
|
const username = common_vendor.ref("");
|
|
const password = common_vendor.ref("");
|
|
const handleLogin = () => {
|
|
if (username.value === "") {
|
|
common_vendor.index.showToast({
|
|
title: "请输入用户名",
|
|
icon: "none"
|
|
});
|
|
return;
|
|
}
|
|
if (password.value === "") {
|
|
common_vendor.index.showToast({
|
|
title: "请输入密码",
|
|
icon: "none"
|
|
});
|
|
return;
|
|
}
|
|
api_index.fetchLogin({
|
|
user_name: username.value,
|
|
password: password.value
|
|
}).then((res) => {
|
|
common_vendor.index.__f__("log", "at pages/login/index.vue:68", res);
|
|
common_vendor.index.setStorageSync("token", res.token);
|
|
common_vendor.index.setStorageSync("uid", res.user.user_id);
|
|
common_vendor.index.setStorageSync("user_name", res.user.user_name);
|
|
common_vendor.index.setStorageSync("role", res.user.role.value);
|
|
common_vendor.index.setStorageSync("staff_name", res.user.staff_name);
|
|
common_vendor.index.showToast({
|
|
title: "登录成功",
|
|
icon: "success"
|
|
});
|
|
common_vendor.index.switchTab({
|
|
url: "/pages/index/index"
|
|
});
|
|
});
|
|
};
|
|
return (_ctx, _cache) => {
|
|
return {
|
|
a: common_vendor.o(($event) => username.value = $event),
|
|
b: common_vendor.p({
|
|
placeholder: "请输入用户名",
|
|
clearable: true,
|
|
label: "用户名",
|
|
modelValue: username.value
|
|
}),
|
|
c: common_vendor.o(($event) => password.value = $event),
|
|
d: common_vendor.p({
|
|
placeholder: "请输入密码",
|
|
clearable: true,
|
|
label: "密码",
|
|
type: "password",
|
|
modelValue: password.value
|
|
}),
|
|
e: common_vendor.o(handleLogin),
|
|
f: common_vendor.p({
|
|
type: "primary",
|
|
block: true
|
|
})
|
|
};
|
|
};
|
|
}
|
|
};
|
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-d08ef7d4"]]);
|
|
wx.createPage(MiniProgramPage);
|
|
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/login/index.js.map
|