parent.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. //导出家长信息存储模块
  2. export default {
  3. //开启命名空间
  4. namespaced: true,
  5. //模块数据
  6. state: () => ({
  7. token: uni.getStorageSync('token') || '',//openid和session_key
  8. parentinfo: JSON.parse(uni.getStorageSync('parentinfo') || '{}'),
  9. // {
  10. // avatarUrl: "https://thirdwx.qlogo.cn/mmopen/vi_32/P79Xu1vuLVV1VykYd37lYsjXJxdBuibMlQRz9qSSzFmjEEf80ibISEtmUoxGQvyJ9QYBIicXYca2mX2qOEVBhuOdw/132",
  11. // city: "",
  12. // country: "",
  13. // gender: 0,
  14. // language: "zh_CN",
  15. // nickName: "荒川",
  16. // province: ""
  17. // }
  18. parentdetail: {
  19. phoneNumber: '17882237075',
  20. name: '家长姓名',
  21. defaultChild: 'tmdid01',
  22. childrenList: [{
  23. avatar: '/static/boy.png',
  24. name: '张三',
  25. classid: '0301',
  26. className: '三年级一班',
  27. tmdid: 'tmdid01'
  28. }, {
  29. avatar: '/static/boy.png',
  30. name: '张五',
  31. classid: '0304',
  32. className: '三年级四班',
  33. tmdid: 'tmdid02'
  34. }, {
  35. avatar: '/static/girl.png',
  36. name: '张梅',
  37. classid: '0504',
  38. className: '五年级四班',
  39. tmdid: 'tmdid03'
  40. },
  41. ]
  42. },
  43. }),
  44. //模块方法(修改数据)
  45. mutations: {
  46. //更新用户信息
  47. updateParentInfo(state, parentinfo) {
  48. state.parentinfo = parentinfo
  49. this.commit('m_parent/saveParentInfoToStorage')
  50. },
  51. //持久化存储
  52. saveParentInfoToStorage(state) {
  53. uni.setStorageSync('parentinfo', JSON.stringify(state.parentinfo))
  54. },
  55. //更新家长详细信息
  56. updateParentDetail(state,parentdetail){
  57. state.parentdetail = parentdetail
  58. this.commit('m_parent/saveParentDetailToStorage')
  59. },
  60. //持久化存储
  61. saveParentDetailToStorage(state){
  62. uni.setStorageSync('parentinfo', JSON.stringify(state.parentdetail))
  63. },
  64. //更新token字符串
  65. updateToken(state, token) {
  66. state.token = token
  67. this.commit('m_parent/saveTokenToStorage')
  68. },
  69. //token持久化存储
  70. saveTokenToStorage(state) {
  71. uni.setStorageSync('token',state.token)
  72. },
  73. },
  74. //模块属性(数据包装)
  75. getters: {
  76. }
  77. }