app.config.js 1.2 KB

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