app.config.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. tabBarHeight:50, // 50 是tabbar 的高度,在pages里面设置
  12. // 涨跌颜色
  13. stocksColor: 'green_rise', // green_rise:绿涨红跌 , red_rise:绿跌红涨
  14. }
  15. const mutations = {
  16. SET_statusBarHeight: (state, Height) => {
  17. state.statusBarHeight = Height
  18. },
  19. SET_windowInfo: (state, info) => {
  20. state.windowInfo = info;
  21. const headH = state.headHeight.split('rpx')[0];
  22. const contentHeight = info.windowHeight - state.statusBarHeight - uni.upx2px(headH);
  23. state.PageContentHeight = contentHeight;
  24. },
  25. SET_STOCKS_COLOR: (state, code) => {
  26. state.stocksColor = code
  27. },
  28. SET_TOKEN: (state, token) => {
  29. setToken(token)
  30. state.token = token
  31. },
  32. // PageContentHeight: (state, contentHeight) => {
  33. // state.PageContentHeight = contentHeight
  34. // },
  35. }
  36. const actions = {
  37. // setToken = (token) => {
  38. // console.log('token = ' , token)
  39. // }
  40. setToken({
  41. commit
  42. }, token) {
  43. commit('SET_TOKEN', token)
  44. },
  45. }
  46. export default {
  47. namespaced: true,
  48. state,
  49. mutations,
  50. actions
  51. }