productitem.vue 4.9 KB

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