confirmLoading.vue 33 KB

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