productitem.vue 5.6 KB

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