app.config.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. state.PageContentHeight = contentHeight;
  27. state.maxPageHeight = info.windowHeight;
  28. },
  29. SET_STOCKS_COLOR: (state, code) => {
  30. state.stocksColor = code
  31. },
  32. SET_TOKEN: (state, token) => {
  33. setToken(token)
  34. state.token = token
  35. },
  36. // PageContentHeight: (state, contentHeight) => {
  37. // state.PageContentHeight = contentHeight
  38. // },
  39. }
  40. const actions = {
  41. // setToken = (token) => {
  42. // console.log('token = ' , token)
  43. // }
  44. setToken({
  45. commit
  46. }, token) {
  47. commit('SET_TOKEN', token)
  48. },
  49. }
  50. export default {
  51. namespaced: true,
  52. state,
  53. mutations,
  54. actions
  55. }