deliver-record.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  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. .shoptitle{
  322. display: flex;
  323. align-items: center;
  324. height: 80rpx;
  325. line-height: 80rpx;
  326. .checkbox-box{
  327. padding: 10rpx;
  328. }
  329. .text{
  330. margin-left: 37rpx;
  331. font-size: $font-size-28;
  332. color: $text-color;
  333. text-align: left;
  334. font-weight: bold;
  335. }
  336. }
  337. .goods-pros{
  338. width: 702rpx;
  339. padding: 0 24rpx;
  340. background: #FFFFFF;
  341. margin-bottom: 24rpx;
  342. }
  343. .goods-pros-t{
  344. display: flex;
  345. width: 100%;
  346. height: auto;
  347. padding:20rpx 0;
  348. .checkbox-box{
  349. padding: 10rpx;
  350. }
  351. .pros-img{
  352. width: 210rpx;
  353. height: 210rpx;
  354. border-radius: 10rpx;
  355. margin:0 20rpx;
  356. border:1px solid #f3f3f3;
  357. image{
  358. width: 100%;
  359. height: 100%;
  360. border-radius: 10rpx;
  361. }
  362. }
  363. }
  364. .goods-pros-b{
  365. width:622rpx;
  366. height: 80rpx;
  367. margin-left: 84rpx;
  368. border-top: 1px solid #F7F7F7;
  369. position: relative;
  370. .productprice{
  371. height: 48rpx;
  372. width: 100%;
  373. margin-top: 15rpx;
  374. .text{
  375. line-height: 48rpx;
  376. float: left;
  377. color: $text-color;
  378. font-size: $font-size-28;
  379. }
  380. .count{
  381. height: 100%;
  382. float: right;
  383. position: relative;
  384. &.show{
  385. display: block;
  386. }
  387. &.none{
  388. display: none;
  389. }
  390. .number-box{
  391. display: flex;
  392. justify-content: center;
  393. align-items: center;
  394. .iconfont{
  395. font-size: $font-size-24;
  396. padding:0 20rpx;
  397. color: $text-color;
  398. text-align: center;
  399. line-height: 48rpx;
  400. font-weight: bold;
  401. }
  402. .btn-input{
  403. width: 62rpx;
  404. height: 48rpx;
  405. line-height: 48rpx;
  406. background: #F8F8F8;
  407. border-radius: 4rpx;
  408. text-align: center;
  409. font-size: $font-size-24;
  410. }
  411. }
  412. .uni-numbox{
  413. position: absolute;
  414. left: 45rpx;
  415. bottom: 0;
  416. .uni-numbox-minus, .uni-numbox-plus{
  417. width: 50rpx;
  418. line-height: 40rpx;
  419. }
  420. .uni-numbox-value {
  421. font-size: $font-size-28;
  422. width: 60rpx;
  423. }
  424. }
  425. }
  426. }
  427. }
  428. .pros-product{
  429. width: 402rpx;
  430. height: 100%;
  431. line-height: 36rpx;
  432. font-size: $font-size-28;
  433. position: relative;
  434. .producttitle{
  435. width: 100%;
  436. display: inline-block;
  437. height: auto;
  438. text-overflow:ellipsis;
  439. display: -webkit-box;
  440. word-break: break-all;
  441. -webkit-box-orient: vertical;
  442. -webkit-line-clamp: 2;
  443. overflow: hidden;
  444. margin-bottom: 8rpx;
  445. }
  446. .productspec{
  447. height: 44rpx;
  448. color: #999999;
  449. line-height: 44rpx;
  450. font-size: $font-size-26;
  451. }
  452. .product-view{
  453. width: 100%;
  454. height: auto;
  455. display: flex;
  456. .view-num{
  457. flex: 1;
  458. text-align: left;
  459. font-size: $font-size-26;
  460. color: #666666;
  461. line-height: 44rpx;
  462. }
  463. }
  464. }
  465. }
  466. .footer{
  467. width: 100%;
  468. background-color: #FFFFFF;
  469. height: 110rpx;
  470. position: fixed;
  471. bottom: 0rpx;
  472. z-index: 100;
  473. .footer-le{
  474. width: 490rpx;
  475. height: 100%;
  476. padding:0 30rpx;
  477. float: left;
  478. .text{
  479. font-weight: bold;
  480. }
  481. .foot-check{
  482. width: 100rpx;
  483. float: left;
  484. line-height: 110rpx;
  485. font-size: $font-size-24;
  486. .checkbox{
  487. width: 40rpx;
  488. text-align: center;
  489. }
  490. .text{
  491. width: 60rpx;
  492. float: right;
  493. }
  494. }
  495. .foot-check-delbtn{
  496. float: left;
  497. .delBtn{
  498. margin: 0;
  499. padding: 0;
  500. display: flex;
  501. flex-direction: column;
  502. align-items: center;
  503. box-sizing: border-box;
  504. font-size: $font-size-24;
  505. text-align: center;
  506. text-decoration: none;
  507. border-radius: 0;
  508. -webkit-tap-highlight-color: transparent;
  509. overflow: hidden;
  510. background-color:#FFFFFF;
  511. color: #FF2A2A;
  512. padding: 0 24rpx;
  513. display: flex;
  514. justify-content: center;
  515. align-items: center;
  516. line-height: 110rpx;
  517. font-weight: bold;
  518. &.none{
  519. display: none;
  520. }
  521. }
  522. }
  523. .sum{
  524. font-size: $font-size-28;
  525. line-height: 110rpx;
  526. color: $text-color;
  527. display: flex;
  528. justify-content: flex-end;
  529. .money{
  530. color: #FF2A2A;
  531. }
  532. .money-sign{
  533. font-size: $font-size-24;
  534. color: #FF2A2A;
  535. }
  536. }
  537. }
  538. .footer-ri{
  539. width: 200rpx;
  540. height: 100%;
  541. background:linear-gradient(135deg,rgba(242,143,49,1) 0%,rgba(225,86,22,1) 100%);
  542. float: right;
  543. display: flex;
  544. justify-content: space-between;
  545. align-items: center;
  546. z-index: 999;
  547. &.none{
  548. display: none;
  549. }
  550. .btn{
  551. width: 200rpx;
  552. height: 100%;
  553. font-size: $font-size-28;
  554. line-height: 110rpx;
  555. color: #FFFFFF;
  556. display: flex;
  557. justify-content: center;
  558. align-items: center;
  559. }
  560. }
  561. }
  562. </style>