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. // 涨跌颜色
  12. stocksColor: 'green_rise', // green_rise:绿涨红跌 , red_rise:绿跌红涨
  13. }
  14. const mutations = {
  15. SET_statusBarHeight: (state, Height) => {
  16. state.statusBarHeight = Height
  17. },
  18. SET_windowInfo: (state, info) => {
  19. state.windowInfo = info;
  20. const headH = state.headHeight.split('rpx')[0];
  21. const contentHeight = info.windowHeight - state.statusBarHeight - uni.upx2px(headH);
  22. state.PageContentHeight = contentHeight;
  23. console.log('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. }