productitem.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  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 rebate-tag" v-if="item.shopProductSubsidy&&item.shopProductSubsidy.subsidyAmount<item.price&&!item.shopPromoProduct&&showBalanceAuth">
  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. computed:{
  119. // 抵扣余额支付是否可用
  120. showBalanceAuth(){
  121. return this.$store.state.vuex_showBalanceAuth
  122. },
  123. },
  124. methods: {
  125. inputQty(item){
  126. this.isChange = true
  127. },
  128. changeQty(value,item,type) {
  129. const max = 999
  130. const v = value > max ? max : (value==''||value==0?1:value)
  131. if(type == 0){
  132. if(!this.isChange){
  133. return
  134. }
  135. this.updateNums(value,item.cartSn)
  136. this.$nextTick(()=>{
  137. setTimeout(()=>{
  138. this.updateNums(v,item.cartSn)
  139. this.isChange = false
  140. },100)
  141. })
  142. }else{
  143. if(value<=max && value >= 1){
  144. this.updateNums(v,item.cartSn)
  145. }
  146. }
  147. },
  148. updateNums(e, cartSn) {
  149. this.$emit('changeQty', Number(e), cartSn)
  150. },
  151. remove(cartSn){
  152. this.$emit('remove', [cartSn], false)
  153. },
  154. checkItem(item){
  155. if(item.edit || (item.status==1&&item.dealerScopeFlag==1)){
  156. this.$emit('check',item.cartSn)
  157. }
  158. },
  159. editQty(item){
  160. this.$emit('editQty',item)
  161. }
  162. }
  163. }
  164. </script>
  165. <style lang="less" scoped>
  166. .qty-box{
  167. display: flex;
  168. .qty-btn{
  169. display: flex;
  170. align-items: center;
  171. justify-content: center;
  172. width: 22px;
  173. height: 20px;
  174. border-radius: 50px;
  175. font-size: 18px;
  176. color: #066cff;
  177. &.qty-disabled{
  178. color: #999;
  179. }
  180. }
  181. .qty-num{
  182. width: 24px;
  183. height: 20px;
  184. line-height: 20px;
  185. text-align: center;
  186. background-color: #efefef;
  187. margin: 0 3px;
  188. border-radius: 3px;
  189. font-size: 12px;
  190. input{
  191. width: 100%;
  192. height: 100%;
  193. text-align: center;
  194. color: #333;
  195. }
  196. }
  197. }
  198. .choose-product-item{
  199. display: flex;
  200. justify-content: space-between;
  201. padding: 10px;
  202. background: #fff;
  203. margin: 8px 8px 0 8px;
  204. border-radius: 10px;
  205. .price-txt{
  206. color: red;
  207. display: flex;
  208. align-items: baseline;
  209. font-size: 12px;
  210. text{
  211. font-size: 32rpx;
  212. }
  213. }
  214. > view{
  215. &:last-child{
  216. flex-grow: 1;
  217. width: 80%;
  218. >view{
  219. width: 100%;
  220. display: flex;
  221. align-items: center;
  222. justify-content: space-between;
  223. }
  224. }
  225. }
  226. .choose-product-item-check{
  227. padding: 0 10rpx 0 0;
  228. width: 24px;
  229. margin-top: 33px;
  230. }
  231. .choose-product-item-img{
  232. margin-right: 20rpx;
  233. width: 80px;
  234. height: 80px;
  235. position: relative;
  236. overflow: hidden;
  237. border: 1px solid #eee;
  238. padding: 3rpx;
  239. border-radius: 10rpx;
  240. .back-price{
  241. zoom: calc(0.8);
  242. padding: 6rpx 65rpx;
  243. position: absolute;
  244. top: 18rpx;
  245. right: -45rpx;
  246. z-index: 2;
  247. font-size: 20rpx;
  248. text-align: center;
  249. transform: rotate(40deg);
  250. display: flex;
  251. align-items: center;
  252. text{
  253. font-size: 28rpx;
  254. margin: 0 5rpx;
  255. }
  256. }
  257. .xiajia{
  258. background: #ececec;
  259. color: #5f5f5f;
  260. }
  261. .choose-product-item-left-info-code{
  262. color: #666;
  263. position: absolute;
  264. width: 100%;
  265. left:0;
  266. bottom:0;
  267. background: rgba(255,255,255,0.7);
  268. text-align: center;
  269. font-size: 12px;
  270. }
  271. }
  272. .choose-product-item-info{
  273. width: 70%;
  274. flex-grow: 1;
  275. .choose-product-item-left-info-price{
  276. display: flex;
  277. justify-content: space-between;
  278. >view{
  279. display: flex;
  280. align-items:baseline;
  281. }
  282. .edit-qty{
  283. display: flex;
  284. align-items:center;
  285. justify-content: space-between;
  286. color: #999;
  287. font-size: 10px;
  288. > text{
  289. color: #666;
  290. font-size: 12px;
  291. margin-left: 5px;
  292. margin-right: 10px;
  293. }
  294. }
  295. }
  296. .rebate-tag{
  297. background: #ffe7df;
  298. color: #E91E63;
  299. padding: 2px 5px;
  300. font-size: 10px;
  301. border-radius: 3px;
  302. margin-left: 6px;
  303. }
  304. .tejia-tag{
  305. color: #E91E63;
  306. margin-left: 6px;
  307. font-size: 10px;
  308. text{
  309. font-size: 12px;
  310. color: #999;
  311. margin-left: 5px;
  312. text-decoration: line-through;
  313. }
  314. }
  315. .choose-product-item-left-info-name{
  316. font-size: 28rpx;
  317. color: #333;
  318. }
  319. .choose-product-item-left-info-guige{
  320. margin: 10rpx 0;
  321. font-size: 12px;
  322. text{
  323. color: #666;
  324. &:last-child{
  325. color: #2196F3;
  326. }
  327. }
  328. }
  329. }
  330. .gift-box{
  331. margin-top: 10px;
  332. border-top: 1px solid #ececec;
  333. padding-top: 10px;
  334. .choose-product-item-img{
  335. width: 60px;
  336. height: 60px;
  337. margin-left: 20px;
  338. }
  339. .choose-product-item-info .choose-product-item-left-info-guige{
  340. margin: 10rpx 0 0 0;
  341. }
  342. .choose-product-item-info .choose-product-item-left-info-name{
  343. font-size: 24rpx;
  344. .rebate-tag{
  345. margin: 0 5px 0 2px;
  346. background: #ff0000;
  347. color: #fff;
  348. display: flex;
  349. justify-content: center;
  350. }
  351. .text{
  352. width: 80%;
  353. flex-grow: 1;
  354. }
  355. }
  356. }
  357. }
  358. </style>