authorize.ts 776 B

12345678910111213141516171819202122232425262728293031323334
  1. // import useState from '@/store/useState';
  2. // const tokenID = useState(['tokenID'])
  3. import {getLifeData} from '@/store/liveSave.js'
  4. const modalText = {
  5. // TODO 完善异常提醒
  6. SUCCESS: ()=> {}
  7. }
  8. const setLoginFun = (options : ReturnLoginInfo,_this) => {
  9. const {status,data = {}} = options
  10. status ? modalText[status] : ''
  11. const {tokenID} = data
  12. if(status === 'SUCCESS'&&tokenID) {
  13. uni.$uv.vuex('tokenID', tokenID)
  14. _this.tokenID = tokenID
  15. authorize.tokenID = tokenID
  16. }
  17. }
  18. // 类型声明
  19. interface ReturnLoginInfo {
  20. status: string;
  21. data: object;
  22. }
  23. class authorize {
  24. static tokenID: string;
  25. static getTokenID() {
  26. return authorize.tokenID || getLifeData('tokenID')
  27. };
  28. constructor(data : ReturnLoginInfo){
  29. setLoginFun(data,this)
  30. }
  31. }
  32. export {
  33. authorize
  34. }