index.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. import Vue from 'vue'
  2. import Vuex from 'vuex'
  3. import {
  4. isLogin
  5. } from "@/access/common.js"
  6. Vue.use(Vuex)
  7. const cartNum = uni.getStorageSync('cartNum') || 0
  8. const cartPrice = uni.getStorageSync('cartPrice') || 0
  9. if (cartNum > 0) {
  10. uni.setTabBarBadge({
  11. index: 2,
  12. text: cartNum
  13. });
  14. }
  15. const store = new Vuex.Store({
  16. state: {
  17. nowAddress: {},
  18. distributionTextSet: '',
  19. businessmanId: '',
  20. staffId: '',
  21. hasLogin: !!uni.getStorageSync('token'),
  22. user_address: {},
  23. cateModel: 4,
  24. cartNum: cartNum,
  25. cartPrice: cartPrice,
  26. enterpriseInfo: {}, // 获取企业详情
  27. baseSet: uni.getStorageSync('baseSet') || {
  28. themeStyle: {
  29. label: '热情红',
  30. theme: 'red',
  31. color_t: '#ff3883',
  32. color_o: '#fd463e',
  33. }
  34. },
  35. locationObj: uni.getStorageSync('locationObj') ? JSON.parse(uni.getStorageSync('locationObj')) : {},
  36. userStatus: uni.getStorageSync('userStatus'),
  37. distributionSet: {}, // 分销商设置
  38. iosAuditStatus: 5 ,//判断IOS是否审核通过,因为IOS审核必须要账号密码登录,4为审核中,跳账号密码登录页面,5已通过审核,跳微信登录页面
  39. },
  40. mutations: {
  41. // 获取企业详情
  42. commit_enterpriseInfo(state, detail) {
  43. state.enterpriseInfo = detail
  44. uni.setStorageSync('enterpriseInfo', detail)
  45. },
  46. // 设置默认地址
  47. commit_nowAddress(state, nowAddress) {
  48. state.nowAddress = nowAddress
  49. },
  50. // 分销文字设置
  51. commit_distributionTextSet(state, stateTextSet) {
  52. state.distributionTextSet = stateTextSet
  53. },
  54. // 设置分销商上级ID
  55. commit_businessmanId(state, businessmanId) {
  56. state.businessmanId = businessmanId
  57. },
  58. // 设置指定业务员ID
  59. commit_staffId(state, staffId) {
  60. state.staffId = staffId
  61. },
  62. // 分销商基础设置
  63. commit_distributionSet(state, distributionSet) {
  64. state.distributionSet = distributionSet
  65. },
  66. // 判断登录状态
  67. commit_hasLogin(state, hasLogin) {
  68. state.hasLogin = hasLogin
  69. },
  70. // IOS提交APPstore审核状态
  71. commit_iosAuditStatus(state, sttaus) {
  72. state.iosAuditStatus = sttaus
  73. },
  74. // 用户信息
  75. commit_userStatus(state, obj) {
  76. state.userStatus = obj
  77. uni.setStorageSync('userStatus', obj)
  78. },
  79. // 当前定位
  80. commit_locationObj(state, obj) {
  81. state.locationObj = obj
  82. uni.setStorageSync('locationObj', JSON.stringify(obj))
  83. },
  84. // 商城基础设置信息
  85. commit_baseSet(state, obj) {
  86. state.baseSet = obj
  87. uni.setStorageSync('baseSet', obj)
  88. },
  89. // 分类页面模版
  90. commit_cateModel(state, obj) {
  91. state.cateModel = obj
  92. },
  93. // 用户地址
  94. commit_address(state, obj) {
  95. state.user_address = obj
  96. },
  97. commit_cartNum(state, num) {
  98. state.cartNum = num
  99. uni.setStorageSync('cartNum', cartNum)
  100. },
  101. commit_cartPrice(state, price) {
  102. // console.log('price',price)
  103. state.cartPrice = price
  104. uni.setStorageSync('cartPrice', price)
  105. },
  106. logout(state) {
  107. state.hasLogin = false;
  108. state.userStatus = {};
  109. uni.removeStorage({
  110. key: 'userStatus'
  111. })
  112. }
  113. },
  114. actions: {
  115. }
  116. })
  117. export default store