productitem.vue 8.9 KB

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