confirmLoading.vue 33 KB

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