productItem.vue 3.9 KB

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