confirmLoading.vue 31 KB

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