productitem.vue 5.9 KB

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