index.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <template>
  2. <view class="index">
  3. <!-- section -->
  4. <view class="section">
  5. <view v-for="(item, index) in typeList" :key="index" class="item padding bg-white ">
  6. <view class="flex">
  7. <view style="width: 20upx;background-color: #4d6bab;" class="margin-right-xs"></view>
  8. <view style="flex: auto; background-image: linear-gradient(120deg,#4d6bab 0%, #fff 80%);" class="padding-tb-sm text-white bg-white padding-left-sm">
  9. {{ item.name }}
  10. <!-- <view @click="commodityFunc(item.id)" class="text-grey" style="float: right;">
  11. 查看更多<text class="cuIcon-right"></text>
  12. </view> -->
  13. </view>
  14. </view>
  15. <view class="content padding-tb flex flex-wrap align-center">
  16. <view
  17. @click="handler(it.id)"
  18. v-for="(it, ind) in item.commodity_list"
  19. :key="ind"
  20. class="content-item margin-bottom"
  21. style="width: calc(100vw / 3 - 40upx);border-radius: 20upx;overflow: hidden;"
  22. >
  23. <image
  24. style="width: calc(100vw / 3 - 40upx);height: calc(100vw / 3 - 40upx);"
  25. lazy-load="true"
  26. :src="it.show_image_url | lazyImage"
  27. mode="aspectFit"
  28. ></image>
  29. <view class="padding-xs">
  30. <view class="name text-black">{{ it.name }}</view>
  31. <view class="text-gray">销量:{{ it.sale_count }}</view>
  32. <view class="flex justify-between ">
  33. <view>
  34. <view v-if="it.type == 1" class="text-red text-price"><cu-price :value="it.price" size="32" /></view>
  35. <view v-else class="text-yellow">{{ it.point_price }}积分</view>
  36. <view class="bg-orange light text-xs padding-lr-xs">
  37. <text class="cuIcon-vip lg"></text>
  38. <text class="text-price margin-left-xs">{{ it.vip_price }}</text>
  39. </view>
  40. </view>
  41. <text class="cuIcon-cart text-xl"></text>
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. <!-- footer -->
  49. <cu-bar active="0" />
  50. </view>
  51. </template>
  52. <script>
  53. import { mapState } from 'vuex';
  54. import api from './api.js';
  55. export default {
  56. data() {
  57. return {
  58. typeList: []
  59. };
  60. },
  61. computed: {
  62. ...mapState(['customer_id'])
  63. },
  64. async onLoad(options) {
  65. let { referrer } = options;
  66. if (referrer) uni.setStorageSync('referrer', referrer);
  67. var result = await api.index();
  68. if (result.code != 0) return false;
  69. if (result.data.length == 0) return false;
  70. result.data = result.data.filter(item => {
  71. return item['commodity_list'] && item['commodity_list'].length > 0;
  72. });
  73. this.typeList = result.data;
  74. },
  75. methods: {
  76. handler(id) {
  77. uni.navigateTo({
  78. url: `/pages/detail/index?id=${id}`
  79. });
  80. },
  81. commodityFunc(id){
  82. uni.switchTab({
  83. url:`/pages/commodity/index`
  84. })
  85. }
  86. },
  87. onShareAppMessage() {
  88. return {
  89. title: '首页',
  90. path: '/pages/index/index?referrer=' + this.customer_id
  91. };
  92. },
  93. onShareTimeline() {
  94. return {
  95. title: '首页',
  96. query: 'referrer=' + this.customer_id
  97. };
  98. }
  99. };
  100. </script>
  101. <style lang="scss" scoped>
  102. .index {
  103. .section {
  104. .item {
  105. .content {
  106. .content-item {
  107. margin-right: 30upx;
  108. image {
  109. vertical-align: top;
  110. }
  111. .name {
  112. text-align: justify;
  113. display: -webkit-box;
  114. overflow: hidden;
  115. text-overflow: ellipsis;
  116. -webkit-line-clamp: 2;
  117. -webkit-box-orient: vertical;
  118. }
  119. }
  120. .content-item:nth-child(3n) {
  121. margin-right: 0;
  122. }
  123. }
  124. }
  125. }
  126. }
  127. </style>