app.config.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import {
  2. getToken,
  3. setToken
  4. } from "@/utils/common.js"
  5. const state = {
  6. token: getToken(),
  7. headHeight: '100rpx', // 头部标题的高度
  8. statusBarHeight: 0, // 头部状态栏的高度
  9. navBarHeight:0, // 头部标题 + 头部状态栏 的高度
  10. windowInfo:{},
  11. PageContentHeight:0, // 页面内容的高度,去掉了 (头部标题 + 头部状态栏)
  12. maxPageHeight:0, // 页面的高度,包含(头部标题 + 头部状态栏)
  13. tabBarHeight:50, // 50 是tabbar 的高度,在pages里面设置
  14. // 涨跌颜色
  15. stocksColor: 'green_rise', // green_rise:绿涨红跌 , red_rise:绿跌红涨
  16. }
  17. const mutations = {
  18. SET_statusBarHeight: (state, Height) => {
  19. state.statusBarHeight = Height
  20. },
  21. SET_windowInfo: (state, info) => {
  22. state.windowInfo = info;
  23. const headH = state.headHeight.split('rpx')[0];
  24. const contentHeight = info.windowHeight - state.statusBarHeight - uni.upx2px(headH);
  25. state.navBarHeight = uni.upx2px(headH) + state.statusBarHeight;
  26. console.log('state.navigationBarHeight = ' , state.navBarHeight)
  27. state.PageContentHeight = contentHeight;
  28. state.maxPageHeight = info.windowHeight;
  29. },
  30. SET_STOCKS_COLOR: (state, code) => {
  31. state.stocksColor = code
  32. },
  33. SET_TOKEN: (state, token) => {
  34. setToken(token)
  35. state.token = token
  36. },
  37. // PageContentHeight: (state, contentHeight) => {
  38. // state.PageContentHeight = contentHeight
  39. // },
  40. }
  41. const actions = {
  42. // setToken = (token) => {
  43. // console.log('token = ' , token)
  44. // }
  45. setToken({
  46. commit
  47. }, token) {
  48. commit('SET_TOKEN', token)
  49. },
  50. }
  51. export default {
  52. namespaced: true,
  53. state,
  54. mutations,
  55. actions
  56. }