| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- /**
- * 用户状态管理
- */
- import {
- defineStore
- } from 'pinia'
- import {
- getCardInfo,
- getCardQrcode,
- getCompanyInfo
- } from '@/api/card.js'
- export const useUserStore = defineStore('user', {
- state: () => ({
- cardInfo: {
- "userId": "",
- "nickName": "",
- "phonenumber": "",
- "postName": "",
- "companyName": "",
- "companyAddress": "",
- "email": "",
- "sex": null,
- "avatar": ""
- },
- companyInfo: {
- "name": "",
- "email": "",
- "address": "",
- "introduce": ""
- },
- qrInfo: {
- }
- }),
- actions: {
- // 获取用户卡片信息
- queryCardInfo(userId = null) {
- return new Promise(async (resolve, reject) => {
- let parmas = userId ? {
- userId
- } : {}
- let res = await getCardInfo(parmas)
- console.log(res, "resresresresresres");
- this.cardInfo = res.data
- resolve(res.data)
- })
- },
- queryCompanyInfo(userId = null) {
- return new Promise(async (resolve, reject) => {
- let parmas = userId ? {
- userId
- } : {}
- let res = await getCompanyInfo(parmas)
- this.companyInfo = res.data
- resolve(res.data)
- })
- },
- queryCardQrcode(userId = null) {
- return new Promise(async (resolve, reject) => {
- let parmas = userId ? {
- userId
- } : {
- userId: this.cardInfo.userId
- }
- let res = await getCardQrcode(parmas)
- this.qrInfo = res.data ||{}
- resolve(res.data)
- })
- },
- // 退出登录,重置状态
- logout() {
- this.$reset()
- }
- }
- })
|