初始化
This commit is contained in:
166
store/index.js
Normal file
166
store/index.js
Normal file
@@ -0,0 +1,166 @@
|
||||
import Vue from 'vue'
|
||||
import Vuex from 'vuex'
|
||||
import Api from '@/common/js/api.js'
|
||||
Vue.use(Vuex);
|
||||
|
||||
//Vuex.Store 构造器选项
|
||||
const store = new Vuex.Store({
|
||||
state: { //存放状态
|
||||
"login": false,
|
||||
"info": {
|
||||
ft_sum: 0,
|
||||
},
|
||||
"BarHeight": {
|
||||
statusBar: '',
|
||||
customBar: '',
|
||||
info: '',
|
||||
custwidth: '',
|
||||
bottompadding: ""
|
||||
},
|
||||
'ationbottomnavigation': {
|
||||
// 'activeColor':'#666',
|
||||
// 'data.inactiveColor':'#333',
|
||||
// common_style: {
|
||||
// '--bg-color-button': '#404136', // (提交 确认) 主色
|
||||
// '--bg-color-buttonone': '#ABAD98', // 辅色一
|
||||
// '--bg-color-buttontow': '#6E7062', // 辅色二
|
||||
// // 首页
|
||||
// '--bgbuttonbackground': 'linear-gradient(267deg, #ABAD98 0%, #ABAD98 51%, rgba(255,255,255,0.65) 100%)', //首页 横杆渐变色
|
||||
// 'bgbutton': '#ABAD98', //首页金刚区横杆 没有默认填写一个颜色
|
||||
// '--bgbuttonqq': ' linear-gradient(90deg, #9A9D88 0%, #373831 100%)', //首页立即抢购
|
||||
// '--bgbuttonxilie': '#ccc', //首页服装系背景颜色
|
||||
// //购物车和商城
|
||||
// 'cartbutton': '#404136', //购物车圆圈选中按钮
|
||||
// 'cartpieces': '#404136', //购物车件数添加按钮 和主色一样
|
||||
// '--cart-text-color': '#FFFFFF', //购物车 立即购买字体颜色 不变
|
||||
// '--cart-background-color': '#ABAD98', //加入购物车背景颜色
|
||||
// '--cartbuy-background-color': '#404136', //立即购买背景颜色
|
||||
// 规格颜色
|
||||
// '--specbackground-color': '#FFFFFF', //背景颜色
|
||||
// '--spec-text-color': '#ABAD98', 字体颜色
|
||||
// // 订单
|
||||
// '--chakabackground': '#ffffff', //查看物流背景颜色
|
||||
// '--chakaborder': '#404136', //边颜色
|
||||
// '--chakacolor': '#404136', //字体
|
||||
// },
|
||||
|
||||
},
|
||||
|
||||
},
|
||||
getters: {
|
||||
theme(state) {
|
||||
return state.ationbottomnavigation.common_style
|
||||
},
|
||||
is_login(state) {
|
||||
return state.login;
|
||||
},
|
||||
bottomnavigation(state) {
|
||||
return state.ationbottomnavigation;
|
||||
},
|
||||
is_BarHeight(state) {
|
||||
//二次修改后的值 或者过滤的
|
||||
return state.BarHeight;
|
||||
},
|
||||
get_info(state) {
|
||||
//二次修改后的值 或者过滤的
|
||||
return state.info;
|
||||
},
|
||||
},
|
||||
mutations: {
|
||||
updateTheme(state, theme) {
|
||||
state.theme = theme
|
||||
},
|
||||
// 登录
|
||||
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;
|
||||
},
|
||||
Bottom_Padding(state, data) {
|
||||
state.BarHeight.bottompadding = data;
|
||||
},
|
||||
SUS_THIDTH(state, data) {
|
||||
state.BarHeight.custwidth = data;
|
||||
},
|
||||
CLSAA_IFIC_CATIO(state, data) {
|
||||
state.ationbottomnavigation = data;
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async actionsclassification(context) {
|
||||
let res = await Api.classificationbottomnavigation({
|
||||
store_id: uni.cache.get('store_id')
|
||||
});
|
||||
uni.setStorageSync('bgnothave', res.bgnothave);
|
||||
uni.setStorageSync('selected', res.selected);
|
||||
uni.setStorageSync('shoppingcart', res.shoppingcart);
|
||||
context.commit('CLSAA_IFIC_CATIO', res)
|
||||
},
|
||||
|
||||
HeightActions({
|
||||
commit
|
||||
}) {
|
||||
uni.getSystemInfo({
|
||||
success: (e) => {
|
||||
let statusBar = 0
|
||||
let customBar = 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
|
||||
custwidth = custom.width + 7,
|
||||
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
|
||||
customBar = e.statusBarHeight + 45
|
||||
bottomPadding = (e.screenHeight - e.safeArea.bottom)
|
||||
// #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('SET_SYSTEM_INFO', e)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
export default store
|
||||
Reference in New Issue
Block a user