productitem.vue 9.3 KB

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