productItem.vue 4.4 KB

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