index.js 617 B

1234567891011121314151617181920212223242526272829303132333435
  1. export default class GlobalConfig {
  2. constructor () {
  3. this.theme = {
  4. active: 'green',
  5. items: [
  6. {
  7. color: '#04b00f',
  8. name: 'green'
  9. },
  10. {
  11. color: '#C20C0C',
  12. name: 'red'
  13. },
  14. {
  15. color: '#F0C040',
  16. name: 'yellow'
  17. }
  18. ]
  19. }
  20. }
  21. init () {
  22. const { color } = this.theme.items.find(item => item.name === this.theme.active)
  23. this.setThemeColor(color)
  24. }
  25. setThemeColor (v) {
  26. wx.setStorageSync('themeColor', v)
  27. }
  28. getThemeColor () {
  29. return wx.getStorageSync('themeColor')
  30. }
  31. }