index.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import store from '@/store'
  2. export default {
  3. data() {
  4. return {
  5. pattern: '',
  6. fontMain: '',
  7. bgMain: ''
  8. }
  9. },
  10. onShow() {
  11. this.themeInit()
  12. },
  13. onReady() {
  14. this.themeInit()
  15. },
  16. methods: {
  17. themeInit() {
  18. this.pattern = store.getters.pattern
  19. this.setNavbar(this.pattern)
  20. this.setTabbar(this.pattern)
  21. this.fontMain = this.pattern == 'dark' ? '#FFFFFF' : '#000000'
  22. this.bgMain = this.pattern == 'dark' ? '#102030' : '#F6F6F6'
  23. },
  24. setNavbar(item) {
  25. if (item == 'dark') {
  26. uni.setNavigationBarColor({
  27. frontColor: "#ffffff",
  28. backgroundColor: "#102030"
  29. })
  30. } else {
  31. uni.setNavigationBarColor({
  32. frontColor: "white",
  33. backgroundColor: "rgb(9 56 106)"
  34. })
  35. }
  36. },
  37. setTabbar(item) {
  38. if (item == 'dark') {
  39. uni.setTabBarStyle({
  40. color: '#a2a6a5',
  41. selectedColor: '#1881d2',
  42. backgroundColor: '#16263e',
  43. borderStyle: 'black'
  44. })
  45. } else {
  46. uni.setTabBarStyle({
  47. color: '#999999',
  48. selectedColor: '#292C35',
  49. backgroundColor: '#ffffff',
  50. borderStyle: 'white'
  51. })
  52. }
  53. },
  54. }
  55. }