工单小程序2024-11-20
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.

88 lines
1.7 KiB

8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
  1. import Vue from 'vue'
  2. import Vuex from 'vuex'
  3. Vue.use(Vuex); //vue的插件机制
  4. import api from '@/api/api.js'
  5. //Vuex.Store 构造器选项
  6. const store = new Vuex.Store({
  7. state: {
  8. configList: [], //配置列表
  9. userInfo : {}, //用户信息
  10. permissions : [],//权限列表
  11. statusList : [],
  12. },
  13. getters: {
  14. },
  15. mutations: {
  16. // 初始化配置
  17. initConfig(state){
  18. // api('getConfig', res => {
  19. // if(res.code == 200){
  20. // state.configList = res.result
  21. // }
  22. // })
  23. let config = ['getPrivacyPolicy', 'getUserAgreement']
  24. config.forEach(k => {
  25. api(k, res => {
  26. if (res.code == 200) {
  27. state.configList[k] = res.result
  28. }
  29. })
  30. })
  31. },
  32. // 账号密码登录
  33. accountLogin(state, form){
  34. api('login', form, res => {
  35. if(res.code == 200){
  36. state.userInfo = res.result
  37. uni.setStorageSync('token', res.result.id)
  38. uni.navigateBack(-1)
  39. }
  40. })
  41. },
  42. // 退出登录
  43. logout(state){
  44. uni.showModal({
  45. title: '确认退出登录吗',
  46. success(r) {
  47. if(r.confirm){
  48. state.userInfo = {}
  49. state.role = false
  50. uni.removeStorageSync('token')
  51. uni.reLaunch({
  52. url: '/pages/index/index'
  53. })
  54. }
  55. }
  56. })
  57. },
  58. // 获取个人信息
  59. getUserInfo(state){
  60. api('queryUserById', {
  61. userId : uni.getStorageSync('token')
  62. }, res => {
  63. if(res.code == 200){
  64. state.userInfo = res.result
  65. }
  66. })
  67. },
  68. // 获取工单状态列表
  69. templateStatusInfo(state){
  70. api('templateStatusInfo', res => {
  71. if(res.code == 200){
  72. state.statusList = [
  73. {
  74. name : '全部'
  75. },
  76. ...res.result.records,
  77. ]
  78. }
  79. })
  80. },
  81. },
  82. actions: {},
  83. })
  84. export default store