铝交易,微信公众号
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.

134 lines
2.8 KiB

9 months ago
9 months ago
9 months ago
8 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
7 months ago
9 months ago
8 months ago
9 months ago
9 months ago
9 months ago
9 months ago
8 months ago
9 months ago
8 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
8 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 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. import { date } from '../uni_modules/uv-ui-tools/libs/function/test';
  6. //Vuex.Store 构造器选项
  7. const store = new Vuex.Store({
  8. state: {
  9. configList: {}, //配置列表
  10. shop : true,
  11. userInfo : {}, //用户信息
  12. shopData : {},
  13. buy : {},
  14. customerPhone : '',//客服电话
  15. productDetail : {},//商品详情用于中转
  16. orderDetail : {},//订单详情用于中转
  17. cartInfo : {},//采购商下单的时候供应商开户行信息
  18. pic : '',//清关服务图片
  19. },
  20. getters: {
  21. // 角色 true 为供应商 false 为采购商
  22. userShop(state){
  23. return state.shop
  24. },
  25. userInfo(state){
  26. return state.userInfo
  27. },
  28. },
  29. mutations: {
  30. // 初始化配置
  31. initConfig(state){
  32. api('getConfig', res => {
  33. if(res.code == 200){
  34. // state.configList = res.result
  35. res.result.forEach(n => {
  36. state.configList[n.name] = n
  37. })
  38. }
  39. })
  40. // let config = ['getPrivacyPolicy', 'getUserAgreement']
  41. // config.forEach(k => {
  42. // api(k, res => {
  43. // if (res.code == 200) {
  44. // state.configList[k] = res.result
  45. // }
  46. // })
  47. // })
  48. },
  49. login(state, form){
  50. uni.showLoading({
  51. title: '登录中...'
  52. })
  53. api('loginUser', form, res => {
  54. uni.hideLoading()
  55. if(res.code != 200){
  56. return
  57. }
  58. state.userInfo = res.result.userInfo
  59. state.buy = res.result.buy
  60. state.shopData = res.result.shop
  61. state.shop = !!res.result.shop
  62. uni.setStorageSync('token', res.result.token)
  63. if(!state.shopData && !state.buy){
  64. uni.reLaunch({
  65. url: '/pages_order/auth/selectionIdentity?back=no&'
  66. })
  67. }else{
  68. uni.reLaunch({
  69. url: '/pages/index/index'
  70. })
  71. }
  72. })
  73. },
  74. // 获取个人信息
  75. getUserInfo(state){
  76. api('getImagePhoneOther', res => {
  77. if(res.code == 200){
  78. state.userInfo = res.result.my
  79. state.customerPhone = res.result.phone
  80. state.buy = res.result.buy
  81. state.shopData = res.result.shop
  82. state.pic = res.result.pic
  83. // 如果什么身份都没有,就去注册
  84. if(!state.shopData && !state.buy){
  85. uni.reLaunch({
  86. url: '/pages_order/auth/selectionIdentity?back=no&'
  87. })
  88. }
  89. // 没有供应商身份
  90. if(!state.shopData){
  91. state.shop = false
  92. // 没有采购商身份
  93. }else if(!state.buy){
  94. state.shop = true
  95. }
  96. }
  97. })
  98. },
  99. logout(state){
  100. uni.showModal({
  101. title: '确认退出登录吗',
  102. success(r) {
  103. if(r.confirm){
  104. state.userInfo = {}
  105. state.role = false
  106. uni.removeStorageSync('token')
  107. uni.redirectTo({
  108. url: '/pages/index/index'
  109. })
  110. }
  111. }
  112. })
  113. },
  114. setShop(state, date){
  115. state.shop = date
  116. },
  117. },
  118. actions: {},
  119. })
  120. export default store