初始化
This commit is contained in:
102
store/index.js
Normal file
102
store/index.js
Normal file
@@ -0,0 +1,102 @@
|
||||
import Vue from 'vue'
|
||||
import Vuex from 'vuex'
|
||||
Vue.use(Vuex);
|
||||
|
||||
//Vuex.Store 构造器选项
|
||||
const store = new Vuex.Store({
|
||||
state: { //存放状态
|
||||
"login": false,
|
||||
"info": {
|
||||
ft_sum: 0,
|
||||
},
|
||||
"BarHeight":{
|
||||
statusBar:'',
|
||||
customBar:'',
|
||||
info:'',
|
||||
custwidth:''
|
||||
}
|
||||
},
|
||||
getters: {
|
||||
is_login(state) {
|
||||
return state.login;
|
||||
},
|
||||
is_BarHeight(state) {
|
||||
//二次修改后的值 或者过滤的
|
||||
return state.BarHeight;
|
||||
},
|
||||
get_info(state) {
|
||||
//二次修改后的值 或者过滤的
|
||||
return state.info;
|
||||
},
|
||||
},
|
||||
mutations: {
|
||||
// 登录
|
||||
set_login(state, status) {
|
||||
// 变更状态
|
||||
state.login = status;
|
||||
},
|
||||
set_ft_sum(state, e) { //例子
|
||||
state.info.ft_sum = e;
|
||||
},
|
||||
|
||||
SET_STATUS_BAR(state, data) {
|
||||
state.BarHeight.statusBar = data;
|
||||
},
|
||||
SET_CUSTOM_BAR(state, data) {
|
||||
state.BarHeight.customBar = data;
|
||||
},
|
||||
SET_SYSTEM_INFO(state, data) {
|
||||
state.BarHeight.info = data;
|
||||
},
|
||||
SUS_THIDTH(state, data){
|
||||
state.BarHeight.custwidth = data;
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
HeightActions({commit}) {
|
||||
uni.getSystemInfo({
|
||||
success: (e) => {
|
||||
let statusBar = 0
|
||||
let customBar = 0
|
||||
let custwidth = 0
|
||||
// #ifdef MP
|
||||
statusBar = e.statusBarHeight
|
||||
customBar = e.statusBarHeight + 45
|
||||
if (e.platform === 'android') {
|
||||
commit('SET_SYSTEM_IOSANDROID', false)
|
||||
customBar = e.statusBarHeight + 50
|
||||
}
|
||||
// #endif
|
||||
// #ifdef MP-WEIXIN
|
||||
statusBar = e.statusBarHeight
|
||||
// @ts-ignore
|
||||
const custom = wx.getMenuButtonBoundingClientRect()
|
||||
customBar = custom.bottom + custom.top - e.statusBarHeight
|
||||
custwidth = custom.width + 7,
|
||||
console.log(custom)
|
||||
// #endif
|
||||
// #ifdef MP-ALIPAY
|
||||
statusBar = e.statusBarHeight
|
||||
customBar = e.statusBarHeight + e.titleBarHeight
|
||||
// #endif
|
||||
// #ifdef APP-PLUS
|
||||
console.log('app-plus', e)
|
||||
statusBar = e.statusBarHeight
|
||||
customBar = e.statusBarHeight + 45
|
||||
// #endif
|
||||
// #ifdef H5
|
||||
statusBar = 0
|
||||
customBar = e.statusBarHeight == 0
|
||||
// #endif
|
||||
// console.log(statusBar,customBar,custwidth,e)
|
||||
commit('SET_STATUS_BAR', statusBar)//状态栏高度
|
||||
commit('SET_CUSTOM_BAR', customBar)//顶部距离
|
||||
commit('SUS_THIDTH',custwidth)//胶囊宽度
|
||||
commit('SET_SYSTEM_INFO', e)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
export default store
|
||||
Reference in New Issue
Block a user