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

101 lines
2.1 KiB

6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
5 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
5 months ago
6 months ago
6 months ago
6 months ago
6 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. // state.permissions = res.result.permissionRoleList.map(n => n.permissionName)
  39. uni.setStorageSync('token', res.result.id)
  40. uni.navigateBack(-1)
  41. }
  42. })
  43. },
  44. // 退出登录
  45. logout(state){
  46. uni.showModal({
  47. title: '确认退出登录吗',
  48. success(r) {
  49. if(r.confirm){
  50. state.userInfo = {}
  51. state.role = false
  52. uni.removeStorageSync('token')
  53. uni.reLaunch({
  54. url: '/pages/index/index'
  55. })
  56. }
  57. }
  58. })
  59. },
  60. // 获取个人信息
  61. getUserInfo(state){
  62. api('queryUserById', {
  63. userId : uni.getStorageSync('token')
  64. }, res => {
  65. if(res.code == 200){
  66. state.userInfo = res.result
  67. // state.permissions = res.result.permissionRoleList.map(n => n.permissionName)
  68. }
  69. })
  70. },
  71. // 获取工单状态列表
  72. templateStatusInfo(state){
  73. api('templateStatusInfo', res => {
  74. if(res.code == 200){
  75. state.statusList = [
  76. {
  77. name : '全部'
  78. },
  79. ...res.result.records,
  80. ]
  81. }
  82. })
  83. },
  84. // 根据id获取工单详情
  85. // queryTemplateById(templateId){
  86. // api('queryTemplateById', {
  87. // templateId
  88. // }, res =>{
  89. // if(res.code == 200){
  90. // this.workDetail = res.result
  91. // }
  92. // })
  93. // },
  94. },
  95. actions: {},
  96. })
  97. export default store