add-logistics.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556
  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 "@/api/utils.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({ logisticsBatchId : this.logisticsBatchId, shopOrderId:this.info.shopOrderId }).then(response =>{
  111. const data = response.data.logisticsBatch
  112. if(data.remarkImages!=null){
  113. this.photoLists = data.remarkImages
  114. }else{
  115. this.photoLists =[]
  116. }
  117. this.info.note = data.remark
  118. }).catch(error =>{
  119. this.$util.msg(error.msg,2000);
  120. })
  121. },
  122. AddScanCode(item){
  123. let self = this;
  124. uni.scanCode({
  125. onlyFromCamera: true,
  126. success: function (res) {
  127. item.number= res.result
  128. self.ShopService.GetExpressInformation({number:res.result}).then(response =>{
  129. item.label= response.data.label
  130. item.value= response.data.value
  131. self.selectID = response.data.id
  132. }).catch(error =>{
  133. self.$util.msg(error.msg,2000);
  134. })
  135. }
  136. });
  137. },
  138. addListFn(){//添加
  139. this.isShowRemarks = false
  140. let obj ={name:'',number:'',value:''};
  141. this.logisticsList.push(obj)
  142. },
  143. deleteLogistItemFn(item,index){
  144. this.$util.modal('提示','确认删除物流信息吗?','确定','取消',true,() =>{
  145. this.logisticsList.splice(index, 1);
  146. })
  147. },
  148. pageNavigateTo(index){//选择物流公司
  149. this.isChange = false
  150. this.checkLogicsIndex = index
  151. this.$api.navigateTo(`/supplier/pages/deliver/logistics-list?selectID=${this.selectID}`)
  152. },
  153. showShowRemarksFn(){//显示发货备注
  154. this.isShowRemarks = !this.isShowRemarks
  155. if(this.isShowRemarks){
  156. this.specClass = 'show';
  157. }else{
  158. this.specClass = 'hide';
  159. }
  160. },
  161. uploadPhotoFn(){//添加发货备注图片
  162. uploadFileImage().then(res =>{
  163. this.photoLists.push(JSON.parse(res.data).data)
  164. })
  165. },
  166. deletePhotoFn(index){//删除发货备注图片
  167. this.photoLists.splice(index, 1);
  168. },
  169. confirmDeliverFn(){//确认发货
  170. switch(this.addLogisticsType){
  171. case 'add':
  172. this.isNewAddLogisticsFn()
  173. break;
  174. case 'reple':
  175. this.isRepleAddLogisticsFn()
  176. break;
  177. }
  178. },
  179. isRepleAddLogisticsFn(){//重新添加物流信息
  180. //统一处理物流单号
  181. let logisticsArray = []
  182. let checkRepeat = false
  183. for (const el of this.logisticsList) {
  184. // 检查缓存中是否已经存在
  185. if (logisticsArray.find(c => c.number === el.number && c.number === el.number)) {
  186. // 已经存在
  187. checkRepeat = true
  188. }else{
  189. // 不存在就说明以前没遇到过,把它记录下来
  190. let logisticsObj = {
  191. number:el.number,
  192. logisticsCompanyName:el.label,
  193. logisticsCompanyCode:el.value
  194. }
  195. logisticsArray.push(logisticsObj)
  196. }
  197. }
  198. if(checkRepeat){
  199. this.$util.msg('物流单号重复',2000);
  200. return
  201. }
  202. //统一处理备注图片
  203. this.photoLists.forEach(el =>{
  204. this.info.image += el+'##'
  205. })
  206. let params = {
  207. logistics:logisticsArray,
  208. remarkImage:this.info.image,
  209. remark:this.info.note,
  210. logisticsBatchID:this.logisticsBatchId
  211. }
  212. this.ShopService.ShopAddLogisticsInfo({params:JSON.stringify(params)}).then(response =>{
  213. this.$util.msg('添加物流成功',2000,true,'success')
  214. setTimeout(()=>{
  215. this.$api.navigateTo(`/supplier/pages/deliver/deliver-record?shopOrderId=${this.info.shopOrderId}`)
  216. },2000)
  217. }).catch(error =>{
  218. this.$util.msg(error.msg,2000);
  219. })
  220. },
  221. isNewAddLogisticsFn(){//第一次添加发货物流信息
  222. if(this.logisticsList[0].label == ''){
  223. this.$util.msg('请选择物流公司',2000);
  224. return
  225. }
  226. if(this.logisticsList[0].number == ''){
  227. this.$util.msg('请输入物流单号',2000);
  228. return
  229. }
  230. //统一处理物流单号
  231. let logisticsArray = []
  232. let checkRepeat = false
  233. for (const el of this.logisticsList) {
  234. // 检查缓存中是否已经存在
  235. if (logisticsArray.find(c => c.number === el.number && c.number === el.number)) {
  236. // 已经存在
  237. checkRepeat = true
  238. }else{
  239. // 不存在就说明以前没遇到过,把它记录下来
  240. let logisticsObj = {
  241. number:el.number,
  242. logisticsCompanyName:el.label,
  243. logisticsCompanyCode:el.value
  244. }
  245. logisticsArray.push(logisticsObj)
  246. }
  247. }
  248. if(checkRepeat){
  249. this.$util.msg('物流单号重复',2000);
  250. return
  251. }
  252. //统一处理备注图片
  253. this.photoLists.forEach(el =>{
  254. this.info.image += el+'##'
  255. })
  256. let params = {
  257. logistics:logisticsArray,
  258. record:this.record,
  259. info:this.info
  260. }
  261. this.ShopService.ShopAddLogistics({params:JSON.stringify(params)}).then(response =>{
  262. this.$util.msg('发货成功',2000,true,'success')
  263. setTimeout(()=>{
  264. this.$api.navigateTo(`/supplier/pages/deliver/deliver-record?shopOrderId=${this.info.shopOrderId}`)
  265. },2000)
  266. }).catch(error =>{
  267. this.$util.msg(error.msg,2000);
  268. })
  269. },
  270. previewImg (index) {//顶部商品图片预览
  271. isPreviewImg = true
  272. let previewUrls = this.photoLists
  273. uni.previewImage({
  274. current: index, //图片索引
  275. urls: previewUrls, //必须是http图片,本地图片无效
  276. longPressActions:''
  277. })
  278. },
  279. conInput(e){//备注文字字数限制
  280. let value = e.detail.value;
  281. let len = parseInt(value.length);
  282. if (len > this.max) return;
  283. this.min = len;
  284. if(this.min == 200){
  285. this.$util.msg('您输入的字数已达上限',2000);
  286. }
  287. }
  288. },
  289. onShow() {
  290. //处理选择物流公司
  291. let pages = getCurrentPages();
  292. let currPage = pages[pages.length-1];
  293. if(currPage.data.select =='select'){
  294. let SelectData = uni.getStorageSync('selectLogics')
  295. this.selectID = SelectData.id
  296. let setNewLogisticsList = this.logisticsList
  297. setNewLogisticsList.forEach((el,index,arr) =>{
  298. if(index == this.checkLogicsIndex ){
  299. arr[this.checkLogicsIndex] = Object.assign({},arr[this.checkLogicsIndex],SelectData)
  300. }
  301. })
  302. this.logisticsList = setNewLogisticsList
  303. }
  304. this.isChange = true
  305. }
  306. }
  307. </script>
  308. <style lang="scss">
  309. page {
  310. height: auto;
  311. background:#F7F7F7;
  312. }
  313. @keyframes showRemarks {
  314. 0% {opacity: 0;}
  315. 20% {opacity: 0.2;}
  316. 40% {opacity: 0.4;}
  317. 60% {opacity: 0.6;}
  318. 80% {opacity: 0.8;}
  319. 100% {opacity: 1;}
  320. }
  321. @keyframes hideRemarks {
  322. 0% {opacity: 1;}
  323. 20% {opacity: 0.8;}
  324. 40% {opacity: 0.6;}
  325. 60% {opacity: 0.4;}
  326. 80% {opacity: 0.2;}
  327. 100% {opacity: 0;}
  328. }
  329. .logistics{
  330. border-top: 1px solid #EBEBEB;
  331. }
  332. .logistics-list{
  333. width: 100%;
  334. height: auto;
  335. padding: 10rpx 0;
  336. background-color: #FFFFFF;
  337. margin-bottom: 24rpx;
  338. .item-title{
  339. width: 702rpx;
  340. height: 80rpx;
  341. padding: 0 24rpx;
  342. line-height: 80rpx;
  343. text-align: left;
  344. font-size: $font-size-28;
  345. color: $text-color;
  346. border-bottom: 1px solid #EBEBEB;
  347. .title-left{
  348. float: left;
  349. }
  350. .title-right{
  351. float: right;
  352. .icon-shanchu{
  353. font-size: $font-size-30;
  354. color: #FF2A2A;
  355. }
  356. }
  357. }
  358. .item-main{
  359. width: 702rpx;
  360. padding: 0 24rpx;
  361. .item-main-cell{
  362. width: 100%;
  363. height: 80rpx;
  364. line-height: 80rpx;
  365. border-bottom: 1px solid #EBEBEB;
  366. position: relative;
  367. &.none{
  368. border-bottom: none;
  369. text-align: center;
  370. font-size: $font-size-28;
  371. color: $color-system;
  372. }
  373. .icon-xiayibu{
  374. width: 40rpx;
  375. height: 80rpx;
  376. display: block;
  377. position: absolute;
  378. right: 0;
  379. top: 0;
  380. font-size: $font-size-32;
  381. color: $text-color;
  382. text-align: center;
  383. }
  384. .icon-icon-test{
  385. color: $color-system;
  386. font-size: $font-size-28;
  387. margin-right: 10rpx;
  388. }
  389. .input{
  390. width: 100%;
  391. height: 44rpx;
  392. line-height: 44rpx;
  393. padding: 18rpx 0;
  394. font-size: $font-size-28;
  395. color: $text-color;
  396. }
  397. }
  398. }
  399. }
  400. .logistics-btn{
  401. width: 702rpx;
  402. height: 88rpx;
  403. margin: 0 auto;
  404. .btn{
  405. width: 100%;
  406. height: 100%;
  407. background-color: #FFF;
  408. border-radius: 14rpx;
  409. border: 1px solid $color-system;
  410. line-height: 88rpx;
  411. text-align: center;
  412. color: $color-system;
  413. }
  414. }
  415. .logistics-btn-fiexd{
  416. width: 702rpx;
  417. padding: 0 24rpx;
  418. height:auto;
  419. position: fixed;
  420. bottom: 0;
  421. left: 0;
  422. background-color: #FFF;
  423. border-radius: 20rpx 20rpx 0 0;
  424. box-shadow:0px 3px 10px rgba(51, 51, 51,0.5);
  425. z-index: 999;
  426. .btn-tips{
  427. height: 80rpx;
  428. line-height: 80rpx;
  429. text-align: center;
  430. font-size: $font-size-28;
  431. color: #999999;
  432. }
  433. .confim-btn{
  434. width: 702rpx;
  435. height: 88rpx;
  436. background: $btn-confirm;
  437. line-height: 88rpx;
  438. text-align: center;
  439. color: #FFF;
  440. font-size: $font-size-28;
  441. border-radius: 14rpx;
  442. }
  443. .logistics-remarks{
  444. width: 100%;
  445. height: auto;
  446. &.show {
  447. animation: showRemarks 0.2s linear both;
  448. }
  449. &.hide {
  450. animation: hideRemarks 0.2s linear both;
  451. }
  452. .label{
  453. height: 44rpx;
  454. line-height: 44rpx;
  455. font-size: $font-size-28;
  456. color: $text-color;
  457. }
  458. .remarks-photo{
  459. width: 100%;
  460. height: auto;
  461. padding: 10rpx 0;
  462. .photo-item{
  463. display: inline-block;
  464. width: 112rpx;
  465. height: 112rpx;
  466. margin: 10rpx 0;
  467. margin-right: 25rpx;
  468. border-radius: 10rpx;
  469. border:1px solid #F5F5F5;
  470. position: relative;
  471. float: left;
  472. &.add{
  473. width: 112rpx;
  474. height: 112rpx;
  475. border-color: #FFC684;
  476. text-align: center;
  477. line-height: 112rpx;
  478. margin-right: 0rpx;
  479. .icon-jiahao{
  480. font-size: $font-size-44;
  481. color:#FFC684 ;
  482. font-weight: bold;
  483. }
  484. }
  485. .icon-iconfontguanbi{
  486. width: 24rpx;
  487. height: 24rpx;
  488. border-radius: 0 10rpx 0 0;
  489. display: block;
  490. position: absolute;
  491. right: 0;
  492. top: 0;
  493. background: rgba(51, 51, 51, 0.7);
  494. text-align: center;
  495. line-height: 24rpx;
  496. color: #FFF;
  497. font-size: $font-size-22;
  498. }
  499. image{
  500. width: 112rpx;
  501. height: 112rpx;
  502. border-radius: 10rpx;
  503. }
  504. }
  505. .photo-list{
  506. width: 100%;
  507. height: 116rpx;
  508. overflow: hidden;
  509. white-space: nowrap;
  510. display: flex;
  511. align-items: flex-start;
  512. }
  513. .scoll-wrapper{
  514. display:flex;
  515. align-items: flex-start;
  516. }
  517. }
  518. .remarks-textarea{
  519. width: 652rpx;
  520. height: 124rpx;
  521. padding:10rpx 24rpx 24rpx 24rpx;
  522. margin-top: 20rpx;
  523. background-color: #F5F5F5;
  524. border-radius: 10rpx;
  525. position: relative;
  526. .textarea{
  527. width: 100%;
  528. height: 100%;
  529. line-height: 36rpx;
  530. font-size: $font-size-24;
  531. color: $text-color;
  532. z-index: 1;
  533. }
  534. .limit-text{
  535. position: absolute;
  536. right: 20rpx;
  537. bottom: 0;
  538. line-height: 44rpx;
  539. font-size: $font-size-24;
  540. color: #D0D0D0;
  541. .red{
  542. color: $color-system;
  543. }
  544. }
  545. }
  546. .remarks-tips{
  547. width: 100%;
  548. line-height: 70rpx;
  549. font-size: $font-size-24;
  550. color: #999999;
  551. }
  552. }
  553. }
  554. </style>