productitem.vue 6.1 KB

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