confirmLoading.vue 31 KB

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