confirmLoading.vue 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991
  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.loadingDate1?detailData.loadingDate1:'来自合同'}}
  58. </view>
  59. </view>
  60. <view class='row-between'>
  61. <view class="">装车毛重(吨)</view>
  62. {{detailData.grossWeight ? detailData.grossWeight:"来自合同"}}
  63. </view>
  64. <view class='row-between'>
  65. <view class="">装车净重(吨)</view>
  66. {{detailData.weight ? detailData.weight:"来自合同"}}
  67. </view>
  68. <view class='row-between'>
  69. <view class="">预计运费(元)</view>
  70. <view class="">{{detailData.driverContract == 1 ? detailData.freight:"来自合同"}}</view>
  71. <!-- {{detailData.freight ? detailData.freight:"来自合同"}} -->
  72. <!-- <view class=""><input class="input" type="text" value="" v-model="detailData.carrierInfo.freight"
  73. placeholder="请输入运费"></view> -->
  74. </view>
  75. <view class='row-between'>
  76. <view class="">预付款(元)</view>
  77. {{detailData.advanceCharge ? detailData.advanceCharge:"0"}}
  78. <!-- <view class=""><input class="input" type="text" value="" v-model="detailData.carrierInfo.freight"
  79. placeholder="请输入运费"></view> -->
  80. </view>
  81. <view class='row-between'>
  82. <view class="">定位</view>
  83. <view class="flex align-center">{{localtion.city}}
  84. {{localtion.sendArea}}
  85. <view class="sx-style" @click.stop="getLngLat()">刷新</view>
  86. </view>
  87. </view>
  88. <view class='row-between'>
  89. <view class="">运输时长(小时)</view>
  90. <view class="flex align-center">
  91. <u--input placeholder="请输入运输时长" border="none" type="digit"
  92. v-model="detailData.transportationDuration" inputAlign='right' clearable></u--input>
  93. </view>
  94. </view>
  95. <view class='s-flex'>
  96. <view class="" style="margin:20rpx 0;">上传装车照片</view>
  97. <u-upload class="uview-upload" :fileList="fileList1" @afterRead="afterRead($event)" @delete="deletePic"
  98. name="1" :multiple='true' :maxCount="3"></u-upload>
  99. </view>
  100. <!-- <view class='s-flex'>
  101. <view class="">上传装车磅单</view>
  102. <upload class="upload" ref="upload" :action="action" :max-size="maxSize" :max-count="1"
  103. :size-type="['compressed']" @on-success="getImgUrl" @on-error="onError" @on-remove="onRemove"
  104. @on-uploaded="isAdd = true" :before-upload="filterFileType" @on-progress="onProgress"></upload>
  105. </view> -->
  106. </view>
  107. <view class="bottom-btn">
  108. <view class="store" @click="$u.throttle(submit(1), 1000)">暂存</view>
  109. <view class="submit" @click="$u.throttle(submit(3), 1000)">提交</view>
  110. </view>
  111. <u-modal :show="isShowAlert" :title="alertTitle" :content='alertContent' :closeOnClickOverlay='true'
  112. :showCancelButton='true' confirmColor='#F5BA3C' @confirm="confirmClick" @close="cancelClick"
  113. @cancel="cancelClick"></u-modal>
  114. <master-keyboard ref="keyboard" keyboardtype="car" :show="keyShow" :randomNumber="true" :newCar="false"
  115. :defaultValue="carNumber" @keyboardClick="handleClick"></master-keyboard>
  116. <u-toast ref="uToast"></u-toast>
  117. <u-calendar :show="showDate" :mode="mode" @confirm="confirmDate" @close="showDate= false"></u-calendar>
  118. </view>
  119. </template>
  120. <script>
  121. var that;
  122. //插件对象
  123. var sdkwx = uni.requireNativePlugin('Hdgq-LocSdkWX');
  124. import uploadImage from '@/components/ossutil/uploadFile.js';
  125. import * as config from '@/config/index.js'
  126. import {
  127. mapState
  128. } from 'vuex';
  129. export default {
  130. data() {
  131. return {
  132. firstAuthentication: {},
  133. cyId: '',
  134. localtion: {
  135. city: '',
  136. sendArea: ''
  137. },
  138. imgList: [],
  139. fileList1: [],
  140. showDate: false,
  141. mode: 'single',
  142. id: '',
  143. sourceType: ['camera'],
  144. detailData: {
  145. hyCarrierInfo: {},
  146. loadingDate: {}
  147. },
  148. action: this.$helper.ossUploadUrl,
  149. maxSize: 50 * 1024 * 1024, //限制文件大小 50M
  150. isAdd: true,
  151. isShowAlert: false,
  152. alertContent: '',
  153. alertTitle: '',
  154. keyShow: false,
  155. carNumber: '',
  156. gjList: [],
  157. //网络货运信息定位
  158. appId: "", //网络货运企业APP的唯一标识
  159. appSecurity: "", //网络货运企业在省平台申请的接入安全码
  160. enterpriseSenderCode: "", //网络货运企业在省平台申请的企业发送代码
  161. environment: "debug", //环境:“debug”接入测试环境,“release”接入正式环境。
  162. shippingNoteInfos: [{
  163. shippingNoteNumber: '',
  164. serialNumber: "",
  165. startCountrySubdivisionCode: "",
  166. endCountrySubdivisionCode: "",
  167. startLongitude: "",
  168. startLatitude: "",
  169. endLongitude: "",
  170. endLatitude: "",
  171. startLocationText: "",
  172. endLocationText: "",
  173. vehicleNumber: "",
  174. driverName: "",
  175. interval: "",
  176. }],
  177. timer: null
  178. }
  179. },
  180. onLoad(options) {
  181. that = this
  182. let phoneType = uni.getSystemInfoSync().platform //判断手机类型
  183. this.enterpriseSenderCode = config.def().enterpriseSenderCode
  184. this.environment = config.def().environment
  185. if (phoneType == "android") {
  186. this.appId = config.def().androidAppId
  187. this.appSecurity = config.def().androidAppSecurity
  188. } else if (phoneType == "ios") {
  189. // this.appId = "uni.UNIDCD13AC"
  190. // this.appSecurity = "b01e4805276646eeb25f0fad91de97a4f32e8c2c0e0d42e5b24cc4737e9f040f"
  191. this.appId = config.def().iosAppId
  192. this.appSecurity = config.def().iosAppSecurity
  193. }
  194. if (!uni.getStorageSync('contractdata')) {
  195. this.id = JSON.parse(decodeURIComponent(options.obj)).id
  196. this.detailData.hyCarrierInfo.id = JSON.parse(decodeURIComponent(options.obj)).carrierId
  197. this.cyId = JSON.parse(decodeURIComponent(options.obj)).carrierId
  198. this.getInfo()
  199. }
  200. console.log(options)
  201. var isContains = true; //隐私权政策是否包含高德开平隐私权政策 true是包含
  202. var isShow = true; //隐私权政策是否弹窗展示告知用户 true是展示
  203. sdkwx.updatePrivacyShow(isContains, isShow);
  204. var isAgree = true; //隐私权政策是否取得用户同意 true是用户同意
  205. sdkwx.updatePrivacyAgree(isAgree);
  206. //检查定位权限
  207. sdkwx.checkLocationPermission(function(res) {
  208. console.log(res);
  209. });
  210. // this.auth()
  211. },
  212. onHide() {
  213. uni.removeStorageSync(
  214. "contractdata")
  215. },
  216. onShow() {
  217. this.firstAuthentication = uni.getStorageSync("firstAuthentication")
  218. if (uni.getStorageSync('contractdata')) {
  219. this.id = uni.getStorageSync('contractdata').id
  220. this.detailData.hyCarrierInfo.id = uni.getStorageSync('contractdata').carrierId
  221. this.cyId = uni.getStorageSync('contractdata').carrierId
  222. this.getInfo()
  223. }
  224. },
  225. computed: {
  226. ...mapState(['hasLogin', 'userInfo'])
  227. },
  228. methods: {
  229. toSignContract() {
  230. console.log(this.detailData)
  231. this.$request.baseRequest('get', '/orderInfo/getOrderInfo', {
  232. id: this.id,
  233. }).then(res => {
  234. uni.$u.route('/pages/order/signContract', {
  235. obj: JSON.stringify(res.data),
  236. });
  237. });
  238. },
  239. selectDate() {
  240. this.showDate = true
  241. },
  242. confirmDate(e) {
  243. this.detailData.hyCarrierInfo.loadingDate = e[0]
  244. this.showDate = false
  245. },
  246. getInfo() {
  247. this.$request.baseRequest('get', '/orderInfo/getOrderInfo', {
  248. id: this.id,
  249. }).then(res => {
  250. if (res.code == 200) {
  251. this.detailData = res.data
  252. if (res.data.hyCarrierInfo && res.data.hyCarrierInfo.transportationDuration) {
  253. this.detailData.transportationDuration = res.data.hyCarrierInfo.transportationDuration
  254. }
  255. // #ifdef APP-PLUS
  256. this.getLngLat();
  257. // #endif
  258. this.$request.baseRequest('get', '/carrierInfo/getHyCarrierInfo', {
  259. orderId: this.detailData.id,
  260. }).then(res => {
  261. if (res.data) {
  262. if (res.data.loadingImg) {
  263. var data = res.data.loadingImg.split(',')
  264. this.imgList = res.data.loadingImg.split(',')
  265. for (var i = 0; i < data.length; i++) {
  266. if (data[i] != '') {
  267. this.fileList1.push({
  268. url: data[i]
  269. })
  270. }
  271. }
  272. }
  273. console.log(this.fileList1)
  274. this.detailData.carNo = res.data.carNo
  275. this.detailData.loadingDate = res.data.loadingDate
  276. if (res.data.loadingDate) {
  277. this.detailData.loadingDate1 = res.data.loadingDate.split(' ')[0]
  278. }
  279. this.detailData.weight = res.data.loadingWeight
  280. this.detailData.grossWeight = res.data.loadingGrossWeight
  281. this.detailData.freight = res.data.estimatedFreight
  282. }
  283. })
  284. }
  285. })
  286. },
  287. //车牌号弹出键盘
  288. handleShowKeyboard() {
  289. if (this.detailData.hyCarrierInfo.carNo == '') {
  290. this.carNumber = ''
  291. } else {
  292. this.carNumber = this.detailData.hyCarrierInfo.carNo
  293. }
  294. if (this.$refs.keyboard.open) {
  295. this.$refs.keyboard.open(false) //true 键盘显示 false 键盘隐藏
  296. } else {
  297. this.$refs.keyboard[0].open(false)
  298. }
  299. if (this.$refs.keyboard.open) {
  300. this.$refs.keyboard.open(true) //true 键盘显示 false 键盘隐藏
  301. } else {
  302. this.$refs.keyboard[0].open(true)
  303. }
  304. },
  305. //车牌号弹出键盘
  306. handleClick(e) {
  307. this.carNumber = e.value
  308. this.detailData.hyCarrierInfo.carNo = e.value //键盘输入值
  309. },
  310. checkOpenGPSServiceByAndroidIOS() {
  311. let system = uni.getSystemInfoSync(); // 获取系统信息
  312. if (system.platform === 'android') { // 判断平台
  313. var context = plus.android.importClass("android.content.Context");
  314. var locationManager = plus.android.importClass("android.location.LocationManager");
  315. var main = plus.android.runtimeMainActivity();
  316. var mainSvr = main.getSystemService(context.LOCATION_SERVICE);
  317. if (!mainSvr.isProviderEnabled(locationManager.GPS_PROVIDER)) {
  318. uni.showModal({
  319. title: '提示',
  320. content: '请打开定位服务功能',
  321. // showCancel: false, // 不显示取消按钮
  322. success(res) {
  323. if (res.confirm) {
  324. if (!mainSvr.isProviderEnabled(locationManager.GPS_PROVIDER)) {
  325. var Intent = plus.android.importClass('android.content.Intent');
  326. var Settings = plus.android.importClass('android.provider.Settings');
  327. var intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
  328. main.startActivity(intent); // 打开系统设置GPS服务页面
  329. }
  330. }
  331. }
  332. });
  333. }
  334. } else if (system.platform === 'ios') {
  335. // console.log("苹果");
  336. var cllocationManger = plus.ios.import("CLLocationManager");
  337. var enable = cllocationManger.locationServicesEnabled();
  338. var status = cllocationManger.authorizationStatus();
  339. plus.ios.deleteObject(cllocationManger);
  340. if (enable && status != 2) {
  341. console.log("手机系统的定位已经打开");
  342. } else {
  343. console.log("手机系统的定位没有打开");
  344. uni.showModal({
  345. title: '提示',
  346. content: '请前往设置-隐私-定位服务打开定位服务功能',
  347. // showCancel: false, // 不显示取消按钮
  348. success(res) {
  349. if (res.confirm) {
  350. var UIApplication = plus.ios.import("UIApplication");
  351. var application2 = UIApplication.sharedApplication();
  352. var NSURL2 = plus.ios.import("NSURL");
  353. // var setting2 = NSURL2.URLWithString("prefs:root=LOCATION_SERVICES");
  354. // var setting2 = NSURL2.URLWithString("App-Prefs:root=LOCATION_SERVICES");
  355. // var setting2 = NSURL2.URLWithString("app-settings");
  356. var setting2 = NSURL2.URLWithString("App-Prefs:root=Privacy&path=LOCATION");
  357. // var setting2 = NSURL2.URLWithString("App-Prefs:root=Privacy&path=LOCATION_SERVICES");
  358. application2.openURL(setting2);
  359. plus.ios.deleteObject(setting2);
  360. plus.ios.deleteObject(NSURL2);
  361. plus.ios.deleteObject(application2);
  362. }
  363. }
  364. });
  365. }
  366. }
  367. },
  368. getLngLat() {
  369. this.checkOpenGPSServiceByAndroidIOS()
  370. var that = this
  371. uni.showLoading({
  372. title: '获取定位中',
  373. mask: true
  374. })
  375. uni.getLocation({
  376. type: 'gcj02',
  377. geocode: true,
  378. success: res => {
  379. if (res.latitude) {
  380. that.detailData.hyCarrierInfo.longitudeLatitude = res.longitude + ',' + res
  381. .latitude
  382. that.detailData.hyCarrierInfo.loadingAreaLongitude = res.longitude;
  383. that.detailData.hyCarrierInfo.loadingAreaLatitude = res.latitude;
  384. that.detailData.hyCarrierInfo.sendCity = that.$helper.filterUrban(res.address.city)
  385. that.localtion.city = that.$helper.filterUrban(res.address.city)
  386. that.$set(that.detailData, 'loadingArea', that.$helper.filterUrban(res.address
  387. .district))
  388. that.$set(that.detailData, 'loadingCity', that.$helper.filterUrban(res.address
  389. .city))
  390. that.localtion.sendArea = that.$helper.filterUrban(res.address.district)
  391. // .loadingCity = that.$helper.filterUrban(res.address.city)
  392. that.detailData.loadingLongitude = res.longitude;
  393. that.detailData.loadingLatitude = 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. cancelClick() {
  439. this.isShowAlert = false
  440. },
  441. // 删除图片
  442. deletePic(event) {
  443. this[`fileList${event.name}`].splice(event.index, 1)
  444. this.imgList.splice(event.index, 1)
  445. },
  446. // 新增图片
  447. async afterRead(event) {
  448. // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
  449. let lists = [].concat(event.file)
  450. let fileListLen = this[`fileList${event.name}`].length
  451. lists.map((item) => {
  452. this[`fileList${event.name}`].push({
  453. ...item,
  454. status: 'uploading',
  455. message: '上传中'
  456. })
  457. })
  458. for (let i = 0; i < lists.length; i++) {
  459. const result = await this.uploadFilePromise(lists[i].url)
  460. let item = this[`fileList${event.name}`][fileListLen]
  461. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  462. status: 'success',
  463. message: '',
  464. url: result
  465. }))
  466. fileListLen++
  467. }
  468. },
  469. uploadFilePromise(url) {
  470. uploadImage('image', url, 'appData/',
  471. result => {
  472. // 上传成功回调函数
  473. console.log('图片地址', result)
  474. this.imgList.push(result)
  475. }
  476. )
  477. },
  478. onProgress(e) {
  479. console.log(e)
  480. },
  481. submit(type) {
  482. if (type == 1) {
  483. if (this.detailData.driverContract != 1) { //合同签订标识
  484. this.$refs.uToast.show({
  485. type: 'error',
  486. message: "合同未签订不能暂存!"
  487. })
  488. return
  489. }
  490. this.alertTitle = '确定暂存装车信息?'
  491. } else {
  492. if (this.detailData.driverContract != 1) {
  493. this.$refs.uToast.show({
  494. type: 'error',
  495. message: "合同未签订不能提交!"
  496. })
  497. return
  498. }
  499. this.alertTitle = '确定提交装车信息?'
  500. }
  501. if (this.validate()) return
  502. this.isShowAlert = true
  503. this.detailData.statusFlag = type
  504. },
  505. validate() {
  506. if (uni.$u.test.isEmpty(this.detailData.carNo)) {
  507. this.$refs.uToast.show({
  508. type: 'error',
  509. message: "车牌号不能为空!",
  510. })
  511. return true
  512. }
  513. if (uni.$u.test.isEmpty(this.detailData.loadingDate)) {
  514. this.$refs.uToast.show({
  515. type: 'error',
  516. message: "装车日期不能为空!",
  517. })
  518. return true
  519. }
  520. if (uni.$u.test.isEmpty(this.detailData.freight)) {
  521. this.$refs.uToast.show({
  522. type: 'error',
  523. message: "预计运费不能为空!",
  524. })
  525. return true
  526. }
  527. // if (uni.$u.test.isEmpty(this.detailData.loadingCity)) {
  528. // this.$refs.uToast.show({
  529. // type: 'error',
  530. // message: "定位不能为空!",
  531. // })
  532. // return true
  533. // }
  534. // if (uni.$u.test.isEmpty(this.detailData.loadingArea)) {
  535. // this.$refs.uToast.show({
  536. // type: 'error',
  537. // message: "定位不能为空!",
  538. // })
  539. // return true
  540. // }
  541. if (uni.$u.test.isEmpty(this.detailData.transportationDuration)) {
  542. this.$refs.uToast.show({
  543. type: 'error',
  544. message: "运输时长不能为空!",
  545. })
  546. return true
  547. }
  548. if (this.detailData.transportationDuration < 0 || this.detailData.transportationDuration > 1000) {
  549. this.$refs.uToast.show({
  550. type: 'error',
  551. message: "运输时长输入错误!",
  552. })
  553. return true
  554. }
  555. if (this.imgList.length == 0) {
  556. this.$refs.uToast.show({
  557. type: 'error',
  558. message: "装车照片不能为空!",
  559. })
  560. return true
  561. }
  562. },
  563. affirm(data) {
  564. this.$request.baseRequest('post', '/carrierInfo/loadingAdd', data).then(res => {
  565. console.log("提交状态", res)
  566. uni.hideLoading()
  567. if (res.code == 200) {
  568. that.$refs.uToast.show({
  569. type: 'success',
  570. message: '暂存成功',
  571. complete() {
  572. uni.switchTab({
  573. url: '/pages/order/index'
  574. })
  575. }
  576. })
  577. }
  578. }).catch(res => {
  579. uni.hideLoading()
  580. console.log("2", res.message)
  581. // uni.$u.toast(res.message);
  582. that.$refs.uToast.show({
  583. type: 'error',
  584. message: res.message,
  585. })
  586. });
  587. },
  588. confirmClick() {
  589. uni.removeStorageSync('contractdata')
  590. var that = this
  591. this.isShowAlert = false
  592. //1暂存
  593. if (this.detailData.statusFlag == 1) {
  594. delete this.detailData.hyCarrierInfo.loadingAreaLongitude;
  595. delete this.detailData.hyCarrierInfo.loadingAreaLatitude;
  596. delete this.detailData.hyCarrierInfo.sendCity;
  597. delete this.detailData.hyCarrierInfo.sendArea;
  598. }
  599. // uni.showLoading({
  600. // title: '加载中'
  601. // })
  602. let time = new Date() //装车时间 去当前时间的时分秒
  603. let h = time.getHours();
  604. if (h < 10) {
  605. h = "0" + h
  606. }
  607. let f = time.getMinutes();
  608. if (f < 10) {
  609. f = "0" + f
  610. }
  611. let m = time.getSeconds();
  612. if (m < 10) {
  613. m = "0" + m
  614. }
  615. var data = {
  616. loadingImg: this.imgList.toString(),
  617. statusFlag: this.detailData.statusFlag,
  618. loadingDate: this.detailData.hyCarrierInfo.loadingDate.split(" ")[0] + " " + h + ":" + f + ":" + m,
  619. loadingArea: this.detailData.loadingArea,
  620. loadingCity: this.detailData.loadingCity,
  621. loadingLongitude: this.detailData.loadingLongitude,
  622. loadingLatitude: this.detailData.loadingLatitude,
  623. id: this.detailData.hyCarrierInfo.id,
  624. transportationDuration: this.detailData.transportationDuration
  625. }
  626. if (that.detailData.statusFlag == 1) { //暂存
  627. console.log("暂存")
  628. this.affirm(data)
  629. } else { //提交
  630. this.submitInfo(data) //先调用管局start
  631. }
  632. },
  633. async submitInfo(data) {
  634. console.log(11)
  635. let _auth = await this.auth()
  636. if (_auth.type == "onFailure") {
  637. that.$refs.uToast.show({
  638. type: 'error',
  639. message: "管局授权失败-" + res.data.errorMsg
  640. })
  641. return
  642. }
  643. // then(res => {
  644. // if (res.type == "onFailure") {
  645. // that.$refs.uToast.show({
  646. // type: 'error',
  647. // message: "管局授权失败-" + res.data.errorMsg
  648. // })
  649. // return
  650. // }
  651. // })
  652. let _start = this.start()
  653. if (_start.type == 'onFailure') {
  654. that.$refs.uToast.show({
  655. type: 'error',
  656. message: "管局上报-" + res.data.errorMsg
  657. })
  658. return
  659. }
  660. // .then(res => {
  661. // console.log(4)
  662. // var shippingNoteInfos = res.data[0]; //运单信息列表
  663. // if (res.type == "onSuccess") {
  664. // } else if (res.type == "onFailure") {
  665. // that.$refs.uToast.show({
  666. // type: 'error',
  667. // message: "管局上报1-" + res.data.errorMsg
  668. // })
  669. // return
  670. // }
  671. // })
  672. console.log("_start", _start)
  673. let _send = await this.send()
  674. // .then(res => {
  675. // console.log(6)
  676. // if (res.type == "onSuccess") {
  677. // var shippingNoteInfos = res.data[0]; //运单信息列表
  678. // let dateTtime = Number(shippingNoteInfos.interval + 1000)
  679. // that.timer = setTimeout(() => {
  680. // that.send()
  681. // }, dateTtime);
  682. // } else if (res.type == "onFailure") {
  683. // var errorCode = res.data.errorCode; //错误码
  684. // var errorMsg = res.data.errorMsg; //错误描述
  685. // that.$refs.uToast.show({
  686. // type: 'error',
  687. // message: "管局上报2-" + errorMsg
  688. // })
  689. // return
  690. // }
  691. // })
  692. console.log("_send", _send)
  693. if (_send.type == "onSuccess") {
  694. var shippingNoteInfos = _send.data[0]; //运单信息列表
  695. let dateTtime = Number(shippingNoteInfos.interval + 1000)
  696. that.timer = setTimeout(() => {
  697. that.send()
  698. }, dateTtime);
  699. } else if (_send.type == "onFailure") {
  700. var errorCode = _send.data.errorCode; //错误码
  701. var errorMsg = _send.data.errorMsg; //错误描述
  702. that.$refs.uToast.show({
  703. type: 'error',
  704. message: "管局上报-" + errorMsg
  705. })
  706. return
  707. }
  708. console.log(35453454)
  709. this.$request.baseRequest('post', '/carrierInfo/loadingAdd', data).then(res => {
  710. console.log("提交状态", res)
  711. uni.hideLoading()
  712. if (res.code == 200) {
  713. that.$helper.fUN_AmapLocation.start({
  714. // intervalTime: 1000 * 60,
  715. intervalTime: 60000,
  716. // locationCacheEnable:true,
  717. isReport: false
  718. },
  719. res => {
  720. // console.log('====确认装车开启连续定位====');
  721. // console.log(res)
  722. let _data = {
  723. orderId: that.id,
  724. longitude: res.longitude,
  725. latitude: res.latitude,
  726. province: res.province,
  727. city: res.city,
  728. area: res.district
  729. }
  730. if (this.shippingNoteInfos && this.shippingNoteInfos.length >
  731. 0) { //更新持续定位经纬度
  732. for (let i = 0; i < this.shippingNoteInfos.length; i++) {
  733. this.shippingNoteInfos[i].startLatitude = _data.latitude //纬度
  734. this.shippingNoteInfos[i].startLocationText = _data.city //起点
  735. this.shippingNoteInfos[i].startLongitude = _data.longitude //经度
  736. }
  737. }
  738. this.$helper.gjList.push(_data)
  739. uni.setStorageSync('mapGJ', this.$helper.gjList);
  740. console.log("条数", uni.getStorageSync('mapGJ').length)
  741. if (uni.getStorageSync('mapGJ').length > 10) {
  742. that.$request.baseRequest('post', '/hyOrderTravelPath/api/addInfo', {
  743. orderId: that.id,
  744. longitudeLatitude: JSON.stringify(uni.getStorageSync(
  745. 'mapGJ'))
  746. }).then(res => {
  747. console.log("已发送定位----------------", res)
  748. uni.removeStorageSync('mapGJ');
  749. that.$helper.gjList = []
  750. })
  751. .catch(res => {
  752. console.log("0", res.message)
  753. uni.$u.toast(res.message);
  754. });
  755. }
  756. }
  757. );
  758. that.$refs.uToast.show({
  759. type: 'success',
  760. message: '提交成功!',
  761. complete() {
  762. uni.switchTab({
  763. url: '/pages/order/index'
  764. })
  765. }
  766. })
  767. } else {
  768. console.log("1", res)
  769. // uni.$u.toast(res.message);
  770. that.$refs.uToast.show({
  771. type: 'error',
  772. message: res.message,
  773. })
  774. }
  775. }).catch(res => {
  776. uni.hideLoading()
  777. console.log("2", res.message)
  778. // uni.$u.toast(res.message);
  779. that.$refs.uToast.show({
  780. type: 'error',
  781. message: res.message,
  782. })
  783. });
  784. },
  785. auth() {
  786. //授权
  787. // console.log("appid:" + this.appId + "安全码:" + this.appSecurity + "发送代码:" + this.enterpriseSenderCode +
  788. // "环境" + this.environment)
  789. console.log(2)
  790. let promise = new Promise(function(resolve, reject) {
  791. sdkwx.auth(that.appId, that.appSecurity, that.enterpriseSenderCode, that.environment, function(
  792. res) {
  793. console.log("authres", res)
  794. resolve(res)
  795. });
  796. })
  797. return promise
  798. },
  799. start() {
  800. console.log(3)
  801. //车牌号 //司机姓名 //备注 //运单信息列表
  802. this.shippingNoteInfos[0].shippingNoteNumber = this.detailData.orderNo //运单号
  803. this.shippingNoteInfos[0].serialNumber = "0000" //分单号
  804. this.shippingNoteInfos[0].startCountrySubdivisionCode = this.detailData.publishTaskInfo
  805. .sendAdCode //起点位置行政区划代码,调 用 start/stop/pause/restart 时 必填,调用 send 非必填
  806. this.shippingNoteInfos[0].endCountrySubdivisionCode = this.detailData.publishTaskInfo
  807. .unsendAdCode //到达位置行政区划代码,调 用 start/stop/pause/restart 时 必填,调用 send 非必填
  808. this.shippingNoteInfos[0].startLongitude = this.detailData.publishTaskInfo
  809. .sendLongitude //起点位置经度,调用 start/stop/pause/restart 时必 填,调用 send 非必填
  810. this.shippingNoteInfos[0].startLatitude = this.detailData.publishTaskInfo
  811. .sendLatitude //起点位置纬度,调用 start/stop/pause/restart 时必 填,调用 send 非必填
  812. this.shippingNoteInfos[0].endLongitude = this.detailData.publishTaskInfo
  813. .unsendLongitude //到达位置经度,调用 start/stop/pause/restart 时必 填,调用 send 非必填
  814. this.shippingNoteInfos[0].endLatitude = this.detailData.publishTaskInfo
  815. .unsendLatitude //到达位置纬度,调用 start/stop/pause/restart 时必 填,调用 send 非必填
  816. this.shippingNoteInfos[0].startLocationText = this.detailData
  817. .sendCity //起点地址文字描述,调用 start/stop/pause/restart 时必 填,调用 send 非必填
  818. this.shippingNoteInfos[0].endLocationText = this.detailData
  819. .unloadCity //到达地址文字描述,调用 start/stop/pause/restart 时必 填,调用 send 非必填
  820. this.shippingNoteInfos[0].vehicleNumber = this.detailData
  821. .carNumber //车牌号,SDK 回调返回,调 用 start/stop/pause/restart/必 填,send 时非必填
  822. this.shippingNoteInfos[0].driverName = this.detailData
  823. .driverName //司机姓名,SDK 回调返回, 调用 start/stop/pause/restart/ 必填,send 时非必填
  824. this.shippingNoteInfos[0].interval = "5000" //请求时间间隔,SDK 回调返 回(单位 ms)
  825. //}],//运单信息列表,一辆车运单数最大支持数为 10
  826. var remark = "测试"; //备注
  827. var param = {}
  828. param.carNo = this.detailData.carNo
  829. param.driverName = this.firstAuthentication.driverName
  830. param.remark = remark
  831. param.shippingNoteInfos = this.shippingNoteInfos
  832. let promise = new Promise(function(resolve, reject) {
  833. sdkwx.start(that.detailData.carNo, that.firstAuthentication.driverName, remark, that
  834. .shippingNoteInfos,
  835. function(res) {
  836. console.log("startres", res)
  837. resolve(res)
  838. });
  839. })
  840. return promise
  841. },
  842. send() { //发送定位
  843. console.log(5)
  844. var remark = ""; //备注
  845. let that = this
  846. console.log("send this.shippingNoteInfos")
  847. console.log(this.shippingNoteInfos)
  848. let promise = new Promise(function(resolve, reject) {
  849. sdkwx.send(that.detailData.carNo, that.firstAuthentication.driverName, remark, that
  850. .shippingNoteInfos,
  851. function(res) {
  852. resolve(res)
  853. });
  854. })
  855. return promise
  856. },
  857. // send() { //发送定位
  858. // console.log(5)
  859. // var remark = ""; //备注
  860. // let that = this
  861. // console.log("send this.shippingNoteInfos")
  862. // console.log(this.shippingNoteInfos)
  863. // sdkwx.send(this.detailData.carNo, this.firstAuthentication.driverName, remark, this.shippingNoteInfos,
  864. // function(res) {
  865. // console.log('发送定位', res);
  866. // if (res.type == "onSuccess") {
  867. // var shippingNoteInfos = res.data[0]; //运单信息列表
  868. // let dateTtime = Number(shippingNoteInfos.interval + 1000)
  869. // console.log("开始定时", dateTtime)
  870. // that.timer = setTimeout(() => {
  871. // that.send()
  872. // }, dateTtime);
  873. // } else if (res.type == "onFailure") {
  874. // var errorCode = res.data.errorCode; //错误码
  875. // var errorMsg = res.data.errorMsg; //错误描述
  876. // that.timer = setTimeout(() => {
  877. // console.log("定时")
  878. // that.send()
  879. // }, 915204); //15分钟
  880. // // that.$refs.uToast.show({
  881. // // type: 'error',
  882. // // message: "管局上报-" + errorMsg
  883. // // })
  884. // }
  885. // });
  886. // },
  887. },
  888. }
  889. </script>
  890. <style scoped lang="scss">
  891. .content {
  892. // . {
  893. // color: #333333;
  894. // }
  895. }
  896. .level2-title {
  897. margin: 0 0 20rpx 0;
  898. }
  899. .content1,
  900. .content2 {
  901. background: white;
  902. margin: 20rpx;
  903. border-radius: 20rpx;
  904. padding: 20rpx;
  905. .place {
  906. width: 80%;
  907. text-align: right;
  908. }
  909. }
  910. .upload {}
  911. .bottom-btn {
  912. display: flex;
  913. justify-content: space-around;
  914. margin-bottom: 50rpx;
  915. background: #FFFFFF;
  916. padding: 40rpx 0;
  917. }
  918. .store {
  919. padding: 20rpx 30rpx;
  920. color: #F5BA3C;
  921. width: 40%;
  922. background: #EEF4FF;
  923. border-radius: 40rpx;
  924. font-size: 36rpx;
  925. text-align: center;
  926. }
  927. .submit {
  928. font-size: 36rpx;
  929. padding: 20rpx 30rpx;
  930. color: white;
  931. width: 40%;
  932. background: #F5BA3C;
  933. border-radius: 40rpx;
  934. text-align: center;
  935. }
  936. .row-between {
  937. margin: 20rpx 0;
  938. }
  939. .sx-style {
  940. background: #F5BA3C;
  941. color: white;
  942. padding: 2rpx 16rpx;
  943. box-sizing: border-box;
  944. border-radius: 10rpx;
  945. margin-left: 20rpx;
  946. }
  947. .input {
  948. text-align: right;
  949. }
  950. .date-style {}
  951. </style>