confirmLoading.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603
  1. <!-- 确认装车 -->
  2. <template>
  3. <view class="content">
  4. <div class='content1'>
  5. <view class="level2-title">承运合同</view>
  6. <view class='row-between'>
  7. <view class="">合同编号</view>
  8. <view class="" @click="toSignContract">{{detailData.contractNo?detailData.contractNo:'去签订合同'}}</view>
  9. </view>
  10. </div>
  11. <view class="content2">
  12. <view class="level2-title">基本信息</view>
  13. <view class='row-between'>
  14. <view class="">订单编号</view>
  15. <view class="">{{detailData.orderNo}}</view>
  16. </view>
  17. <view class='row-between'>
  18. <view class="">货主</view>
  19. <view class="">{{detailData.cargoOwner}}</view>
  20. </view>
  21. <view class='row-between'>
  22. <view class="">货主单位</view>
  23. <view class="">{{detailData.compName?detailData.compName:'个人货主'}}</view>
  24. </view>
  25. <view class='row-between'>
  26. <view class="">发货地</view>
  27. <view class=" place">
  28. {{detailData.sendPrivate}}{{detailData.sendCity}}{{detailData.sendArea}}{{detailData.sendDetailedAddress}}
  29. </view>
  30. </view>
  31. <view class='row-between'>
  32. <view class="">卸货地</view>
  33. <view class=" place">
  34. {{detailData.unloadPrivate}}{{detailData.unloadCity}}{{detailData.unloadArea}}{{detailData.unloadDetailedAddress}}
  35. </view>
  36. </view>
  37. <view class='row-between'>
  38. <view class="">货名</view>
  39. <view class="">{{detailData.goodsName}}</view>
  40. </view>
  41. <!-- <view class='row-between'>
  42. <view class="">运费</view>
  43. <view class="">{{detailData.freight}}{{detailData.illingMethod==0?'元/吨':'元/车'}}</view>
  44. </view>-->
  45. </view>
  46. <view class="content2">
  47. <view class="level2-title">装车信息</view>
  48. <view class='row-between'>
  49. <view class="">车牌号</view>
  50. {{detailData.carNo?detailData.carNo:"来自合同"}}
  51. <!-- <input class="car-uumber input" v-model='detailData.carrierInfo.carNo'
  52. :disabled="true" placeholder="输入车牌号" name="input" disabled="true"></input> -->
  53. </view>
  54. <view class='row-between'>
  55. <view class="">装车日期</view>
  56. <view class="date-style">
  57. {{detailData.loadingDate?detailData.loadingDate:'来自合同'}}
  58. </view>
  59. </view>
  60. <view class='row-between'>
  61. <view class="">装车净重(吨)</view>
  62. {{detailData.weight ? detailData.weight:"来自合同"}}
  63. </view>
  64. <view class='row-between'>
  65. <view class="">预计运费(元)</view>
  66. {{detailData.freight ? detailData.freight:"来自合同"}}
  67. <!-- <view class=""><input class="input" type="text" value="" v-model="detailData.carrierInfo.freight"
  68. placeholder="请输入运费"></view> -->
  69. </view>
  70. <view class='row-between'>
  71. <view class="">定位</view>
  72. <view class="flex align-center">{{detailData.carrierInfo?detailData.carrierInfo.sendCity:""}} {{detailData.carrierInfo?detailData.carrierInfo.sendArea:""}}
  73. <view class="sx-style" @click.stop="getLngLat()">刷新</view>
  74. </view>
  75. </view>
  76. <view class='s-flex'>
  77. <view class="" style="margin:20rpx 0;">上传装车照片</view>
  78. <u-upload class="uview-upload" :fileList="fileList1" @afterRead="afterRead($event)" @delete="deletePic"
  79. name="1" multiple :maxCount="3"></u-upload>
  80. </view>
  81. <!-- <view class='s-flex'>
  82. <view class="">上传装车磅单</view>
  83. <upload class="upload" ref="upload" :action="action" :max-size="maxSize" :max-count="1"
  84. :size-type="['compressed']" @on-success="getImgUrl" @on-error="onError" @on-remove="onRemove"
  85. @on-uploaded="isAdd = true" :before-upload="filterFileType" @on-progress="onProgress"></upload>
  86. </view> -->
  87. </view>
  88. <view class="bottom-btn">
  89. <view class="store" @click="submit(1)">暂存</view>
  90. <view class="submit" @click="submit(3)">提交</view>
  91. </view>
  92. <u-modal :show="isShowAlert" :title="alertTitle" :content='alertContent' :closeOnClickOverlay='true'
  93. :showCancelButton='true' confirmColor='#2772FB' @confirm="confirmClick" @close="cancelClick"
  94. @cancel="cancelClick"></u-modal>
  95. <master-keyboard ref="keyboard" keyboardtype="car" :show="keyShow" :randomNumber="true" :newCar="false"
  96. :defaultValue="carNumber" @keyboardClick="handleClick"></master-keyboard>
  97. <u-toast ref="uToast"></u-toast>
  98. <u-calendar :show="showDate" :mode="mode" @confirm="confirmDate" @close="showDate= false"></u-calendar>
  99. </view>
  100. </template>
  101. <script>
  102. let that;
  103. import uploadImage from '@/components/ossutil/uploadFile.js';
  104. export default {
  105. data() {
  106. return {
  107. imgList: [],
  108. fileList1: [],
  109. showDate: false,
  110. mode: 'single',
  111. id: '',
  112. sourceType: ['camera'],
  113. detailData: {
  114. carrierInfo: {},
  115. loadingDate:{}
  116. },
  117. action: this.$helper.ossUploadUrl,
  118. maxSize: 50 * 1024 * 1024, //限制文件大小 50M
  119. isAdd: true,
  120. isShowAlert: false,
  121. alertContent: '',
  122. alertTitle: '',
  123. keyShow: false,
  124. carNumber: '',
  125. gjList: []
  126. }
  127. },
  128. onLoad(options) {
  129. that = this
  130. // #ifdef APP-PLUS
  131. this.getLngLat();
  132. // #endif
  133. console.log(options)
  134. this.id = JSON.parse(decodeURIComponent(options.obj)).id
  135. this.getInfo()
  136. // this.detailData = JSON.parse(options.obj) ;
  137. // console.log(this.detailData)
  138. // CYHT20220317000001
  139. },
  140. methods: {
  141. //确认装车提交成功后,开启实时定位,
  142. // 调接口5分钟一次发送轨迹,[
  143. // {latitude: 39.997761, longitude: 116.478935},
  144. // {latitude: 39.997825, longitude: 116.478939},
  145. // {latitude: 39.998549, longitude: 116.478912},
  146. // {latitude: 39.998555, longitude: 116.478998},
  147. // {latitude: 39.998566, longitude: 116.479282},
  148. // {latitude: 39.998528, longitude: 116.479658},
  149. // {latitude: 39.998453, longitude: 116.480151},
  150. // {latitude: 39.998302, longitude: 116.480784},
  151. // {latitude: 39.998184, longitude: 116.481149},
  152. // {latitude: 39.997997, longitude: 116.481573},
  153. // {latitude: 39.997846, longitude: 116.481863},
  154. // {latitude: 39.997718, longitude: 116.482072},
  155. // {latitude: 39.997718, longitude: 116.482362},
  156. // {latitude: 39.998935, longitude: 116.483633},
  157. // {latitude: 39.998968, longitude: 116.48367},
  158. // {latitude: 39.999861, longitude: 116.484648}
  159. // ]
  160. // a(){},
  161. toSignContract(){
  162. uni.$u.route('/pages/order/signContract', {
  163. obj: JSON.stringify(this.detailData),
  164. });
  165. },
  166. selectDate() {
  167. this.showDate = true
  168. },
  169. confirmDate(e) {
  170. this.detailData.carrierInfo.loadingDate = e[0]
  171. this.showDate = false
  172. },
  173. getInfo() {
  174. this.$request.baseRequest('get', '/orderInfo/getOrderInfo', {
  175. id: this.id,
  176. }).then(res => {
  177. if (res.code == 200) {
  178. this.detailData = res.data
  179. this.$request.baseRequest('get', '/carrierInfo/getHyCarrierInfo', {
  180. orderId: this.detailData.id,
  181. }).then(res => {
  182. if(res.data){
  183. this.detailData.carNo = res.data.carNo
  184. this.detailData.loadingDate =res.data.loadingDate
  185. this.detailData.weight =res.data. loadingWeight
  186. this.detailData.freight = res.data.estimatedFreight
  187. }
  188. })
  189. // this.detailData.contractNo = ''
  190. // this.detailData.id = this.detailData.carrierId
  191. // this.detailData.carrierInfo.loadingDate = ''
  192. // this.detailData.carrierInfo.carNo = ''
  193. // this.detailData.carrierInfo.loadingAreaLongitude = ''
  194. // this.detailData.carrierInfo.loadingAreaLatitude = ''
  195. // this.detailData.carrierInfo.sendCity = '营口'
  196. // this.detailData.carrierInfo.sendArea = '鲅鱼圈'
  197. // this.detailData.carrierInfo.loadingImg = ''
  198. // this.carrierInfo = res.data.carrierInfo
  199. // this.freightInfo = res.data.freightInfo
  200. // this.zcPhoneList = this.carrierInfo.loadingImg.split(',')
  201. // if(res.data.orderStatus!="待货主确认"&&res.data.orderStatus!="未装车"&&res.data.orderStatus!="已终止"){
  202. // this.status1 = true
  203. // }
  204. // if(res.data.orderStatus!="已终止"&&res.data.orderStatus!="平台驳回装车信息"&&res.data.orderStatus!="待平台确认装车"&&res.data.orderStatus!="待货主确认"&&res.data.orderStatus!="未装车"&&res.data.orderStatus!="待货主确认装车"&&res.data.orderStatus!="货主驳回装车信息"){
  205. // this.status2 = true
  206. // }
  207. }
  208. })
  209. },
  210. //车牌号弹出键盘
  211. handleShowKeyboard() {
  212. if (this.detailData.carrierInfo.carNo == '') {
  213. this.carNumber = ''
  214. } else {
  215. this.carNumber = this.detailData.carrierInfo.carNo
  216. }
  217. if (this.$refs.keyboard.open) {
  218. this.$refs.keyboard.open(false) //true 键盘显示 false 键盘隐藏
  219. } else {
  220. this.$refs.keyboard[0].open(false)
  221. }
  222. if (this.$refs.keyboard.open) {
  223. this.$refs.keyboard.open(true) //true 键盘显示 false 键盘隐藏
  224. } else {
  225. this.$refs.keyboard[0].open(true)
  226. }
  227. },
  228. //车牌号弹出键盘
  229. handleClick(e) {
  230. this.carNumber = e.value
  231. this.detailData.carrierInfo.carNo = e.value //键盘输入值
  232. },
  233. getLngLat() {
  234. uni.showLoading({
  235. title: '获取定位中',
  236. mask: true
  237. })
  238. this.$helper.fUN_AmapLocation.start({
  239. intervalTime: 1000 * 3,
  240. isReport: false,
  241. },
  242. res => {
  243. //见下方定位返回示例
  244. console.log('====fUN_AmapLocation定位====', JSON.stringify(res));
  245. if (res.latitude) {
  246. this.detailData.carrierInfo.loadingAreaLongitude = res.longitude;
  247. this.detailData.carrierInfo.loadingAreaLatitude = res.latitude;
  248. this.detailData.carrierInfo.sendCity = this.$helper.filterUrban(res.city)
  249. this.detailData.carrierInfo.sendArea = this.$helper.filterArea(res.district);
  250. console.log(this.detailData.carrierInfo.sendCity)
  251. console.log(this.detailData.carrierInfo.sendArea)
  252. this.$forceUpdate()
  253. }
  254. uni.hideLoading()
  255. this.$helper.fUN_AmapLocation.stop({}, result => {
  256. console.log('====fUN_AmapLocation定位stop====', JSON.stringify(result));
  257. });
  258. }
  259. );
  260. // uni.getLocation({
  261. // type: 'gcj02',
  262. // geocode: true,
  263. // success: res => {
  264. // console.log('定位地址')
  265. // console.log(res)
  266. // if (res.latitude) {
  267. // this.detailData.carrierInfo.loadingAreaLongitude = res.longitude;
  268. // this.detailData.carrierInfo.loadingAreaLatitude = res.latitude;
  269. // this.detailData.carrierInfo.sendCity = this.$helper.filterUrban(res.address.city)
  270. // this.detailData.carrierInfo.sendArea = this.$helper.filterArea(res.address
  271. // .district);
  272. // console.log(this.detailData.carrierInfo.sendCity)
  273. // console.log(this.detailData.carrierInfo.sendArea)
  274. // this.$forceUpdate()
  275. // uni.hideLoading()
  276. // } else {
  277. // if (uni.getSystemInfoSync().platform == 'android') {
  278. // var context = plus.android.importClass("android.content.Context");
  279. // var locationManager = plus.android.importClass(
  280. // "android.location.LocationManager");
  281. // var main = plus.android.runtimeMainActivity();
  282. // var mainSvr = main.getSystemService(context.LOCATION_SERVICE);
  283. // this.bool = mainSvr.isProviderEnabled(locationManager.GPS_PROVIDER)
  284. // }
  285. // if (this.bool === false) {
  286. // uni.showModal({
  287. // title: '提示',
  288. // content: '请打开定位服务',
  289. // success: ({
  290. // confirm,
  291. // cancel
  292. // }) => {
  293. // if (confirm) {
  294. // if (uni.getSystemInfoSync().platform == 'android') {
  295. // var Intent = plus.android.importClass(
  296. // 'android.content.Intent');
  297. // var Settings = plus.android.importClass(
  298. // 'android.provider.Settings');
  299. // var intent = new Intent(Settings
  300. // .ACTION_LOCATION_SOURCE_SETTINGS);
  301. // var main = plus.android.runtimeMainActivity();
  302. // main.startActivity(intent); // 打开系统设置GPS服务页面
  303. // }
  304. // }
  305. // }
  306. // });
  307. // }
  308. // }
  309. // },
  310. // fail: res => {
  311. // console.log('定位失败')
  312. // console.log(res)
  313. // }
  314. // });
  315. },
  316. alertBtn() {
  317. // uni.navigateTo({
  318. // url: '/pages/public/login'
  319. // })
  320. },
  321. cancelClick() {
  322. this.isShowAlert = false
  323. },
  324. // 删除图片
  325. deletePic(event) {
  326. this[`fileList${event.name}`].splice(event.index, 1)
  327. },
  328. // 新增图片
  329. async afterRead(event) {
  330. // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
  331. let lists = [].concat(event.file)
  332. let fileListLen = this[`fileList${event.name}`].length
  333. lists.map((item) => {
  334. this[`fileList${event.name}`].push({
  335. ...item,
  336. status: 'uploading',
  337. message: '上传中'
  338. })
  339. })
  340. for (let i = 0; i < lists.length; i++) {
  341. const result = await this.uploadFilePromise(lists[i].url)
  342. let item = this[`fileList${event.name}`][fileListLen]
  343. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  344. status: 'success',
  345. message: '',
  346. url: result
  347. }))
  348. fileListLen++
  349. }
  350. },
  351. uploadFilePromise(url) {
  352. uploadImage('image', url, 'appData/',
  353. result => {
  354. // 上传成功回调函数
  355. console.log('图片地址', result)
  356. this.imgList.push(result)
  357. }
  358. )
  359. },
  360. onProgress(e) {
  361. console.log(e)
  362. },
  363. submit(type) {
  364. console.log(type)
  365. if (type == 1) {
  366. if (!this.detailData.contractNo) {
  367. this.$refs.uToast.show({
  368. type: 'error',
  369. message: "合同未签订不能暂存!"
  370. })
  371. return
  372. }
  373. this.alertTitle = '确定暂存装车信息?'
  374. } else {
  375. this.alertTitle = '确定提交装车信息?'
  376. }
  377. this.isShowAlert = true
  378. this.detailData.statusFlag = type
  379. console.log(15456)
  380. // this.$refs.uToast.show({
  381. // ...params,
  382. // complete() {
  383. // params.url && uni.navigateTo({
  384. // url: params.url
  385. // })
  386. // }
  387. // })
  388. },
  389. validate() {
  390. // uni.$u.test.isEmpty(this.detailData.carrierInfo.carNo
  391. if (uni.$u.test.isEmpty(this.detailData.carNo)) {
  392. this.$refs.uToast.show({
  393. type: 'error',
  394. message: "车牌号不能为空!",
  395. })
  396. return true
  397. }
  398. if (uni.$u.test.isEmpty(this.detailData.loadingDate)) {
  399. this.$refs.uToast.show({
  400. type: 'error',
  401. message: "装车日期不能为空!",
  402. })
  403. return true
  404. }
  405. if (uni.$u.test.isEmpty(this.detailData.freight)) {
  406. this.$refs.uToast.show({
  407. type: 'error',
  408. message: "预计运费不能为空!",
  409. })
  410. return true
  411. }
  412. // if (uni.$u.test.isEmpty(this.detailData.carrierInfo.sendCity)) {
  413. // this.$refs.uToast.show({
  414. // type: 'error',
  415. // message: "定位不能为空!",
  416. // })
  417. // return true
  418. // }
  419. // if (uni.$u.test.isEmpty(this.detailData.carrierInfo.sendArea)) {
  420. // this.$refs.uToast.show({
  421. // type: 'error',
  422. // message: "定位不能为空!",
  423. // })
  424. // return true
  425. // }
  426. // if (uni.$u.test.isEmpty(this.detailData.carrierInfo.loadingImg)) {
  427. // this.$refs.uToast.show({
  428. // type: 'error',
  429. // message: "装车照片不能为空!",
  430. // })
  431. // return true
  432. // }
  433. },
  434. confirmClick() {
  435. this.isShowAlert = false
  436. if(this.validate()) return
  437. //1暂存
  438. if (this.detailData.statusFlag == 1) {
  439. delete this.detailData.carrierInfo.loadingAreaLongitude;
  440. delete this.detailData.carrierInfo.loadingAreaLatitude;
  441. delete this.detailData.carrierInfo.sendCity;
  442. delete this.detailData.carrierInfo.sendArea;
  443. }
  444. this.detailData.carrierInfo = {}
  445. this.detailData.carrierInfo.statusFlag = this.detailData.statusFlag
  446. this.detailData.carrierInfo.loadingImg = this.imgList.toString()
  447. this.$request.baseRequest('post', '/carrierInfo/loadingAdd', this.detailData.carrierInfo).then(res => {
  448. if (res.code == 200) {
  449. let _title = ''
  450. if (this.detailData.statusFlag == 1) {
  451. _title = '暂存成功!'
  452. } else {
  453. _title = '提交成功!'
  454. }
  455. this.$helper.fUN_AmapLocation.start({
  456. // intervalTime: 1000 * 60,
  457. intervalTime: 5000,
  458. // isReport: true,
  459. reportInterval: 5,
  460. // url: 'http://192.168.0.66/fun/open/test_json.do',
  461. // params: {
  462. // a: 1,
  463. // B: '测试',
  464. // c: true
  465. // },
  466. // headers: {
  467. // a: '123',
  468. // B: 'abcd'
  469. // }
  470. },
  471. res => {
  472. console.log('====确认装车开启连续定位====');
  473. console.log(res)
  474. let _data = {
  475. orderId: that.id,
  476. longitude: res.longitude,
  477. latitude: res.latitude,
  478. province: res.province,
  479. city: res.city,
  480. area: res.district
  481. }
  482. this.$helper.gjList.push(_data)
  483. uni.setStorageSync('mapGJ', this.$helper.gjList);
  484. console.log('this.$helper.gjList')
  485. console.log(this.$helper.gjList)
  486. if (uni.getStorageSync('mapGJ').length > 100) {
  487. console.log(uni.getStorageSync('mapGJ'))
  488. this.$request.baseRequest('post', '/vehicleTrajectoryInfo/api/addInfo', {
  489. vehicleTrajectoryInfos: uni.getStorageSync('mapGJ')
  490. }).then(res => {
  491. this.$helper.gjList = []
  492. uni.setStorageSync('mapGJ', []);
  493. })
  494. .catch(res => {
  495. uni.$u.toast(res.message);
  496. });
  497. }
  498. //判断缓存数据条数,超过reportInterval时清空缓存,重新存入缓存
  499. }
  500. );
  501. this.$refs.uToast.show({
  502. type: 'success',
  503. message: _title,
  504. complete() {
  505. uni.switchTab({
  506. url: '/pages/order/index'
  507. })
  508. }
  509. })
  510. }
  511. })
  512. .catch(res => {
  513. uni.$u.toast(res.message);
  514. });
  515. }
  516. },
  517. }
  518. </script>
  519. <style scoped lang="scss">
  520. .content {
  521. // . {
  522. // color: #333333;
  523. // }
  524. }
  525. .level2-title {
  526. margin: 0 0 20rpx 0;
  527. }
  528. .content1,
  529. .content2 {
  530. background: white;
  531. margin: 20rpx;
  532. border-radius: 20rpx;
  533. padding: 20rpx;
  534. .place {
  535. width: 80%;
  536. text-align: right;
  537. }
  538. }
  539. .upload {}
  540. .bottom-btn {
  541. display: flex;
  542. justify-content: space-around;
  543. margin-bottom: 50rpx;
  544. background: #FFFFFF;
  545. padding: 40rpx 0;
  546. }
  547. .store {
  548. padding: 20rpx 30rpx;
  549. color: #2772FB;
  550. width: 40%;
  551. background: #EEF4FF;
  552. border-radius: 40rpx;
  553. font-size: 36rpx;
  554. text-align: center;
  555. }
  556. .submit {
  557. font-size: 36rpx;
  558. padding: 20rpx 30rpx;
  559. color: white;
  560. width: 40%;
  561. background: #2772FB;
  562. border-radius: 40rpx;
  563. text-align: center;
  564. }
  565. .row-between {
  566. margin: 20rpx 0;
  567. }
  568. .sx-style {
  569. background: #2772FB;
  570. color: white;
  571. padding: 2rpx 16rpx;
  572. box-sizing: border-box;
  573. border-radius: 10rpx;
  574. margin-left: 20rpx;
  575. }
  576. .input {
  577. text-align: right;
  578. }
  579. .date-style {}
  580. </style>