productItem.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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&&showBalanceAuth">
  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. computed:{
  77. // 抵扣余额支付是否可用
  78. showBalanceAuth(){
  79. return this.$store.state.vuex_showBalanceAuth
  80. },
  81. },
  82. methods: {
  83. toDetail(item){
  84. if(this.isLogin){
  85. // 游客去认证
  86. if(this.sysUserFlag == '0'){
  87. toAuthStore()
  88. return true
  89. }
  90. }else{
  91. toLogin()
  92. return true
  93. }
  94. uni.navigateTo({
  95. url:'/pagesB/shopiing/productDetail?sn='+item.shopProductSn
  96. })
  97. this.$emit('detail',item)
  98. },
  99. },
  100. }
  101. </script>
  102. <style lang="less">
  103. /* 显示一行省略号 */
  104. .ellipsis-one{
  105. white-space: nowrap;
  106. text-overflow: ellipsis;
  107. overflow: hidden;
  108. word-break: break-all;
  109. }
  110. /* 显示两行,省略号 */
  111. .ellipsis-two{
  112. overflow: hidden;
  113. text-overflow: ellipsis;
  114. display: -webkit-box;
  115. -webkit-line-clamp: 2;
  116. line-clamp: 2;
  117. -webkit-box-orient: vertical;
  118. }
  119. .product-list{
  120. display:flex;
  121. flex-wrap: wrap;
  122. justify-content: space-between;
  123. padding: 0;
  124. width: 100%;
  125. }
  126. .product-item{
  127. background: #ffffff;
  128. border-radius: 10upx;
  129. border: 1px solid #eee;
  130. width: 48%;
  131. margin: 10px 0 0 0;
  132. display: flex;
  133. flex-direction: column;
  134. .price-txt{
  135. color: red;
  136. display: flex;
  137. align-items: baseline;
  138. font-size: 12px;
  139. text{
  140. font-size: 36rpx;
  141. }
  142. }
  143. > view{
  144. &:first-child{
  145. position: relative;
  146. overflow: hidden;
  147. .product-code{
  148. color: #666;
  149. position: absolute;
  150. width: 100%;
  151. left:0;
  152. bottom:0;
  153. background: rgba(255,255,255,0.7);
  154. text-align: center;
  155. }
  156. }
  157. &:last-child{
  158. position: relative;
  159. flex-grow: 1;
  160. padding: 10px 10px 35px;
  161. .product-name{
  162. font-size: 28rpx;
  163. color: #333;
  164. }
  165. .product-guige{
  166. margin: 10rpx 0;
  167. color: #2196F3;
  168. }
  169. }
  170. .product-button{
  171. position: absolute;
  172. left: 5%;
  173. bottom: 0;
  174. width: 90%;
  175. padding: 5px 0 10px;
  176. display: flex;
  177. align-items: center;
  178. .rebate-tag{
  179. background: #ffe7df;
  180. color: #E91E63;
  181. padding: 2px 5px;
  182. font-size: 10px;
  183. border-radius: 3px;
  184. margin-left: 6px;
  185. }
  186. .tejia-tag{
  187. color: #E91E63;
  188. margin-left: 6px;
  189. font-size: 12px;
  190. text{
  191. font-size: 12px;
  192. color: #999;
  193. margin-left: 5px;
  194. text-decoration: line-through;
  195. }
  196. }
  197. }
  198. }
  199. .back-price{
  200. padding: 6rpx 65rpx;
  201. background: #ececec;
  202. position: absolute;
  203. top: 18rpx;
  204. right: -45rpx;
  205. color: #666;
  206. z-index: 2;
  207. font-size: 20rpx;
  208. text-align: center;
  209. transform: rotate(40deg);
  210. display: flex;
  211. align-items: center;
  212. text{
  213. font-size: 28rpx;
  214. margin: 0 5rpx;
  215. }
  216. }
  217. }
  218. </style>