goods_cate.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <view :style="colorStyle">
  3. <goodsCate1 v-if="category==1" ref="classOne" :isNew="isNew"></goodsCate1>
  4. <goodsCate2 v-if="category==2" ref="classTwo" :isNew="isNew" @jumpIndex="jumpIndex"></goodsCate2>
  5. <goodsCate3 v-if="category==3" ref="classThree" :isNew="isNew" @jumpIndex="jumpIndex"></goodsCate3>
  6. </view>
  7. </template>
  8. <script>
  9. import colors from "@/mixins/color";
  10. import goodsCate1 from './goods_cate1';
  11. import goodsCate2 from './goods_cate2';
  12. import goodsCate3 from './goods_cate3';
  13. import {
  14. colorChange
  15. } from '@/api/api.js';
  16. import {
  17. mapGetters
  18. } from 'vuex';
  19. import {
  20. getCategoryVersion
  21. } from '@/api/public.js'
  22. import tabBar from "@/pages/index/visualization/components/tabBar.vue"
  23. export default {
  24. computed: mapGetters(['isLogin', 'uid']),
  25. components: {
  26. goodsCate1,
  27. goodsCate2,
  28. goodsCate3,
  29. tabBar
  30. },
  31. mixins: [colors],
  32. data() {
  33. return {
  34. category: '',
  35. is_diy: uni.getStorageSync('is_diy'),
  36. status: 0,
  37. version: '',
  38. isNew: false
  39. }
  40. },
  41. onLoad() {},
  42. onReady() {},
  43. onShow() {
  44. this.getCategoryVersion()
  45. },
  46. methods: {
  47. getCategoryVersion() {
  48. getCategoryVersion().then(res => {
  49. if (!uni.getStorageSync('CAT_VERSION') || res.data.version != uni.getStorageSync(
  50. 'CAT_VERSION')) {
  51. this.isNew = !this.isNew
  52. uni.setStorageSync('CAT_VERSION', res.data.version)
  53. } else {
  54. // this.isNew = false
  55. }
  56. this.classStyle();
  57. })
  58. },
  59. jumpIndex() {
  60. // uni.reLaunch({
  61. // url: '/pages/index/index'
  62. // })
  63. },
  64. classStyle() {
  65. colorChange('category').then(res => {
  66. let status = res.data.status;
  67. this.category = status
  68. uni.setStorageSync('is_diy', res.data.is_diy)
  69. this.status = res.data.status
  70. this.$nextTick(e => {
  71. if (this.status == 2 || this.status == 3) {
  72. uni.hideTabBar();
  73. } else if (this.status == 1) {
  74. this.$refs.classOne.is_diy = res.data.is_diy
  75. this.$refs.classOne.getNav();
  76. }
  77. if (status == 2) {
  78. if (this.isLogin) {
  79. this.$refs.classTwo.getCartNum();
  80. this.$refs.classTwo.getCartList(1);
  81. }
  82. this.$refs.classTwo.getAllCategory()
  83. }
  84. if (status == 3) {
  85. if (this.isLogin) {
  86. this.$refs.classThree.getCartNum();
  87. this.$refs.classThree.getCartList(1);
  88. }
  89. this.$refs.classThree.getAllCategory()
  90. }
  91. if (status == 2 || status == 3) {
  92. uni.hideTabBar()
  93. } else {
  94. if (!this.is_diy) {
  95. uni.hideTabBar()
  96. } else {}
  97. this.$refs.classOne.getNav();
  98. }
  99. })
  100. })
  101. }
  102. },
  103. onReachBottom: function() {
  104. if (this.category == 2) {
  105. this.$refs.classTwo.productslist();
  106. }
  107. if (this.category == 3) {
  108. this.$refs.classThree.productslist();
  109. }
  110. }
  111. }
  112. </script>
  113. <style scoped lang="scss">
  114. /deep/.mask {
  115. z-index: 99;
  116. }
  117. </style>