userinfo.js 588 B

123456789101112131415161718192021222324
  1. import Vue from 'vue'
  2. export default {
  3. namespaced: true,
  4. state: uni.getStorageSync("userInfo") ? JSON.parse(uni.getStorageSync("userInfo")) : {},
  5. mutations: {
  6. UPDATA_USERINFO(state, payload) {
  7. Object.keys(payload).forEach(e => Vue.set(state, e, payload[e]))
  8. uni.setStorageSync("userInfo", JSON.stringify(state))
  9. },
  10. REDUCEMONEY(state, money) {
  11. state.money -= +money
  12. },
  13. SET_CODE(state, code) {
  14. state.code = code
  15. },
  16. SET_OPENID(state, openid) {
  17. state.openid = openid
  18. },
  19. SET_ACCESSTOKEN(state, access_token) {
  20. state.access_token = access_token
  21. }
  22. }
  23. }