confirmLoading.vue 32 KB

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