confirmLoading.vue 32 KB

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