productitem.vue 4.9 KB

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