productitem.vue 6.0 KB

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