货无忧
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

212 lines
7.9 KiB

"use strict";
const common_vendor = require("../../common/vendor.js");
const api_user = require("../../api/user.js");
const utils_utils = require("../../utils/utils.js");
const store_uaeUserStore = require("../../store/uaeUserStore.js");
const store_useBluetoothStore = require("../../store/useBluetoothStore.js");
const store_useStorageStore = require("../../store/useStorageStore.js");
require("../../utils/request.js");
require("../../store/index.js");
require("../../utils/functions.js");
require("../../utils/IDCardVerification.js");
require("../../utils/base64.js");
require("../../config/host.js");
require("../../utils/md5.js");
if (!Array) {
const _component_tips = common_vendor.resolveComponent("tips");
const _component_tiplist = common_vendor.resolveComponent("tiplist");
(_component_tips + _component_tiplist)();
}
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
__name: "login",
setup(__props) {
const { HANDLE_CLEARSTORAGE } = store_useStorageStore.useStorageStore();
const { HANDLE_INITBLUETOOTH } = store_useBluetoothStore.useBluetoothStore();
const userStore = store_uaeUserStore.useUserStore();
const { HANDLE_ACCTOKEN, HANDLE_REFTOKEN, HANDLE_USERINFO } = userStore;
let tip = common_vendor.ref(null);
let details = common_vendor.reactive({
tenantId: "",
password: "",
username: "",
isremember: true,
showck: false,
warehouseList: [],
checkitem: {}
});
const tiplists = common_vendor.ref(null);
const bluetoothList = utils_utils.utils.initbl();
console.log("bluetoothList :>> ", bluetoothList);
common_vendor.onLoad(() => {
let users = common_vendor.index.getStorageSync("loginuser");
details.isremember = common_vendor.index.getStorageSync("isremember");
if (users) {
if (details.isremember)
details.password = users.password;
details.tenantId = users.tenantId;
details.username = users.username;
}
HANDLE_INITBLUETOOTH();
});
common_vendor.onShow(() => {
const timer = setTimeout(() => {
HANDLE_CLEARSTORAGE();
clearTimeout(timer);
}, 2e3);
});
common_vendor.onPullDownRefresh(() => {
const timer = setTimeout(() => {
details.username = "";
details.tenantId = "";
details.password = "";
common_vendor.index.stopPullDownRefresh();
clearTimeout(timer);
}, 500);
});
function ckeckitem(item) {
details.checkitem = item;
}
async function sbckck() {
if (!details.checkitem.id) {
common_vendor.index.showToast({
title: "没有选择仓库,请先选择仓库",
icon: "none"
});
utils_utils.utils.ttsspke("没有选择仓库,请先选择仓库");
return;
}
await api_user.preserveCurrentWarehouse(details.checkitem);
common_vendor.index.setStorageSync("checkname", details.checkitem);
common_vendor.index.switchTab({
url: "/pages/index/index"
});
}
async function submitlogin() {
try {
let data = {
"grant_type": "password",
"scope": "all",
"username": details.username,
"password": details.password,
"tenantId": details.tenantId,
"isLogin": true
};
common_vendor.index.showLoading({
mask: true,
title: "登录中"
});
let response = await api_user.oauthtoken(data);
console.log(response);
if (response == null ? void 0 : response.refresh_token) {
setloctuser(response);
common_vendor.index.setStorageSync("checkname", {
warehouse_id: response.detail.warehouse_id,
warehouse_name: response.detail.warehouse_name,
name: response.detail.warehouse_name
});
if (response.detail.warehouse_id) {
common_vendor.index.switchTab({
url: "/pages/index/index"
});
return;
}
let res = await api_user.getMyWarehouseList({});
details.warehouseList = res.data;
if (details.warehouseList.length == 1) {
let resdata = await api_user.preserveCurrentWarehouse(details.warehouseList[0]);
common_vendor.index.setStorageSync("checkname", details.warehouseList[0]);
common_vendor.index.switchTab({
url: "/pages/index/index"
});
return;
}
details.showck = true;
} else {
tip.value.setdetails({
title: "提示",
content: "请确认账号密码正确,多次错误后禁止登录",
confirmTxt: "确认",
isshow: true,
isshowcancel: false,
success: () => {
tip.value.setisshow(false);
},
cancel: () => {
tip.value.setisshow(false);
},
close: () => {
tip.value.setisshow(false);
}
});
console.log("登录错误");
}
} catch (err) {
console.log("err :>> ", err);
} finally {
common_vendor.index.hideLoading();
}
}
function setisremember() {
details.isremember = !details.isremember;
common_vendor.index.setStorageSync("isremember", details.isremember);
}
function back() {
common_vendor.index.navigateBack();
}
function setloctuser(userinfo) {
common_vendor.index.setStorageSync("access_token", userinfo.access_token);
HANDLE_ACCTOKEN("userinfo.access_token");
common_vendor.index.setStorageSync("refresh_token", userinfo.refresh_token);
HANDLE_REFTOKEN(userinfo.refresh_token);
common_vendor.index.setStorageSync("userinfo", userinfo);
HANDLE_USERINFO(userinfo);
common_vendor.index.removeStorageSync("authbuts");
common_vendor.index.removeStorageSync("homerouter");
if (details.isremember) {
let user = {
tenantId: details.tenantId,
password: details.password,
username: details.username
};
common_vendor.index.setStorageSync("loginuser", user);
}
}
const { checkitem, warehouseList, showck, username, password, tenantId, isremember } = common_vendor.toRefs(details);
return (_ctx, _cache) => {
return common_vendor.e({
a: common_vendor.o(back),
b: common_vendor.unref(tenantId),
c: common_vendor.o(($event) => common_vendor.isRef(tenantId) ? tenantId.value = $event.detail.value : null),
d: common_vendor.unref(username),
e: common_vendor.o(($event) => common_vendor.isRef(username) ? username.value = $event.detail.value : null),
f: common_vendor.unref(password),
g: common_vendor.o(($event) => common_vendor.isRef(password) ? password.value = $event.detail.value : null),
h: common_vendor.unref(isremember) ? "/static/ck.png" : "/static/nock.png",
i: common_vendor.o(setisremember),
j: common_vendor.o(submitlogin),
k: common_vendor.unref(showck)
}, common_vendor.unref(showck) ? {
l: common_vendor.f(common_vendor.unref(warehouseList), (item, k0, i0) => {
return {
a: common_vendor.t(item.name),
b: common_vendor.o(($event) => ckeckitem(item)),
c: common_vendor.n(item.name == common_vendor.unref(checkitem).name ? "items xzck" : "items")
};
}),
m: common_vendor.o(sbckck),
n: common_vendor.o(() => {
}),
o: common_vendor.o(($event) => showck.value = false)
} : {}, {
p: common_vendor.sr(tip, "673df138-0", {
"k": "tip"
}),
q: common_vendor.sr(tiplists, "673df138-1", {
"k": "tiplists"
})
});
};
}
});
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "D:/worksp/logpm/pages/login/login.vue"]]);
wx.createPage(MiniProgramPage);