12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- import {
- getToken,
- setToken
- } from "@/utils/common.js"
- const state = {
- token: getToken(),
- headHeight: '100rpx', // 头部标题的高度
- statusBarHeight: 0, // 头部状态栏的高度
- navBarHeight:0, // 头部标题 + 头部状态栏 的高度
- windowInfo:{},
- PageContentHeight:0, // 页面内容的高度,去掉了 (头部标题 + 头部状态栏)
- maxPageHeight:0, // 页面的高度,包含(头部标题 + 头部状态栏)
- tabBarHeight:50, // 50 是tabbar 的高度,在pages里面设置
- // 涨跌颜色
- stocksColor: 'green_rise', // green_rise:绿涨红跌 , red_rise:绿跌红涨
- }
- const mutations = {
- SET_statusBarHeight: (state, Height) => {
- state.statusBarHeight = Height
- },
- SET_windowInfo: (state, info) => {
- state.windowInfo = info;
- const headH = state.headHeight.split('rpx')[0];
- const contentHeight = info.windowHeight - state.statusBarHeight - uni.upx2px(headH);
- state.navBarHeight = uni.upx2px(headH) + state.statusBarHeight;
- state.PageContentHeight = contentHeight;
- state.maxPageHeight = info.windowHeight;
- },
- SET_STOCKS_COLOR: (state, code) => {
- state.stocksColor = code
- },
- SET_TOKEN: (state, token) => {
- setToken(token)
- state.token = token
- },
- // PageContentHeight: (state, contentHeight) => {
- // state.PageContentHeight = contentHeight
- // },
- }
- const actions = {
- // setToken = (token) => {
- // console.log('token = ' , token)
- // }
- setToken({
- commit
- }, token) {
- commit('SET_TOKEN', token)
- },
- }
- export default {
- namespaced: true,
- state,
- mutations,
- actions
- }
|