confirmLoading.vue 33 KB

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