app-index-cat.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <template>
  2. <view class="u-index-cat">
  3. <view v-for="item in newData" :key="item.relation_id">
  4. <view class="cross-center cat-top" @click="route(item.relation_id)">
  5. <view class="box-grow-1 main-center">
  6. <image v-if="item.cat_pic_url" class="cat-pic-url" :src="item.cat_pic_url" ></image>
  7. <text class="u-cat-name">{{item.name}}</text>
  8. </view>
  9. <view class="cross-center u-more">
  10. <text class="u-more-text">更多</text>
  11. <image class="u-arrow-right" src="/static/image/icon/arrow-right.png"></image>
  12. </view>
  13. </view>
  14. <u-ordinary-list @buyProduct="buyProduct" :is-under-line-price="isListUnderlinePrice == 1 ? true : false" :list="item.goods" :theme="theme" :list-style="item.list_style | listStyle"></u-ordinary-list>
  15. </view>
  16. </view>
  17. </template>
  18. <script>
  19. import uOrdinaryList from '../../page-component/u-goods-list/u-ordinary-list.vue';
  20. import {mapState} from "vuex";
  21. export default {
  22. name: "app-index-cat",
  23. components: {
  24. uOrdinaryList
  25. },
  26. props: {
  27. theme: {
  28. type: Object
  29. },
  30. page_id: {
  31. type: Number
  32. },
  33. index: {
  34. type: Number
  35. },
  36. is_required: {
  37. type: Boolean
  38. }
  39. },
  40. data() {
  41. return {
  42. newData: {}
  43. }
  44. },
  45. methods: {
  46. route(relation_id) {
  47. uni.navigateTo({
  48. url: `/pages/goods/list?cat_id=${relation_id}`
  49. });
  50. },
  51. loadData() {
  52. this.$request({
  53. url: this.$api.index.extra,
  54. data: {
  55. type: 'mall',
  56. key: 'cat',
  57. page_id: this.page_id,
  58. index: this.index
  59. }
  60. }).then(e => {
  61. this.newData = e.data;
  62. if (e.code === 0 && e.data) {
  63. let storage = this.$storage.getStorageSync('INDEX_MALL');
  64. console.log(storage);
  65. storage.home_pages[this.index].list = this.newData;
  66. this.$storage.setStorageSync('INDEX_MALL', storage);
  67. }
  68. });
  69. },
  70. getStorage() {
  71. let storage = this.$storage.getStorageSync('INDEX_MALL');
  72. this.newData = storage.home_pages[this.index].list;
  73. },
  74. buyProduct(data) {
  75. this.$emit('buyProduct', data);
  76. }
  77. },
  78. mounted() {
  79. this.is_required ? this.loadData() : this.getStorage();
  80. },
  81. computed: {
  82. ...mapState({
  83. isListUnderlinePrice: state => state.mallConfig.mall.setting.is_list_underline_price
  84. })
  85. },
  86. filters: {
  87. listStyle(list_style) {
  88. return list_style === 1 ? -1 : list_style === 2 ? 2 : list_style === 3 ? 3 : null;
  89. }
  90. }
  91. }
  92. </script>
  93. <style scoped lang="scss">
  94. .u-index-cat {
  95. background-color: #ffffff;
  96. }
  97. .cat-top {
  98. height: 80upx;
  99. padding: 0 24upx;
  100. position: relative;
  101. }
  102. .u-cat-name {
  103. color: #353535;
  104. font-size: 28upx;
  105. }
  106. .cat-pic-url {
  107. width: 40upx;
  108. height: 40upx;
  109. margin-right: 24upx;
  110. }
  111. .u-more {
  112. position: absolute;
  113. right: 24upx;
  114. top: 0;
  115. z-index: 10;
  116. height: 100%;
  117. }
  118. .u-more-text {
  119. font-size: 26upx;
  120. color: #999999;
  121. }
  122. .u-arrow-right {
  123. width: 12upx;
  124. height: 24upx;
  125. margin-left: 12upx;
  126. }
  127. </style>