goods_cate.vue 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <template>
  2. <!-- 商品分类 -->
  3. <view :style="colorStyle">
  4. <!-- 商品分类的三种样式布局 pdHeight:自定义导航diy设置的上下边距 -->
  5. <template1 v-if="activeIndex == 0" :level="level" :isFooter="isFooter" :pdHeight="pdHeight" ref="classOne"></template1>
  6. <template2 v-if="showTemplateTwo" :level="level" :showType="activeIndex" :isFooter="isFooter" ref="classTwo"></template2>
  7. <template3 v-if="showTemplateThree" :showType="activeIndex" :isFooter="isFooter" ref="classThree"></template3>
  8. <template4 v-if="showTemplateFour" :level="level" :isFooter="isFooter" :pdHeight="pdHeight" @toggleBar="toggleBar" ref="classFour"></template4>
  9. <pageFooter @newDataStatus="newDataStatus" v-show="showBar"></pageFooter>
  10. </view>
  11. </template>
  12. <script>
  13. import colors from "@/mixins/color";
  14. import template1 from './template/template1.vue';
  15. import template2 from './template/template2.vue';
  16. import template3 from './template/template3.vue';
  17. import template4 from './template/template4.vue';
  18. import pageFooter from '@/components/pageFooter/index.vue'
  19. import { colorChange } from '@/api/api.js';
  20. import { mapGetters } from 'vuex';
  21. export default {
  22. computed: {
  23. ...mapGetters(['isLogin', 'uid', 'diyCategory']),
  24. //diyCategory 暴露两个属性 level 和 index ,分别为分类等级和模板下标
  25. level(){
  26. return this.diyCategory.level
  27. },
  28. activeIndex(){
  29. return this.diyCategory.index
  30. },
  31. showTemplateTwo(){
  32. if(([2,3].includes(this.activeIndex) && this.level == 2) || ([1,2].includes(this.activeIndex) && this.level == 3)){
  33. return true
  34. }
  35. },
  36. showTemplateThree(){
  37. if([1,4].includes(this.activeIndex) && this.level == 2){
  38. return true
  39. }
  40. },
  41. showTemplateFour(){
  42. if((this.activeIndex == 5 && this.level == 2) || (this.activeIndex == 3 && this.level == 3)){
  43. return true
  44. }
  45. }
  46. },
  47. components: {
  48. template1,
  49. template2,
  50. template3,
  51. template4,
  52. pageFooter
  53. },
  54. mixins: [colors],
  55. provide(){
  56. return {
  57. parent:this
  58. }
  59. },
  60. data() {
  61. return {
  62. isFooter:false,
  63. showBar:false,
  64. pdHeight:0
  65. }
  66. },
  67. onUnload(){
  68. uni.$off('newAttrNum')
  69. },
  70. methods: {
  71. newDataStatus(val,num){
  72. this.isFooter = val ? true : false;
  73. this.showBar = val ? true : false;
  74. this.pdHeight = num;
  75. },
  76. toggleBar(val){
  77. this.showBar = val;
  78. }
  79. },
  80. onPageScroll(e) {
  81. if(this.showTemplateFour || this.showTemplateTwo){
  82. uni.$emit('scroll', e.scrollTop);
  83. }
  84. },
  85. onReachBottom() {
  86. if(this.showTemplateFour){
  87. this.$refs.classFour.productslist();
  88. }
  89. if(this.showTemplateTwo){
  90. uni.$emit('onReachBottom');
  91. }
  92. }
  93. }
  94. </script>