productitem.vue 5.2 KB

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