confirmLoading.vue 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952
  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='#2772FB' @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. let 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. let phoneType = uni.getSystemInfoSync().platform //判断手机类型
  182. this.enterpriseSenderCode = config.def().enterpriseSenderCode
  183. this.environment = config.def().environment
  184. if (phoneType == "android") {
  185. this.appId = config.def().androidAppId
  186. this.appSecurity = config.def().androidAppSecurity
  187. } else if (phoneType == "ios") {
  188. // this.appId = "uni.UNIDCD13AC"
  189. // this.appSecurity = "b01e4805276646eeb25f0fad91de97a4f32e8c2c0e0d42e5b24cc4737e9f040f"
  190. this.appId = config.def().iosAppId
  191. this.appSecurity = config.def().iosAppSecurity
  192. }
  193. if (!uni.getStorageSync('contractdata')) {
  194. this.id = JSON.parse(decodeURIComponent(options.obj)).id
  195. this.detailData.hyCarrierInfo.id = JSON.parse(decodeURIComponent(options.obj)).carrierId
  196. this.cyId = JSON.parse(decodeURIComponent(options.obj)).carrierId
  197. this.getInfo()
  198. }
  199. console.log(options)
  200. var isContains = true; //隐私权政策是否包含高德开平隐私权政策 true是包含
  201. var isShow = true; //隐私权政策是否弹窗展示告知用户 true是展示
  202. sdkwx.updatePrivacyShow(isContains, isShow);
  203. var isAgree = true; //隐私权政策是否取得用户同意 true是用户同意
  204. sdkwx.updatePrivacyAgree(isAgree);
  205. //检查定位权限
  206. sdkwx.checkLocationPermission(function(res) {
  207. console.log(res);
  208. });
  209. this.auth()
  210. },
  211. onHide() {
  212. uni.removeStorageSync(
  213. "contractdata")
  214. },
  215. onShow() {
  216. this.firstAuthentication = uni.getStorageSync("firstAuthentication")
  217. if (uni.getStorageSync('contractdata')) {
  218. this.id = uni.getStorageSync('contractdata').id
  219. this.detailData.hyCarrierInfo.id = uni.getStorageSync('contractdata').carrierId
  220. this.cyId = uni.getStorageSync('contractdata').carrierId
  221. this.getInfo()
  222. }
  223. },
  224. computed: {
  225. ...mapState(['hasLogin', 'userInfo'])
  226. },
  227. methods: {
  228. auth() { //授权
  229. console.log("appid:" + this.appId + "安全码:" + this.appSecurity + "发送代码:" + this.enterpriseSenderCode+"环境"+this.environment)
  230. var that = this
  231. sdkwx.auth(this.appId, this.appSecurity, this.enterpriseSenderCode, this.environment, function(res) {
  232. if (res.type == "onSuccess") {
  233. //成功
  234. console.log("授权成功")
  235. console.log(res)
  236. } else if (res.type == "onFailure") {
  237. //失败
  238. var errorCode = res.data.errorCode; //错误码
  239. var errorMsg = res.data.errorMsg; //错误描述
  240. that.$refs.uToast.show({
  241. type: 'error',
  242. message: "管局授权失败-"+errorMsg
  243. })
  244. console.log("授权失败")
  245. console.log(res)
  246. }
  247. });
  248. },
  249. start(val) { //开启定位
  250. var that = this
  251. //车牌号 //司机姓名 //备注 //运单信息列表
  252. this.shippingNoteInfos[0].shippingNoteNumber = this.detailData.orderNo //运单号
  253. this.shippingNoteInfos[0].serialNumber = "0000" //分单号
  254. this.shippingNoteInfos[0].startCountrySubdivisionCode = this.detailData.publishTaskInfo
  255. .sendAdCode //起点位置行政区划代码,调 用 start/stop/pause/restart 时 必填,调用 send 非必填
  256. this.shippingNoteInfos[0].endCountrySubdivisionCode = this.detailData.publishTaskInfo
  257. .unsendAdCode //到达位置行政区划代码,调 用 start/stop/pause/restart 时 必填,调用 send 非必填
  258. this.shippingNoteInfos[0].startLongitude = this.detailData.publishTaskInfo
  259. .sendLongitude //起点位置经度,调用 start/stop/pause/restart 时必 填,调用 send 非必填
  260. this.shippingNoteInfos[0].startLatitude = this.detailData.publishTaskInfo
  261. .sendLatitude //起点位置纬度,调用 start/stop/pause/restart 时必 填,调用 send 非必填
  262. this.shippingNoteInfos[0].endLongitude = this.detailData.publishTaskInfo
  263. .unsendLongitude //到达位置经度,调用 start/stop/pause/restart 时必 填,调用 send 非必填
  264. this.shippingNoteInfos[0].endLatitude = this.detailData.publishTaskInfo
  265. .unsendLatitude //到达位置纬度,调用 start/stop/pause/restart 时必 填,调用 send 非必填
  266. this.shippingNoteInfos[0].startLocationText = this.detailData
  267. .sendCity //起点地址文字描述,调用 start/stop/pause/restart 时必 填,调用 send 非必填
  268. this.shippingNoteInfos[0].endLocationText = this.detailData
  269. .unloadCity //到达地址文字描述,调用 start/stop/pause/restart 时必 填,调用 send 非必填
  270. this.shippingNoteInfos[0].vehicleNumber = this.detailData
  271. .carNumber //车牌号,SDK 回调返回,调 用 start/stop/pause/restart/必 填,send 时非必填
  272. this.shippingNoteInfos[0].driverName = this.detailData
  273. .driverName //司机姓名,SDK 回调返回, 调用 start/stop/pause/restart/ 必填,send 时非必填
  274. this.shippingNoteInfos[0].interval = "5000" //请求时间间隔,SDK 回调返 回(单位 ms)
  275. //}],//运单信息列表,一辆车运单数最大支持数为 10
  276. var remark = "测试"; //备注
  277. var param = {}
  278. param.carNo = this.detailData.carNo
  279. param.driverName = this.firstAuthentication.driverName
  280. param.remark = remark
  281. param.shippingNoteInfos = this.shippingNoteInfos
  282. sdkwx.start(this.detailData.carNo, this.firstAuthentication.driverName, remark, this.shippingNoteInfos,
  283. function(res) {
  284. if (res.type == "onSuccess") {
  285. //成功
  286. console.log("开启定位成功!!!")
  287. console.log(res)
  288. var shippingNoteInfos = res.data[0]; //运单信息列表
  289. if (shippingNoteInfos) {
  290. let dateTtime = Number(shippingNoteInfos.interval + 1000)
  291. console.log("开始定时", dateTtime)
  292. that.send()
  293. }
  294. that.affirm(val)//管局上报成功后提交
  295. } else if (res.type == "onFailure") {
  296. //失败
  297. console.log("开启定位失败!!!")
  298. console.log(res)
  299. var errorCode = res.data.errorCode; //错误码
  300. var errorMsg = res.data.errorMsg; //错误描述
  301. uni.hideLoading()
  302. that.$refs.uToast.show({
  303. type: 'error',
  304. message: "管局上报-"+errorMsg
  305. })
  306. that.timer = setTimeout(() => {
  307. console.log("定时")
  308. that.send()
  309. }, 915204);
  310. }
  311. });
  312. },
  313. send() { //发送定位
  314. var remark = ""; //备注
  315. let that = this
  316. console.log("send this.shippingNoteInfos")
  317. console.log(this.shippingNoteInfos)
  318. sdkwx.send(this.detailData.carNo, this.firstAuthentication.driverName, remark, this.shippingNoteInfos,
  319. function(res) {
  320. console.log('发送定位', res);
  321. if (res.type == "onSuccess") {
  322. var shippingNoteInfos = res.data[0]; //运单信息列表
  323. let dateTtime = Number(shippingNoteInfos.interval + 1000)
  324. console.log("开始定时", dateTtime)
  325. that.timer = setTimeout(() => {
  326. that.send()
  327. }, dateTtime);
  328. } else if (res.type == "onFailure") {
  329. var errorCode = res.data.errorCode; //错误码
  330. var errorMsg = res.data.errorMsg; //错误描述
  331. that.timer = setTimeout(() => {
  332. console.log("定时")
  333. that.send()
  334. }, 915204); //15分钟
  335. }
  336. });
  337. },
  338. toSignContract() {
  339. console.log(this.detailData)
  340. this.$request.baseRequest('get', '/orderInfo/getOrderInfo', {
  341. id: this.id,
  342. }).then(res => {
  343. uni.$u.route('/pages/order/signContract', {
  344. obj: JSON.stringify(res.data),
  345. });
  346. });
  347. },
  348. selectDate() {
  349. this.showDate = true
  350. },
  351. confirmDate(e) {
  352. this.detailData.hyCarrierInfo.loadingDate = e[0]
  353. this.showDate = false
  354. },
  355. getInfo() {
  356. this.$request.baseRequest('get', '/orderInfo/getOrderInfo', {
  357. id: this.id,
  358. }).then(res => {
  359. if (res.code == 200) {
  360. this.detailData = res.data
  361. if (res.data.hyCarrierInfo && res.data.hyCarrierInfo.transportationDuration) {
  362. this.detailData.transportationDuration = res.data.hyCarrierInfo.transportationDuration
  363. }
  364. // #ifdef APP-PLUS
  365. this.getLngLat();
  366. // #endif
  367. this.$request.baseRequest('get', '/carrierInfo/getHyCarrierInfo', {
  368. orderId: this.detailData.id,
  369. }).then(res => {
  370. if (res.data) {
  371. if (res.data.loadingImg) {
  372. var data = res.data.loadingImg.split(',')
  373. this.imgList = res.data.loadingImg.split(',')
  374. for (var i = 0; i < data.length; i++) {
  375. if (data[i] != '') {
  376. this.fileList1.push({
  377. url: data[i]
  378. })
  379. }
  380. }
  381. }
  382. console.log(this.fileList1)
  383. this.detailData.carNo = res.data.carNo
  384. this.detailData.loadingDate = res.data.loadingDate
  385. if (res.data.loadingDate) {
  386. this.detailData.loadingDate1 = res.data.loadingDate.split(' ')[0]
  387. }
  388. this.detailData.weight = res.data.loadingWeight
  389. this.detailData.grossWeight = res.data.loadingGrossWeight
  390. this.detailData.freight = res.data.estimatedFreight
  391. }
  392. })
  393. // this.detailData.contractNo = ''
  394. // this.detailData.id = this.detailData.carrierId
  395. // this.detailData.carrierInfo.loadingDate = ''
  396. // this.detailData.carrierInfo.carNo = ''
  397. // this.detailData.carrierInfo.loadingAreaLongitude = ''
  398. // this.detailData.carrierInfo.loadingAreaLatitude = ''
  399. // this.detailData.carrierInfo.sendCity = '营口'
  400. // this.detailData.carrierInfo.sendArea = '鲅鱼圈'
  401. // this.detailData.carrierInfo.loadingImg = ''
  402. // this.carrierInfo = res.data.carrierInfo
  403. // this.freightInfo = res.data.freightInfo
  404. // this.zcPhoneList = this.carrierInfo.loadingImg.split(',')
  405. // if(res.data.orderStatus!="待货主确认"&&res.data.orderStatus!="未装车"&&res.data.orderStatus!="已终止"){
  406. // this.status1 = true
  407. // }
  408. // if(res.data.orderStatus!="已终止"&&res.data.orderStatus!="平台驳回装车信息"&&res.data.orderStatus!="待平台确认装车"&&res.data.orderStatus!="待货主确认"&&res.data.orderStatus!="未装车"&&res.data.orderStatus!="待货主确认装车"&&res.data.orderStatus!="货主驳回装车信息"){
  409. // this.status2 = true
  410. // }
  411. }
  412. })
  413. },
  414. //车牌号弹出键盘
  415. handleShowKeyboard() {
  416. if (this.detailData.hyCarrierInfo.carNo == '') {
  417. this.carNumber = ''
  418. } else {
  419. this.carNumber = this.detailData.hyCarrierInfo.carNo
  420. }
  421. if (this.$refs.keyboard.open) {
  422. this.$refs.keyboard.open(false) //true 键盘显示 false 键盘隐藏
  423. } else {
  424. this.$refs.keyboard[0].open(false)
  425. }
  426. if (this.$refs.keyboard.open) {
  427. this.$refs.keyboard.open(true) //true 键盘显示 false 键盘隐藏
  428. } else {
  429. this.$refs.keyboard[0].open(true)
  430. }
  431. },
  432. //车牌号弹出键盘
  433. handleClick(e) {
  434. this.carNumber = e.value
  435. this.detailData.hyCarrierInfo.carNo = e.value //键盘输入值
  436. },
  437. checkOpenGPSServiceByAndroidIOS() {
  438. let system = uni.getSystemInfoSync(); // 获取系统信息
  439. if (system.platform === 'android') { // 判断平台
  440. var context = plus.android.importClass("android.content.Context");
  441. var locationManager = plus.android.importClass("android.location.LocationManager");
  442. var main = plus.android.runtimeMainActivity();
  443. var mainSvr = main.getSystemService(context.LOCATION_SERVICE);
  444. if (!mainSvr.isProviderEnabled(locationManager.GPS_PROVIDER)) {
  445. uni.showModal({
  446. title: '提示',
  447. content: '请打开定位服务功能',
  448. // showCancel: false, // 不显示取消按钮
  449. success(res) {
  450. if (res.confirm) {
  451. if (!mainSvr.isProviderEnabled(locationManager.GPS_PROVIDER)) {
  452. var Intent = plus.android.importClass('android.content.Intent');
  453. var Settings = plus.android.importClass('android.provider.Settings');
  454. var intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
  455. main.startActivity(intent); // 打开系统设置GPS服务页面
  456. }
  457. }
  458. }
  459. });
  460. }
  461. } else if (system.platform === 'ios') {
  462. // console.log("苹果");
  463. var cllocationManger = plus.ios.import("CLLocationManager");
  464. var enable = cllocationManger.locationServicesEnabled();
  465. var status = cllocationManger.authorizationStatus();
  466. plus.ios.deleteObject(cllocationManger);
  467. if (enable && status != 2) {
  468. console.log("手机系统的定位已经打开");
  469. } else {
  470. console.log("手机系统的定位没有打开");
  471. uni.showModal({
  472. title: '提示',
  473. content: '请前往设置-隐私-定位服务打开定位服务功能',
  474. // showCancel: false, // 不显示取消按钮
  475. success(res) {
  476. if (res.confirm) {
  477. var UIApplication = plus.ios.import("UIApplication");
  478. var application2 = UIApplication.sharedApplication();
  479. var NSURL2 = plus.ios.import("NSURL");
  480. // var setting2 = NSURL2.URLWithString("prefs:root=LOCATION_SERVICES");
  481. // var setting2 = NSURL2.URLWithString("App-Prefs:root=LOCATION_SERVICES");
  482. // var setting2 = NSURL2.URLWithString("app-settings");
  483. var setting2 = NSURL2.URLWithString("App-Prefs:root=Privacy&path=LOCATION");
  484. // var setting2 = NSURL2.URLWithString("App-Prefs:root=Privacy&path=LOCATION_SERVICES");
  485. application2.openURL(setting2);
  486. plus.ios.deleteObject(setting2);
  487. plus.ios.deleteObject(NSURL2);
  488. plus.ios.deleteObject(application2);
  489. }
  490. }
  491. });
  492. }
  493. }
  494. },
  495. getLngLat() {
  496. this.checkOpenGPSServiceByAndroidIOS()
  497. var that = this
  498. uni.showLoading({
  499. title: '获取定位中',
  500. mask: true
  501. })
  502. // this.$helper.fUN_AmapLocation.start({
  503. // intervalTime: 1000 * 3,
  504. // isReport: false,
  505. // },
  506. // res => {
  507. // //见下方定位返回示例
  508. // console.log('====fUN_AmapLocation定位====', JSON.stringify(res));
  509. // if (res.latitude) {
  510. // this.detailData.carrierInfo.loadingAreaLongitude = res.longitude;
  511. // this.detailData.carrierInfo.loadingAreaLatitude = res.latitude;
  512. // this.detailData.carrierInfo.sendCity = this.$helper.filterUrban(res.city)
  513. // this.detailData.carrierInfo.sendArea = this.$helper.filterArea(res.district);
  514. // console.log(this.detailData.carrierInfo.sendCity)
  515. // console.log(this.detailData.carrierInfo.sendArea)
  516. // this.$forceUpdate()
  517. // }
  518. // this.$helper.fUN_AmapLocation.stop({}, result => {
  519. // uni.hideLoading()
  520. // console.log('====fUN_AmapLocation定位stop====', JSON.stringify(result));
  521. // });
  522. // }
  523. // );
  524. // console.log(that.detailData,111111)
  525. uni.getLocation({
  526. type: 'gcj02',
  527. geocode: true,
  528. success: res => {
  529. if (res.latitude) {
  530. that.detailData.hyCarrierInfo.longitudeLatitude = res.longitude + ',' + res
  531. .latitude
  532. that.detailData.hyCarrierInfo.loadingAreaLongitude = res.longitude;
  533. that.detailData.hyCarrierInfo.loadingAreaLatitude = res.latitude;
  534. that.detailData.hyCarrierInfo.sendCity = that.$helper.filterUrban(res.address.city)
  535. that.localtion.city = that.$helper.filterUrban(res.address.city)
  536. that.$set(that.detailData, 'loadingArea', that.$helper.filterUrban(res.address
  537. .district))
  538. that.$set(that.detailData, 'loadingCity', that.$helper.filterUrban(res.address
  539. .city))
  540. that.localtion.sendArea = that.$helper.filterUrban(res.address.district)
  541. // .loadingCity = that.$helper.filterUrban(res.address.city)
  542. that.detailData.loadingLongitude = res.longitude;
  543. that.detailData.loadingLatitude = res.latitude;
  544. that.$forceUpdate()
  545. uni.hideLoading()
  546. } else {
  547. if (uni.getSystemInfoSync().platform == 'android') {
  548. var context = plus.android.importClass("android.content.Context");
  549. var locationManager = plus.android.importClass(
  550. "android.location.LocationManager");
  551. var main = plus.android.runtimeMainActivity();
  552. var mainSvr = main.getSystemService(context.LOCATION_SERVICE);
  553. that.bool = mainSvr.isProviderEnabled(locationManager.GPS_PROVIDER)
  554. }
  555. if (that.bool === false) {
  556. uni.showModal({
  557. title: '提示',
  558. content: '请打开定位服务',
  559. success: ({
  560. confirm,
  561. cancel
  562. }) => {
  563. if (confirm) {
  564. if (uni.getSystemInfoSync().platform == 'android') {
  565. var Intent = plus.android.importClass(
  566. 'android.content.Intent');
  567. var Settings = plus.android.importClass(
  568. 'android.provider.Settings');
  569. var intent = new Intent(Settings
  570. .ACTION_LOCATION_SOURCE_SETTINGS);
  571. var main = plus.android.runtimeMainActivity();
  572. main.startActivity(intent); // 打开系统设置GPS服务页面
  573. }
  574. }
  575. }
  576. });
  577. uni.hideLoading()
  578. }
  579. }
  580. },
  581. fail: res => {
  582. console.log('定位失败')
  583. console.log(res)
  584. uni.hideLoading()
  585. }
  586. });
  587. },
  588. alertBtn() {
  589. // uni.navigateTo({
  590. // url: '/pages/public/login'
  591. // })
  592. },
  593. cancelClick() {
  594. this.isShowAlert = false
  595. },
  596. // 删除图片
  597. deletePic(event) {
  598. this[`fileList${event.name}`].splice(event.index, 1)
  599. this.imgList.splice(event.index, 1)
  600. },
  601. // 新增图片
  602. async afterRead(event) {
  603. // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
  604. let lists = [].concat(event.file)
  605. let fileListLen = this[`fileList${event.name}`].length
  606. lists.map((item) => {
  607. this[`fileList${event.name}`].push({
  608. ...item,
  609. status: 'uploading',
  610. message: '上传中'
  611. })
  612. })
  613. for (let i = 0; i < lists.length; i++) {
  614. const result = await this.uploadFilePromise(lists[i].url)
  615. let item = this[`fileList${event.name}`][fileListLen]
  616. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  617. status: 'success',
  618. message: '',
  619. url: result
  620. }))
  621. fileListLen++
  622. }
  623. },
  624. uploadFilePromise(url) {
  625. uploadImage('image', url, 'appData/',
  626. result => {
  627. // 上传成功回调函数
  628. console.log('图片地址', result)
  629. this.imgList.push(result)
  630. }
  631. )
  632. },
  633. onProgress(e) {
  634. console.log(e)
  635. },
  636. submit(type) {
  637. if (type == 1) {
  638. if (this.detailData.driverContract != 1) { //合同签订标识
  639. this.$refs.uToast.show({
  640. type: 'error',
  641. message: "合同未签订不能暂存!"
  642. })
  643. return
  644. }
  645. this.alertTitle = '确定暂存装车信息?'
  646. } else {
  647. if (this.detailData.driverContract != 1) {
  648. this.$refs.uToast.show({
  649. type: 'error',
  650. message: "合同未签订不能提交!"
  651. })
  652. return
  653. }
  654. this.alertTitle = '确定提交装车信息?'
  655. }
  656. if (this.validate()) return
  657. this.isShowAlert = true
  658. this.detailData.statusFlag = type
  659. // this.$refs.uToast.show({
  660. // ...params,
  661. // complete() {
  662. // params.url && uni.navigateTo({
  663. // url: params.url
  664. // })
  665. // }
  666. // })
  667. },
  668. validate() {
  669. // uni.$u.test.isEmpty(this.detailData.carrierInfo.carNo
  670. if (uni.$u.test.isEmpty(this.detailData.carNo)) {
  671. this.$refs.uToast.show({
  672. type: 'error',
  673. message: "车牌号不能为空!",
  674. })
  675. return true
  676. }
  677. if (uni.$u.test.isEmpty(this.detailData.loadingDate)) {
  678. this.$refs.uToast.show({
  679. type: 'error',
  680. message: "装车日期不能为空!",
  681. })
  682. return true
  683. }
  684. if (uni.$u.test.isEmpty(this.detailData.freight)) {
  685. this.$refs.uToast.show({
  686. type: 'error',
  687. message: "预计运费不能为空!",
  688. })
  689. return true
  690. }
  691. // if (uni.$u.test.isEmpty(this.detailData.loadingCity)) {
  692. // this.$refs.uToast.show({
  693. // type: 'error',
  694. // message: "定位不能为空!",
  695. // })
  696. // return true
  697. // }
  698. // if (uni.$u.test.isEmpty(this.detailData.loadingArea)) {
  699. // this.$refs.uToast.show({
  700. // type: 'error',
  701. // message: "定位不能为空!",
  702. // })
  703. // return true
  704. // }
  705. if (uni.$u.test.isEmpty(this.detailData.transportationDuration)) {
  706. this.$refs.uToast.show({
  707. type: 'error',
  708. message: "运输时长不能为空!",
  709. })
  710. return true
  711. }
  712. if (this.detailData.transportationDuration < 0 || this.detailData.transportationDuration > 1000) {
  713. this.$refs.uToast.show({
  714. type: 'error',
  715. message: "运输时长输入错误!",
  716. })
  717. return true
  718. }
  719. if (this.imgList.length == 0) {
  720. this.$refs.uToast.show({
  721. type: 'error',
  722. message: "装车照片不能为空!",
  723. })
  724. return true
  725. }
  726. },
  727. affirm(data){
  728. console.log("提交",data)
  729. var that = this
  730. this.$request.baseRequest('post', '/carrierInfo/loadingAdd', data).then(res => {
  731. console.log("提交状态",res)
  732. uni.hideLoading()
  733. if (res.code == 200) {
  734. let _title = ''
  735. if (that.detailData.statusFlag == 1) {
  736. _title = '暂存成功!'
  737. return
  738. } else {
  739. // that.start() //开始授权并开始定位
  740. _title = '提交成功!'
  741. }
  742. that.$helper.fUN_AmapLocation.start({
  743. // intervalTime: 1000 * 60,
  744. intervalTime: 60000,
  745. // locationCacheEnable:true,
  746. isReport: false
  747. },
  748. res => {
  749. // console.log('====确认装车开启连续定位====');
  750. // console.log(res)
  751. let _data = {
  752. orderId: that.id,
  753. longitude: res.longitude,
  754. latitude: res.latitude,
  755. province: res.province,
  756. city: res.city,
  757. area: res.district
  758. }
  759. if (this.shippingNoteInfos && this.shippingNoteInfos.length > 0) { //更新持续定位经纬度
  760. for (let i = 0; i < this.shippingNoteInfos.length; i++) {
  761. this.shippingNoteInfos[i].startLatitude = _data.latitude //纬度
  762. this.shippingNoteInfos[i].startLocationText = _data.city //起点
  763. this.shippingNoteInfos[i].startLongitude = _data.longitude //经度
  764. }
  765. }
  766. this.$helper.gjList.push(_data)
  767. uni.setStorageSync('mapGJ', this.$helper.gjList);
  768. // console.log('this.$helper.gjList')
  769. // console.log(this.$helper.gjList)
  770. console.log("条数", uni.getStorageSync('mapGJ').length)
  771. // console.log("条数", uni.getStorageSync('mapGJ'))
  772. if (uni.getStorageSync('mapGJ').length > 100) {
  773. // console.log(JSON.stringify(uni.getStorageSync('mapGJ')))
  774. // that.send()
  775. that.$request.baseRequest('post', '/hyOrderTravelPath/api/addInfo', {
  776. orderId: that.id,
  777. longitudeLatitude: JSON.stringify(uni.getStorageSync('mapGJ'))
  778. }).then(res => {
  779. console.log("已发送定位----------------", res)
  780. uni.removeStorageSync('mapGJ');
  781. that.$helper.gjList = []
  782. })
  783. .catch(res => {
  784. console.log("0",res.message)
  785. uni.$u.toast(res.message);
  786. });
  787. }
  788. //判断缓存数据条数,超过reportInterval时清空缓存,重新存入缓存
  789. }
  790. );
  791. that.$refs.uToast.show({
  792. type: 'success',
  793. message: _title,
  794. complete() {
  795. uni.switchTab({
  796. url: '/pages/order/index'
  797. })
  798. }
  799. })
  800. } else {
  801. console.log("1",res)
  802. // uni.$u.toast(res.message);
  803. that.$refs.uToast.show({
  804. type: 'error',
  805. message: res.message,
  806. })
  807. }
  808. }).catch(res => {
  809. uni.hideLoading()
  810. console.log("2",res.message)
  811. // uni.$u.toast(res.message);
  812. that.$refs.uToast.show({
  813. type: 'error',
  814. message: res.message,
  815. })
  816. });
  817. },
  818. confirmClick() {
  819. uni.removeStorageSync('contractdata')
  820. var that = this
  821. this.isShowAlert = false
  822. //1暂存
  823. if (this.detailData.statusFlag == 1) {
  824. delete this.detailData.hyCarrierInfo.loadingAreaLongitude;
  825. delete this.detailData.hyCarrierInfo.loadingAreaLatitude;
  826. delete this.detailData.hyCarrierInfo.sendCity;
  827. delete this.detailData.hyCarrierInfo.sendArea;
  828. }
  829. uni.showLoading({
  830. title: '加载中'
  831. })
  832. let time = new Date() //装车时间 去当前时间的时分秒
  833. let h = time.getHours();
  834. if (h < 10) {
  835. h = "0" + h
  836. }
  837. let f = time.getMinutes();
  838. if (f < 10) {
  839. f = "0" + f
  840. }
  841. let m = time.getSeconds();
  842. if (m < 10) {
  843. m = "0" + m
  844. }
  845. var data = {
  846. loadingImg: this.imgList.toString(),
  847. statusFlag: this.detailData.statusFlag,
  848. loadingDate: this.detailData.hyCarrierInfo.loadingDate.split(" ")[0] + " " + h + ":" + f + ":" + m,
  849. loadingArea: this.detailData.loadingArea,
  850. loadingCity: this.detailData.loadingCity,
  851. loadingLongitude: this.detailData.loadingLongitude,
  852. loadingLatitude: this.detailData.loadingLatitude,
  853. id: this.detailData.hyCarrierInfo.id,
  854. transportationDuration: this.detailData.transportationDuration
  855. }
  856. if (that.detailData.statusFlag == 1) {//暂存
  857. console.log("暂存")
  858. this.affirm(data)
  859. } else {//提交
  860. this.start(data)//先调用管局start
  861. }
  862. }
  863. },
  864. }
  865. </script>
  866. <style scoped lang="scss">
  867. .content {
  868. // . {
  869. // color: #333333;
  870. // }
  871. }
  872. .level2-title {
  873. margin: 0 0 20rpx 0;
  874. }
  875. .content1,
  876. .content2 {
  877. background: white;
  878. margin: 20rpx;
  879. border-radius: 20rpx;
  880. padding: 20rpx;
  881. .place {
  882. width: 80%;
  883. text-align: right;
  884. }
  885. }
  886. .upload {}
  887. .bottom-btn {
  888. display: flex;
  889. justify-content: space-around;
  890. margin-bottom: 50rpx;
  891. background: #FFFFFF;
  892. padding: 40rpx 0;
  893. }
  894. .store {
  895. padding: 20rpx 30rpx;
  896. color: #2772FB;
  897. width: 40%;
  898. background: #EEF4FF;
  899. border-radius: 40rpx;
  900. font-size: 36rpx;
  901. text-align: center;
  902. }
  903. .submit {
  904. font-size: 36rpx;
  905. padding: 20rpx 30rpx;
  906. color: white;
  907. width: 40%;
  908. background: #2772FB;
  909. border-radius: 40rpx;
  910. text-align: center;
  911. }
  912. .row-between {
  913. margin: 20rpx 0;
  914. }
  915. .sx-style {
  916. background: #2772FB;
  917. color: white;
  918. padding: 2rpx 16rpx;
  919. box-sizing: border-box;
  920. border-radius: 10rpx;
  921. margin-left: 20rpx;
  922. }
  923. .input {
  924. text-align: right;
  925. }
  926. .date-style {}
  927. </style>