add-logistics.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  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' : '0'}">
  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. userID:'',
  63. isIphoneX:this.$store.state.isIphoneX,
  64. isChange:true,
  65. isShowRemarks:false,
  66. specClass:'',
  67. photoLists:[],
  68. checkLogicsIndex:0,
  69. selectID:0,
  70. info:{
  71. image:'',
  72. note:'',
  73. shopOrderId:''
  74. },//备注信息
  75. record:[],//子订单商品信息
  76. logisticsList:[{
  77. label:'',
  78. number:'',
  79. value:'',
  80. }],
  81. min:0,
  82. max:200
  83. }
  84. },
  85. watch: {
  86. logisticsList: {
  87. handler: function (el) {//监听对象的变换使用 function,箭头函数容易出现this指向不正确
  88. console.log(el)
  89. this.logisticsList = el
  90. },
  91. deep: true
  92. }
  93. },
  94. onLoad(option) {
  95. // console.log(option)
  96. this.info.shopOrderId = option.shopOrderId;
  97. this.record = JSON.parse(option.data)
  98. // console.log(this.record)
  99. },
  100. methods:{
  101. ...mapMutations(['login']),
  102. AddScanCode(item){
  103. let self = this;
  104. uni.scanCode({
  105. onlyFromCamera: true,
  106. success: function (res) {
  107. // console.log('条码内容:' + res.result);
  108. item.number= res.result
  109. self.ShopService.GetExpressInformation({number:res.result}).then(response =>{
  110. console.log(response)
  111. item.label= response.data.label
  112. item.value= response.data.value
  113. self.selectID = response.data.id
  114. }).catch(error =>{
  115. self.$util.msg(error.msg,2000);
  116. })
  117. }
  118. });
  119. },
  120. addListFn(){
  121. this.isShowRemarks = false
  122. let obj ={name:'',number:'',value:''};
  123. this.logisticsList.push(obj)
  124. },
  125. deleteLogistItemFn(item,index){
  126. this.$util.modal('提示','确认删除物流信息吗?','确定','取消',true,() =>{
  127. this.logisticsList.splice(index, 1);
  128. })
  129. },
  130. pageNavigateTo(index){//选择物流公司
  131. this.isChange = false
  132. this.checkLogicsIndex = index
  133. console.log(this.checkLogicsIndex)
  134. this.$api.navigateTo(`/supplier/pages/deliver/logistics-list?selectID=${this.selectID}`)
  135. },
  136. showShowRemarksFn(){//显示发货备注
  137. this.isShowRemarks = !this.isShowRemarks
  138. if(this.isShowRemarks){
  139. this.specClass = 'show';
  140. }else{
  141. this.specClass = 'hide';
  142. }
  143. },
  144. uploadPhotoFn(){//添加发货备注图片
  145. uploadFileImage().then(res =>{
  146. this.photoLists.push(JSON.parse(res.data).data)
  147. })
  148. },
  149. deletePhotoFn(index){//删除发货备注图片
  150. this.photoLists.splice(index, 1);
  151. },
  152. confirmDeliverFn(){//确认发货
  153. console.log(this.logisticsList)
  154. if(this.logisticsList[0].label == ''){
  155. this.$util.msg('请选择物流公司',2000);
  156. return
  157. }
  158. if(this.logisticsList[0].number == ''){
  159. this.$util.msg('请输入物流单号',2000);
  160. return
  161. }
  162. //统一处理物流单号
  163. let logisticsObj = {}
  164. let logisticsArray = []
  165. let map = new Map()
  166. this.logisticsList.forEach(el =>{
  167. if(map.get(el.number)!== el.number){
  168. logisticsObj = {
  169. number:el.number,
  170. logisticsCompanyName:el.label,
  171. logisticsCompanyCode:el.value
  172. }
  173. logisticsArray.push(logisticsObj)
  174. }else{
  175. this.$util.msg('物流单号重复',2000);
  176. return
  177. }
  178. })
  179. //统一处理备注图片
  180. this.photoLists.forEach(el =>{
  181. this.info.image+=el+'##'
  182. })
  183. let params = {
  184. logistics:logisticsArray,
  185. record:this.record,
  186. info:this.info
  187. }
  188. console.log(params)
  189. this.ShopService.ShopAddLogistics({params:JSON.stringify(params)}).then(response =>{
  190. console.log(response)
  191. this.$util.msg('发货成功',2000,true,'success')
  192. setTimeout(()=>{
  193. this.$api.navigateTo(`/supplier/pages/deliver/deliver-record`)
  194. },2000)
  195. }).catch(error =>{
  196. this.$util.msg(error.msg,2000);
  197. })
  198. },
  199. previewImg (index) {//顶部商品图片预览
  200. isPreviewImg = true
  201. let previewUrls = this.photoLists
  202. uni.previewImage({
  203. current: index, //图片索引
  204. urls: previewUrls, //必须是http图片,本地图片无效
  205. longPressActions:''
  206. })
  207. },
  208. conInput(e){
  209. let value = e.detail.value;
  210. let len = parseInt(value.length);
  211. if (len > this.max) return;
  212. this.min = len;
  213. if(this.min == 200){
  214. this.$util.msg('您输入的次数已达上限',2000);
  215. }
  216. }
  217. },
  218. onShow() {
  219. let pages = getCurrentPages();
  220. let currPage = pages[pages.length-1];
  221. if(currPage.data.select =='select'){
  222. let SelectData = uni.getStorageSync('selectLogics')
  223. this.selectID = SelectData.id
  224. let setNewLogisticsList = this.logisticsList
  225. setNewLogisticsList.forEach((el,index,arr) =>{
  226. if(index == this.checkLogicsIndex ){
  227. arr[this.checkLogicsIndex] = Object.assign({},arr[this.checkLogicsIndex],SelectData)
  228. }
  229. })
  230. this.logisticsList = setNewLogisticsList
  231. }
  232. this.isChange = true
  233. }
  234. }
  235. </script>
  236. <style lang="scss">
  237. page {
  238. height: auto;
  239. background:#F7F7F7;
  240. }
  241. @keyframes showRemarks {
  242. 0% {opacity: 0;}
  243. 20% {opacity: 0.2;}
  244. 40% {opacity: 0.4;}
  245. 60% {opacity: 0.6;}
  246. 80% {opacity: 0.8;}
  247. 100% {opacity: 1;}
  248. }
  249. @keyframes hideRemarks {
  250. 0% {opacity: 1;}
  251. 20% {opacity: 0.8;}
  252. 40% {opacity: 0.6;}
  253. 60% {opacity: 0.4;}
  254. 80% {opacity: 0.2;}
  255. 100% {opacity: 0;}
  256. }
  257. .logistics{
  258. border-top: 1px solid #EBEBEB;
  259. }
  260. .logistics-list{
  261. width: 100%;
  262. height: auto;
  263. padding: 10rpx 0;
  264. background-color: #FFFFFF;
  265. margin-bottom: 24rpx;
  266. .item-title{
  267. width: 702rpx;
  268. height: 80rpx;
  269. padding: 0 24rpx;
  270. line-height: 80rpx;
  271. text-align: left;
  272. font-size: $font-size-28;
  273. color: $text-color;
  274. border-bottom: 1px solid #EBEBEB;
  275. .title-left{
  276. float: left;
  277. }
  278. .title-right{
  279. float: right;
  280. .icon-shanchu{
  281. font-size: $font-size-30;
  282. color: #FF2A2A;
  283. }
  284. }
  285. }
  286. .item-main{
  287. width: 702rpx;
  288. padding: 0 24rpx;
  289. .item-main-cell{
  290. width: 100%;
  291. height: 80rpx;
  292. line-height: 80rpx;
  293. border-bottom: 1px solid #EBEBEB;
  294. position: relative;
  295. &.none{
  296. border-bottom: none;
  297. text-align: center;
  298. font-size: $font-size-28;
  299. color: $color-system;
  300. }
  301. .icon-xiayibu{
  302. width: 40rpx;
  303. height: 80rpx;
  304. display: block;
  305. position: absolute;
  306. right: 0;
  307. top: 0;
  308. font-size: $font-size-32;
  309. color: $text-color;
  310. text-align: center;
  311. }
  312. .icon-icon-test{
  313. color: $color-system;
  314. font-size: $font-size-28;
  315. margin-right: 10rpx;
  316. }
  317. .input{
  318. width: 100%;
  319. height: 44rpx;
  320. line-height: 44rpx;
  321. padding: 18rpx 0;
  322. font-size: $font-size-28;
  323. color: $text-color;
  324. }
  325. }
  326. }
  327. }
  328. .logistics-btn{
  329. width: 702rpx;
  330. height: 88rpx;
  331. margin: 0 auto;
  332. .btn{
  333. width: 100%;
  334. height: 100%;
  335. background-color: #FFF;
  336. border-radius: 14rpx;
  337. border: 1px solid $color-system;
  338. line-height: 88rpx;
  339. text-align: center;
  340. color: $color-system;
  341. }
  342. }
  343. .logistics-btn-fiexd{
  344. width: 702rpx;
  345. padding: 0 24rpx;
  346. height:auto;
  347. position: fixed;
  348. bottom: 0;
  349. left: 0;
  350. background-color: #FFF;
  351. border-radius: 20rpx 20rpx 0 0;
  352. box-shadow:0px 3px 10px rgba(51, 51, 51,0.5);
  353. z-index: 999;
  354. .btn-tips{
  355. height: 80rpx;
  356. line-height: 80rpx;
  357. text-align: center;
  358. font-size: $font-size-28;
  359. color: #999999;
  360. }
  361. .confim-btn{
  362. width: 702rpx;
  363. height: 88rpx;
  364. background: $btn-confirm;
  365. line-height: 88rpx;
  366. text-align: center;
  367. color: #FFF;
  368. font-size: $font-size-28;
  369. border-radius: 14rpx;
  370. }
  371. .logistics-remarks{
  372. width: 100%;
  373. height: auto;
  374. &.show {
  375. animation: showRemarks 0.2s linear both;
  376. }
  377. &.hide {
  378. animation: hideRemarks 0.2s linear both;
  379. }
  380. .label{
  381. height: 44rpx;
  382. line-height: 44rpx;
  383. font-size: $font-size-28;
  384. color: $text-color;
  385. }
  386. .remarks-photo{
  387. width: 100%;
  388. height: auto;
  389. padding: 10rpx 0;
  390. .photo-item{
  391. display: inline-block;
  392. width: 112rpx;
  393. height: 112rpx;
  394. margin: 10rpx 0;
  395. margin-right: 25rpx;
  396. border-radius: 10rpx;
  397. border:1px solid #F5F5F5;
  398. position: relative;
  399. float: left;
  400. &.add{
  401. width: 112rpx;
  402. height: 112rpx;
  403. border-color: #FFC684;
  404. text-align: center;
  405. line-height: 112rpx;
  406. margin-right: 0rpx;
  407. .icon-jiahao{
  408. font-size: $font-size-44;
  409. color:#FFC684 ;
  410. font-weight: bold;
  411. }
  412. }
  413. .icon-iconfontguanbi{
  414. width: 24rpx;
  415. height: 24rpx;
  416. border-radius: 0 10rpx 0 0;
  417. display: block;
  418. position: absolute;
  419. right: 0;
  420. top: 0;
  421. background: rgba(51, 51, 51, 0.7);
  422. text-align: center;
  423. line-height: 24rpx;
  424. color: #FFF;
  425. font-size: $font-size-22;
  426. }
  427. image{
  428. width: 112rpx;
  429. height: 112rpx;
  430. border-radius: 10rpx;
  431. }
  432. }
  433. .photo-list{
  434. width: 100%;
  435. height: 116rpx;
  436. overflow: hidden;
  437. white-space: nowrap;
  438. display: flex;
  439. align-items: flex-start;
  440. }
  441. .scoll-wrapper{
  442. display:flex;
  443. align-items: flex-start;
  444. }
  445. }
  446. .remarks-textarea{
  447. width: 652rpx;
  448. height: 124rpx;
  449. padding:10rpx 24rpx 24rpx 24rpx;
  450. margin-top: 20rpx;
  451. background-color: #F5F5F5;
  452. border-radius: 10rpx;
  453. position: relative;
  454. .textarea{
  455. width: 100%;
  456. height: 100%;
  457. line-height: 36rpx;
  458. font-size: $font-size-24;
  459. color: $text-color;
  460. z-index: 1;
  461. }
  462. .limit-text{
  463. position: absolute;
  464. right: 20rpx;
  465. bottom: 0;
  466. line-height: 44rpx;
  467. font-size: $font-size-24;
  468. color: #D0D0D0;
  469. .red{
  470. color: $color-system;
  471. }
  472. }
  473. }
  474. .remarks-tips{
  475. width: 100%;
  476. line-height: 70rpx;
  477. font-size: $font-size-24;
  478. color: #999999;
  479. }
  480. }
  481. }
  482. </style>