H5
This commit is contained in:
120
store/index.js
Normal file
120
store/index.js
Normal file
@@ -0,0 +1,120 @@
|
||||
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: '',
|
||||
bottompadding: "",
|
||||
heightBar: ''
|
||||
},
|
||||
|
||||
},
|
||||
getters: {
|
||||
is_login(state) {
|
||||
return state.login;
|
||||
},
|
||||
bottomnavigation(state) {
|
||||
return state.ationbottomnavigation;
|
||||
},
|
||||
is_BarHeight(state) {
|
||||
//二次修改后的值 或者过滤的
|
||||
return state.BarHeight;
|
||||
},
|
||||
get_info(state) {
|
||||
//二次修改后的值 或者过滤的
|
||||
return state.info;
|
||||
},
|
||||
},
|
||||
mutations: {
|
||||
SET_STATUS_BAR(state, data) {
|
||||
state.BarHeight.statusBar = data;
|
||||
},
|
||||
SET_CUSTOM_BAR(state, data) {
|
||||
state.BarHeight.customBar = data;
|
||||
},
|
||||
Bottom_heightBar(state, data) {
|
||||
state.BarHeight.heightBar = data;
|
||||
},
|
||||
SET_SYSTEM_INFO(state, data) {
|
||||
state.BarHeight.info = data;
|
||||
},
|
||||
Bottom_Padding(state, data) {
|
||||
state.BarHeight.bottompadding = data;
|
||||
},
|
||||
SUS_THIDTH(state, data) {
|
||||
state.BarHeight.custwidth = data;
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
|
||||
HeightActions({
|
||||
commit
|
||||
}) {
|
||||
uni.getSystemInfo({
|
||||
success: (e) => {
|
||||
let statusBar = 0
|
||||
let customBar = 0
|
||||
let heightBar = 0
|
||||
let custwidth = 0
|
||||
let bottomPadding = 0
|
||||
// #ifdef MP
|
||||
statusBar = e.statusBarHeight
|
||||
customBar = e.statusBarHeight + 45
|
||||
bottomPadding = (e.screenHeight - e.safeArea.bottom)
|
||||
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
|
||||
customBar = custom.height
|
||||
heightBar = custom.top
|
||||
custwidth = custom.width + 10,
|
||||
bottomPadding = (e.screenHeight - e.safeArea.bottom)
|
||||
// #endif
|
||||
// #ifdef MP-ALIPAY
|
||||
statusBar = e.statusBarHeight
|
||||
customBar = e.statusBarHeight + e.titleBarHeight
|
||||
bottomPadding = (e.screenHeight - e.safeArea.bottom)
|
||||
// #endif
|
||||
// #ifdef APP-PLUS
|
||||
console.log('app-plus', e)
|
||||
statusBar = e.statusBarHeight
|
||||
heightBar = e.statusBarHeight
|
||||
customBar = e.statusBarHeight
|
||||
bottomPadding = (e.screenHeight - e.safeArea.bottom)
|
||||
// customBar = 0
|
||||
// #endif
|
||||
// #ifdef H5
|
||||
statusBar = 0
|
||||
customBar = e.statusBarHeight == 0
|
||||
bottomPadding = (e.screenHeight - e.safeArea.bottom)
|
||||
// #endif
|
||||
// console.log(statusBar,customBar,custwidth,e)
|
||||
commit('SET_STATUS_BAR', statusBar) //状态栏高度
|
||||
commit('SET_CUSTOM_BAR', customBar) //顶部距离
|
||||
commit('SUS_THIDTH', custwidth) //胶囊宽度
|
||||
commit('Bottom_Padding', bottomPadding) //底部导航栏Padding
|
||||
commit('Bottom_heightBar', heightBar) //底部导航栏Padding
|
||||
commit('SET_SYSTEM_INFO', e)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
export default store
|
||||
Reference in New Issue
Block a user