tpl_goods.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <template>
  2. <div class="layout">
  3. <div class="goods-cell-title">
  4. <div class="goods-item-title" :class="{ 'selected-title': selected.index == index }" @click="handleClickTitle(title, index)" v-for="(title, index) in res.list[0].titleWay" :key="index">
  5. <h4 class="h4">{{ title.title }}</h4>
  6. <div>{{ title.desc }}</div>
  7. </div>
  8. </div>
  9. <div class="goods-list">
  10. <div v-if="selected.val == item.type" @click="handleClick(item)" class="goods-item" v-for="(item, item_index) in res.list[0].listWay" :key="item_index">
  11. <div class="goods-img">
  12. <u-image :src="item.img" height="350rpx" mode="aspectFit" width="100%">
  13. <u-loading slot="loading"></u-loading>
  14. </u-image>
  15. </div>
  16. <div class="goods-desc">
  17. <div class="goods-title">
  18. {{ item.title }}
  19. </div>
  20. <div class="goods-bottom">
  21. <div class="goods-price">¥{{ item.price | unitPrice }}</div>
  22. </div>
  23. </div>
  24. </div>
  25. </div>
  26. </div>
  27. </template>
  28. <script>
  29. export default {
  30. title: "商品分类以及商品",
  31. data() {
  32. return {
  33. selected: {
  34. index: 0,
  35. val: "精选",
  36. },
  37. };
  38. },
  39. props: ["res"],
  40. mounted() {},
  41. methods: {
  42. handleClick(item) {
  43. uni.navigateTo({
  44. url: `/pages/product/goods?id=${item.id}&goodsId=${item.goodsId}`,
  45. });
  46. },
  47. closeGoods(val, index) {
  48. this.res.list[0].listWay.splice(index, 1);
  49. },
  50. handleClickTitle(val, index) {
  51. this.selected.index = index;
  52. this.selected.val = val.title;
  53. },
  54. },
  55. };
  56. </script>
  57. <style lang="scss" scoped>
  58. $w_94: 94%;
  59. .layout {
  60. padding: 8px 0;
  61. background: #f9f9f9;
  62. }
  63. .selected-title {
  64. > h4 {
  65. font-size: 30rpx;
  66. color: #000 !important;
  67. }
  68. > div {
  69. font-weight: bold;
  70. color: $main-color !important;
  71. }
  72. }
  73. .goods-cell-title {
  74. padding: 10px;
  75. transition: 0.35s;
  76. display: flex;
  77. cursor: pointer;
  78. > .goods-item-title {
  79. flex: 1;
  80. text-align: center;
  81. > h4 {
  82. font-size: 32rpx;
  83. }
  84. > div {
  85. color: #999;
  86. font-size: 24rpx;
  87. }
  88. }
  89. }
  90. .goods-list {
  91. width: 100%;
  92. display: flex;
  93. flex-wrap: wrap;
  94. }
  95. .goods-item {
  96. width: 50%;
  97. margin-bottom: 10px;
  98. border-radius: 0.4em;
  99. overflow: hidden;
  100. }
  101. .goods-img {
  102. position: relative;
  103. margin: 0 auto;
  104. // width: 158px;
  105. width: $w_94;
  106. border-top-left-radius: 20rpx;
  107. border-top-right-radius: 20rpx;
  108. overflow: hidden;
  109. > img {
  110. width: 100%;
  111. height: 100%;
  112. }
  113. }
  114. .goods-desc {
  115. border-bottom-left-radius: 20rpx;
  116. border-bottom-right-radius: 20rpx;
  117. width: $w_94;
  118. background: #fff;
  119. padding: 8rpx 0 8rpx 8rpx;
  120. margin: 0 auto;
  121. > .goods-title {
  122. font-size: 24rpx;
  123. height: 70rpx;
  124. display: -webkit-box;
  125. font-weight: 500;
  126. -webkit-box-orient: vertical;
  127. -webkit-line-clamp: 2;
  128. overflow: hidden;
  129. }
  130. > .goods-bottom {
  131. display: flex;
  132. font-weight: bold;
  133. > .goods-price {
  134. line-height: 2;
  135. color: $main-color;
  136. }
  137. }
  138. }
  139. .goods-icon {
  140. right: 10rpx;
  141. top: 10rpx;
  142. position: absolute;
  143. }
  144. </style>