confirmLoading.vue 17 KB

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