2024-08-22 15:03:30 +08:00

55 lines
1.2 KiB
JavaScript

/**
* @description 锁信息数据持久化
*/
import { defineStore } from 'pinia'
import { getLockListRequest } from '@/api/lock'
export const useLockStore = defineStore('lock', {
state() {
return {
// 锁列表
lockList: [],
// 锁总数
lockTotal: 0
}
},
actions: {
getRole(userType) {
if(userType === 110301) {
return '超级管理员'
} else {
return '普通用户'
}
},
getTimeLimit(keyType) {
if(keyType === 1) {
return '永久'
} else if(keyType === 2) {
return '限时'
} else if(keyType === 3) {
return '单次'
} else {
return '循环'
}
},
async getLockList(params) {
const { code, data, message } = await getLockListRequest(params)
if(code === 0) {
this.lockTotal = data.total
if(params.pageNo === 1) {
this.lockList = data.groupList
} else {
this.lockList = this.lockList.concat(data.groupList)
}
return { code }
} else {
uni.showToast({
title: message,
icon: 'none'
})
return { code, message }
}
}
}
})