MrShi
15 小时以前 47d56a8b0f22fb15a46b69dfd46fac23560ad2cd
mini-program/store/index.js
@@ -9,13 +9,15 @@
const shopInfo = uni.getStorageSync('shopInfo');
const openid = uni.getStorageSync('openid');
const token = uni.getStorageSync('token');
const recuserid = uni.getStorageSync('recuserid');
const recshopid = uni.getStorageSync('recshopid');
const shopToken = uni.getStorageSync('shopToken');
const store = new Vuex.Store({
   
   state: {
      imgUrl: 'https://www.duijiaoniwo.com',     // 服务器资源前缀
      imgUrl: 'https://mall.dynometacn.com/dmmall_web_api/',     // 服务器资源前缀
      navHeight: navHeight || '',
      statusbarHeight: statusbarHeight || '',
      userInfo: userInfo || '',     // 用户信息
@@ -23,7 +25,9 @@
      token: token || '',
      shopToken: shopToken || '',
      openid: openid || '',
      position: null
      position: null,
      recuserid:recuserid||'',
      recshopid:recshopid||'',
   },
   mutations: {
      // 设置导航栏高度
@@ -47,6 +51,14 @@
         state.openid = openid
         uni.setStorageSync('openid', openid);
      },
      setRecUserId(state, recuserid) {
         state.recuserid = recuserid
         uni.setStorageSync('recuserid', recuserid);
      },
      setRecShopId(state, recshopid) {
         state.recshopid = recshopid
         uni.setStorageSync('recshopid', recshopid);
      },
      // 设置用户信息
      setUserInfo(state, val) {
         state.userInfo = val
@@ -68,6 +80,26 @@
         uni.removeStorageSync('userInfo');
         uni.removeStorageSync('token');
         uni.removeStorageSync('openid');
         uni.removeStorageSync('recshopid');
         uni.removeStorageSync('recuserid');
      },
      // 登录过期
      guoqi(state) {
         state.userInfo = ''
         state.token = ''
         state.openid = ''
         state.shopInfo = ''
         state.shopToken = ''
         state.recshopid = ''
         state.recuserid = ''
         uni.removeStorageSync('userInfo');
         uni.removeStorageSync('token');
         uni.removeStorageSync('openid');
         uni.removeStorageSync('shopInfo');
         uni.removeStorageSync('shopToken');
         uni.removeStorageSync('recshopid');
         uni.removeStorageSync('recuserid');
      }
   },