productitem.vue 9.2 KB

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