Files
cashier-ipad-new/stores/account.js
2025-11-27 19:01:45 +08:00

52 lines
1.4 KiB
JavaScript

import { defineStore } from "pinia";
import { shopStaffInfo } from "@/http/yskApi/account/shopStaff";
import { login, getCodeImg } from "@/http/yskApi/login.js";
export const useAccountStore = defineStore("account", {
state: () => {
return {
shopInfo: {},
//员工信息
shopStaff: {},
//员工账号
staffUserName: "",
loginInfo: {},
tokenInfo: {},
shopId: "",
loginType: "",
};
},
getters: {
isPayAfter(state){
return state.shopInfo.registerType==='after'?true:false
}
},
actions: {
//获取员工信息
async getShopStaffInfo() {
const res = await shopStaffInfo();
if (res) {
this.shopStaffInfo = res;
}
},
async login(params) {
const res = await login(params);
if (res) {
this.loginInfo = res;
this.shopInfo = res.shopInfo;
this.tokenInfo = res.tokenInfo;
this.shopId = res.shopInfo.id;
this.loginType = res.loginType;
this.shopStaff = res.shopStaff;
this.staffUserName = params.staffUserName
uni.setStorageSync("shopInfo", res.shopInfo);
uni.setStorageSync("tokenInfo", res.tokenInfo);
uni.setStorageSync("shopId", res.shopInfo.id);
uni.setStorageSync("loginType", res.loginType);
}
return res;
},
},
unistorage: true, // 开启后对 state 的数据读写都将持久化
});