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

105 lines
2.0 KiB

8 months ago
7 months ago
8 months ago
7 months ago
8 months ago
7 months ago
7 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
7 months ago
7 months ago
8 months ago
7 months ago
8 months ago
7 months ago
8 months ago
7 months ago
8 months ago
7 months ago
7 months ago
8 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. },
  16. getters: {
  17. // 角色 true 为供应商 false 为采购商
  18. userShop(state){
  19. return state.shop
  20. },
  21. userInfo(state){
  22. return state.userInfo
  23. },
  24. },
  25. mutations: {
  26. // 初始化配置
  27. initConfig(state){
  28. // api('getConfig', res => {
  29. // if(res.code == 200){
  30. // state.configList = res.result
  31. // }
  32. // })
  33. let config = ['getPrivacyPolicy', 'getUserAgreement']
  34. config.forEach(k => {
  35. api(k, res => {
  36. if (res.code == 200) {
  37. state.configList[k] = res.result
  38. }
  39. })
  40. })
  41. },
  42. login(state, form){
  43. uni.showLoading({
  44. title: '登录中...'
  45. })
  46. api('loginUser', form, res => {
  47. uni.hideLoading()
  48. if(res.code != 200){
  49. return
  50. }
  51. state.userInfo = res.result.userInfo
  52. state.buy = res.result.buy
  53. state.shopData = res.result.shop
  54. state.shop = !!res.result.shop
  55. uni.setStorageSync('token', res.result.token)
  56. if(!state.shop && !state.buy){
  57. uni.reLaunch({
  58. url: '/pages_order/auth/selectionIdentity?back=no&'
  59. })
  60. }else{
  61. uni.reLaunch({
  62. url: '/pages/index/index'
  63. })
  64. }
  65. })
  66. },
  67. getUserInfo(state){
  68. api('getImagePhoneOther', res => {
  69. if(res.code == 200){
  70. state.userInfo = res.result.my
  71. state.customerPhone = res.result.phone
  72. }
  73. })
  74. },
  75. logout(state){
  76. uni.showModal({
  77. title: '确认退出登录吗',
  78. success(r) {
  79. if(r.confirm){
  80. state.userInfo = {}
  81. state.role = false
  82. uni.removeStorageSync('token')
  83. uni.redirectTo({
  84. url: '/pages/index/index'
  85. })
  86. }
  87. }
  88. })
  89. },
  90. setShop(state, date){
  91. state.shop = date
  92. },
  93. },
  94. actions: {},
  95. })
  96. export default store