deliver-goods.vue 14 KB

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