提交
This commit is contained in:
19
store/index.js
Normal file
19
store/index.js
Normal file
@@ -0,0 +1,19 @@
|
||||
import Vue from "vue";
|
||||
import Vuex from "vuex";
|
||||
|
||||
Vue.use(Vuex);
|
||||
const files = require.context("./modules", false, /\.js$/);
|
||||
let modules = {
|
||||
state: {},
|
||||
mutations: {},
|
||||
actions: {}
|
||||
};
|
||||
|
||||
files.keys().forEach((key) => {
|
||||
Object.assign(modules.state, files(key)["state"]);
|
||||
Object.assign(modules.mutations, files(key)["mutations"]);
|
||||
Object.assign(modules.actions, files(key)["actions"]);
|
||||
});
|
||||
const store = new Vuex.Store(modules);
|
||||
export default store;
|
||||
|
||||
111
store/modules/common.js
Normal file
111
store/modules/common.js
Normal file
@@ -0,0 +1,111 @@
|
||||
export const state = {
|
||||
//webView地址
|
||||
webViewUrl: "",
|
||||
loadingShow: false,
|
||||
videoTimer: false,
|
||||
//微信场景参数
|
||||
chatScenesInfo: {},
|
||||
//绑定微信头像昵称弹窗状态
|
||||
bindUserInfoShow: false,
|
||||
//当前位置
|
||||
currentAddress: {
|
||||
areaName: "请选择",
|
||||
areaId: ''
|
||||
},
|
||||
guidePages:1
|
||||
};
|
||||
//缓存浏览器的数据名称
|
||||
const cacheNameList = ["userInfo","HealthMes","webViewUrl","hisRecords"];
|
||||
let clearTime;
|
||||
export const mutations = {
|
||||
//取出缓存数据(打开APP就取出)
|
||||
setCacheData(state) {
|
||||
for (let name of cacheNameList) {
|
||||
let data;
|
||||
// #ifndef H5
|
||||
data = uni.getStorageSync(name);
|
||||
// #endif
|
||||
// #ifdef H5
|
||||
data = sessionStorage.getItem(name) || localStorage.getItem(name);
|
||||
// #endif
|
||||
if (data) {
|
||||
// #ifdef H5
|
||||
try {
|
||||
data = JSON.parse(data);
|
||||
} catch (e) {
|
||||
}
|
||||
// #endif
|
||||
state[name] = data;
|
||||
}
|
||||
}
|
||||
},
|
||||
//WebView地址
|
||||
setWebViewUrl(state, data) {
|
||||
if (data) {
|
||||
state.webViewUrl = data;
|
||||
// #ifdef H5
|
||||
window.sessionStorage.setItem('webViewUrl', data);
|
||||
// #endif
|
||||
}
|
||||
},
|
||||
setVideoTimer(state, data) {
|
||||
if (data) {
|
||||
state.videoTimer = data;
|
||||
// #ifdef H5
|
||||
// window.sessionStorage.setItem('webViewUrl', data);
|
||||
// #endif
|
||||
}
|
||||
},
|
||||
//数据加载状态
|
||||
setLoadingShow(state, data) {
|
||||
if(state.loadingShow){
|
||||
if(data){
|
||||
clearTime && clearTimeout(clearTime);
|
||||
clearTime = setTimeout(function(){
|
||||
state.loadingShow = false;
|
||||
},5000);
|
||||
} else {
|
||||
clearTime && clearTimeout(clearTime);
|
||||
clearTime = setTimeout(function(){
|
||||
state.loadingShow = false;
|
||||
},50);
|
||||
}
|
||||
} else {
|
||||
state.loadingShow = data;
|
||||
}
|
||||
// console.log('加载状态',state.loadingShow)
|
||||
},
|
||||
//微信场景参数
|
||||
setChatScenesInfo(state, data) {
|
||||
if (data) {
|
||||
state.chatScenesInfo = Object.assign({}, state.chatScenesInfo, data);
|
||||
}
|
||||
},
|
||||
//绑定微信头像昵称弹窗状态
|
||||
setBindUserInfoShow(state, data) {
|
||||
state.bindUserInfoShow = data;
|
||||
},
|
||||
//当前地址
|
||||
setCurrentAddress(state, data) {
|
||||
if (data) {
|
||||
state.currentAddress = Object.assign(state.currentAddress, data);
|
||||
let addressInfo = {
|
||||
"provinceId": state.currentAddress.provinceId,
|
||||
"provinceName": state.currentAddress.provinceName,
|
||||
"cityId": state.currentAddress.cityId,
|
||||
"cityName": state.currentAddress.cityName,
|
||||
"areaId": state.currentAddress.areaId,
|
||||
"areaName": state.currentAddress.areaName,
|
||||
};
|
||||
uni.setStorageSync('currentAddress', addressInfo);
|
||||
}
|
||||
},
|
||||
// 苹果支付验证
|
||||
checkIapOrder(){
|
||||
console.log('验证苹果支付未关闭订单')
|
||||
},
|
||||
|
||||
};
|
||||
export const actions = {
|
||||
|
||||
};
|
||||
9
store/modules/order.js
Normal file
9
store/modules/order.js
Normal file
@@ -0,0 +1,9 @@
|
||||
export const state = {
|
||||
|
||||
};
|
||||
export const mutations = {
|
||||
|
||||
};
|
||||
export const actions = {
|
||||
|
||||
};
|
||||
74
store/modules/user.js
Normal file
74
store/modules/user.js
Normal file
@@ -0,0 +1,74 @@
|
||||
export const state = {
|
||||
//用户数据
|
||||
userInfo: {},
|
||||
videoOssList:[],
|
||||
videoList:[],
|
||||
};
|
||||
export const mutations = {
|
||||
//储存用户信息
|
||||
setUserInfo(state, data) {
|
||||
// console.log(state)
|
||||
// console.log(data)
|
||||
if (data) {
|
||||
state.userInfo = Object.assign({}, state.userInfo, data);
|
||||
// #ifdef H5
|
||||
window.sessionStorage.setItem('userInfo', JSON.stringify(state.userInfo));
|
||||
// #endif
|
||||
// #ifndef H5
|
||||
uni.setStorageSync('userInfo', state.userInfo);
|
||||
// #endif
|
||||
}
|
||||
},
|
||||
setVideoOssList(state, data) {
|
||||
// console.log(state)
|
||||
// console.log(data)
|
||||
if (data) {
|
||||
state.videoOssList = data;
|
||||
// #ifdef H5
|
||||
window.sessionStorage.setItem('videoOssList', JSON.stringify(state.videoOssList));
|
||||
// #endif
|
||||
// #ifndef H5
|
||||
uni.setStorageSync('videoOssList', state.videoOssList);
|
||||
// #endif
|
||||
}
|
||||
},
|
||||
setVideoList(state, data) {
|
||||
// console.log(state)
|
||||
// console.log(data)
|
||||
if (data) {
|
||||
state.videoOssList = data;
|
||||
// #ifdef H5
|
||||
window.sessionStorage.setItem('videoList', JSON.stringify(state.videoList));
|
||||
// #endif
|
||||
// #ifndef H5
|
||||
uni.setStorageSync('videoList', state.videoList);
|
||||
// #endif
|
||||
}
|
||||
},
|
||||
//储存一路健康用户信息
|
||||
setHealthMes(state, data) {
|
||||
console.log(data)
|
||||
if (data) {
|
||||
state.HealthMes = Object.assign({}, state.HealthMes, data);
|
||||
// #ifdef H5
|
||||
window.sessionStorage.setItem('HealthMes', JSON.stringify(state.HealthMes));
|
||||
// #endif
|
||||
// #ifndef H5
|
||||
uni.setStorageSync('HealthMes', state.HealthMes);
|
||||
// #endif
|
||||
}
|
||||
},
|
||||
// 退出APP
|
||||
emptyUserInfo(state) {
|
||||
state.userInfo = {};
|
||||
// #ifdef H5
|
||||
window.sessionStorage.removeItem("userInfo");
|
||||
// #endif
|
||||
// #ifndef H5
|
||||
uni.removeStorageSync("userInfo");
|
||||
// #endif
|
||||
},
|
||||
};
|
||||
export const actions = {
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user