index.js 3.0 KB

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