confirmLoading.vue 31 KB

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