confirmUnloading.vue 27 KB

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