productItem.vue 4.7 KB

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