productitem.vue 8.7 KB

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