confirmLoading.vue 32 KB

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