productItem.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <template>
  2. <view
  3. class="product-list"
  4. >
  5. <view
  6. class="product-item"
  7. :style="{width:itemWidth+'px',marginTop:gap+'px'}"
  8. v-for="(item,index) in list"
  9. :key="item.id" @click="toDetail(item)">
  10. <view>
  11. <image mode="aspectFit" :src="item.productImage+'?x-oss-process=image/resize,p_30'" style="height: 140px;width: 100%;"></image>
  12. <!-- <view class="back-price" v-if="item.promoRuleValue">返<text>{{item.promoRuleValue}}</text>元</view> -->
  13. <view class="product-code"><text class="ellipsis-one" overflow="ellipsis">{{item.productCode}}</text></view>
  14. </view>
  15. <view>
  16. <view class="product-name ellipsis-two">{{item.productName}}</view>
  17. <view class="product-guige"><text class="ellipsis-two" max-lines="2" overflow="ellipsis">{{item.productOrigCode}}</text></view>
  18. <view class="product-button">
  19. <view class="price-txt">¥<text>{{item.cost}}</text></view>
  20. <view>
  21. </view>
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. </template>
  27. <script>
  28. export default {
  29. name: 'productItem',
  30. props: {
  31. list: {
  32. type: Array,
  33. default: () => []
  34. },
  35. index:{
  36. type: [Number,String],
  37. default: 0
  38. },
  39. gap:{
  40. type: [Number,String],
  41. default: 10
  42. },
  43. itemWidth:{
  44. type: [Number,String],
  45. default: 0
  46. }
  47. },
  48. data() {
  49. return {
  50. }
  51. },
  52. methods: {
  53. toDetail(item){
  54. uni.navigateTo({
  55. url:'/pagesB/shopiing/productDetail?sn='+item.productSn
  56. })
  57. this.$emit('detail',item)
  58. },
  59. },
  60. }
  61. </script>
  62. <style lang="less">
  63. /* 显示一行省略号 */
  64. .ellipsis-one{
  65. white-space: nowrap;
  66. text-overflow: ellipsis;
  67. overflow: hidden;
  68. word-break: break-all;
  69. }
  70. /* 显示两行,省略号 */
  71. .ellipsis-two{
  72. overflow: hidden;
  73. text-overflow: ellipsis;
  74. display: -webkit-box;
  75. -webkit-line-clamp: 2;
  76. line-clamp: 2;
  77. -webkit-box-orient: vertical;
  78. }
  79. .product-list{
  80. display:flex;
  81. flex-wrap: wrap;
  82. justify-content: space-between;
  83. padding: 0;
  84. width: 100%;
  85. }
  86. .product-item{
  87. background: #ffffff;
  88. border-radius: 10upx;
  89. box-shadow: 1px 1px 3px #EEEEEE;
  90. width: 48%;
  91. margin: 10px 0 0 0;
  92. display: flex;
  93. flex-direction: column;
  94. .price-txt{
  95. color: red;
  96. display: flex;
  97. align-items: center;
  98. text{
  99. font-size: 36rpx;
  100. }
  101. }
  102. > view{
  103. &:first-child{
  104. position: relative;
  105. overflow: hidden;
  106. .product-code{
  107. color: #666;
  108. position: absolute;
  109. width: 100%;
  110. left:0;
  111. bottom:0;
  112. background: rgba(255,255,255,0.7);
  113. text-align: center;
  114. }
  115. }
  116. &:last-child{
  117. position: relative;
  118. flex-grow: 1;
  119. padding: 10px 10px 40px;
  120. .product-name{
  121. font-size: 28rpx;
  122. color: #333;
  123. }
  124. .product-guige{
  125. margin: 10rpx 0;
  126. color: #2196F3;
  127. }
  128. }
  129. .product-button{
  130. position: absolute;
  131. left: 5%;
  132. bottom: 0;
  133. width: 90%;
  134. padding: 5px 0 10px;
  135. display: flex;
  136. justify-content: space-between;
  137. align-items: center;
  138. button{
  139. display: flex;
  140. align-items: center;
  141. text-align: center;
  142. justify-content: center;
  143. min-width:50rpx;
  144. height: 50rpx;
  145. font-size: 28rpx;
  146. border-radius: 25rpx;
  147. padding: 0 10rpx;
  148. color: #fff;
  149. &:active{
  150. background: #2abcff;
  151. }
  152. }
  153. .bg-0{
  154. background: #066cff;
  155. }
  156. .bg-1{
  157. background: #34aa0a;
  158. }
  159. }
  160. }
  161. .back-price{
  162. padding: 6rpx 65rpx;
  163. background: rgba(255 ,87 ,34 , 1);
  164. position: absolute;
  165. top: 18rpx;
  166. right: -45rpx;
  167. color: #fff;
  168. z-index: 2;
  169. font-size: 20rpx;
  170. text-align: center;
  171. transform: rotate(40deg);
  172. display: flex;
  173. align-items: center;
  174. text{
  175. font-size: 28rpx;
  176. margin: 0 5rpx;
  177. }
  178. }
  179. }
  180. </style>