productitem.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  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>
  13. <view class="choose-product-item-img">
  14. <image mode="aspectFit" :src="item.productImage?item.productImage+'?x-oss-process=image/resize,p_30':'/static/def_imgs.png'" style="width: 100%;height: 100%;"></image>
  15. <view class="back-price xiajia" v-if="!item.status">下架</view>
  16. <view class="back-price xiajia" v-else-if="item.dealerScopeFlag==0">售罄</view>
  17. </view>
  18. <view class="choose-product-item-info">
  19. <view class="choose-product-item-left-info-name">
  20. <text :max-lines="1" overflow="ellipsis">{{item.productName}}</text>
  21. </view>
  22. <view class="choose-product-item-left-info-guige">
  23. <text :max-lines="1" overflow="ellipsis">{{item.productCode}}</text>
  24. <text :max-lines="2" overflow="ellipsis">{{item.productOrigCode}}</text>
  25. </view>
  26. <view class="choose-product-item-left-info-price">
  27. <view>
  28. <view class="price-txt" v-if="item.status==1">¥<text>{{item.price}}</text></view>
  29. <view class="flex align_center rebate-tag" v-if="item.promoType=='BUY_PROD_GIVE_VALID'">
  30. 返<text>{{item.resultValue}}</text>元
  31. </view>
  32. <view class="flex align_center rebate-tag" v-if="item.promoType=='BUY_PROD_GIVE_PROD'">
  33. 买{{item.conditionValue}}赠{{item.resultValue}}
  34. </view>
  35. <view class="flex align_center tejia-tag" v-if="item.promoType=='PROMO_PROD'">
  36. 特价<text>¥{{item.orginPrice}}</text>
  37. </view>
  38. </view>
  39. <view>
  40. <view v-if="item.status==1&&item.dealerScopeFlag==1" :style="{opacity:!item.edit?1:0,width:!item.edit?'auto':0}">
  41. <view class="flex align_center qty-box">
  42. <view class="qty-btn" @click="changeQty(item.qty-1,item,1)" :class="(item.qty <= 1)?'qty-disabled':''">-</view>
  43. <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>
  44. <view class="qty-btn" @click="changeQty(item.qty+1,item,1)" :class="(item.qty >= 999)?'qty-disabled':''">+</view>
  45. </view>
  46. </view>
  47. <view v-if="!item.edit && (!item.status||item.dealerScopeFlag==0)" class="edit-qty">
  48. X <text>{{item.qty}}</text>
  49. </view>
  50. <view v-if="item.edit" class="edit-qty">
  51. X <text>{{item.qty}}</text>
  52. <uni-icons type="minus-filled" size="24" color="#dd0000" @click="remove(item.cartSn)"></uni-icons>
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. <!-- 赠品 -->
  59. <view class="gift-box" v-if="item.giftQty">
  60. <view class="choose-product-item-img">
  61. <image mode="aspectFit" :src="item.productImage?item.productImage+'?x-oss-process=image/resize,p_30':'/static/def_imgs.png'" style="width: 100%;height: 100%;"></image>
  62. <view class="back-price xiajia" v-if="!item.status">下架</view>
  63. <view class="back-price xiajia" v-else-if="item.dealerScopeFlag==0">售罄</view>
  64. </view>
  65. <view class="choose-product-item-info">
  66. <view class="choose-product-item-left-info-name flex align_center">
  67. <view class="flex align_center rebate-tag">赠品</view>
  68. <text :max-lines="1" overflow="ellipsis">{{item.productName}}</text>
  69. </view>
  70. <view class="choose-product-item-left-info-guige">
  71. <text :max-lines="1" overflow="ellipsis">{{item.productCode}}</text>
  72. <text :max-lines="1" overflow="ellipsis">{{item.productOrigCode}}</text>
  73. </view>
  74. <view class="choose-product-item-left-info-price">
  75. <view></view>
  76. <view>
  77. <view class="edit-qty">
  78. X <text>{{item.qty}}</text>
  79. </view>
  80. </view>
  81. </view>
  82. </view>
  83. </view>
  84. </view>
  85. </view>
  86. </block>
  87. </template>
  88. <script>
  89. export default {
  90. name: 'productItem',
  91. props: {
  92. list: {
  93. type: Array,
  94. default: () => []
  95. },
  96. },
  97. data() {
  98. return {
  99. isChange: false
  100. }
  101. },
  102. methods: {
  103. inputQty(item){
  104. this.isChange = true
  105. },
  106. changeQty(value,item,type) {
  107. const max = 999
  108. const v = value > max ? max : (value==''||value==0?1:value)
  109. if(type == 0){
  110. if(!this.isChange){
  111. return
  112. }
  113. this.updateNums(value,item.cartSn)
  114. this.$nextTick(()=>{
  115. setTimeout(()=>{
  116. this.updateNums(v,item.cartSn)
  117. this.isChange = false
  118. },100)
  119. })
  120. }else{
  121. if(value<=max && value >= 1){
  122. this.updateNums(v,item.cartSn)
  123. }
  124. }
  125. },
  126. updateNums(e, cartSn) {
  127. this.$emit('changeQty', Number(e), cartSn)
  128. },
  129. remove(cartSn){
  130. this.$emit('remove', [cartSn], false)
  131. },
  132. checkItem(item){
  133. if(item.edit || (item.status==1&&item.dealerScopeFlag==1)){
  134. this.$emit('check',item.cartSn)
  135. }
  136. }
  137. }
  138. }
  139. </script>
  140. <style lang="less" scoped>
  141. .qty-box{
  142. display: flex;
  143. .qty-btn{
  144. display: flex;
  145. align-items: center;
  146. justify-content: center;
  147. width: 22px;
  148. height: 22px;
  149. border-radius: 50px;
  150. font-size: 18px;
  151. background-color: #066cff;
  152. color: #fff;
  153. &.qty-disabled{
  154. background-color: #c0c0c0;
  155. }
  156. }
  157. .qty-num{
  158. width: 24px;
  159. height: 22px;
  160. line-height: 22px;
  161. padding:0 3px;
  162. input{
  163. width: 100%;
  164. height: 100%;
  165. text-align: center;
  166. color: #333;
  167. }
  168. }
  169. }
  170. .choose-product-item{
  171. display: flex;
  172. justify-content: space-between;
  173. padding: 10px;
  174. background: #fff;
  175. margin: 8px 8px 0 8px;
  176. border-radius: 10px;
  177. .price-txt{
  178. color: red;
  179. display: flex;
  180. align-items: baseline;
  181. font-size: 12px;
  182. text{
  183. font-size: 32rpx;
  184. }
  185. }
  186. > view{
  187. &:last-child{
  188. flex-grow: 1;
  189. width: 80%;
  190. >view{
  191. width: 100%;
  192. display: flex;
  193. align-items: center;
  194. justify-content: space-between;
  195. }
  196. }
  197. }
  198. .choose-product-item-check{
  199. padding: 0 10rpx 0 0;
  200. width: 24px;
  201. margin-top: 33px;
  202. }
  203. .choose-product-item-img{
  204. margin-right: 20rpx;
  205. width: 90px;
  206. height: 90px;
  207. position: relative;
  208. overflow: hidden;
  209. border: 1px solid #eee;
  210. padding: 3rpx;
  211. border-radius: 10rpx;
  212. .back-price{
  213. zoom: calc(0.8);
  214. padding: 6rpx 65rpx;
  215. position: absolute;
  216. top: 18rpx;
  217. right: -45rpx;
  218. z-index: 2;
  219. font-size: 20rpx;
  220. text-align: center;
  221. transform: rotate(40deg);
  222. display: flex;
  223. align-items: center;
  224. text{
  225. font-size: 28rpx;
  226. margin: 0 5rpx;
  227. }
  228. }
  229. .xiajia{
  230. background: #ececec;
  231. color: #5f5f5f;
  232. }
  233. .choose-product-item-left-info-code{
  234. color: #666;
  235. position: absolute;
  236. width: 100%;
  237. left:0;
  238. bottom:0;
  239. background: rgba(255,255,255,0.7);
  240. text-align: center;
  241. font-size: 12px;
  242. }
  243. }
  244. .choose-product-item-info{
  245. width: 70%;
  246. flex-grow: 1;
  247. .choose-product-item-left-info-price{
  248. display: flex;
  249. align-items:center;
  250. justify-content: space-between;
  251. >view{
  252. display: flex;
  253. align-items:center;
  254. }
  255. .edit-qty{
  256. display: flex;
  257. align-items:center;
  258. justify-content: space-between;
  259. color: #999;
  260. font-size: 10px;
  261. > text{
  262. color: #666;
  263. font-size: 14px;
  264. margin-left: 5px;
  265. margin-right: 10px;
  266. }
  267. }
  268. }
  269. .rebate-tag{
  270. background: #ffe7df;
  271. color: #E91E63;
  272. padding: 2px 5px;
  273. font-size: 10px;
  274. border-radius: 3px;
  275. margin-left: 6px;
  276. }
  277. .tejia-tag{
  278. color: #E91E63;
  279. margin-left: 6px;
  280. font-size: 10px;
  281. text{
  282. font-size: 10px;
  283. color: #999;
  284. margin-left: 5px;
  285. text-decoration: line-through;
  286. }
  287. }
  288. .choose-product-item-left-info-name{
  289. font-size: 28rpx;
  290. color: #333;
  291. }
  292. .choose-product-item-left-info-guige{
  293. margin: 10rpx 0;
  294. font-size: 12px;
  295. text{
  296. color: #666;
  297. &:last-child{
  298. color: #2196F3;
  299. }
  300. }
  301. }
  302. }
  303. .gift-box{
  304. margin-top: 10px;
  305. border-top: 1px solid #ececec;
  306. padding-top: 10px;
  307. .choose-product-item-img{
  308. width: 70px;
  309. height: 70px;
  310. margin-left: 20px;
  311. }
  312. .choose-product-item-info .choose-product-item-left-info-guige{
  313. margin: 10rpx 0 0 0;
  314. }
  315. .choose-product-item-info .choose-product-item-left-info-name{
  316. font-size: 24rpx;
  317. .rebate-tag{
  318. margin: 0 5px 0 2px;
  319. background: #ff0000;
  320. color: #fff;
  321. width: 40px;
  322. display: flex;
  323. justify-content: center;
  324. }
  325. }
  326. }
  327. }
  328. </style>