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">
  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. import { toAuthStore, toLogin } from "@/utils/index.js"
  31. export default {
  32. name: 'productItem',
  33. props: {
  34. list: {
  35. type: Array,
  36. default: () => []
  37. },
  38. index:{
  39. type: [Number,String],
  40. default: 0
  41. },
  42. gap:{
  43. type: [Number,String],
  44. default: 10
  45. },
  46. itemWidth:{
  47. type: [Number,String],
  48. default: 0
  49. },
  50. isLogin: {
  51. type: Boolean,
  52. default: false
  53. },
  54. sysUserFlag:{
  55. type: String,
  56. default: '1'
  57. }
  58. },
  59. data() {
  60. return {
  61. }
  62. },
  63. methods: {
  64. toDetail(item){
  65. if(this.isLogin){
  66. // 游客去认证
  67. if(this.sysUserFlag == '0'){
  68. toAuthStore()
  69. return true
  70. }
  71. }else{
  72. toLogin()
  73. return true
  74. }
  75. uni.navigateTo({
  76. url:'/pagesB/shopiing/productDetail?sn='+item.shopProductSn
  77. })
  78. this.$emit('detail',item)
  79. },
  80. },
  81. }
  82. </script>
  83. <style lang="less">
  84. /* 显示一行省略号 */
  85. .ellipsis-one{
  86. white-space: nowrap;
  87. text-overflow: ellipsis;
  88. overflow: hidden;
  89. word-break: break-all;
  90. }
  91. /* 显示两行,省略号 */
  92. .ellipsis-two{
  93. overflow: hidden;
  94. text-overflow: ellipsis;
  95. display: -webkit-box;
  96. -webkit-line-clamp: 2;
  97. line-clamp: 2;
  98. -webkit-box-orient: vertical;
  99. }
  100. .product-list{
  101. display:flex;
  102. flex-wrap: wrap;
  103. justify-content: space-between;
  104. padding: 0;
  105. width: 100%;
  106. }
  107. .product-item{
  108. background: #ffffff;
  109. border-radius: 10upx;
  110. border: 1px solid #eee;
  111. width: 48%;
  112. margin: 10px 0 0 0;
  113. display: flex;
  114. flex-direction: column;
  115. .price-txt{
  116. color: red;
  117. display: flex;
  118. align-items: baseline;
  119. font-size: 12px;
  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>