add-logistics.vue 14 KB

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