productItem.vue 4.0 KB

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