virtual-promo-product.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <template>
  2. <view class="product-list">
  3. <view
  4. class="check-order-list"
  5. v-for="(sub,i) in item.list"
  6. :key="i"
  7. >
  8. <view class="video-item" >
  9. <view>
  10. <u-image :src="sub.productImage+'?x-oss-process=image/resize,p_50'" height="140px" width="100%"></u-image>
  11. <view class="back-price" v-if="sub.promoRuleValue">返<text>{{sub.promoRuleValue}}</text>元</view>
  12. <view class="product-code">{{sub.productCode}}</view>
  13. </view>
  14. <view>
  15. <view class="product-name">{{sub.productName}}</view>
  16. <view class="product-guige ellipsis-two">{{sub.productOrigCode}}</view>
  17. <view class="product-button">
  18. <view class="price-txt">¥<text>{{sub.cost}}</text></view>
  19. <view @click="chooseProduct(sub)">
  20. <view class="cart-add" :class="!sub.checked?'colr-add':'colr-checks'">
  21. <u-icon v-if="!sub.checked" color="#fff" name="plus"></u-icon>
  22. <view v-else>
  23. <u-icon name="plus" color="#fff"></u-icon>{{sub.qty}}
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. export default {
  35. name:"virtual-promo-product",
  36. props: {
  37. item: null,
  38. index: 0,
  39. extraData: null
  40. },
  41. data() {
  42. return {
  43. };
  44. },
  45. methods: {
  46. chooseProduct(row){
  47. //如果要把点击事件传给页面,可以通过给extraData中添加对应的函数,然后在当前组件中触发这个函数,在页面中监听即可
  48. //注意,微信小程序中无法通过props传递事件,在微信小程序中可以使用uni.$emit、uni.$on代替
  49. if(this.extraData.chooseProduct){
  50. this.extraData.chooseProduct(row);
  51. }
  52. }
  53. }
  54. }
  55. </script>
  56. <style lang="less">
  57. .product-list{
  58. display: flex;
  59. flex-wrap: wrap;
  60. }
  61. .check-order-list{
  62. width: 50%;
  63. padding: 10upx;
  64. .video-item{
  65. background: #ffffff;
  66. border-radius: 10upx;
  67. box-shadow: 1px 1px 3px #EEEEEE;
  68. height: 100%;
  69. display: flex;
  70. flex-direction: column;
  71. > view{
  72. &:first-child{
  73. position: relative;
  74. overflow: hidden;
  75. border-bottom: 1px solid #eee;
  76. .product-code{
  77. color: #666;
  78. position: absolute;
  79. width: 100%;
  80. left:0;
  81. bottom:0;
  82. background: rgba(255,255,255,0.7);
  83. text-align: center;
  84. }
  85. }
  86. &:last-child{
  87. padding: 20rpx 20rpx 70rpx 20rpx;
  88. position: relative;
  89. flex-grow: 1;
  90. .product-name{
  91. font-size: 28rpx;
  92. }
  93. .product-guige{
  94. margin: 10rpx 0 20rpx 0;
  95. color: #2196F3;
  96. text{
  97. margin-right: 10rpx;
  98. }
  99. }
  100. }
  101. .product-button{
  102. display: flex;
  103. justify-content: space-between;
  104. align-items: center;
  105. position: absolute;
  106. bottom: 20rpx;
  107. left: 0;
  108. width: 100%;
  109. padding: 0 20rpx;
  110. }
  111. .cart-add{
  112. padding: 6rpx 15rpx;
  113. border-radius: 30rpx;
  114. background: #2196F3;
  115. color: #fff;
  116. display: flex;
  117. align-items: center;
  118. justify-content: center;
  119. font-size: 24rpx;
  120. }
  121. .colr-add{
  122. background: #2196F3;
  123. padding: 10rpx 20rpx;
  124. }
  125. .colr-checks{
  126. background: #00aa00;
  127. }
  128. }
  129. }
  130. }
  131. </style>