add-logistics.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  1. <template>
  2. <view class="container logistics" :style="{paddingBottom :isIphoneX ? (236+68)+'rpx' : '236rpx'}" v-if="isChange">
  3. <view class="logistics-list" v-for="(item,index) in logisticsList" :key="index">
  4. <view class="item-title">
  5. <view class="title-left">物流{{index+1}}</view>
  6. <view class="title-right" v-if="(index+1) > 1" @click="deleteLogistItemFn(item,index)">
  7. <text class="iconfont icon-shanchu" ></text>删除
  8. </view>
  9. </view>
  10. <view class="item-main">
  11. <view class="item-main-cell" @click.stop="pageNavigateTo(index)">
  12. <input class="input" type="text" v-model="item.label" placeholder="物流公司" disabled="true">
  13. <text class="iconfont icon-xiayibu"></text>
  14. </view>
  15. <view class="item-main-cell">
  16. <input class="input" type="text" v-model="item.number" placeholder="物流单号">
  17. </view>
  18. <view class="item-main-cell none" @click.stop="AddScanCode(item)" >
  19. <text class="iconfont icon-icon-test" ></text><text>扫码录入</text>
  20. </view>
  21. </view>
  22. </view>
  23. <view class="logistics-btn">
  24. <view class="btn add-btn" @click="addListFn">添加物流</view>
  25. </view>
  26. <view class="logistics-btn-fiexd" :style="{paddingBottom :isIphoneX ? '68rpx' : '34rpx'}">
  27. <view class="btn-tips" @click.stop="showShowRemarksFn">
  28. <text class="iconfont icon-xiangxiajiantou" v-if="isShowRemarks"></text>
  29. <text class="iconfont icon-xiangshangjiantou" v-else></text>
  30. 添加备注
  31. </view>
  32. <view class="logistics-remarks" :class="specClass" v-show="isShowRemarks">
  33. <view class="label">拍照备注</view>
  34. <view class="remarks-photo clearfix">
  35. <view class="photo-item" v-for="(item, index) in photoLists" :key="index">
  36. <image :src="item" mode="aspectFill" @click.stop="previewImg(index)"></image>
  37. <text class="iconfont icon-iconfontguanbi" @click.stop="deletePhotoFn(index)"></text>
  38. </view>
  39. <view class="photo-item add" @click.stop="uploadPhotoFn" v-if="photoLists.length<10 || photoLists.length == 0">
  40. <text class="iconfont icon-jiahao"></text>
  41. </view>
  42. </view>
  43. <view class="label">文字备注</view>
  44. <view class="remarks-textarea">
  45. <textarea class="textarea" v-model="info.note" value="" placeholder="文字备注,200字以内" maxlength="200" @input="conInput"/>
  46. <text class="limit-text"><text class="red">{{min}}</text>/{{max}}</text>
  47. </view>
  48. <view class="remarks-tips">请备注快递单、发货现场和货物的照片,最多10张</view>
  49. </view>
  50. <view class="btn confim-btn" @click="confirmDeliverFn">确认发货</view>
  51. </view>
  52. </view>
  53. </template>
  54. <script>
  55. import { mapState,mapMutations } from 'vuex'
  56. import authorize from '@/common/config/authorize.js'
  57. import { uploadFileImage } from "@/services/public.js"
  58. var isPreviewImg;
  59. export default{
  60. data() {
  61. return{
  62. logisticsBatchId:'',
  63. isIphoneX:this.$store.state.isIphoneX,
  64. isChange:true,
  65. isShowRemarks:false,
  66. specClass:'',
  67. photoLists:[],
  68. checkLogicsIndex:0,
  69. selectID:0,
  70. addLogisticsType:'',
  71. info:{
  72. image:'',
  73. note:'',
  74. shopOrderId:''
  75. },//备注信息
  76. record:[],//子订单商品信息
  77. logisticsList:[{
  78. label:'',
  79. number:'',
  80. value:'',
  81. }],
  82. min:0,
  83. max:200
  84. }
  85. },
  86. watch: {
  87. logisticsList: {
  88. handler: function (el) {//监听对象的变换使用 function,箭头函数容易出现this指向不正确
  89. this.logisticsList = el
  90. },
  91. deep: true
  92. }
  93. },
  94. onLoad(option) {
  95. if(option.type == 'add'){
  96. this.addLogisticsType = option.type
  97. this.info.shopOrderId = option.shopOrderId;
  98. this.record = JSON.parse(option.data)
  99. }else{
  100. let queryData = JSON.parse(option.data);
  101. this.addLogisticsType = option.type
  102. this.logisticsBatchId = queryData.logisticsBatchId
  103. this.info.shopOrderId = option.shopOrderId;
  104. this.initGetLogisticsInfo()
  105. }
  106. },
  107. methods:{
  108. ...mapMutations(['login']),
  109. initGetLogisticsInfo(){
  110. this.ShopService.GetLogisticsInfo(
  111. {
  112. logisticsBatchId : this.logisticsBatchId,
  113. shopOrderId:this.info.shopOrderId ,
  114. }
  115. ).then(response =>{
  116. const data = response.data.logisticsBatch
  117. if(data.remarkImages!=null){
  118. this.photoLists = data.remarkImages
  119. }else{
  120. this.photoLists =[]
  121. }
  122. this.info.note = data.remark
  123. })
  124. .catch(error =>{
  125. this.$util.msg(error.msg,2000);
  126. })
  127. },
  128. AddScanCode(item){
  129. let self = this;
  130. uni.scanCode({
  131. onlyFromCamera: true,
  132. success: function (res) {
  133. item.number= res.result
  134. self.ShopService.GetExpressInformation({number:res.result}).then(response =>{
  135. item.label= response.data.label
  136. item.value= response.data.value
  137. self.selectID = response.data.id
  138. }).catch(error =>{
  139. self.$util.msg(error.msg,2000);
  140. })
  141. }
  142. });
  143. },
  144. addListFn(){//添加
  145. this.isShowRemarks = false
  146. let obj ={name:'',number:'',value:''};
  147. this.logisticsList.push(obj)
  148. },
  149. deleteLogistItemFn(item,index){
  150. this.$util.modal('提示','确认删除物流信息吗?','确定','取消',true,() =>{
  151. this.logisticsList.splice(index, 1);
  152. })
  153. },
  154. pageNavigateTo(index){//选择物流公司
  155. this.isChange = false
  156. this.checkLogicsIndex = index
  157. this.$api.navigateTo(`/supplier/pages/deliver/logistics-list?selectID=${this.selectID}`)
  158. },
  159. showShowRemarksFn(){//显示发货备注
  160. this.isShowRemarks = !this.isShowRemarks
  161. if(this.isShowRemarks){
  162. this.specClass = 'show';
  163. }else{
  164. this.specClass = 'hide';
  165. }
  166. },
  167. uploadPhotoFn(){//添加发货备注图片
  168. uploadFileImage().then(res =>{
  169. this.photoLists.push(JSON.parse(res.data).data)
  170. })
  171. },
  172. deletePhotoFn(index){//删除发货备注图片
  173. this.photoLists.splice(index, 1);
  174. },
  175. confirmDeliverFn(){//确认发货
  176. switch(this.addLogisticsType){
  177. case 'add':
  178. this.isNewAddLogisticsFn()
  179. break;
  180. case 'reple':
  181. this.isRepleAddLogisticsFn()
  182. break;
  183. }
  184. },
  185. isRepleAddLogisticsFn(){//重新添加物流信息
  186. // 校验物流公司不能为空
  187. let isLogisticsLabel = false
  188. let isLogisticsNumber = false
  189. this.logisticsList.forEach(el =>{
  190. if(el.label == ''){
  191. isLogisticsLabel = true
  192. }
  193. if(el.number == ''){
  194. isLogisticsNumber = true
  195. }
  196. })
  197. if(isLogisticsLabel){
  198. this.$util.msg('请选择物流公司',2000);
  199. return
  200. }
  201. if(isLogisticsNumber){
  202. this.$util.msg('请输入物流单号',2000);
  203. return
  204. }
  205. //统一处理物流单号
  206. let logisticsArray = []
  207. let checkRepeat = false
  208. for (const el of this.logisticsList) {
  209. // 检查缓存中是否已经存在
  210. if (logisticsArray.find(c => c.number === el.number && c.number === el.number)) {
  211. // 已经存在
  212. checkRepeat = true
  213. }else{
  214. // 不存在就说明以前没遇到过,把它记录下来
  215. let logisticsObj = {
  216. number:el.number,
  217. logisticsCompanyName:el.label,
  218. logisticsCompanyCode:el.value
  219. }
  220. logisticsArray.push(logisticsObj)
  221. }
  222. }
  223. if(checkRepeat){
  224. this.$util.msg('物流单号重复',2000);
  225. return
  226. }
  227. //统一处理备注图片
  228. this.photoLists.forEach(el =>{
  229. this.info.image += el+'##'
  230. })
  231. let params = {
  232. logistics:logisticsArray,
  233. remarkImage:this.info.image,
  234. remark:this.info.note,
  235. logisticsBatchID:this.logisticsBatchId
  236. }
  237. this.ShopService.ShopAddLogisticsInfo({params:JSON.stringify(params)}).then(response =>{
  238. this.$util.msg('添加物流成功',2000,true,'success')
  239. setTimeout(()=>{
  240. this.$api.navigateTo(`/supplier/pages/deliver/deliver-record?shopOrderId=${this.info.shopOrderId}`)
  241. },2000)
  242. }).catch(error =>{
  243. this.$util.msg(error.msg,2000);
  244. })
  245. },
  246. isNewAddLogisticsFn(){//第一次添加发货物流信息
  247. // 校验物流公司不能为空
  248. let isLogisticsLabel = false
  249. let isLogisticsNumber = false
  250. this.logisticsList.forEach(el =>{
  251. if(el.label == ''){
  252. isLogisticsLabel = true
  253. }
  254. if(el.number == ''){
  255. isLogisticsNumber = true
  256. }
  257. })
  258. if(isLogisticsLabel){
  259. this.$util.msg('请选择物流公司',2000);
  260. return
  261. }
  262. if(isLogisticsNumber){
  263. this.$util.msg('请输入物流单号',2000);
  264. return
  265. }
  266. //统一处理物流单号
  267. let logisticsArray = []
  268. let checkRepeat = false
  269. for (const el of this.logisticsList) {
  270. // 检查缓存中是否已经存在
  271. if (logisticsArray.find(c => c.number === el.number && c.number === el.number)) {
  272. // 已经存在
  273. checkRepeat = true
  274. }else{
  275. // 不存在就说明以前没遇到过,把它记录下来
  276. let logisticsObj = {
  277. number:el.number,
  278. logisticsCompanyName:el.label,
  279. logisticsCompanyCode:el.value
  280. }
  281. logisticsArray.push(logisticsObj)
  282. }
  283. }
  284. if(checkRepeat){
  285. this.$util.msg('物流单号重复',2000);
  286. return
  287. }
  288. //统一处理备注图片
  289. this.info.image = ''
  290. this.photoLists.forEach(el =>{
  291. this.info.image += el+'##'
  292. })
  293. let params = {
  294. logistics:logisticsArray,
  295. record:this.record,
  296. info:this.info
  297. }
  298. this.ShopService.ShopAddLogistics({params:JSON.stringify(params)}).then(response =>{
  299. this.$util.msg('发货成功',2000,true,'success')
  300. let logisticsBatchId = response.data
  301. setTimeout(()=>{
  302. this.$api.navigateTo(`/supplier/pages/deliver/qualifications-add?logisticsBatchId=${logisticsBatchId}&shopOrderId=${this.info.shopOrderId}`)
  303. },2000)
  304. }).catch(error =>{
  305. this.$util.msg(error.msg,2000);
  306. })
  307. },
  308. previewImg (index) {//顶部商品图片预览
  309. isPreviewImg = true
  310. let previewUrls = this.photoLists
  311. uni.previewImage({
  312. current: index, //图片索引
  313. urls: previewUrls, //必须是http图片,本地图片无效
  314. longPressActions:''
  315. })
  316. },
  317. conInput(e){//备注文字字数限制
  318. let value = e.detail.value;
  319. let len = parseInt(value.length);
  320. if (len > this.max) return;
  321. this.min = len;
  322. if(this.min == 200){
  323. this.$util.msg('您输入的字数已达上限',2000);
  324. }
  325. }
  326. },
  327. onShow() {
  328. //处理选择物流公司
  329. let pages = getCurrentPages();
  330. let currPage = pages[pages.length-1];
  331. if(currPage.data.select =='select'){
  332. let SelectData = uni.getStorageSync('selectLogics')
  333. this.selectID = SelectData.id
  334. let setNewLogisticsList = this.logisticsList
  335. setNewLogisticsList.forEach((el,index,arr) =>{
  336. if(index == this.checkLogicsIndex ){
  337. arr[this.checkLogicsIndex] = Object.assign({},arr[this.checkLogicsIndex],SelectData)
  338. }
  339. })
  340. this.logisticsList = setNewLogisticsList
  341. }
  342. this.isChange = true
  343. }
  344. }
  345. </script>
  346. <style lang="scss">
  347. page {
  348. height: auto;
  349. background:#F7F7F7;
  350. }
  351. @keyframes showRemarks {
  352. 0% {opacity: 0;}
  353. 20% {opacity: 0.2;}
  354. 40% {opacity: 0.4;}
  355. 60% {opacity: 0.6;}
  356. 80% {opacity: 0.8;}
  357. 100% {opacity: 1;}
  358. }
  359. @keyframes hideRemarks {
  360. 0% {opacity: 1;}
  361. 20% {opacity: 0.8;}
  362. 40% {opacity: 0.6;}
  363. 60% {opacity: 0.4;}
  364. 80% {opacity: 0.2;}
  365. 100% {opacity: 0;}
  366. }
  367. .logistics{
  368. border-top: 1px solid #EBEBEB;
  369. }
  370. .logistics-list{
  371. width: 100%;
  372. height: auto;
  373. padding: 10rpx 0;
  374. background-color: #FFFFFF;
  375. margin-bottom: 24rpx;
  376. .item-title{
  377. width: 702rpx;
  378. height: 80rpx;
  379. padding: 0 24rpx;
  380. line-height: 80rpx;
  381. text-align: left;
  382. font-size: $font-size-28;
  383. color: $text-color;
  384. border-bottom: 1px solid #EBEBEB;
  385. .title-left{
  386. float: left;
  387. }
  388. .title-right{
  389. float: right;
  390. .icon-shanchu{
  391. font-size: $font-size-30;
  392. color: #FF2A2A;
  393. }
  394. }
  395. }
  396. .item-main{
  397. width: 702rpx;
  398. padding: 0 24rpx;
  399. .item-main-cell{
  400. width: 100%;
  401. height: 80rpx;
  402. line-height: 80rpx;
  403. border-bottom: 1px solid #EBEBEB;
  404. position: relative;
  405. &.none{
  406. border-bottom: none;
  407. text-align: center;
  408. font-size: $font-size-28;
  409. color: $color-system;
  410. }
  411. .icon-xiayibu{
  412. width: 40rpx;
  413. height: 80rpx;
  414. display: block;
  415. position: absolute;
  416. right: 0;
  417. top: 0;
  418. font-size: $font-size-32;
  419. color: $text-color;
  420. text-align: center;
  421. }
  422. .icon-icon-test{
  423. color: $color-system;
  424. font-size: $font-size-28;
  425. margin-right: 10rpx;
  426. }
  427. .input{
  428. width: 100%;
  429. height: 44rpx;
  430. line-height: 44rpx;
  431. padding: 18rpx 0;
  432. font-size: $font-size-28;
  433. color: $text-color;
  434. }
  435. }
  436. }
  437. }
  438. .logistics-btn{
  439. width: 702rpx;
  440. height: 88rpx;
  441. margin: 0 auto;
  442. .btn{
  443. width: 100%;
  444. height: 100%;
  445. background-color: #FFF;
  446. border-radius: 44rpx;
  447. border: 1px solid $color-system;
  448. line-height: 88rpx;
  449. text-align: center;
  450. color: $color-system;
  451. }
  452. }
  453. .logistics-btn-fiexd{
  454. width: 702rpx;
  455. padding: 0 24rpx;
  456. height:auto;
  457. position: fixed;
  458. bottom: 0;
  459. left: 0;
  460. background-color: #FFF;
  461. border-radius: 20rpx 20rpx 0 0;
  462. box-shadow:0px 3px 10px rgba(51, 51, 51,0.5);
  463. z-index: 999;
  464. .btn-tips{
  465. height: 80rpx;
  466. line-height: 80rpx;
  467. text-align: center;
  468. font-size: $font-size-28;
  469. color: #999999;
  470. }
  471. .confim-btn{
  472. width: 702rpx;
  473. height: 88rpx;
  474. background: $btn-confirm;
  475. line-height: 88rpx;
  476. text-align: center;
  477. color: #FFF;
  478. font-size: $font-size-28;
  479. border-radius: 44rpx;
  480. }
  481. .logistics-remarks{
  482. width: 100%;
  483. height: auto;
  484. &.show {
  485. animation: showRemarks 0.2s linear both;
  486. }
  487. &.hide {
  488. animation: hideRemarks 0.2s linear both;
  489. }
  490. .label{
  491. height: 44rpx;
  492. line-height: 44rpx;
  493. font-size: $font-size-28;
  494. color: $text-color;
  495. }
  496. .remarks-photo{
  497. width: 100%;
  498. height: auto;
  499. padding: 10rpx 0;
  500. .photo-item{
  501. display: inline-block;
  502. width: 112rpx;
  503. height: 112rpx;
  504. margin: 10rpx 0;
  505. margin-right: 25rpx;
  506. border-radius: 10rpx;
  507. border:1px solid #F5F5F5;
  508. position: relative;
  509. float: left;
  510. &.add{
  511. width: 112rpx;
  512. height: 112rpx;
  513. border-color: #FFC684;
  514. text-align: center;
  515. line-height: 112rpx;
  516. margin-right: 0rpx;
  517. .icon-jiahao{
  518. font-size: $font-size-44;
  519. color:#FFC684 ;
  520. font-weight: bold;
  521. }
  522. }
  523. .icon-iconfontguanbi{
  524. width: 24rpx;
  525. height: 24rpx;
  526. border-radius: 0 10rpx 0 0;
  527. display: block;
  528. position: absolute;
  529. right: 0;
  530. top: 0;
  531. background: rgba(51, 51, 51, 0.7);
  532. text-align: center;
  533. line-height: 24rpx;
  534. color: #FFF;
  535. font-size: $font-size-22;
  536. }
  537. image{
  538. width: 112rpx;
  539. height: 112rpx;
  540. border-radius: 10rpx;
  541. }
  542. }
  543. .photo-list{
  544. width: 100%;
  545. height: 116rpx;
  546. overflow: hidden;
  547. white-space: nowrap;
  548. display: flex;
  549. align-items: flex-start;
  550. }
  551. .scoll-wrapper{
  552. display:flex;
  553. align-items: flex-start;
  554. }
  555. }
  556. .remarks-textarea{
  557. width: 652rpx;
  558. height: 124rpx;
  559. padding:10rpx 24rpx 24rpx 24rpx;
  560. margin-top: 20rpx;
  561. background-color: #F5F5F5;
  562. border-radius: 10rpx;
  563. position: relative;
  564. .textarea{
  565. width: 100%;
  566. height: 100%;
  567. line-height: 36rpx;
  568. font-size: $font-size-24;
  569. color: $text-color;
  570. z-index: 1;
  571. }
  572. .limit-text{
  573. position: absolute;
  574. right: 20rpx;
  575. bottom: 0;
  576. line-height: 44rpx;
  577. font-size: $font-size-24;
  578. color: #D0D0D0;
  579. .red{
  580. color: $color-system;
  581. }
  582. }
  583. }
  584. .remarks-tips{
  585. width: 100%;
  586. line-height: 70rpx;
  587. font-size: $font-size-24;
  588. color: #999999;
  589. }
  590. }
  591. }
  592. </style>