3
0

goods.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <template>
  2. <view class="goods" :style="{height:getGoodsHeight + 'rpx!important'}">
  3. <view class="top">
  4. <h3>商品列表</h3>
  5. <u-search placeholder="搜索" v-model="keyword" :showAction="false"></u-search>
  6. </view>
  7. <view class="goodsBox">
  8. <view class="left">
  9. <view class="a1">111</view>
  10. <view class="a2">222</view>
  11. </view>
  12. <view class="right">
  13. <view class="goodsLi" v-for="(item,index) in goodsList" :key="index" @click="activeGoods(item)"
  14. :class="activeList.some(i => i.goodsId === item.goodsId)?'activeGoodsLi':''">
  15. <view class="title">
  16. {{item.goodsName}}
  17. </view>
  18. <view class="priceA">
  19. ¥{{item.priceB}} + {{item.internage}}积分
  20. </view>
  21. <view class="priceB">
  22. 原价:<text>{{item.priceA}}元</text>
  23. </view>
  24. <img v-if="activeList.some(i => i.goodsId === item.goodsId)" class="icon"
  25. src="@/static/images/icon_gx@2x.png" alt="">
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. </template>
  31. <script>
  32. import {
  33. mapGetters
  34. } from "vuex"
  35. export default {
  36. data() {
  37. return {
  38. keyword: "",
  39. goodsList: [{
  40. goodsId: 1,
  41. goodsName: "A鲁花花生油鲁花花生油鲁花花生油花生油",
  42. priceA: 2200.58,
  43. priceB: 2045.99,
  44. internage: 200,
  45. }, {
  46. goodsId: 2,
  47. goodsName: "B鲁花花生油鲁花花生油鲁花花生油花生油",
  48. priceA: 2200.58,
  49. priceB: 2045.99,
  50. internage: 200,
  51. }, {
  52. goodsId: 3,
  53. goodsName: "C鲁花花生油鲁花花生油鲁花花生油花生油",
  54. priceA: 2200.58,
  55. priceB: 2045.99,
  56. internage: 200,
  57. }],
  58. activeList: [],
  59. }
  60. },
  61. computed: {
  62. ...mapGetters(['getGoodsHeight'])
  63. },
  64. onLoad() {
  65. console.log()
  66. },
  67. methods: {
  68. activeGoods(row) {
  69. const CheckExistInt = this.activeList.findIndex(i => i.goodsId === row.goodsId)
  70. if (CheckExistInt === -1) {
  71. this.activeList.push(row)
  72. } else {
  73. this.activeList.splice(CheckExistInt, 1)
  74. }
  75. }
  76. }
  77. }
  78. </script>
  79. <style lang="scss" scoped>
  80. .goods {
  81. border-top-left-radius: 32rpx;
  82. border-top-right-radius: 32rpx;
  83. background-color: #fff;
  84. margin-top: -52rpx;
  85. display: flex;
  86. flex-direction: column;
  87. &>.top {
  88. height: 144rpx;
  89. padding: 32rpx;
  90. display: flex;
  91. align-items: center;
  92. justify-content: space-between;
  93. &>h3 {
  94. font-weight: bold;
  95. color: #222;
  96. font-size: 32rpx;
  97. margin-right: 50rpx;
  98. }
  99. }
  100. &>.goodsBox {
  101. flex: 1;
  102. height: 1px;
  103. display: flex;
  104. &>.left {
  105. overflow: auto;
  106. width: 192rpx;
  107. height: 100%;
  108. background-color: #a4a4a4;
  109. flex-shrink: 0;
  110. &>.a1 {
  111. height: 600rpx;
  112. background-color: red;
  113. }
  114. &>.a2 {
  115. height: 600rpx;
  116. background-color: skyblue;
  117. }
  118. }
  119. &>.right {
  120. overflow: auto;
  121. margin: 0rpx 24rpx 0rpx 40rpx;
  122. height: 100%;
  123. flex: 1;
  124. &>.activeGoodsLi {
  125. border: 2rpx solid #F57737 !important;
  126. }
  127. &>.goodsLi {
  128. position: relative;
  129. padding: 28rpx 36rpx 32rpx 28rpx;
  130. background-color: #F9F9F9;
  131. border-radius: 28rpx;
  132. overflow: hidden;
  133. margin-bottom: 32rpx;
  134. border: 2rpx solid transparent;
  135. &>.icon {
  136. width: 32rpx;
  137. height: 32rpx;
  138. position: absolute;
  139. bottom: 0;
  140. right: 0;
  141. }
  142. &>.title {
  143. margin-bottom: 24rpx;
  144. color: #222;
  145. font-size: 28rpx;
  146. font-weight: 500;
  147. overflow: hidden;
  148. -webkit-line-clamp: 1;
  149. text-overflow: ellipsis;
  150. display: -webkit-box;
  151. -webkit-box-orient: vertical;
  152. }
  153. &>.priceA {
  154. flex: 1;
  155. color: #EB5757;
  156. font-weight: bold;
  157. font-size: 32rpx;
  158. margin-bottom: 8rpx;
  159. }
  160. &>.priceB {
  161. flex: 1;
  162. font-size: 24rpx;
  163. color: #828282;
  164. &>text {
  165. text-decoration: line-through;
  166. }
  167. }
  168. }
  169. }
  170. }
  171. }
  172. </style>