deliver-goods.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601
  1. <template>
  2. <view class="container cart clearfix">
  3. <view class="container-cart-main">
  4. <view class="container-cart">
  5. <view class="cart-content" :style="{paddingBottom :isIphoneX ? '130rpx' : '100rpx'}">
  6. <view class="goods-list">
  7. <view class="goods-pros" v-for="(pros,idx) in productsList" :key="idx" @click.stop="ischeck(pros)" >
  8. <view class="goods-pros-t">
  9. <!--选择商品-->
  10. <view class="checkbox-box">
  11. <button class="checkbox iconfont" :class="[pros.checked ?'icon-gouxuanl':'icon-weigouxuan']"></button>
  12. </view>
  13. <view class="pros-img"><image :src="pros.mainImage ? pros.mainImage:''" alt="" /></view>
  14. <view class="pros-product">
  15. <view class="producttitle">{{pros.name}}</view>
  16. <view class="productspec">规格:{{pros.productUnit ? pros.productUnit : ''}}</view>
  17. <view class="productspec">商品编码:{{pros.productCode ? pros.productCode : ''}}</view>
  18. <view class="product-view">
  19. <view class="view-num">数量:{{pros.num}}</view>
  20. </view>
  21. <view class="product-view">
  22. <view class="view-num">已发货:{{pros.taxRate}}</view>
  23. <view class="view-num">未发货:{{pros.discount == null ? '0' : pros.discount}}</view>
  24. </view>
  25. <view class="product-view">
  26. <view class="view-num">已退货:{{pros.discountPrice}}</view>
  27. </view>
  28. </view>
  29. </view>
  30. <view class="goods-pros-b">
  31. <view class="productprice">
  32. <view class="text">本次发货</view>
  33. <view class="count">
  34. <view class="number-box">
  35. <view class="iconfont icon-jianhao" :class="[pros.validFlag == '3'?'disabled':'']" @click="changeCountSub(item,pros)"></view>
  36. <input class="btn-input" type="number" maxlength='4' v-model="pros.productCount" @blur="changeNnmber($event,item,pros)">
  37. <view class="iconfont icon-jiahao" :class="[pros.validFlag == '3'?'disabled':'']" @click="changeCountAdd(item,pros)"></view>
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. <!-- 脚部菜单 -->
  46. <view class="footer" :style="{paddingBottom :isIphoneX ? '68rpx' : '0rpx'}">
  47. <view class="footer-le">
  48. <view class="foot-check checkbox-box" @tap.stop="checkAll()">
  49. <button class="checkbox iconfont" :class="[isCheckAll?'icon-gouxuan':'icon-weigouxuan']"></button>
  50. <view class="text">全选</view>
  51. </view>
  52. </view>
  53. <view class="footer-ri" >
  54. <view class="btn" @tap="toConfirmation">去发货</view>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. </template>
  61. <script>
  62. import authorize from '@/common/config/authorize.js'
  63. import { mapState,mapMutations } from 'vuex';
  64. import { queryShoppingCartList,shoppingCartUpdate,shoppingCartDelete } from "@/api/cart.js"
  65. export default{
  66. data(){
  67. return{
  68. CustomBar:this.CustomBar,// 顶部导航栏高度
  69. isIphoneX:this.$store.state.isIphoneX,
  70. userID:'',
  71. alertType:'',
  72. isStock:'',
  73. productsList:[
  74. {
  75. mainImage:'https://img14.360buyimg.com/n7/jfs/t1/114670/38/7458/171560/5ec3b80fE5c5f15f9/549ceeeca82f0d02.jpg',
  76. name:'华西生物奥斯卡等级阿奥术大师大所打撒大啊萨达时代萨德',
  77. productUnit:'盒',
  78. productCode:'FXSW2131231231',
  79. num:20,
  80. taxRate:5,
  81. discount:5,
  82. discountPrice:3,
  83. price:'200.00',
  84. checked:false
  85. },{
  86. mainImage:'https://img14.360buyimg.com/n7/jfs/t1/114670/38/7458/171560/5ec3b80fE5c5f15f9/549ceeeca82f0d02.jpg',
  87. name:'华西生物奥斯卡等级阿奥术大师大所打撒大啊萨达时代萨德',
  88. productUnit:'盒',
  89. productCode:'FXSW2131231231',
  90. num:20,
  91. taxRate:5,
  92. discount:5,
  93. discountPrice:3,
  94. price:'200.00',
  95. checked:false
  96. }
  97. ], //购物车的商品
  98. setGoodData:'', //确认订单的商品
  99. isCheckAll:false,//是否全选
  100. isModallayer:false,
  101. isDisabled: false, // 供应商/店铺全选是否禁用状态
  102. isNoConfim:false,
  103. }
  104. },
  105. onLoad(option){
  106. console.log(option)
  107. // this.initGetCartGoodsList();
  108. },
  109. computed: {
  110. ...mapState(['hasLogin','userInfo'])
  111. },
  112. methods:{
  113. initGetCartGoodsList(){//初始化购物车 index:1
  114. let params = {userID:this.userID}
  115. queryShoppingCartList(params).then(response =>{
  116. this.$store.commit('updateAllNum',response.data.cartQuantity)
  117. const responseData = response.data
  118. if(responseData.pageDate && responseData.pageDate.length > 0 ){
  119. this.productsList = responseData.pageDate;
  120. this.productsList.forEach((item,index) => {
  121. let productsListLength = item.productsList.length,
  122. invalidLength = 0;
  123. item.productsList.forEach(pros => {
  124. pros.shopID = item.shopID;
  125. if(pros.validFlag == '3' ) {invalidLength++;}
  126. })
  127. item.isDisabled = invalidLength === productsListLength;
  128. })
  129. } else {
  130. this.productsList = [];
  131. }
  132. }).catch(error =>{
  133. this.$util.msg(error.msg,2000);
  134. })
  135. },
  136. ischeck(pro){//为未选中的时候改变为true,反之为true
  137. pro.checked = !pro.checked;
  138. this.updateCheckAllBtn();
  139. },
  140. updateCheckAllBtn() {// 全选勾选判断
  141. let goodsCheckedLength = 0,
  142. productsList = this.productsList;
  143. productsList.forEach(item => {
  144. if(item.checked) {
  145. goodsCheckedLength++;
  146. }
  147. })
  148. this.isCheckAll = goodsCheckedLength === productsList.lengt;
  149. },
  150. updateBothCheckBtn() {
  151. this.productsList.forEach((item)=>{
  152. item.checked = this.isCheckAll ;
  153. })
  154. },
  155. checkAll(){//全选方法内调用方法
  156. this.isCheckAll = !this.isCheckAll;
  157. this.updateBothCheckBtn();
  158. },
  159. changeCountAdd(item,pros){//商品数量加加
  160. if(pros.productCount>=pros.stock){
  161. pros.productCount= pros.stock
  162. this.isStock =true
  163. return
  164. }else{
  165. pros.productCount++
  166. this.isStock =false
  167. }
  168. this.updateShoppogNum(pros)
  169. this.totalShopPeice();
  170. },
  171. changeCountSub(item,pros){//商品数量减减
  172. if(pros.productCount<=pros.minBuyNumber){
  173. pros.productCount= pros.minBuyNumber
  174. this.$util.msg(`该商品最小起订量为${pros.minBuyNumber}`,2000);
  175. return
  176. }else{
  177. pros.productCount--
  178. }
  179. this.updateShoppogNum(pros)
  180. this.totalShopPeice();
  181. },
  182. changeNnmber(e,item,pros){//输入商品数量更新
  183. let _value = e.detail.value;
  184. if(!this.$api.isNumber(_value)){
  185. pros.productCount = pros.minBuyNumber
  186. }else if(_value < pros.minBuyNumber){
  187. this.$util.msg(`该商品最小起订量为${pros.minBuyNumber}`,2000);
  188. pros.productCount = pros.minBuyNumber
  189. }else{
  190. pros.productCount = e.detail.value
  191. }
  192. this.updateShoppogNum(pros)
  193. this.totalShopPeice();
  194. },
  195. updateShoppogNum(pros){//加减购物车商品更新到后台
  196. let params ={userID:this.userID,productID:pros.productID,productCount:pros.productCount}
  197. shoppingCartUpdate(params).then(response =>{
  198. this.isshowDelbtn = false;
  199. this.initGetCartGoodsList();
  200. }).catch(error =>{
  201. this.$util.msg(error.msg,2000);
  202. })
  203. },
  204. toConfirmation(){//跳转确认订单页面
  205. let setGoodsList=[];
  206. this.goodsList.forEach(res=>{
  207. let products = res.productsList
  208. products.forEach(pros=>{
  209. if(pros.productsChecked){
  210. setGoodsList.push(pros.productID)
  211. }
  212. })
  213. })
  214. if(setGoodsList == ''){
  215. this.$util.msg("请先选择结算商品~",2000);
  216. return
  217. }else{
  218. this.isNoConfim = false
  219. this.goodsList.forEach(el=>{
  220. el.productsList.forEach(pros=>{
  221. if(pros.productsChecked){
  222. if(pros.productCount<pros.minBuyNumber){
  223. this.isNoConfim = true
  224. }
  225. }
  226. })
  227. })
  228. if(this.isNoConfim){
  229. this.$util.modal('','有商品的购买量没达到最小起订量,请修改数量后再次提交结算','去修改','',false,() =>{})
  230. return;
  231. }else{
  232. let productID = '';
  233. this.goodsList.forEach(el=>{//获取勾选的商品ID拼接字符串逗号隔开,最后一个逗号去掉
  234. el.productsList.forEach(pros=>{
  235. if(pros.productsChecked){
  236. productID += pros.productID+','
  237. }
  238. })
  239. })
  240. let cartPramsData={
  241. allPrice:this.allPrice,
  242. allCount:this.allCount,
  243. productID:productID.substring(0,productID.lastIndexOf(',')),
  244. productCount:''
  245. }
  246. this.$api.navigateTo(`/pages/user/order/create-order?data=${JSON.stringify({data:cartPramsData})}`)
  247. }
  248. }
  249. },
  250. },
  251. onPullDownRefresh() {//下拉刷新
  252. // this.initGetCartGoodsList()
  253. // uni.stopPullDownRefresh()
  254. },
  255. onShow(){
  256. },
  257. }
  258. </script>
  259. <style lang="scss">
  260. page{
  261. background: #f7f7f7;
  262. height: auto;
  263. }
  264. .cart-content{
  265. position: relative;
  266. margin-top: 24rpx;
  267. }
  268. .checkbox-box{
  269. display: flex;
  270. align-items: center;
  271. .checkbox{
  272. display: flex;
  273. margin: 0;
  274. padding: 0;
  275. display: flex;
  276. flex-direction: column;
  277. align-items: center;
  278. box-sizing: border-box;
  279. text-align: center;
  280. text-decoration: none;
  281. border-radius: 0;
  282. -webkit-tap-highlight-color: transparent;
  283. overflow: hidden;
  284. background-color:#FFFFFF;
  285. font-size: 36rpx;
  286. color:$color-system;
  287. }
  288. &.disabled{
  289. .checkbox{
  290. color:#999999
  291. }
  292. }
  293. .text{
  294. font-size: $font-size-24;
  295. margin-left: 10rpx;
  296. }
  297. }
  298. .goods-list{
  299. width: 100%;
  300. height: auto;
  301. background-color: #F7F7F7;
  302. border-top: 1px solid #F7F7F7;
  303. .goods-item{
  304. width: 702rpx;
  305. padding: 0 24rpx;
  306. background: #FFFFFF;
  307. margin-bottom: 24rpx;
  308. }
  309. .shoptitle{
  310. display: flex;
  311. align-items: center;
  312. height: 80rpx;
  313. // border-bottom: 1px solid #EBEBEB;
  314. line-height: 80rpx;
  315. .checkbox-box{
  316. padding: 10rpx;
  317. }
  318. .text{
  319. margin-left: 37rpx;
  320. font-size: $font-size-28;
  321. color: $text-color;
  322. text-align: left;
  323. font-weight: bold;
  324. }
  325. }
  326. .goods-pros{
  327. width: 702rpx;
  328. padding: 0 24rpx;
  329. background: #FFFFFF;
  330. margin-bottom: 24rpx;
  331. }
  332. .goods-pros-t{
  333. display: flex;
  334. width: 100%;
  335. height: auto;
  336. padding:20rpx 0;
  337. .checkbox-box{
  338. padding: 10rpx;
  339. }
  340. .pros-img{
  341. width: 210rpx;
  342. height: 210rpx;
  343. border-radius: 10rpx;
  344. margin:0 20rpx;
  345. border:1px solid #f3f3f3;
  346. image{
  347. width: 100%;
  348. height: 100%;
  349. border-radius: 10rpx;
  350. }
  351. }
  352. }
  353. .goods-pros-b{
  354. width:622rpx;
  355. height: 80rpx;
  356. margin-left: 84rpx;
  357. border-top: 1px solid #F7F7F7;
  358. position: relative;
  359. .productprice{
  360. height: 48rpx;
  361. width: 100%;
  362. margin-top: 15rpx;
  363. .text{
  364. line-height: 48rpx;
  365. float: left;
  366. color: $text-color;
  367. font-size: $font-size-28;
  368. }
  369. .count{
  370. height: 100%;
  371. float: right;
  372. position: relative;
  373. &.show{
  374. display: block;
  375. }
  376. &.none{
  377. display: none;
  378. }
  379. .number-box{
  380. display: flex;
  381. justify-content: center;
  382. align-items: center;
  383. .iconfont{
  384. font-size: $font-size-24;
  385. padding:0 20rpx;
  386. color: $text-color;
  387. text-align: center;
  388. line-height: 48rpx;
  389. font-weight: bold;
  390. }
  391. .btn-input{
  392. width: 62rpx;
  393. height: 48rpx;
  394. line-height: 48rpx;
  395. background: #F8F8F8;
  396. border-radius: 4rpx;
  397. text-align: center;
  398. font-size: $font-size-24;
  399. }
  400. }
  401. .uni-numbox{
  402. position: absolute;
  403. left: 45rpx;
  404. bottom: 0;
  405. .uni-numbox-minus, .uni-numbox-plus{
  406. width: 50rpx;
  407. line-height: 40rpx;
  408. }
  409. .uni-numbox-value {
  410. font-size: $font-size-28;
  411. width: 60rpx;
  412. }
  413. }
  414. }
  415. }
  416. }
  417. .pros-product{
  418. width: 402rpx;
  419. height: 100%;
  420. line-height: 36rpx;
  421. font-size: $font-size-28;
  422. position: relative;
  423. .producttitle{
  424. width: 100%;
  425. display: inline-block;
  426. height: auto;
  427. text-overflow:ellipsis;
  428. display: -webkit-box;
  429. word-break: break-all;
  430. -webkit-box-orient: vertical;
  431. -webkit-line-clamp: 2;
  432. overflow: hidden;
  433. margin-bottom: 8rpx;
  434. }
  435. .productspec{
  436. height: 44rpx;
  437. color: #999999;
  438. line-height: 44rpx;
  439. font-size: $font-size-26;
  440. }
  441. .product-view{
  442. width: 100%;
  443. height: auto;
  444. display: flex;
  445. .view-num{
  446. flex: 1;
  447. text-align: left;
  448. font-size: $font-size-26;
  449. color: #666666;
  450. line-height: 44rpx;
  451. }
  452. }
  453. }
  454. }
  455. .footer{
  456. width: 100%;
  457. background-color: #FFFFFF;
  458. height: 110rpx;
  459. position: fixed;
  460. bottom: 0rpx;
  461. z-index: 100;
  462. .footer-le{
  463. width: 490rpx;
  464. height: 100%;
  465. padding:0 30rpx;
  466. float: left;
  467. .text{
  468. font-weight: bold;
  469. }
  470. .foot-check{
  471. width: 100rpx;
  472. float: left;
  473. line-height: 110rpx;
  474. font-size: $font-size-24;
  475. .checkbox{
  476. width: 40rpx;
  477. text-align: center;
  478. }
  479. .text{
  480. width: 60rpx;
  481. float: right;
  482. }
  483. }
  484. .foot-check-delbtn{
  485. float: left;
  486. .delBtn{
  487. margin: 0;
  488. padding: 0;
  489. display: flex;
  490. flex-direction: column;
  491. align-items: center;
  492. box-sizing: border-box;
  493. font-size: $font-size-24;
  494. text-align: center;
  495. text-decoration: none;
  496. border-radius: 0;
  497. -webkit-tap-highlight-color: transparent;
  498. overflow: hidden;
  499. background-color:#FFFFFF;
  500. color: #FF2A2A;
  501. padding: 0 24rpx;
  502. display: flex;
  503. justify-content: center;
  504. align-items: center;
  505. line-height: 110rpx;
  506. font-weight: bold;
  507. &.none{
  508. display: none;
  509. }
  510. }
  511. }
  512. .sum{
  513. font-size: $font-size-28;
  514. line-height: 110rpx;
  515. color: $text-color;
  516. display: flex;
  517. justify-content: flex-end;
  518. .money{
  519. color: #FF2A2A;
  520. }
  521. .money-sign{
  522. font-size: $font-size-24;
  523. color: #FF2A2A;
  524. }
  525. }
  526. }
  527. .footer-ri{
  528. width: 200rpx;
  529. height: 100%;
  530. background:linear-gradient(135deg,rgba(242,143,49,1) 0%,rgba(225,86,22,1) 100%);
  531. float: right;
  532. display: flex;
  533. justify-content: space-between;
  534. align-items: center;
  535. z-index: 999;
  536. &.none{
  537. display: none;
  538. }
  539. .btn{
  540. width: 200rpx;
  541. height: 100%;
  542. font-size: $font-size-28;
  543. line-height: 110rpx;
  544. color: #FFFFFF;
  545. display: flex;
  546. justify-content: center;
  547. align-items: center;
  548. }
  549. }
  550. .footer-del{
  551. width: 400rpx;
  552. height: 110rpx;
  553. position: absolute;
  554. padding-left: 200rpx;
  555. background: #FFFFFF;
  556. right: 0;
  557. top: 0;
  558. z-index: 1000;
  559. &.show{
  560. animation: showDelbtn 0s linear both;
  561. }
  562. &.none{
  563. animation: hideDelbtn 0s linear both;
  564. }
  565. .btn{
  566. width: 50%;
  567. height: 100%;
  568. line-height: 110rpx;
  569. font-size: $font-size-28;
  570. color: #FFFFFF;
  571. text-align: center;
  572. float: left;
  573. }
  574. .btn.btn-cancel{
  575. background:#EEC1AB;
  576. }
  577. .btn.btn-confirm{
  578. background:#FF2A2A;
  579. }
  580. @keyframes showDelbtn {
  581. 0% {
  582. transform: translateX(0);
  583. }
  584. 100% {
  585. transform: translateX(-100%);
  586. }
  587. }
  588. @keyframes hideDelbtn {
  589. 0% {
  590. transform: translateX(-100%);
  591. }
  592. 100% {
  593. transform: translateX(0);
  594. }
  595. }
  596. }
  597. }
  598. </style>