app-index-cat.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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.theme" :themeObject="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. storage.home_pages[this.index].list = this.newData;
  65. this.$storage.setStorageSync('INDEX_MALL', storage);
  66. }
  67. });
  68. },
  69. getStorage() {
  70. let storage = this.$storage.getStorageSync('INDEX_MALL');
  71. this.newData = storage.home_pages[this.index].list;
  72. },
  73. buyProduct(data) {
  74. this.$emit('buyProduct', data);
  75. }
  76. },
  77. mounted() {
  78. this.is_required ? this.loadData() : this.getStorage();
  79. },
  80. computed: {
  81. ...mapState({
  82. isListUnderlinePrice: state => state.mallConfig.mall.setting.is_list_underline_price
  83. })
  84. },
  85. filters: {
  86. listStyle(list_style) {
  87. return list_style === 1 ? -1 : list_style === 2 ? 2 : list_style === 3 ? 3 : null;
  88. }
  89. }
  90. }
  91. </script>
  92. <style scoped lang="scss">
  93. .u-index-cat {
  94. background-color: #ffffff;
  95. }
  96. .cat-top {
  97. height: 80upx;
  98. padding: 0 24upx;
  99. position: relative;
  100. }
  101. .u-cat-name {
  102. color: #353535;
  103. font-size: 28upx;
  104. }
  105. .cat-pic-url {
  106. width: 40upx;
  107. height: 40upx;
  108. margin-right: 24upx;
  109. }
  110. .u-more {
  111. position: absolute;
  112. right: 24upx;
  113. top: 0;
  114. z-index: 10;
  115. height: 100%;
  116. }
  117. .u-more-text {
  118. font-size: 26upx;
  119. color: #999999;
  120. }
  121. .u-arrow-right {
  122. width: 12upx;
  123. height: 24upx;
  124. margin-left: 12upx;
  125. }
  126. </style>