productitem.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <template>
  2. <block>
  3. <view class="choose-product-item"
  4. v-for="(item, dix) in list"
  5. :key="item.id"
  6. >
  7. <view class="choose-product-item-check" @click="checkItem(item.id)">
  8. <image style="width: 24px;height: 24px;" mode="aspectFill" :src="'../static/'+(item.checked?'round_check_fill':'round')+'.png'"></image>
  9. </view>
  10. <view>
  11. <view class="choose-product-item-img">
  12. <image mode="aspectFit" :src="item.productImage+'?x-oss-process=image/resize,p_30'" style="width: 100%;height: 180rpx;"></image>
  13. <!-- <view class="back-price" v-if="item.promoRuleValue">返<text>{{item.promoRuleValue}}</text>元</view> -->
  14. <view class="choose-product-item-left-info-code ellipsis-one">{{item.productCode}}</view>
  15. </view>
  16. <view class="choose-product-item-info">
  17. <view class="choose-product-item-left-info-name ellipsis-two">{{item.productName}}</view>
  18. <view class="choose-product-item-left-info-guige">
  19. <text class="ellipsis-two" max-lines="2" overflow="ellipsis">{{item.productOrigCode}}</text>
  20. </view>
  21. <view class="choose-product-item-left-info-price">
  22. <view class="price-txt">¥<text>{{item.cost}}</text></view>
  23. <view>
  24. <view :style="{opacity:!item.edit?1:0,width:!item.edit?'auto':0}">
  25. <uni-number-box v-show="!item.edit" v-model="item.qty" :min="1" :max="999999" @change="v=>{changeQty(v,item.id)}"></uni-number-box>
  26. </view>
  27. <view v-if="item.edit" class="edit-qty">
  28. X <text>{{item.qty}}</text>
  29. <image style="width: 24px;height: 24px;" mode="aspectFill" :src="'../static/ashbin.png'" @click="remove(item.id)"></image>
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. </block>
  37. </template>
  38. <script>
  39. import uniNumberBox from '@/components/uni-number-box/uni-number-box.vue'
  40. export default {
  41. name: 'productItem',
  42. components: {
  43. uniNumberBox
  44. },
  45. props: {
  46. index: {
  47. type: Number,
  48. default: 0
  49. },
  50. list: {
  51. type: Array,
  52. default: () => []
  53. },
  54. },
  55. data() {
  56. return {
  57. }
  58. },
  59. methods: {
  60. changeQty(e, id) {
  61. this.$emit('changeQty', e, id)
  62. },
  63. remove(id){
  64. this.$emit('remove', id, false)
  65. },
  66. checkItem(id){
  67. this.$emit('check',id)
  68. }
  69. }
  70. }
  71. </script>
  72. <style lang="less" scoped>
  73. .choose-product-item{
  74. display: flex;
  75. align-items: center;
  76. justify-content: space-between;
  77. padding: 10px;
  78. background: #fff;
  79. margin: 8px 8px 0 8px;
  80. border-radius: 10px;
  81. .price-txt{
  82. color: red;
  83. display: flex;
  84. align-items: center;
  85. text{
  86. font-size: 36rpx;
  87. }
  88. }
  89. > view{
  90. display: flex;
  91. align-items: center;
  92. justify-content: space-between;
  93. &:last-child{
  94. flex-grow: 1;
  95. width: 80%;
  96. }
  97. }
  98. .choose-product-item-check{
  99. padding: 0 20rpx 0 0;
  100. width: 24px;
  101. }
  102. .choose-product-item-img{
  103. margin-right: 20rpx;
  104. width: 30%;
  105. position: relative;
  106. overflow: hidden;
  107. border: 1px solid #eee;
  108. padding: 10rpx;
  109. .back-price{
  110. zoom: calc(0.8);
  111. padding: 6rpx 65rpx;
  112. background: rgba(255 ,87 ,34 , 1);
  113. position: absolute;
  114. top: 18rpx;
  115. right: -45rpx;
  116. color: #fff;
  117. z-index: 2;
  118. font-size: 20rpx;
  119. text-align: center;
  120. transform: rotate(40deg);
  121. display: flex;
  122. align-items: center;
  123. text{
  124. font-size: 28rpx;
  125. margin: 0 5rpx;
  126. }
  127. }
  128. .choose-product-item-left-info-code{
  129. color: #666;
  130. position: absolute;
  131. width: 100%;
  132. left:0;
  133. bottom:0;
  134. background: rgba(255,255,255,0.7);
  135. text-align: center;
  136. }
  137. }
  138. .choose-product-item-info{
  139. width: 70%;
  140. flex-grow: 1;
  141. .choose-product-item-left-info-price{
  142. display: flex;
  143. align-items:center;
  144. justify-content: space-between;
  145. >view{
  146. &:last-child{
  147. display: flex;
  148. align-items:center;
  149. }
  150. }
  151. .edit-qty{
  152. display: flex;
  153. align-items:center;
  154. justify-content: space-between;
  155. color: #999;
  156. font-size: 12px;
  157. > text{
  158. color: #666;
  159. font-size: 14px;
  160. margin-right: 20px;
  161. }
  162. }
  163. }
  164. .choose-product-item-left-info-name{
  165. font-size: 28rpx;
  166. color: #666;
  167. }
  168. .choose-product-item-left-info-guige{
  169. color: #2196F3;
  170. margin: 10rpx 0;
  171. text{
  172. margin-right: 10rpx;
  173. }
  174. }
  175. }
  176. }
  177. </style>