productitem.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  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.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>
  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 class="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: 20px;
  156. border-radius: 50px;
  157. font-size: 18px;
  158. color: #066cff;
  159. &.qty-disabled{
  160. color: #999;
  161. }
  162. }
  163. .qty-num{
  164. width: 24px;
  165. height: 20px;
  166. line-height: 20px;
  167. text-align: center;
  168. background-color: #efefef;
  169. margin: 0 3px;
  170. border-radius: 3px;
  171. font-size: 12px;
  172. input{
  173. width: 100%;
  174. height: 100%;
  175. text-align: center;
  176. color: #333;
  177. }
  178. }
  179. }
  180. .choose-product-item{
  181. display: flex;
  182. justify-content: space-between;
  183. padding: 10px;
  184. background: #fff;
  185. margin: 8px 8px 0 8px;
  186. border-radius: 10px;
  187. .price-txt{
  188. color: red;
  189. display: flex;
  190. align-items: baseline;
  191. font-size: 12px;
  192. text{
  193. font-size: 32rpx;
  194. }
  195. }
  196. > view{
  197. &:last-child{
  198. flex-grow: 1;
  199. width: 80%;
  200. >view{
  201. width: 100%;
  202. display: flex;
  203. align-items: center;
  204. justify-content: space-between;
  205. }
  206. }
  207. }
  208. .choose-product-item-check{
  209. padding: 0 10rpx 0 0;
  210. width: 24px;
  211. margin-top: 33px;
  212. }
  213. .choose-product-item-img{
  214. margin-right: 20rpx;
  215. width: 80px;
  216. height: 80px;
  217. position: relative;
  218. overflow: hidden;
  219. border: 1px solid #eee;
  220. padding: 3rpx;
  221. border-radius: 10rpx;
  222. .back-price{
  223. zoom: calc(0.8);
  224. padding: 6rpx 65rpx;
  225. position: absolute;
  226. top: 18rpx;
  227. right: -45rpx;
  228. z-index: 2;
  229. font-size: 20rpx;
  230. text-align: center;
  231. transform: rotate(40deg);
  232. display: flex;
  233. align-items: center;
  234. text{
  235. font-size: 28rpx;
  236. margin: 0 5rpx;
  237. }
  238. }
  239. .xiajia{
  240. background: #ececec;
  241. color: #5f5f5f;
  242. }
  243. .choose-product-item-left-info-code{
  244. color: #666;
  245. position: absolute;
  246. width: 100%;
  247. left:0;
  248. bottom:0;
  249. background: rgba(255,255,255,0.7);
  250. text-align: center;
  251. font-size: 12px;
  252. }
  253. }
  254. .choose-product-item-info{
  255. width: 70%;
  256. flex-grow: 1;
  257. .choose-product-item-left-info-price{
  258. display: flex;
  259. justify-content: space-between;
  260. >view{
  261. display: flex;
  262. align-items:baseline;
  263. }
  264. .edit-qty{
  265. display: flex;
  266. align-items:center;
  267. justify-content: space-between;
  268. color: #999;
  269. font-size: 10px;
  270. > text{
  271. color: #666;
  272. font-size: 14px;
  273. margin-left: 5px;
  274. margin-right: 10px;
  275. }
  276. }
  277. }
  278. .rebate-tag{
  279. background: #ffe7df;
  280. color: #E91E63;
  281. padding: 2px 5px;
  282. font-size: 10px;
  283. border-radius: 3px;
  284. margin-left: 6px;
  285. }
  286. .tejia-tag{
  287. color: #E91E63;
  288. margin-left: 6px;
  289. font-size: 10px;
  290. text{
  291. font-size: 10px;
  292. color: #999;
  293. margin-left: 5px;
  294. text-decoration: line-through;
  295. }
  296. }
  297. .choose-product-item-left-info-name{
  298. font-size: 28rpx;
  299. color: #333;
  300. }
  301. .choose-product-item-left-info-guige{
  302. margin: 10rpx 0;
  303. font-size: 12px;
  304. text{
  305. color: #666;
  306. &:last-child{
  307. color: #2196F3;
  308. }
  309. }
  310. }
  311. }
  312. .gift-box{
  313. margin-top: 10px;
  314. border-top: 1px solid #ececec;
  315. padding-top: 10px;
  316. .choose-product-item-img{
  317. width: 60px;
  318. height: 60px;
  319. margin-left: 20px;
  320. }
  321. .choose-product-item-info .choose-product-item-left-info-guige{
  322. margin: 10rpx 0 0 0;
  323. }
  324. .choose-product-item-info .choose-product-item-left-info-name{
  325. font-size: 24rpx;
  326. .rebate-tag{
  327. margin: 0 5px 0 2px;
  328. background: #ff0000;
  329. color: #fff;
  330. display: flex;
  331. justify-content: center;
  332. }
  333. .text{
  334. width: 80%;
  335. flex-grow: 1;
  336. }
  337. }
  338. }
  339. }
  340. </style>