productitem.vue 8.5 KB

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