confirmLoading.vue 31 KB

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