productItem.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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.productMsg ? item.productMsg+'?x-oss-process=image/resize,p_30':'/static/def_imgs.png'" style="height: 140px;width: 100%;"></image>
  12. <view class="back-price" v-if="item.dealerScopeFlag==0">售罄</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" v-if="!!item.productOrigCode"><text class="ellipsis-two" max-lines="2" overflow="ellipsis">{{item.productOrigCode}}</text></view>
  18. <view class="product-button">
  19. <view class="price-txt flex align_center">¥<text>{{isLogin ? item.price : '***'}}</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. isLogin: {
  48. type: Boolean,
  49. default: false
  50. }
  51. },
  52. data() {
  53. return {
  54. }
  55. },
  56. methods: {
  57. toDetail(item){
  58. uni.navigateTo({
  59. url:'/pagesB/shopiing/productDetail?sn='+item.shopProductSn
  60. })
  61. this.$emit('detail',item)
  62. },
  63. },
  64. }
  65. </script>
  66. <style lang="less">
  67. /* 显示一行省略号 */
  68. .ellipsis-one{
  69. white-space: nowrap;
  70. text-overflow: ellipsis;
  71. overflow: hidden;
  72. word-break: break-all;
  73. }
  74. /* 显示两行,省略号 */
  75. .ellipsis-two{
  76. overflow: hidden;
  77. text-overflow: ellipsis;
  78. display: -webkit-box;
  79. -webkit-line-clamp: 2;
  80. line-clamp: 2;
  81. -webkit-box-orient: vertical;
  82. }
  83. .product-list{
  84. display:flex;
  85. flex-wrap: wrap;
  86. justify-content: space-between;
  87. padding: 0;
  88. width: 100%;
  89. }
  90. .product-item{
  91. background: #ffffff;
  92. border-radius: 10upx;
  93. box-shadow: 1px 1px 3px #EEEEEE;
  94. width: 48%;
  95. margin: 10px 0 0 0;
  96. display: flex;
  97. flex-direction: column;
  98. .price-txt{
  99. color: red;
  100. display: flex;
  101. align-items: center;
  102. text{
  103. font-size: 36rpx;
  104. }
  105. }
  106. > view{
  107. &:first-child{
  108. position: relative;
  109. overflow: hidden;
  110. .product-code{
  111. color: #666;
  112. position: absolute;
  113. width: 100%;
  114. left:0;
  115. bottom:0;
  116. background: rgba(255,255,255,0.7);
  117. text-align: center;
  118. }
  119. }
  120. &:last-child{
  121. position: relative;
  122. flex-grow: 1;
  123. padding: 10px 10px 40px;
  124. .product-name{
  125. font-size: 28rpx;
  126. color: #333;
  127. }
  128. .product-guige{
  129. margin: 10rpx 0;
  130. color: #2196F3;
  131. }
  132. }
  133. .product-button{
  134. position: absolute;
  135. left: 5%;
  136. bottom: 0;
  137. width: 90%;
  138. padding: 5px 0 10px;
  139. display: flex;
  140. justify-content: space-between;
  141. align-items: center;
  142. button{
  143. display: flex;
  144. align-items: center;
  145. text-align: center;
  146. justify-content: center;
  147. min-width:50rpx;
  148. height: 50rpx;
  149. font-size: 28rpx;
  150. border-radius: 25rpx;
  151. padding: 0 10rpx;
  152. color: #fff;
  153. &:active{
  154. background: #2abcff;
  155. }
  156. }
  157. .bg-0{
  158. background: #066cff;
  159. }
  160. .bg-1{
  161. background: #34aa0a;
  162. }
  163. }
  164. }
  165. .back-price{
  166. padding: 6rpx 65rpx;
  167. background: #ececec;
  168. position: absolute;
  169. top: 18rpx;
  170. right: -45rpx;
  171. color: #666;
  172. z-index: 2;
  173. font-size: 20rpx;
  174. text-align: center;
  175. transform: rotate(40deg);
  176. display: flex;
  177. align-items: center;
  178. text{
  179. font-size: 28rpx;
  180. margin: 0 5rpx;
  181. }
  182. }
  183. }
  184. </style>