goods_cate.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. if(this.category==2){
  48. this.$refs.classTwo.getNoCart();
  49. this.$refs.classTwo.getCartList(1);
  50. }else if(this.category==3){
  51. this.$refs.classThree.getNoCart();
  52. this.$refs.classThree.getCartList(1);
  53. }
  54. // if(uni.getStorageSync('form_type_cart')){
  55. // this.classStyle();
  56. // }
  57. },
  58. methods: {
  59. newDataStatus(val){
  60. this.isFooter = val;
  61. },
  62. otherFun(object){
  63. if(!!object){
  64. if(this.category==2){
  65. this.$refs.classTwo.updateFun(object);
  66. }
  67. if(this.category==3){
  68. this.$refs.classThree.updateFun(object);
  69. }
  70. }
  71. },
  72. classStyle(){
  73. colorChange('category').then(res=>{
  74. let status = res.data.status;
  75. this.category = status;
  76. if(status==1){
  77. this.$refs.classOne.getAllCategory();
  78. }
  79. if(status==2){
  80. if(this.isLogin){
  81. this.$refs.classTwo.getCartList(1);
  82. }
  83. this.$refs.classTwo.getAllCategory();
  84. this.$refs.classTwo.getMarTop();
  85. }
  86. if(status==3){
  87. if(this.isLogin){
  88. this.$refs.classThree.getCartList(1);
  89. }
  90. this.$refs.classThree.getAllCategory();
  91. this.$refs.classThree.getMarTop();
  92. }
  93. })
  94. }
  95. },
  96. onReachBottom: function() {
  97. if(this.category==2){
  98. this.$refs.classTwo.productslist();
  99. }
  100. if(this.category==3){
  101. this.$refs.classThree.productslist();
  102. }
  103. }
  104. }
  105. </script>
  106. <style scoped lang="scss">
  107. /deep/.goodCate .uni-badge-left-margin .uni-badge--error{
  108. background-color: #fff !important;
  109. color: var(--view-theme);
  110. border-color: var(--view-theme);
  111. z-index: 8;
  112. }
  113. /deep/.goodCate .footer .cartIcon .uni-badge-left-margin .uni-badge--error{
  114. right: 0 !important;
  115. top: 10px !important;
  116. }
  117. /deep/.mask{
  118. z-index: 99;
  119. }
  120. </style>