confirmUnloading.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581
  1. <!-- 确认装车 -->
  2. <template>
  3. <view class="content">
  4. <view class="content2">
  5. <view class="level2-title">基本信息</view>
  6. <view class='row-between'>
  7. <view class="row-left-text">订单编号</view>
  8. <view class="row-right-text">{{detailData.orderNo}}</view>
  9. </view>
  10. <view class='row-between'>
  11. <view class="row-left-text">货主</view>
  12. <view class="row-right-text">{{detailData.cargoOwner}}</view>
  13. </view>
  14. <view class='row-between'>
  15. <view class="row-left-text">货主单位</view>
  16. <view class="row-right-text">{{detailData.compName?detailData.compName:'个人货主'}}</view>
  17. </view>
  18. <view class='row-between'>
  19. <view class="row-left-text">发货地</view>
  20. <view class="row-right-text place">
  21. {{detailData.sendPrivate}}{{detailData.sendCity}}{{detailData.sendArea}}{{detailData.sendDetailedAddress}}
  22. </view>
  23. </view>
  24. <view class='row-between'>
  25. <view class="row-left-text">卸货地</view>
  26. <view class="row-right-text place">
  27. {{detailData.unloadPrivate}}{{detailData.unloadCity}}{{detailData.unloadArea}}{{detailData.unloadDetailedAddress}}
  28. </view>
  29. </view>
  30. <view class='row-between'>
  31. <view class="row-left-text">货名</view>
  32. <view class="row-right-text">{{detailData.goodsName}}</view>
  33. </view>
  34. <view class='row-between'>
  35. <view class="row-left-text">运费</view>
  36. <view class="row-right-text">{{detailData.freight}}{{detailData.billingMethod==0?'元/吨':'元/车'}}</view>
  37. </view>
  38. </view>
  39. <view class="content2">
  40. <view class="level2-title">卸车信息</view>
  41. <view class='row-between'>
  42. <view class="row-left-text">车牌号</view>
  43. <view class="row-right-text">{{detailData.carNumber}}</view>
  44. </view>
  45. <!-- <view class='row-between'>
  46. <view class="row-left-text">卸车日期</view>
  47. <view class="row-right-text">{{detailData.carrierInfo.unloadingDate}}</view>
  48. </view> -->
  49. <view class="row-between">
  50. <view class="left-text">卸车日期</view>
  51. <view class="" @click="selectUnloadingDate">
  52. {{detailData.carrierInfo.unloadingDate?detailData.carrierInfo.unloadingDate:'选择卸车日期'}}
  53. </view>
  54. </view>
  55. <view class='row-between'>
  56. <view class="row-left-text">合计运费(元)</view>
  57. <view style='position:relative;'>
  58. <input :style="{color:this.detailData.freight!=detailData.totalFreight?'red':'#000'}" class="totalFreight-input" placeholder="输入合计运费" v-model="detailData.totalFreight"
  59. type="number" />
  60. <image @click='eliminate' class='close' v-if='detailData.totalFreight.length>0' src="../../static/images/order/guanbi.png" mode=""></image>
  61. </view>
  62. </view>
  63. <view class='row-between'>
  64. <view class="row-left-text">定位</view>
  65. <view class="flex align-center">
  66. {{detailData.carrierInfo.unloadCity}}{{detailData.carrierInfo.unloadArea}}
  67. <view class="sx-style" @click.stop="getLngLat()">刷新</view>
  68. </view>
  69. </view>
  70. <view class='s-flex'>
  71. <view class="row-left-text" style="margin:20rpx 0;">上传卸车照片(1-3张)</view>
  72. <u-upload class="uview-upload" :fileList="fileList1" @afterRead="afterRead($event)" @delete="deletePic"
  73. name="1" multiple :maxCount="3"></u-upload>
  74. </view>
  75. <view class='s-flex'>
  76. <view class="row-left-text" style="margin:20rpx 0;">上传回单照片(磅单)</view>
  77. <u-upload class="uview-upload" :fileList="fileList2" @afterRead="afterRead1($event)" @delete="deletePic1"
  78. name="2" multiple :maxCount="3"></u-upload>
  79. </view>
  80. </view>
  81. <view class="bottom-btn">
  82. <view class="store" @click="submit(1)">暂存</view>
  83. <view class="submit" @click="submit(3)">提交</view>
  84. </view>
  85. <u-modal :show="isShowAlert" :title="alertTitle" :content='alertContent' :closeOnClickOverlay='true'
  86. :showCancelButton='true' confirmColor='#2772FB' @confirm="confirmClick" @close="cancelClick"
  87. @cancel="cancelClick"></u-modal>
  88. <u-picker :show="isShowValidity" ref="uPicker" :columns="validityPeriod" @confirm="confirmValidityPeriod"
  89. :closeOnClickOverlay='true' @close='isShowValidity=false' @cancel='isShowValidity=false'>
  90. </u-picker>
  91. <u-toast ref="uToast"></u-toast>
  92. </view>
  93. </template>
  94. <script>
  95. let that;
  96. import uploadImage from '@/components/ossutil/uploadFile.js';
  97. export default {
  98. data() {
  99. return {
  100. imgList: [],
  101. fileList1: [],
  102. fileList2:[],
  103. isShowValidity: false,
  104. validityPeriod: [],
  105. sourceType: ['camera'],
  106. imgList1:[],
  107. detailData: {
  108. addressUrl: '',
  109. hyCarrierInfo:{},
  110. totalFreight:''
  111. },
  112. action: this.$helper.ossUploadUrl,
  113. maxSize: 50 * 1024 * 1024, //限制文件大小 50M
  114. isAdd: true,
  115. isShowAlert: false,
  116. alertContent: '',
  117. alertTitle: '',
  118. localtion:{},
  119. }
  120. },
  121. onLoad(options) {
  122. this.detailData = JSON.parse(options.obj)
  123. console.log(this.detailData)
  124. this.fileList1=[]
  125. if(this.detailData.hyCarrierInfo.unloadingImg){
  126. this.imgList=this.detailData.hyCarrierInfo.unloadingImg.split(',')
  127. var data=this.detailData.hyCarrierInfo.unloadingImg.split(',')
  128. for (var i = 0; i < data.length; i++) {
  129. if(data[i]!=''){
  130. this.fileList1.push({url:data[i]})
  131. }
  132. }
  133. }
  134. if(this.detailData.hyCarrierInfo.totalFreight){
  135. this.$set(this.detailData,'totalFreight',String(this.detailData.hyCarrierInfo.totalFreight))
  136. // this.detailData.totalFreight=String(this.detailData.hyCarrierInfo.totalFreight)
  137. }else{
  138. this.$set(this.detailData,'totalFreight',String(this.detailData.freight))
  139. // this.detailData.totalFreight=String(this.detailData.freight)
  140. }
  141. this.detailData.carrierInfo = {
  142. // unloadingDate: '',
  143. // estimatedFreight: '',
  144. // unloadingAreaLongitude: '',
  145. // unloadingAreaLatitude: '',
  146. // unloadCity: '',
  147. // unloadArea: '',
  148. // unloadingImg: '',
  149. // totalFreight: '',
  150. unloadingImg:this.detailData.hyCarrierInfo.unloadingImg,
  151. id: this.detailData.carrierId,
  152. }
  153. this.validityPeriod = this.$helper.makeValidityPeriod()
  154. // #ifdef APP-PLUS
  155. this.getLngLat();
  156. // #endif
  157. this.getNowTime()
  158. },
  159. methods: {
  160. deletePic(event) {
  161. this[`fileList${event.name}`].splice(event.index, 1)
  162. },
  163. deletePic1(event) {
  164. this[`fileList${event.name}`].splice(event.index, 1)
  165. },
  166. getNowTime() {
  167. let now = new Date();
  168. let year = now.getFullYear(); //得到年份
  169. let month = now.getMonth(); //得到月份
  170. let date = now.getDate(); //得到日期
  171. month = month + 1;
  172. month = month.toString().padStart(2, "0");
  173. date = date.toString().padStart(2, "0");
  174. let defaultDate = `${year}-${month}-${date}`
  175. this.detailData.carrierInfo.unloadingDate = defaultDate
  176. // this.$forceUpdate()
  177. },
  178. eliminate(){
  179. console.log(11111)
  180. this.$set(this.detailData,'totalFreight','')
  181. // t.totalFreight=''
  182. console.log(this.detailData.totalFreight)
  183. console.log(this.detailData.totalFreight.length)
  184. },
  185. selectUnloadingDate() {
  186. this.isShowValidity = true
  187. },
  188. getLngLat() {
  189. let that = this
  190. uni.showLoading({
  191. title: '获取定位中',
  192. mask: true
  193. })
  194. // this.$helper.fUN_AmapLocation.start({
  195. // intervalTime: 1000 * 3,
  196. // isReport: false,
  197. // },
  198. // res => {
  199. // //见下方定位返回示例
  200. // console.log('====fUN_AmapLocation定位====', JSON.stringify(res));
  201. // if (res.latitude) {
  202. // this.detailData.carrierInfo.loadingAreaLongitude = res.longitude;
  203. // this.detailData.carrierInfo.loadingAreaLatitude = res.latitude;
  204. // this.detailData.carrierInfo.sendCity = this.$helper.filterUrban(res.city)
  205. // this.detailData.carrierInfo.sendArea = this.$helper.filterArea(res.district);
  206. // console.log(this.detailData.carrierInfo.sendCity)
  207. // console.log(this.detailData.carrierInfo.sendArea)
  208. // this.$forceUpdate()
  209. // }
  210. // this.$helper.fUN_AmapLocation.stop({}, result => {
  211. // uni.hideLoading()
  212. // console.log('====fUN_AmapLocation定位stop====', JSON.stringify(result));
  213. // });
  214. // }
  215. // );
  216. uni.getLocation({
  217. type: 'gcj02',
  218. geocode: true,
  219. success: res => {
  220. if (res.latitude) {
  221. // that.detailData.hyCarrierInfo.loadingAreaLongitude = res.longitude;
  222. // that.detailData.hyCarrierInfo.loadingAreaLatitude = res.latitude;
  223. that.detailData.carrierInfo.unloadingAreaLongitude = res.longitude;
  224. that.detailData.carrierInfo.unloadingAreaLatitude = res.latitude;
  225. console.log("1234567890")
  226. that.detailData.carrierInfo.unloadCity = that.$helper.filterUrban(res.address.city)
  227. that.detailData.carrierInfo.unloadArea = that.$helper.filterUrban(res.address.district)
  228. that.localtion.city = that.$helper.filterUrban(res.address.city)
  229. that.localtion.sendArea = that.$helper.filterUrban(res.address.district)
  230. that.detailData.carrierInfo.unloadingCity = that.$helper.filterUrban(res.address.city)
  231. that.detailData.carrierInfo.unloadingArea = that.$helper.filterUrban(res.address.district)
  232. that.detailData.carrierInfo.unloadingLongitude = res.longitude;
  233. that.detailData.carrierInfo.unloadingLatitude = res.latitude;
  234. that.$forceUpdate()
  235. uni.hideLoading()
  236. } else {
  237. if (uni.getSystemInfoSync().platform == 'android') {
  238. var context = plus.android.importClass("android.content.Context");
  239. var locationManager = plus.android.importClass(
  240. "android.location.LocationManager");
  241. var main = plus.android.runtimeMainActivity();
  242. var mainSvr = main.getSystemService(context.LOCATION_SERVICE);
  243. that.bool = mainSvr.isProviderEnabled(locationManager.GPS_PROVIDER)
  244. }
  245. if (that.bool === false) {
  246. uni.showModal({
  247. title: '提示',
  248. content: '请打开定位服务',
  249. success: ({
  250. confirm,
  251. cancel
  252. }) => {
  253. if (confirm) {
  254. if (uni.getSystemInfoSync().platform == 'android') {
  255. var Intent = plus.android.importClass(
  256. 'android.content.Intent');
  257. var Settings = plus.android.importClass(
  258. 'android.provider.Settings');
  259. var intent = new Intent(Settings
  260. .ACTION_LOCATION_SOURCE_SETTINGS);
  261. var main = plus.android.runtimeMainActivity();
  262. main.startActivity(intent); // 打开系统设置GPS服务页面
  263. }
  264. }
  265. }
  266. });
  267. uni.hideLoading()
  268. }
  269. }
  270. },
  271. fail: res => {
  272. console.log('定位失败')
  273. console.log(res)
  274. uni.hideLoading()
  275. }
  276. });
  277. },
  278. alertBtn() {
  279. // uni.navigateTo({
  280. // url: '/pages/public/login'
  281. // })
  282. },
  283. cancelClick() {
  284. this.isShowAlert = false
  285. },
  286. getImgUrl(res) {
  287. this.detailData.carrierInfo.unloadingImg += res + ','
  288. console.log(res)
  289. console.log('------------res-----------')
  290. },
  291. onError(error) {
  292. alert(error)
  293. console.log('------------error-----------')
  294. console.log(error)
  295. },
  296. onRemove(index) {},
  297. filterFileType(index, lists) {
  298. if (lists[index].fileType != 'jpg' && lists[index].fileType != 'png' && lists[index].fileType != 'gif') {
  299. lists.splice(index, 1);
  300. // 当前文件不支持
  301. uni.showModal({
  302. title: '暂不支持当前图片类型',
  303. showCancel: false
  304. });
  305. } else {
  306. this.isAdd = false;
  307. }
  308. },
  309. // 新增图片
  310. async afterRead(event) {
  311. // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
  312. let lists = [].concat(event.file)
  313. let fileListLen = this[`fileList${event.name}`].length
  314. lists.map((item) => {
  315. this[`fileList${event.name}`].push({
  316. ...item,
  317. status: 'uploading',
  318. message: '上传中'
  319. })
  320. })
  321. for (let i = 0; i < lists.length; i++) {
  322. const result = await this.uploadFilePromise(lists[i].url)
  323. let item = this[`fileList${event.name}`][fileListLen]
  324. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  325. status: 'success',
  326. message: '',
  327. url: result
  328. }))
  329. fileListLen++
  330. }
  331. },
  332. // 新增图片
  333. async afterRead1(event) {
  334. // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
  335. let lists = [].concat(event.file)
  336. let fileListLen = this[`fileList${event.name}`].length
  337. lists.map((item) => {
  338. this[`fileList${event.name}`].push({
  339. ...item,
  340. status: 'uploading',
  341. message: '上传中'
  342. })
  343. })
  344. for (let i = 0; i < lists.length; i++) {
  345. const result = await this.uploadFilePromise1(lists[i].url)
  346. let item = this[`fileList${event.name}`][fileListLen]
  347. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  348. status: 'success',
  349. message: '',
  350. url: result
  351. }))
  352. fileListLen++
  353. }
  354. },
  355. uploadFilePromise(url) {
  356. uploadImage('image', url, 'appData/',
  357. result => {
  358. // 上传成功回调函数
  359. console.log('图片地址', result)
  360. this.imgList.push(result)
  361. }
  362. )
  363. },
  364. uploadFilePromise1(url) {
  365. uploadImage('image', url, 'appData/',
  366. result => {
  367. // 上传成功回调函数
  368. console.log('图片地址', result)
  369. this.imgList1.push(result)
  370. }
  371. )
  372. },
  373. onProgress(e) {
  374. console.log(e)
  375. },
  376. submit(type) {
  377. if (type == 1) {
  378. this.alertContent = '确定暂存卸车信息?'
  379. } else {
  380. this.alertContent = '确定提交卸车信息?'
  381. }
  382. if(!this.detailData.totalFreight){
  383. this.$refs.uToast.show({
  384. type: 'error',
  385. message: "请输入合计运费!",
  386. })
  387. return
  388. }
  389. this.isShowAlert = true
  390. this.detailData.statusFlag = type
  391. },
  392. confirmClick() {
  393. var that=this
  394. if (this.detailData.statusFlag == 1) {
  395. delete this.detailData.carrierInfo.unloadingAreaLongitude;
  396. delete this.detailData.carrierInfo.unloadingAreaLatitude;
  397. delete this.detailData.carrierInfo.unloadCity;
  398. delete this.detailData.carrierInfo.unloadArea;
  399. }
  400. this.detailData.carrierInfo.statusFlag = this.detailData.statusFlag
  401. this.detailData.carrierInfo.unloadingImg = this.imgList.toString()
  402. this.detailData.carrierInfo.receiptImg = this.imgList1.toString()
  403. // if (!this.detailData.carrierInfo.totalFreight) {
  404. // uni.showToast({
  405. // title: '运费不能为空!',
  406. // duration: 2000,
  407. // icon: "none",
  408. // });
  409. // return
  410. // }
  411. if (
  412. this.detailData.carrierInfo.totalFreight < 0 || this.detailData.carrierInfo.totalFreight > 100000 || (
  413. String(this.detailData.carrierInfo.totalFreight).indexOf('.') != -1 && String(this.detailData
  414. .carrierInfo.totalFreight).length - (String(this.detailData.carrierInfo.totalFreight).indexOf(
  415. '.') + 1) > 2)
  416. ) {
  417. uni.showToast({
  418. title: '运费输入错误!',
  419. duration: 2000,
  420. icon: "none",
  421. });
  422. return
  423. }
  424. if (!this.detailData.carrierInfo.unloadingImg) {
  425. uni.showToast({
  426. title: '卸车照片不能为空!',
  427. icon: "none",
  428. duration: 2000
  429. });
  430. return
  431. }
  432. this.isShowAlert = false
  433. uni.showLoading({
  434. title:'加载中'
  435. })
  436. let time = new Date() //卸车时间 去当前时间的时分秒
  437. let h = time.getHours();
  438. if (h < 10) {
  439. h = "0" + h
  440. }
  441. let f = time.getMinutes();
  442. if (f < 10) {
  443. f = "0" + f
  444. }
  445. let m = time.getSeconds();
  446. if (m < 10) {
  447. m = "0" + m
  448. }
  449. if(this.detailData.carrierInfo.unloadingDate){//卸车时间 去当前时间的时分秒
  450. this.detailData.carrierInfo.unloadingDate= this.detailData.carrierInfo.unloadingDate.split(" ")[0] + " " + h + ":" + f + ":" + m
  451. }
  452. this.detailData.carrierInfo.totalFreight = this.detailData.totalFreight
  453. this.detailData.carrierInfo.carNo = this.detailData.carNumber
  454. this.$request.baseRequest('post', '/carrierInfo/unLoadingAdd', this.detailData.carrierInfo).then(res => {
  455. if (res.code == 200) {
  456. let _title = ''
  457. if (this.detailData.statusFlag == 1) {
  458. _title = '暂存成功!'
  459. } else {
  460. _title = '提交成功!'
  461. }
  462. uni.hideLoading()
  463. this.$refs.uToast.show({
  464. type: 'success',
  465. message: _title,
  466. complete() {
  467. uni.hideLoading()
  468. uni.switchTab({
  469. url: '/pages/order/index'
  470. })
  471. that.$helper.fUN_AmapLocation.stop({}, result => {
  472. console.log('====fUN_AmapLocation定位stop====', JSON.stringify(result));
  473. });
  474. }
  475. })
  476. }
  477. })
  478. .catch(res => {
  479. uni.$u.toast(res.message);
  480. });
  481. },
  482. confirmValidityPeriod(e) {
  483. this.detailData.carrierInfo.unloadingDate = e.value[0] + '-' + e.value[1] + '-' + e.value[2]
  484. this.isShowValidity = false
  485. },
  486. },
  487. }
  488. </script>
  489. <style scoped lang="scss">
  490. .content {
  491. .row-left-text {
  492. color: #333333;
  493. }
  494. }
  495. .level2-title {
  496. margin: 0 0 20rpx 0;
  497. }
  498. .content1,
  499. .content2 {
  500. background: white;
  501. margin: 20rpx;
  502. border-radius: 20rpx;
  503. padding: 20rpx;
  504. .place {
  505. width: 80%;
  506. text-align: right;
  507. }
  508. }
  509. .upload {}
  510. .bottom-btn {
  511. display: flex;
  512. justify-content: space-around;
  513. // margin-bottom: 50rpx;
  514. background: #FFFFFF;
  515. padding: 40rpx 0;
  516. }
  517. .store {
  518. padding: 20rpx 30rpx;
  519. color: #2772FB;
  520. width: 40%;
  521. background: #EEF4FF;
  522. border-radius: 40rpx;
  523. font-size: 36rpx;
  524. text-align: center;
  525. }
  526. .submit {
  527. font-size: 36rpx;
  528. padding: 20rpx 30rpx;
  529. color: white;
  530. width: 40%;
  531. background: #2772FB;
  532. border-radius: 40rpx;
  533. text-align: center;
  534. }
  535. .row-between {
  536. margin: 20rpx 0;
  537. }
  538. .sx-style {
  539. background: #2772FB;
  540. color: white;
  541. padding: 2rpx 16rpx;
  542. box-sizing: border-box;
  543. border-radius: 10rpx;
  544. margin-left: 20rpx;
  545. }
  546. .totalFreight-input {
  547. text-align: right;
  548. padding-right:18px;
  549. }
  550. .close{
  551. position:absolute;
  552. right:0;
  553. width:15px;height:15px;
  554. top:50%;
  555. transform: translateY(-50%);
  556. }
  557. </style>