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

99 lines
2.0 KiB

5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 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. // workDetail : {},//工单详情
  13. },
  14. getters: {
  15. },
  16. mutations: {
  17. // 初始化配置
  18. initConfig(state){
  19. // api('getConfig', res => {
  20. // if(res.code == 200){
  21. // state.configList = res.result
  22. // }
  23. // })
  24. let config = ['getPrivacyPolicy', 'getUserAgreement']
  25. config.forEach(k => {
  26. api(k, res => {
  27. if (res.code == 200) {
  28. state.configList[k] = res.result
  29. }
  30. })
  31. })
  32. },
  33. // 账号密码登录
  34. accountLogin(state, form){
  35. api('login', form, res => {
  36. if(res.code == 200){
  37. state.userInfo = res.result
  38. uni.setStorageSync('token', res.result.id)
  39. uni.navigateBack(-1)
  40. }
  41. })
  42. },
  43. // 退出登录
  44. logout(state){
  45. uni.showModal({
  46. title: '确认退出登录吗',
  47. success(r) {
  48. if(r.confirm){
  49. state.userInfo = {}
  50. state.role = false
  51. uni.removeStorageSync('token')
  52. uni.reLaunch({
  53. url: '/pages/index/index'
  54. })
  55. }
  56. }
  57. })
  58. },
  59. // 获取个人信息
  60. getUserInfo(state){
  61. api('queryUserById', {
  62. userId : uni.getStorageSync('token')
  63. }, res => {
  64. if(res.code == 200){
  65. state.userInfo = res.result
  66. }
  67. })
  68. },
  69. // 获取工单状态列表
  70. templateStatusInfo(state){
  71. api('templateStatusInfo', res => {
  72. if(res.code == 200){
  73. state.statusList = [
  74. {
  75. name : '全部'
  76. },
  77. ...res.result.records,
  78. ]
  79. }
  80. })
  81. },
  82. // 根据id获取工单详情
  83. // queryTemplateById(templateId){
  84. // api('queryTemplateById', {
  85. // templateId
  86. // }, res =>{
  87. // if(res.code == 200){
  88. // this.workDetail = res.result
  89. // }
  90. // })
  91. // },
  92. },
  93. actions: {},
  94. })
  95. export default store