confirmUnloading.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873
  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. <view class="flex" style="justify-content: flex-end;" @click="selectMap">
  28. {{detailData.unloadPrivate}}{{detailData.unloadCity}}{{detailData.unloadArea}}
  29. <u-icon name="arrow-right"></u-icon>
  30. </view>
  31. <view>
  32. <u-input placeholder="请输入详细地址" border="none" v-model="detailData.unloadDetailedAddress"
  33. inputAlign="right"></u-input>
  34. <!-- @change="change" -->
  35. </view>
  36. </view>
  37. </view>
  38. <view class='row-between'>
  39. <view class="row-left-text">货名</view>
  40. <view class="row-right-text">{{detailData.goodsName}}</view>
  41. </view>
  42. <view class='row-between'>
  43. <view class="row-left-text">运费</view>
  44. <view class="row-right-text">{{detailData.freight}}{{detailData.billingMethod==0?'元/吨':'元/车'}}</view>
  45. </view>
  46. </view>
  47. <view class="content2">
  48. <view class="level2-title">卸车信息</view>
  49. <view class='row-between'>
  50. <view class="row-left-text">车牌号</view>
  51. <view class="row-right-text">{{detailData.carNumber}}</view>
  52. </view>
  53. <view class='row-between'>
  54. <view class="row-left-text">卸车净重(吨)</view>
  55. <view class="row-right-text">
  56. <u--input placeholder="请输入卸车净重" border="none" type="number" v-model="detailData.unloadingWeight"
  57. inputAlign='right' clearable></u--input>
  58. </view>
  59. </view>
  60. <!-- <view class='row-between'>
  61. <view class="row-left-text">卸车日期</view>
  62. <view class="row-right-text">{{detailData.carrierInfo.unloadingDate}}</view>
  63. </view> -->
  64. <view class="row-between">
  65. <view class="left-text">卸车日期</view>
  66. <view class="row-right-text" @click="selectUnloadingDate">
  67. {{detailData.carrierInfo.unloadingDate?detailData.carrierInfo.unloadingDate:'选择卸车日期'}}
  68. </view>
  69. </view>
  70. <!-- <view class='row-between'>
  71. <view class="row-left-text">合计运费(元)</view>
  72. <view style='position:relative;'>
  73. <input :style="{color:this.detailData.freight!=detailData.totalFreight?'red':'#000'}" class="totalFreight-input" placeholder="输入合计运费" v-model="detailData.totalFreight"
  74. type="number" />
  75. <image @click='eliminate' class='close' v-if='detailData.totalFreight.length>0' src="../../static/images/order/guanbi.png" mode=""></image>
  76. </view>
  77. </view> -->
  78. <view class='row-between'>
  79. <view class="row-left-text">定位</view>
  80. <view style='font-size:14px;' class="flex align-center">
  81. {{detailData.carrierInfo.unloadCity}}{{detailData.carrierInfo.unloadArea}}
  82. <view class="sx-style" @click.stop="getLngLat()">刷新</view>
  83. </view>
  84. </view>
  85. <view class='s-flex'>
  86. <view class="row-left-text" style="margin:20rpx 0;">上传卸车照片(1-3张)</view>
  87. <u-upload class="uview-upload" :fileList="fileList1" @afterRead="afterRead($event)" @delete="deletePic"
  88. name="1" multiple :maxCount="3"></u-upload>
  89. </view>
  90. <view class='s-flex'>
  91. <view class="row-left-text" style="margin:20rpx 0;">上传回单照片(磅单)</view>
  92. <u-upload class="uview-upload" :fileList="fileList2" @afterRead="afterRead1($event)"
  93. @delete="deletePic1" name="2" multiple :maxCount="3"></u-upload>
  94. </view>
  95. </view>
  96. <view class="bottom-btn">
  97. <view class="store" @click="$u.throttle(submit(1), 1000)">暂存</view>
  98. <view class="submit" @click="$u.throttle(submit(3), 1000)">提交</view>
  99. </view>
  100. <u-modal :show="isShowAlert" :title="alertTitle" :content='alertContent' :closeOnClickOverlay='true'
  101. :showCancelButton='true' confirmColor='#F5BA3C' @confirm="confirmClick" @close="cancelClick"
  102. @cancel="cancelClick"></u-modal>
  103. <!--<u- picker :show="isShowValidity" :defaultIndex='defaultIndex' ref="uPicker" :columns="validityPeriod" @confirm="confirmValidityPeriod"
  104. :closeOnClickOverlay='true' @close='isShowValidity=false' @cancel='isShowValidity=false'>
  105. </u-picker> -->
  106. <!-- :endDate="array" -->
  107. <itmister-date-picker :dateStatus="0" ref="dateEl" :startYear="1999" :futureYear="30"
  108. @dateConfirm="confirmValidityPeriod"></itmister-date-picker>
  109. <u-toast ref="uToast"></u-toast>
  110. <u-modal :show="distance" :content="distanceTips" :showConfirmButton="false" :showCancelButton="true"
  111. :closeOnClickOverlay="true" @cancel="distance=false" @close="distance=false"></u-modal>
  112. </view>
  113. </template>
  114. <script>
  115. let that;
  116. import uploadImage from '@/components/ossutil/uploadFile.js';
  117. //插件对象
  118. var sdkwx = uni.requireNativePlugin('Hdgq-LocSdkWX');
  119. export default {
  120. data() {
  121. return {
  122. imgList: [],
  123. fileList1: [],
  124. fileList2: [],
  125. validityPeriod: [],
  126. sourceType: ['camera'],
  127. imgList1: [],
  128. detailData: {
  129. addressUrl: '',
  130. hyCarrierInfo: {},
  131. totalFreight: ''
  132. },
  133. defaultIndex: [],
  134. action: this.$helper.ossUploadUrl,
  135. maxSize: 50 * 1024 * 1024, //限制文件大小 50M
  136. isAdd: true,
  137. isShowAlert: false,
  138. alertContent: '',
  139. alertTitle: '',
  140. localtion: {},
  141. shippingNoteInfos: [{
  142. shippingNoteNumber: '',
  143. serialNumber: "",
  144. startCountrySubdivisionCode: "",
  145. endCountrySubdivisionCode: "",
  146. startLongitude: "",
  147. startLatitude: "",
  148. endLongitude: "",
  149. endLatitude: "",
  150. startLocationText: "",
  151. endLocationText: "",
  152. vehicleNumber: "",
  153. driverName: "",
  154. interval: "",
  155. }],
  156. // unsendLatitude: "",
  157. // unsendLongitude: "",
  158. distance: false,
  159. distanceTips: "",
  160. editPlace: true, //编辑卸车地点标识 true未编辑 false编辑
  161. }
  162. },
  163. onLoad(options) {
  164. this.detailData = JSON.parse(options.obj)
  165. console.log(this.detailData)
  166. this.fileList1 = []
  167. this.fileList2 = []
  168. if (this.detailData.hyCarrierInfo.unloadingImg) {
  169. this.imgList = this.detailData.hyCarrierInfo.unloadingImg.split(',')
  170. var data = this.detailData.hyCarrierInfo.unloadingImg.split(',')
  171. for (var i = 0; i < data.length; i++) {
  172. if (data[i] != '') {
  173. this.fileList1.push({
  174. url: data[i]
  175. })
  176. }
  177. }
  178. }
  179. if (this.detailData.hyCarrierInfo.receiptImg) {
  180. this.imgList1 = this.detailData.hyCarrierInfo.receiptImg.split(',')
  181. var data = this.detailData.hyCarrierInfo.receiptImg.split(',')
  182. for (var i = 0; i < data.length; i++) {
  183. if (data[i] != '') {
  184. this.fileList2.push({
  185. url: data[i]
  186. })
  187. }
  188. }
  189. }
  190. if (this.detailData.hyCarrierInfo.totalFreight) {
  191. this.$set(this.detailData, 'totalFreight', String(this.detailData.hyCarrierInfo.totalFreight))
  192. // this.detailData.totalFreight=String(this.detailData.hyCarrierInfo.totalFreight)
  193. } else {
  194. this.$set(this.detailData, 'totalFreight', String(this.detailData.freight))
  195. // this.detailData.totalFreight=String(this.detailData.freight)
  196. }
  197. this.detailData.carrierInfo = {
  198. // unloadingDate: '',
  199. // estimatedFreight: '',
  200. // unloadingAreaLongitude: '',
  201. // unloadingAreaLatitude: '',
  202. // unloadCity: '',
  203. // unloadArea: '',
  204. // unloadingImg: '',
  205. // totalFreight: '',
  206. unloadingImg: this.detailData.hyCarrierInfo.unloadingImg,
  207. receiptImg: this.detailData.hyCarrierInfo.receiptImg,
  208. id: this.detailData.carrierId ? this.detailData.carrierId : this.detailData.hyCarrierInfo.id,
  209. }
  210. // #ifdef APP-PLUS
  211. this.getLngLat();
  212. // #endif
  213. this.getNowTime()
  214. },
  215. methods: {
  216. selectMap() {
  217. let that = this
  218. // this.isShowMap = true
  219. uni.getLocation({
  220. type: 'gcj02',
  221. geocode: true,
  222. altitude: true,
  223. isHighAccuracy: true,
  224. success: function(res) {
  225. console.log('当前位置的经度:' + res.longitude);
  226. console.log('当前位置的纬度:' + res.latitude);
  227. uni.chooseLocation({
  228. latitude: res.latitude,
  229. longitude: res.longitude,
  230. success: function(res) {
  231. console.log(res);
  232. console.log('位置名称:' + res.name);
  233. console.log('详细地址:' + res.address);
  234. console.log('纬度:' + res.latitude);
  235. console.log('经度:' + res.longitude);
  236. let _address = that.$helper.formatLocation(res.address)
  237. that.detailData.unloadPrivate = _address.Province
  238. that.detailData.unloadCity = _address.City
  239. that.detailData.unloadArea = _address.Country
  240. that.detailData.unloadDetailedAddress = _address.Village
  241. // that.unsendLatitude = res.latitude
  242. // that.unsendLongitude = res.longitude
  243. that.editPlace = false
  244. //获取行政区划代码
  245. // uni.request({
  246. // url: 'https://restapi.amap.com/v3/config/district?key=d29a9d10160efaca0dd616bbec936d7f&subdistrict=1&keywords=' +
  247. // _address.City,
  248. // success: (res) => {
  249. // for(let i = 0 ; i < res.data.districts[0].districts.length ; i++){
  250. // if(res.data.districts[0].districts[i].name == _address.Country){
  251. // that.addressInfo.adCode = res.data.districts[0].districts[i].adcode
  252. // console.log("行政区划代码"+that.addressInfo.adCode)
  253. // break
  254. // }
  255. // }
  256. // }
  257. // });
  258. that.$forceUpdate()
  259. },
  260. fail(err) {
  261. console.log(err)
  262. },
  263. complete(res1) {
  264. console.log(res1)
  265. }
  266. });
  267. }
  268. })
  269. },
  270. stop() { //结束定位
  271. let that = this
  272. this.shippingNoteInfos[0].shippingNoteNumber = this.detailData.orderNo //运单号
  273. this.shippingNoteInfos[0].serialNumber = "0000" //分单号
  274. this.shippingNoteInfos[0].startCountrySubdivisionCode = this.detailData
  275. .sendAdCode //起点位置行政区划代码,调 用 start/stop/pause/restart 时 必填,调用 send 非必填
  276. this.shippingNoteInfos[0].endCountrySubdivisionCode = this.detailData
  277. .unsendAdCode //到达位置行政区划代码,调 用 start/stop/pause/restart 时 必填,调用 send 非必填
  278. this.shippingNoteInfos[0].startLongitude = this.detailData
  279. .sendLongitude //起点位置经度,调用 start/stop/pause/restart 时必 填,调用 send 非必填
  280. this.shippingNoteInfos[0].startLatitude = this.detailData
  281. .sendLatitude //起点位置纬度,调用 start/stop/pause/restart 时必 填,调用 send 非必填
  282. this.shippingNoteInfos[0].endLongitude = this.detailData
  283. .unsendLongitude //到达位置经度,调用 start/stop/pause/restart 时必 填,调用 send 非必填
  284. this.shippingNoteInfos[0].endLatitude = this.detailData
  285. .unsendLatitude //到达位置纬度,调用 start/stop/pause/restart 时必 填,调用 send 非必填
  286. this.shippingNoteInfos[0].startLocationText = this.detailData
  287. .sendCity //起点地址文字描述,调用 start/stop/pause/restart 时必 填,调用 send 非必填
  288. this.shippingNoteInfos[0].endLocationText = this.detailData
  289. .unloadCity //到达地址文字描述,调用 start/stop/pause/restart 时必 填,调用 send 非必填
  290. this.shippingNoteInfos[0].vehicleNumber = this.detailData
  291. .carNumber //车牌号,SDK 回调返回,调 用 start/stop/pause/restart/必 填,send 时非必填
  292. this.shippingNoteInfos[0].driverName = this.detailData
  293. .driverName //司机姓名,SDK 回调返回, 调用 start/stop/pause/restart/ 必填,send 时非必填
  294. this.shippingNoteInfos[0].interval = "5000" //请求时间间隔,SDK 回调返 回(单位 ms)
  295. // var shippingNoteInfos = this.shippingNoteInfos;//运单信息列表
  296. console.log("查看结束参数", this.shippingNoteInfos)
  297. let remark = ""
  298. sdkwx.stop(this.detailData.carNumber, this.detailData.driverName, remark, this.shippingNoteInfos, function(
  299. res) {
  300. if (res.type == "onSuccess") {
  301. console.log("结束成功!!!", res)
  302. //成功
  303. } else if (res.type == "onFailure") {
  304. console.log("结束成功!!!", res)
  305. //失败
  306. var errorCode = res.data.errorCode; //错误码
  307. var errorMsg = res.data.errorMsg; //错误描述
  308. that.$refs.uToast.show({
  309. type: 'error',
  310. message: errorMsg,
  311. })
  312. return
  313. }
  314. });
  315. },
  316. deletePic(event) {
  317. console.log(this[`fileList${event.name}`])
  318. this[`fileList${event.name}`].splice(event.index, 1)
  319. this.imgList.splice(event.index, 1)
  320. },
  321. deletePic1(event) {
  322. this[`fileList${event.name}`].splice(event.index, 1)
  323. this.imgList1.splice(event.index, 1)
  324. },
  325. getNowTime() {
  326. let now = new Date();
  327. let year = now.getFullYear(); //得到年份
  328. let month = now.getMonth(); //得到月份
  329. let date = now.getDate(); //得到日期
  330. month = month + 1;
  331. month = month.toString().padStart(2, "0");
  332. date = date.toString().padStart(2, "0");
  333. let defaultDate = `${year}-${month}-${date}`
  334. this.detailData.carrierInfo.unloadingDate = defaultDate
  335. // this.$forceUpdate()
  336. },
  337. eliminate() {
  338. this.$set(this.detailData, 'totalFreight', '')
  339. // t.totalFreight=''
  340. console.log(this.detailData.totalFreight)
  341. console.log(this.detailData.totalFreight.length)
  342. },
  343. selectUnloadingDate() {
  344. this.$refs.dateEl.show()
  345. },
  346. getLngLat() {
  347. let that = this
  348. uni.showLoading({
  349. title: '获取定位中',
  350. mask: true
  351. })
  352. // this.$helper.fUN_AmapLocation.start({
  353. // intervalTime: 1000 * 3,
  354. // isReport: false,
  355. // },
  356. // res => {
  357. // //见下方定位返回示例
  358. // console.log('====fUN_AmapLocation定位====', JSON.stringify(res));
  359. // if (res.latitude) {
  360. // this.detailData.carrierInfo.loadingAreaLongitude = res.longitude;
  361. // this.detailData.carrierInfo.loadingAreaLatitude = res.latitude;
  362. // this.detailData.carrierInfo.sendCity = this.$helper.filterUrban(res.city)
  363. // this.detailData.carrierInfo.sendArea = this.$helper.filterArea(res.district);
  364. // console.log(this.detailData.carrierInfo.sendCity)
  365. // console.log(this.detailData.carrierInfo.sendArea)
  366. // this.$forceUpdate()
  367. // }
  368. // this.$helper.fUN_AmapLocation.stop({}, result => {
  369. // uni.hideLoading()
  370. // console.log('====fUN_AmapLocation定位stop====', JSON.stringify(result));
  371. // });
  372. // }
  373. // );
  374. uni.getLocation({
  375. type: 'gcj02',
  376. geocode: true,
  377. success: res => {
  378. if (res.latitude) {
  379. // that.detailData.hyCarrierInfo.loadingAreaLongitude = res.longitude;
  380. // that.detailData.hyCarrierInfo.loadingAreaLatitude = res.latitude;
  381. that.detailData.carrierInfo.unloadingAreaLongitude = res.longitude;
  382. that.detailData.carrierInfo.unloadingAreaLatitude = res.latitude;
  383. that.detailData.carrierInfo.unloadCity = that.$helper.filterUrban(res.address.city)
  384. that.detailData.carrierInfo.unloadArea = that.$helper.filterUrban(res.address
  385. .district)
  386. that.localtion.city = that.$helper.filterUrban(res.address.city)
  387. that.localtion.sendArea = that.$helper.filterUrban(res.address.district)
  388. that.detailData.carrierInfo.unloadingCity = that.$helper.filterUrban(res.address
  389. .city)
  390. that.detailData.carrierInfo.unloadingArea = that.$helper.filterUrban(res.address
  391. .district)
  392. that.detailData.carrierInfo.unloadingLongitude = res.longitude;
  393. that.detailData.carrierInfo.unloadingLatitude = res.latitude;
  394. that.$forceUpdate()
  395. uni.hideLoading()
  396. } else {
  397. if (uni.getSystemInfoSync().platform == 'android') {
  398. var context = plus.android.importClass("android.content.Context");
  399. var locationManager = plus.android.importClass(
  400. "android.location.LocationManager");
  401. var main = plus.android.runtimeMainActivity();
  402. var mainSvr = main.getSystemService(context.LOCATION_SERVICE);
  403. that.bool = mainSvr.isProviderEnabled(locationManager.GPS_PROVIDER)
  404. }
  405. if (that.bool === false) {
  406. uni.showModal({
  407. title: '提示',
  408. content: '请打开定位服务',
  409. success: ({
  410. confirm,
  411. cancel
  412. }) => {
  413. if (confirm) {
  414. if (uni.getSystemInfoSync().platform == 'android') {
  415. var Intent = plus.android.importClass(
  416. 'android.content.Intent');
  417. var Settings = plus.android.importClass(
  418. 'android.provider.Settings');
  419. var intent = new Intent(Settings
  420. .ACTION_LOCATION_SOURCE_SETTINGS);
  421. var main = plus.android.runtimeMainActivity();
  422. main.startActivity(intent); // 打开系统设置GPS服务页面
  423. }
  424. }
  425. }
  426. });
  427. uni.hideLoading()
  428. }
  429. }
  430. },
  431. fail: res => {
  432. console.log('定位失败')
  433. console.log(res)
  434. uni.hideLoading()
  435. }
  436. });
  437. },
  438. alertBtn() {
  439. // uni.navigateTo({
  440. // url: '/pages/public/login'
  441. // })
  442. },
  443. cancelClick() {
  444. this.isShowAlert = false
  445. },
  446. getImgUrl(res) {
  447. this.detailData.carrierInfo.unloadingImg += res + ','
  448. console.log(res)
  449. console.log('------------res-----------')
  450. },
  451. onError(error) {
  452. alert(error)
  453. console.log('------------error-----------')
  454. console.log(error)
  455. },
  456. onRemove(index) {},
  457. filterFileType(index, lists) {
  458. if (lists[index].fileType != 'jpg' && lists[index].fileType != 'png' && lists[index].fileType != 'gif') {
  459. lists.splice(index, 1);
  460. // 当前文件不支持
  461. uni.showModal({
  462. title: '暂不支持当前图片类型',
  463. showCancel: false
  464. });
  465. } else {
  466. this.isAdd = false;
  467. }
  468. },
  469. // 新增图片
  470. async afterRead(event) {
  471. // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
  472. let lists = [].concat(event.file)
  473. let fileListLen = this[`fileList${event.name}`].length
  474. lists.map((item) => {
  475. this[`fileList${event.name}`].push({
  476. ...item,
  477. status: 'uploading',
  478. message: '上传中'
  479. })
  480. })
  481. for (let i = 0; i < lists.length; i++) {
  482. const result = await this.uploadFilePromise(lists[i].url)
  483. let item = this[`fileList${event.name}`][fileListLen]
  484. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  485. status: 'success',
  486. message: '',
  487. url: result
  488. }))
  489. fileListLen++
  490. }
  491. },
  492. // 新增图片
  493. async afterRead1(event) {
  494. // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
  495. let lists = [].concat(event.file)
  496. let fileListLen = this[`fileList${event.name}`].length
  497. lists.map((item) => {
  498. this[`fileList${event.name}`].push({
  499. ...item,
  500. status: 'uploading',
  501. message: '上传中'
  502. })
  503. })
  504. for (let i = 0; i < lists.length; i++) {
  505. const result = await this.uploadFilePromise1(lists[i].url)
  506. let item = this[`fileList${event.name}`][fileListLen]
  507. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  508. status: 'success',
  509. message: '',
  510. url: result
  511. }))
  512. fileListLen++
  513. }
  514. },
  515. uploadFilePromise(url) {
  516. uploadImage('image', url, 'appData/',
  517. result => {
  518. // 上传成功回调函数
  519. console.log('图片地址', result)
  520. this.imgList.push(result)
  521. }
  522. )
  523. },
  524. uploadFilePromise1(url) {
  525. uploadImage('image', url, 'appData/',
  526. result => {
  527. // 上传成功回调函数
  528. console.log('图片地址', result)
  529. this.imgList1.push(result)
  530. }
  531. )
  532. },
  533. onProgress(e) {
  534. console.log(e)
  535. },
  536. getDistance(lat1, lng1, lat2, lng2) {
  537. var radLat1 = lat1 * Math.PI / 180.0;
  538. var radLat2 = lat2 * Math.PI / 180.0;
  539. var a = radLat1 - radLat2;
  540. var b = lng1 * Math.PI / 180.0 - lng2 * Math.PI / 180.0;
  541. var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) +
  542. Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
  543. s = s * 6378.137; // EARTH_RADIUS;
  544. s = Math.round(s * 10000) / 10000;
  545. // // 纬度之差
  546. // var a = lat1 - lat2;
  547. // // 经度之差
  548. // var b = lng1 - lng2;
  549. // // 计算两点距离的公式
  550. // var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) +
  551. // Math.cos(lat1) * Math.cos(lat2) * Math.pow(Math.sin(b / 2), 2)));
  552. // // 弧长乘地球半径, 返回单位: 千米
  553. // s = s * 6378.137;
  554. return s;
  555. },
  556. submit(type) {
  557. if (type == 1) {
  558. this.alertContent = '确定暂存卸车信息?'
  559. } else {
  560. if (!this.detailData.unloadingWeight) {
  561. this.$refs.uToast.show({
  562. type: 'error',
  563. message: "请输入卸车净重!",
  564. })
  565. return
  566. }
  567. if (this.fileList1.length == 0) {
  568. this.$refs.uToast.show({
  569. type: 'error',
  570. message: "卸车照片不能为空!",
  571. })
  572. return
  573. }
  574. if (this.fileList2.length == 0) {
  575. this.$refs.uToast.show({
  576. type: 'error',
  577. message: "请上传回单照片!",
  578. })
  579. return
  580. }
  581. this.alertContent = '确定提交卸车信息?'
  582. }
  583. // if(!this.detailData.totalFreight){
  584. // this.$refs.uToast.show({
  585. // type: 'error',
  586. // message: "请输入合计运费!",
  587. // })
  588. // return
  589. // }
  590. // this.detailData.publishTaskInfo.unsendLatitude //任务卸车所在地经纬度
  591. // this.detailData.publishTaskInfo.unsendLongitude
  592. var lat = this.detailData.carrierInfo.unloadingLatitude //当前定位所在的经纬度
  593. var lng = this.detailData.carrierInfo.unloadingLongitude
  594. var endlat = this.detailData.publishTaskInfo ? this.detailData.publishTaskInfo.unsendLatitude : this
  595. .detailData.unsendLatitude
  596. var endlng = this.detailData.publishTaskInfo ? this.detailData.publishTaskInfo.unsendLongitude : this
  597. .detailData.unsendLongitude
  598. if (this.editPlace) { //true 未编辑 判断当前定位与任务卸车地点距离 大于5KM提示,编辑卸车地点后不在判断
  599. let juli = this.getDistance(endlat, endlng, lat, lng)
  600. console.log("更改卸车地后距离", juli)
  601. if (Number(juli) > 5) {
  602. this.distanceTips = "当前定位与运单卸货地不符,请在指定地点确认卸车,如果卸货地发生变化,请修改本页面基本信息中的卸货地址!",
  603. this.distance = true
  604. return
  605. }
  606. }
  607. this.isShowAlert = true
  608. this.detailData.statusFlag = type
  609. },
  610. async stopMap() {
  611. console.log("sjdaisdjdsi")
  612. let that = this
  613. let _isSubmit = true
  614. this.shippingNoteInfos[0].shippingNoteNumber = this.detailData.orderNo //运单号
  615. this.shippingNoteInfos[0].serialNumber = "0000" //分单号
  616. this.shippingNoteInfos[0].startCountrySubdivisionCode = this.detailData
  617. .sendAdCode //起点位置行政区划代码,调 用 start/stop/pause/restart 时 必填,调用 send 非必填
  618. this.shippingNoteInfos[0].endCountrySubdivisionCode = this.detailData
  619. .unsendAdCode //到达位置行政区划代码,调 用 start/stop/pause/restart 时 必填,调用 send 非必填
  620. this.shippingNoteInfos[0].startLongitude = this.detailData
  621. .sendLongitude //起点位置经度,调用 start/stop/pause/restart 时必 填,调用 send 非必填
  622. this.shippingNoteInfos[0].startLatitude = this.detailData
  623. .sendLatitude //起点位置纬度,调用 start/stop/pause/restart 时必 填,调用 send 非必填
  624. this.shippingNoteInfos[0].endLongitude = this.detailData
  625. .unsendLongitude //到达位置经度,调用 start/stop/pause/restart 时必 填,调用 send 非必填
  626. this.shippingNoteInfos[0].endLatitude = this.detailData
  627. .unsendLatitude //到达位置纬度,调用 start/stop/pause/restart 时必 填,调用 send 非必填
  628. this.shippingNoteInfos[0].startLocationText = this.detailData
  629. .sendCity //起点地址文字描述,调用 start/stop/pause/restart 时必 填,调用 send 非必填
  630. this.shippingNoteInfos[0].endLocationText = this.detailData
  631. .unloadCity //到达地址文字描述,调用 start/stop/pause/restart 时必 填,调用 send 非必填
  632. this.shippingNoteInfos[0].vehicleNumber = this.detailData
  633. .carNumber //车牌号,SDK 回调返回,调 用 start/stop/pause/restart/必 填,send 时非必填
  634. this.shippingNoteInfos[0].driverName = this.detailData
  635. .driverName //司机姓名,SDK 回调返回, 调用 start/stop/pause/restart/ 必填,send 时非必填
  636. this.shippingNoteInfos[0].interval = "5000" //请求时间间隔,SDK 回调返 回(单位 ms)
  637. // var shippingNoteInfos = this.shippingNoteInfos;//运单信息列表
  638. console.log("查看结束参数", this.shippingNoteInfos)
  639. try {
  640. await this.sdkWxStop().then((res) => {
  641. console.log(2, res)
  642. })
  643. } catch (e) {
  644. uni.hideLoading()
  645. console.log(22, e.data.errorMsg)
  646. that.$refs.uToast.show({
  647. type: 'error',
  648. message: e.data.errorMsg,
  649. })
  650. _isSubmit = false
  651. }
  652. return _isSubmit
  653. },
  654. sdkWxStop() {
  655. let that = this
  656. return new Promise((resolve, reject) => {
  657. let remark = ""
  658. sdkwx.stop(this.detailData.carNumber, this.detailData.driverName, remark, this
  659. .shippingNoteInfos,
  660. function(res) {
  661. console.log(1)
  662. if (res.type == "onSuccess") {
  663. resolve(res)
  664. console.log("结束成功!!!", res)
  665. //成功
  666. } else if (res.type == "onFailure") {
  667. console.log("结束成功!!失败!", res)
  668. //失败
  669. reject(res)
  670. // var errorCode = res.data.errorCode; //错误码
  671. // var errorMsg = res.data.errorMsg; //错误描述
  672. // that.$refs.uToast.show({
  673. // type: 'error',
  674. // message: errorMsg,
  675. // })
  676. // return
  677. }
  678. })
  679. })
  680. },
  681. async confirmClick() {
  682. var that = this
  683. if (this.detailData.statusFlag == 1) {
  684. delete this.detailData.carrierInfo.unloadingAreaLongitude;
  685. delete this.detailData.carrierInfo.unloadingAreaLatitude;
  686. delete this.detailData.carrierInfo.unloadCity;
  687. delete this.detailData.carrierInfo.unloadArea;
  688. }
  689. this.detailData.carrierInfo.statusFlag = this.detailData.statusFlag
  690. this.detailData.carrierInfo.unloadingImg = this.imgList.toString()
  691. this.detailData.carrierInfo.receiptImg = this.imgList1.toString()
  692. this.detailData.carrierInfo.unloadingWeight = this.detailData.unloadingWeight
  693. // if (!this.detailData.carrierInfo.totalFreight) {
  694. // uni.showToast({
  695. // title: '运费不能为空!',
  696. // duration: 2000,
  697. // icon: "none",
  698. // });
  699. // return
  700. // }
  701. // if (
  702. // this.detailData.carrierInfo.totalFreight < 0 || this.detailData.carrierInfo.totalFreight > 100000 || (
  703. // String(this.detailData.carrierInfo.totalFreight).indexOf('.') != -1 && String(this.detailData
  704. // .carrierInfo.totalFreight).length - (String(this.detailData.carrierInfo.totalFreight).indexOf(
  705. // '.') + 1) > 2)
  706. // ) {
  707. // uni.showToast({
  708. // title: '运费输入错误!',
  709. // duration: 2000,
  710. // icon: "none",
  711. // });
  712. // return
  713. // }
  714. this.isShowAlert = false
  715. uni.showLoading({
  716. title: '加载中'
  717. })
  718. let time = new Date() //卸车时间 去当前时间的时分秒
  719. let h = time.getHours();
  720. if (h < 10) {
  721. h = "0" + h
  722. }
  723. let f = time.getMinutes();
  724. if (f < 10) {
  725. f = "0" + f
  726. }
  727. let m = time.getSeconds();
  728. if (m < 10) {
  729. m = "0" + m
  730. }
  731. if (this.detailData.carrierInfo.unloadingDate) { //卸车时间 去当前时间的时分秒
  732. this.detailData.carrierInfo.unloadingDate = this.detailData.carrierInfo.unloadingDate.split(" ")[
  733. 0] +
  734. " " + h + ":" + f + ":" + m
  735. }
  736. this.detailData.carrierInfo.carNo = this.detailData.carNumber
  737. // if (this.detailData.statusFlag != 1 && this.detailData.orderStatus == "运输中") {
  738. // let _data = await this.stopMap()
  739. // console.log(3)
  740. // if (!_data) return
  741. // }
  742. this.$request.baseRequest('post', '/carrierInfo/unLoadingAdd', this.detailData.carrierInfo).then(
  743. res => {
  744. console.log(4)
  745. if (res.code == 200) {
  746. let _title = ''
  747. if (this.detailData.statusFlag == 1) {
  748. _title = '暂存成功!'
  749. } else {
  750. that.stop()
  751. _title = '提交成功!'
  752. }
  753. uni.hideLoading()
  754. that.$refs.uToast.show({
  755. type: 'success',
  756. message: _title,
  757. complete() {
  758. uni.hideLoading()
  759. uni.switchTab({
  760. url: '/pages/order/index'
  761. })
  762. if (that.$helper.fUN_AmapLocation) {
  763. that.$helper.fUN_AmapLocation.stop({}, result => {
  764. console.log('====fUN_AmapLocation定位stop====', JSON
  765. .stringify(result));
  766. });
  767. }
  768. }
  769. })
  770. }
  771. })
  772. .catch(res => {
  773. uni.$u.toast(res.message);
  774. });
  775. },
  776. confirmValidityPeriod(date) {
  777. this.detailData.carrierInfo.unloadingDate = date.date
  778. },
  779. },
  780. }
  781. </script>
  782. <style scoped lang="scss">
  783. .content {
  784. .row-left-text {
  785. color: #333333;
  786. }
  787. }
  788. .level2-title {
  789. margin: 0 0 20rpx 0;
  790. }
  791. .content1,
  792. .content2 {
  793. background: white;
  794. margin: 20rpx;
  795. border-radius: 20rpx;
  796. padding: 20rpx;
  797. .place {
  798. width: 80%;
  799. text-align: right;
  800. }
  801. }
  802. .upload {}
  803. .bottom-btn {
  804. display: flex;
  805. justify-content: space-around;
  806. // margin-bottom: 50rpx;
  807. background: #FFFFFF;
  808. padding: 40rpx 0;
  809. }
  810. .store {
  811. padding: 20rpx 30rpx;
  812. color: #F5BA3C;
  813. width: 40%;
  814. background: #EEF4FF;
  815. border-radius: 40rpx;
  816. font-size: 36rpx;
  817. text-align: center;
  818. }
  819. .submit {
  820. font-size: 36rpx;
  821. padding: 20rpx 30rpx;
  822. color: white;
  823. width: 40%;
  824. background: #F5BA3C;
  825. border-radius: 40rpx;
  826. text-align: center;
  827. }
  828. .row-between {
  829. margin: 20rpx 0;
  830. }
  831. .sx-style {
  832. background: #F5BA3C;
  833. color: white;
  834. padding: 2rpx 16rpx;
  835. box-sizing: border-box;
  836. border-radius: 10rpx;
  837. margin-left: 20rpx;
  838. }
  839. .totalFreight-input {
  840. text-align: right;
  841. padding-right: 18px;
  842. }
  843. .close {
  844. position: absolute;
  845. right: 0;
  846. width: 15px;
  847. height: 15px;
  848. top: 50%;
  849. transform: translateY(-50%);
  850. }
  851. </style>