goods_cate.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <template>
  2. <!-- 商品分类 -->
  3. <view :style="colorStyle">
  4. <!-- 商品分类的三种样式布局 -->
  5. <goodsCate1 v-show="category==1" ref="classOne" :isFooter="isFooter"></goodsCate1>
  6. <goodsCate2 v-show="category==2" ref="classTwo" :isFooter="isFooter"></goodsCate2>
  7. <goodsCate3 v-show="category==3" ref="classThree" :isFooter="isFooter"></goodsCate3>
  8. <pageFooter @newDataStatus="newDataStatus"></pageFooter>
  9. </view>
  10. </template>
  11. <script>
  12. import colors from "@/mixins/color";
  13. import goodsCate1 from './goods_cate1';
  14. import goodsCate2 from './goods_cate2';
  15. import goodsCate3 from './goods_cate3';
  16. import pageFooter from '@/components/pageFooter/index.vue'
  17. import {
  18. colorChange
  19. } from '@/api/api.js';
  20. import {
  21. mapGetters
  22. } from 'vuex';
  23. export default {
  24. computed: mapGetters(['isLogin', 'uid']),
  25. components: {
  26. goodsCate1,
  27. goodsCate2,
  28. goodsCate3,
  29. pageFooter
  30. },
  31. mixins: [colors],
  32. data() {
  33. return {
  34. category:'',
  35. isFooter:false
  36. }
  37. },
  38. onLoad(options) {
  39. this.classStyle();
  40. },
  41. onUnload(){
  42. uni.$off('newAttrNum')
  43. },
  44. onReady() {
  45. },
  46. onShow() {
  47. console.log(this.category,'this.category')
  48. if(this.category==2){
  49. this.$refs.classTwo.getNoCart();
  50. this.$refs.classTwo.getCartList(1);
  51. }else if(this.category==3){
  52. this.$refs.classThree.getNoCart();
  53. this.$refs.classThree.getCartList(1);
  54. }
  55. // if(uni.getStorageSync('form_type_cart')){
  56. // this.classStyle();
  57. // }
  58. },
  59. methods: {
  60. newDataStatus(val){
  61. this.isFooter = val;
  62. },
  63. otherFun(object){
  64. if(!!object){
  65. if(this.category==2){
  66. this.$refs.classTwo.updateFun(object);
  67. }
  68. if(this.category==3){
  69. this.$refs.classThree.updateFun(object);
  70. }
  71. }
  72. },
  73. classStyle(){
  74. colorChange('category').then(res=>{
  75. let status = res.data.status;
  76. this.category = status;
  77. console.log(this.category,'this.category')
  78. if(status==1){
  79. this.$refs.classOne.getAllCategory();
  80. }
  81. if(status==2){
  82. if(this.isLogin){
  83. this.$refs.classTwo.getCartList(1);
  84. }
  85. this.$refs.classTwo.getAllCategory();
  86. this.$refs.classTwo.getMarTop();
  87. }
  88. if(status==3){
  89. if(this.isLogin){
  90. this.$refs.classThree.getCartList(1);
  91. }
  92. this.$refs.classThree.getAllCategory();
  93. this.$refs.classThree.getMarTop();
  94. }
  95. })
  96. }
  97. },
  98. onReachBottom: function() {
  99. if(this.category==2){
  100. this.$refs.classTwo.productslist();
  101. }
  102. if(this.category==3){
  103. this.$refs.classThree.productslist();
  104. }
  105. }
  106. }
  107. </script>
  108. <style scoped lang="scss">
  109. /deep/.goodCate .uni-badge-left-margin .uni-badge--error{
  110. background-color: #fff !important;
  111. color: var(--view-theme);
  112. border-color: var(--view-theme);
  113. z-index: 8;
  114. }
  115. /deep/.goodCate .footer .cartIcon .uni-badge-left-margin .uni-badge--error{
  116. right: 0 !important;
  117. top: 10px !important;
  118. }
  119. /deep/.mask{
  120. z-index: 99;
  121. }
  122. </style>