productItem.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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="isLogin&&sysUserFlag == '1'&&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">
  20. ¥<text>{{isLogin&&sysUserFlag == '1' ? item.price : '***'}}</text>
  21. </view>
  22. <view>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. </template>
  29. <script>
  30. export default {
  31. name: 'productItem',
  32. props: {
  33. list: {
  34. type: Array,
  35. default: () => []
  36. },
  37. index:{
  38. type: [Number,String],
  39. default: 0
  40. },
  41. gap:{
  42. type: [Number,String],
  43. default: 10
  44. },
  45. itemWidth:{
  46. type: [Number,String],
  47. default: 0
  48. },
  49. isLogin: {
  50. type: Boolean,
  51. default: false
  52. },
  53. sysUserFlag:{
  54. type: String,
  55. default: '1'
  56. }
  57. },
  58. data() {
  59. return {
  60. }
  61. },
  62. methods: {
  63. toDetail(item){
  64. if(this.isLogin){
  65. // 游客去认证
  66. if(this.sysUserFlag == '0'){
  67. uni.navigateTo({
  68. url: '/pages/storeManage/storeAuth'
  69. })
  70. return true
  71. }
  72. }else{
  73. uni.navigateTo({
  74. url: '/pages/login/login'
  75. })
  76. return true
  77. }
  78. uni.navigateTo({
  79. url:'/pagesB/shopiing/productDetail?sn='+item.shopProductSn
  80. })
  81. this.$emit('detail',item)
  82. },
  83. },
  84. }
  85. </script>
  86. <style lang="less">
  87. /* 显示一行省略号 */
  88. .ellipsis-one{
  89. white-space: nowrap;
  90. text-overflow: ellipsis;
  91. overflow: hidden;
  92. word-break: break-all;
  93. }
  94. /* 显示两行,省略号 */
  95. .ellipsis-two{
  96. overflow: hidden;
  97. text-overflow: ellipsis;
  98. display: -webkit-box;
  99. -webkit-line-clamp: 2;
  100. line-clamp: 2;
  101. -webkit-box-orient: vertical;
  102. }
  103. .product-list{
  104. display:flex;
  105. flex-wrap: wrap;
  106. justify-content: space-between;
  107. padding: 0;
  108. width: 100%;
  109. }
  110. .product-item{
  111. background: #ffffff;
  112. border-radius: 10upx;
  113. border: 1px solid #eee;
  114. width: 48%;
  115. margin: 10px 0 0 0;
  116. display: flex;
  117. flex-direction: column;
  118. .price-txt{
  119. color: red;
  120. display: flex;
  121. align-items: baseline;
  122. font-size: 12px;
  123. text{
  124. font-size: 36rpx;
  125. }
  126. }
  127. > view{
  128. &:first-child{
  129. position: relative;
  130. overflow: hidden;
  131. .product-code{
  132. color: #666;
  133. position: absolute;
  134. width: 100%;
  135. left:0;
  136. bottom:0;
  137. background: rgba(255,255,255,0.7);
  138. text-align: center;
  139. }
  140. }
  141. &:last-child{
  142. position: relative;
  143. flex-grow: 1;
  144. padding: 10px 10px 40px;
  145. .product-name{
  146. font-size: 28rpx;
  147. color: #333;
  148. }
  149. .product-guige{
  150. margin: 10rpx 0;
  151. color: #2196F3;
  152. }
  153. }
  154. .product-button{
  155. position: absolute;
  156. left: 5%;
  157. bottom: 0;
  158. width: 90%;
  159. padding: 5px 0 10px;
  160. display: flex;
  161. justify-content: space-between;
  162. align-items: center;
  163. button{
  164. display: flex;
  165. align-items: center;
  166. text-align: center;
  167. justify-content: center;
  168. min-width:50rpx;
  169. height: 50rpx;
  170. font-size: 28rpx;
  171. border-radius: 25rpx;
  172. padding: 0 10rpx;
  173. color: #fff;
  174. &:active{
  175. background: #2abcff;
  176. }
  177. }
  178. .bg-0{
  179. background: #066cff;
  180. }
  181. .bg-1{
  182. background: #34aa0a;
  183. }
  184. }
  185. }
  186. .back-price{
  187. padding: 6rpx 65rpx;
  188. background: #ececec;
  189. position: absolute;
  190. top: 18rpx;
  191. right: -45rpx;
  192. color: #666;
  193. z-index: 2;
  194. font-size: 20rpx;
  195. text-align: center;
  196. transform: rotate(40deg);
  197. display: flex;
  198. align-items: center;
  199. text{
  200. font-size: 28rpx;
  201. margin: 0 5rpx;
  202. }
  203. }
  204. }
  205. </style>