confirmUnloading.vue 16 KB

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