goods_cate.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <template>
  2. <view class="goods-cate">
  3. <router-link to="/pages/goods_search/goods_search">
  4. <view class="header"><u-search bg-color="#F4F4F4" :disabled="true"></u-search></view>
  5. </router-link>
  6. <view class="content" v-if="appConfig.cate_style == 1 || appConfig.cate_style == 4"><cate-two :cate-list="cateList"></cate-two></view>
  7. <view class="content bg-body" v-if="appConfig.cate_style == 3 || appConfig.cate_style == 2"><cate-one :cate-list="cateList"></cate-one></view>
  8. </view>
  9. </template>
  10. <script>
  11. import { getLevelOneList, getGoodsList, getListByLevelOne } from '@/api/store';
  12. import { getRect, trottle, arraySlice } from '@/utils/tools';
  13. import { mapGetters, mapActions } from 'vuex';
  14. import Cache from '@/utils/cache';
  15. export default {
  16. data() {
  17. return {
  18. cateList: [],
  19. cateTwoList: [],
  20. selectIndex: 0,
  21. id: ''
  22. };
  23. },
  24. async onLoad(options) {
  25. if (options.id) {
  26. this.id = options.id;
  27. }
  28. this.getLevelOneListFun();
  29. // this.getListByLevelOneFun()
  30. },
  31. onShow() {
  32. this.getCartNum();
  33. },
  34. methods: {
  35. ...mapActions(['getCartNum']),
  36. async getLevelOneListFun() {
  37. const obj = this;
  38. if (obj.id != '') {
  39. const { code, data } = await getListByLevelOne({ id: obj.id });
  40. if (code == 1) {
  41. console.log(data);
  42. this.cateList = data;
  43. }
  44. } else {
  45. const { code, data } = await getLevelOneList();
  46. if (code == 1) {
  47. let arr = [];
  48. if (obj.id != '') {
  49. arr = data.filter(e => {
  50. console.log(e);
  51. return e.id == obj.id;
  52. });
  53. } else {
  54. arr = data;
  55. }
  56. this.cateList = arr;
  57. console.log(this.cateList, '1234');
  58. }
  59. }
  60. }
  61. },
  62. computed: {
  63. ...mapGetters(['inviteCode', 'appConfig'])
  64. }
  65. // onBackPress() {
  66. // console.log("页面返回")
  67. // return true
  68. // }
  69. };
  70. </script>
  71. <style lang="scss" scoped>
  72. $header-height: 94rpx;
  73. page {
  74. background-color: #fff;
  75. .goods-cate {
  76. .header {
  77. box-sizing: border-box;
  78. height: $header-height;
  79. border-bottom: $-solid-border;
  80. .search {
  81. flex: 1;
  82. height: 60rpx;
  83. input {
  84. flex: 1;
  85. height: 100%;
  86. }
  87. }
  88. }
  89. .content {
  90. height: calc(100vh - #{$header-height} - var(--window-top) - var(--window-bottom));
  91. }
  92. }
  93. }
  94. </style>