productitem.vue 5.0 KB

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