productitem.vue 4.0 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. <u-icon size="45" :color="item.checked?'#ff0000':'#969799'" :name="item.checked?'roundcheckfill':'round'" custom-prefix="custom-icon"></u-icon>
  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 ellipsis-two">{{item.productOrigCode}}</view>
  19. <view class="choose-product-item-left-info-price">
  20. <view class="price-txt">¥<text>{{item.cost}}</text></view>
  21. <view>
  22. <uni-number-box v-if="!edit" v-model="item.qty" :min="1" :max="999999" @change="v=>{changeQty(v,item.id)}"></uni-number-box>
  23. <view v-else class="edit-qty">
  24. X <text>{{item.qty}}</text>
  25. <u-icon size="42" color="#ff0000" name="ashbin" custom-prefix="custom-icon" @click="remove(item.id)"></u-icon>
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. </block>
  33. </template>
  34. <script>
  35. import uniNumberBox from '@/components/uni-number-box/uni-number-box.vue'
  36. export default {
  37. name: 'productItem',
  38. components: {
  39. uniNumberBox
  40. },
  41. props: {
  42. index: {
  43. type: Number,
  44. default: 0
  45. },
  46. list: {
  47. type: Array,
  48. default: () => []
  49. },
  50. edit: {
  51. type: Boolean,
  52. default: false
  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)
  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 0;
  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. }
  96. }
  97. .choose-product-item-check{
  98. padding: 0 20rpx 0 0;
  99. }
  100. .choose-product-item-img{
  101. margin-right: 20rpx;
  102. width: 35%;
  103. position: relative;
  104. overflow: hidden;
  105. border: 1px solid #eee;
  106. padding: 10rpx;
  107. .back-price{
  108. zoom: calc(0.8);
  109. padding: 6rpx 65rpx;
  110. background: rgba(255 ,87 ,34 , 1);
  111. position: absolute;
  112. top: 18rpx;
  113. right: -45rpx;
  114. color: #fff;
  115. z-index: 2;
  116. font-size: 20rpx;
  117. text-align: center;
  118. transform: rotate(40deg);
  119. display: flex;
  120. align-items: center;
  121. text{
  122. font-size: 28rpx;
  123. margin: 0 5rpx;
  124. }
  125. }
  126. .choose-product-item-left-info-code{
  127. color: #666;
  128. position: absolute;
  129. width: 100%;
  130. left:0;
  131. bottom:0;
  132. background: rgba(255,255,255,0.7);
  133. text-align: center;
  134. }
  135. }
  136. .choose-product-item-info{
  137. margin-right: 10rpx;
  138. width: 65%;
  139. flex-grow: 1;
  140. .choose-product-item-left-info-price{
  141. display: flex;
  142. align-items:center;
  143. justify-content: space-between;
  144. >view{
  145. &:last-child{
  146. display: flex;
  147. align-items:center;
  148. }
  149. }
  150. .edit-qty{
  151. display: flex;
  152. align-items:center;
  153. justify-content: space-between;
  154. color: #999;
  155. font-size: 12px;
  156. > text{
  157. color: #666;
  158. font-size: 14px;
  159. margin-right: 20px;
  160. }
  161. }
  162. }
  163. .choose-product-item-left-info-name{
  164. font-size: 28rpx;
  165. font-weight: 900;
  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>