index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692
  1. <template>
  2. <view class="container">
  3. <uni-navbar title="启动运输"></uni-navbar>
  4. <view class="box commonMt" style="overflow: hidden;">
  5. <view class="topMap">
  6. <mapPreview :startPoint='form.startPoint' :endPoint='form.endPoint' v-show="isMap"
  7. :mtRoutePointList='form.mtRoutePointList'></mapPreview>
  8. </view>
  9. <view class="box3">
  10. <view class="commonMt addLineSuccess-big-box commonBj">
  11. <view class="addLineSuccess-big-box-top">
  12. <image style="width: 45rpx;height: 45rpx; margin-left: 30rpx;"
  13. src="../../static/images/transport/dingwei.png" mode="widthFix">
  14. </image>
  15. <text class="listTitle">运输规定信息</text>
  16. </view>
  17. <view class="addLineSuccess-big-box-bottom " style="padding-bottom: 40rpx;">
  18. <view class="addLineSuccess-big-box-bottom-item">
  19. <view class="flexAlignCenter">
  20. <view class="greenCircle">
  21. </view>
  22. <text class="itemText">运输名称:</text>
  23. </view>
  24. <view class="flexAlignCenter">
  25. <text class="infoText">{{form.transportName}}</text>
  26. </view>
  27. </view>
  28. <!-- <view class="map">
  29. <mapImg :startPoint='form.startPoint' :endPoint='form.endPoint'
  30. :mtRoutePointList='form.mtRoutePointList'></mapImg>
  31. <mapNew height="339rpx">
  32. </mapNew>
  33. </view> -->
  34. <view class="addLineSuccess-big-box-bottom-item">
  35. <view class="flexAlignCenter">
  36. <view class="greenCircle">
  37. </view>
  38. <text class="itemText">开始地址:</text>
  39. </view>
  40. <view class="flexAlignCenter">
  41. <text class="infoText">{{form.startName}}</text>
  42. </view>
  43. </view>
  44. <!-- <view class="border-style"></view> -->
  45. <view class="addLineSuccess-big-box-bottom-item">
  46. <view class="flexAlignCenter">
  47. <view class="greenCircle">
  48. </view>
  49. <text class="itemText">结束地址:</text>
  50. </view>
  51. <view class="flexAlignCenter">
  52. <text class="infoText">{{form.endName}}</text>
  53. </view>
  54. </view>
  55. <!-- <view class="border-style"></view> -->
  56. <view class="addLineSuccess-big-box-bottom-item">
  57. <view class="flexAlignCenter">
  58. <view class="greenCircle">
  59. </view>
  60. <text class="itemText">运输期限:</text>
  61. </view>
  62. <view class="flexAlignCenter">
  63. <text class="infoText">{{form.startDate}} 至 {{form.endDate}}</text>
  64. </view>
  65. </view>
  66. <!-- <view class="border-style"></view> -->
  67. <view class="addLineSuccess-big-box-bottom-item">
  68. <view style="width: 50%;display: flex;margin-right: 10rpx;">
  69. <view class="flexAlignCenter">
  70. <view class="greenCircle">
  71. </view>
  72. <text class="itemText">开始时间:</text>
  73. </view>
  74. <view class="flexAlignCenter">
  75. <text class="infoText">{{ changeTime(form.startTime) }}</text>
  76. </view>
  77. </view>
  78. <view style="width: 50%;display: flex;">
  79. <view class="flexAlignCenter">
  80. <view class="greenCircle">
  81. </view>
  82. <text class="itemText">结束时间:</text>
  83. </view>
  84. <view class="flexAlignCenter">
  85. <text class="infoText">{{ changeTime(form.endTime) }}</text>
  86. </view>
  87. </view>
  88. </view>
  89. <!-- <view class="border-style"></view> -->
  90. <!-- <view class="addLineSuccess-big-box-bottom-item">
  91. <view class="flexAlignCenter">
  92. <view class="greenCircle">
  93. </view>
  94. <text class="itemText">结束时间:</text>
  95. </view>
  96. <view class="flexAlignCenter">
  97. <text class="infoText">{{ changeTime(form.endTime) }}</text>
  98. </view>
  99. </view> -->
  100. <!-- <view class="border-style"></view> -->
  101. <view class="addLineSuccess-big-box-bottom-item">
  102. <view style="width: 50%;display: flex;margin-right: 5rpx;">
  103. <view class="flexAlignCenter">
  104. <view class="greenCircle">
  105. </view>
  106. <text class="itemText">车&nbsp;&nbsp;牌&nbsp;&nbsp;号:</text>
  107. </view>
  108. <view class="flexAlignCenter">
  109. <text class="infoText">{{form.carNumber}}</text>
  110. </view>
  111. </view>
  112. <view style="width: 50%;display: flex;">
  113. <view class="flexAlignCenter">
  114. <view class="greenCircle">
  115. </view>
  116. <text class="itemText">车辆司机:</text>
  117. </view>
  118. <view class="flexAlignCenter">
  119. <text class="infoText">{{form.driverName}}</text>
  120. </view>
  121. </view>
  122. </view>
  123. <!-- <view class="border-style"></view> -->
  124. <!-- <view class="addLineSuccess-big-box-bottom-item">
  125. <view class="flexAlignCenter">
  126. <view class="greenCircle">
  127. </view>
  128. <text class="itemText">车辆司机:</text>
  129. </view>
  130. <view class="flexAlignCenter">
  131. <text class="infoText">{{form.driverName}}</text>
  132. </view>
  133. </view> -->
  134. <!-- <view class="border-style"></view> -->
  135. </view>
  136. </view>
  137. <u-button @click="permission" class="custom-style mt33 commonMb" shape="circle"
  138. color="linear-gradient(to top, #F59A02, #FFD334)">启动运输</u-button>
  139. </view>
  140. </view>
  141. <u-popup :show="show" mode="center" class="modelBox">
  142. <view class="model">
  143. <view class="modelTitle">上传车辆开始运输状态<view class="close" @click="show=false"></view>
  144. </view>
  145. <view class="textBox colorStyle2">
  146. <u--form :model="form" ref="uForm" :rules="rules" labelWidth="0">
  147. <u-form-item class="block-box1" prop="truckState">
  148. <view class="textBox">
  149. <view class="redCircle"></view>
  150. <text class="itemText">车辆状态(<text class="redText">拍摄车辆外观图片+视频</text>)</text>
  151. </view>
  152. <view class="textBox mt29 flex-start">
  153. <xfx-image-upload uploadType="1" :max="2" :chooseNum="2" v-model="imgList"
  154. @uploadSuccess="UploadSuccessStateImg" @uploadFail="errorTruckImg"
  155. @imgDelete="delTruckImg" mediaType="image" :action="urlConfig">
  156. </xfx-image-upload>
  157. <xfx-image-upload class="ml29" uploadType="2" :max="1" :chooseNum="1" v-model="carVideo"
  158. @uploadSuccess="UploadSuccessVideo" @uploadFail="errorTruckVideo"
  159. @imgDelete="delVideo" mediaType="video" :action="urlConfig">
  160. </xfx-image-upload>
  161. </view>
  162. </u-form-item>
  163. </u--form>
  164. </view>
  165. <u-button class="custom-style5 widthButton" shape="circle" @click="confirm()"
  166. color="linear-gradient(to top, #F59A02, #FFD334)">
  167. 确 定
  168. </u-button>
  169. </view>
  170. </u-popup>
  171. </view>
  172. </template>
  173. <script>
  174. import {
  175. transportRunDetail,
  176. transportProcess
  177. } from "../../api/company/transport.js"
  178. import config from '@/config.js'
  179. const fUN_AmapLocation = uni.requireNativePlugin('FUN-AmapLocation');
  180. var _this;
  181. export default {
  182. data() {
  183. return {
  184. form: {
  185. startTime: "00:00:00",
  186. endTime: "00:00:00",
  187. // 结束坐标和开始坐标
  188. endPoint: '',
  189. startPoint: '',
  190. mtRoutePointList: [],
  191. },
  192. show: false,
  193. isMap: true,
  194. drivingLicense: [],
  195. carVideo: [],
  196. imgList: [],
  197. imgListData: [],
  198. carVideoData: [],
  199. // 图片上传地址
  200. urlConfig: config.baseUrl + '/file/upload',
  201. pointCoordinate: null,
  202. // 行驶证数据
  203. form: {
  204. truckState: null
  205. },
  206. rules: {
  207. truckState: [{
  208. validator: (rule, value, callback) => {
  209. return this.carVideo.length !== 0 && this.imgList.length === 2
  210. },
  211. message: '请上传两张照片与一段视频'
  212. }, ],
  213. },
  214. // 点击修改传回来的id
  215. id: '',
  216. srcVideo: '',
  217. }
  218. },
  219. methods: {
  220. //获取当前位置
  221. getLocation() {
  222. console.log('我要定位信息了')
  223. // fUN_AmapLocation.once({}, result => {
  224. // console.log('====fUN_AmapLocation::8秒后单次定位示例====', JSON.stringify(result));
  225. // this.pointCoordinate = result.longitude + ',' + result.latitude;
  226. // // _this.msg = JSON.stringify(result);
  227. // });
  228. uni.getLocation({
  229. // type: 'wgs84',
  230. type: 'gcj02',
  231. success: (res) => {
  232. console.log(res, 'res');
  233. this.pointCoordinate = res.longitude + ',' + res.latitude;
  234. console.log(this.pointCoordinate, '我是定位信息')
  235. }
  236. });
  237. },
  238. // 获取权限
  239. permission() {
  240. _this = this;
  241. console.log('获取权限');
  242. fUN_AmapLocation.permission({}, result => {
  243. console.log('====fUN_AmapLocation定位====', JSON.stringify(result));
  244. if (result.code === 0) {
  245. //结果code=0时,flag:true代表有定位权限,flag_br:true代表允许后台定位(AndroidQ即sdk_int>=29)
  246. //sdk_int>28 android Q 有后台定位始终允许(经测 小米6 安卓9 sdk28 也有但无法调请求窗,经测试不影响后台定位[息屏或置于后台])
  247. if ((result.flag === true && result.flag_br === true && result.sdk_int >= 29) || (result
  248. .flag === true && result.sdk_int < 29)) {
  249. _this.battery()
  250. } else {
  251. uni.showModal({
  252. title: '提醒',
  253. showCancel: true,
  254. content: '请在权限-位置信息中选择始终允许',
  255. success: function(res) {
  256. if (res.confirm) {
  257. _this.settingUp();
  258. } else if (res.cancel) {
  259. // alert('用户点击取消');
  260. }
  261. }
  262. })
  263. }
  264. }
  265. });
  266. },
  267. //打开应用设置页
  268. settingUp() {
  269. fUN_AmapLocation.openSetting(function(result) {
  270. });
  271. },
  272. //开启电池优化
  273. battery() {
  274. let _that = this;
  275. //检测是否忽略电池优化(简单解释:开启电池优化,会干掉应用)
  276. fUN_AmapLocation.isIgnoringBatteryOptimizations(function(result) { //SDK>=23,否则返回不支持
  277. if (result.code === 0) {
  278. if (result.flag === true) {
  279. console.log('====忽略电池优化====')
  280. _that.submit();
  281. _that.openWakeLock();
  282. } else {
  283. // 申请忽略电池优化(如果已加入电池优化的白名单 则进入系统电池优化页面,若未加入则弹窗申请。)
  284. fUN_AmapLocation.requestIgnoreBatteryOptimizations(function(result) {
  285. console.log(result)
  286. console.log('====申请电池优化====')
  287. });
  288. }
  289. }
  290. })
  291. },
  292. //打开屏幕唤醒
  293. openWakeLock() {
  294. //1台华为[鸿蒙],2台小米(米6[安卓9]、米11Ultra[安卓11])使用的10分测试的。
  295. fUN_AmapLocation.openWakeLock({
  296. time: 5
  297. }, function(result) {
  298. console.log('====被唤醒了====', JSON.stringify(result))
  299. // if(result.code===0)
  300. // {
  301. // }
  302. });
  303. //参数 time:间隔时间,单位:分,建议5-10。具体看业务
  304. },
  305. // 车辆状态图片上传成功
  306. UploadSuccessStateImg(res) {
  307. var _res = JSON.parse(res.data);
  308. if (_res.code == 200) {
  309. // let obj = {}
  310. // obj.name = this.imgListName
  311. // obj.url = _res.data.url
  312. this.imgListData.push(_res.data);
  313. this.imgList.push(_res.data.url)
  314. }
  315. },
  316. // 车辆状态图片删除
  317. delTruckImg(del, tempFilePaths) {
  318. let obj = {}
  319. if (del.tempFilePaths.length !== 0) {
  320. obj.name = del.tempFilePaths[0].slice(50)
  321. obj.url = del.tempFilePaths[0]
  322. }
  323. this.imgList = del.tempFilePaths;
  324. this.imgListData = this.imgListData.filter(item => {
  325. return item.url === obj.url
  326. })
  327. },
  328. // 车辆图片上传失败的回调
  329. errorTruckImg(res) {},
  330. // 车辆视频上传成功Vedio
  331. UploadSuccessVideo(res, o) {
  332. var _res = JSON.parse(res.data);
  333. if (_res.code == 200) {
  334. this.carVideoData.push(_res.data);
  335. this.srcVideo = _res.data.url;
  336. this.carVideo = [{
  337. cover: o,
  338. url: this.srcVideo
  339. }]
  340. // this.select();
  341. }
  342. },
  343. // 车辆视频删除回调
  344. delVideo(del, tempFilePaths) {
  345. this.carVideo = []
  346. this.carVideoData = []
  347. },
  348. // 视频上传失败的回调
  349. errorTruckVideo(res) {},
  350. // 获取运输申请详情
  351. async getDetail(id) {
  352. this.isMap = false;
  353. const res = await transportRunDetail(id)
  354. this.isMap = true;
  355. console.log('运输详情', res);
  356. this.form = res.data
  357. this.form.startDate = this.form.startDate.replace(/-/g, ' - ')
  358. this.form.endDate = this.form.endDate.replace(/-/g, ' - ')
  359. this.getLocation();
  360. },
  361. changeTime(time) {
  362. if (!time) {
  363. return
  364. }
  365. return time.slice(0, 5)
  366. },
  367. confirm() {
  368. this.$refs.uForm.validate().then(async res => {
  369. // console.log('我通过了', this.form);
  370. // console.log('imgListData', this.imgListData);
  371. // console.log('carVideoData', this.carVideoData);
  372. this.transportProcess({
  373. applyId: this.form.id,
  374. pointCoordinate: this.pointCoordinate,
  375. startVideo: this.carVideoData,
  376. startImg: this.imgListData
  377. })
  378. })
  379. },
  380. submit() {
  381. console.log('开始啦');
  382. this.show = true;
  383. },
  384. transportProcess(data) {
  385. console.log(data, 'data');
  386. transportProcess(data).then(res => {
  387. console.log(res, '我是上传成功之后返回的参数')
  388. this.$tab.redirectTo(
  389. `/pages/driverStartTransportDoPath/index?id=${res.data.processId}&startTime=${res.data.StartTime}`
  390. )
  391. // this.$tab.navigateTo(`/pages/driverStartTransportDoPath/index?id=${res.data.processId}&startTime=${res.data.StartTime}`)
  392. })
  393. }
  394. },
  395. onLoad(option) {
  396. if (option.id) {
  397. this.getDetail(option.id)
  398. }
  399. // uni.getLocation({
  400. // type: 'gcj02',
  401. // success: (res) => {
  402. // // console.log('当前位置的经度:' + res.longitude);
  403. // // console.log('当前位置的纬度:' + res.latitude);
  404. // // this.getLocation = res;
  405. // this.pointCoordinate = res.longitude + ',' + res.latitude;
  406. // console.log(this.pointCoordinate, '我是定位信息')
  407. // }
  408. // });
  409. }
  410. }
  411. </script>
  412. <style lang="scss" scoped>
  413. .addLineSuccess-big-box {
  414. .addLineSuccess-big-box-top {
  415. height: 69rpx;
  416. background: #7FB5FF;
  417. border-radius: 26rpx 26rpx 0rpx 0rpx;
  418. display: flex;
  419. align-items: center;
  420. }
  421. .addLineSuccess-big-box-bottom {
  422. padding: 0rpx 30rpx;
  423. border-radius: 0 0 28rpx 28rpx;
  424. .addLineSuccess-big-box-bottom-item {
  425. display: flex;
  426. margin: 61rpx auto;
  427. }
  428. .map {
  429. // width: 599rpx;
  430. height: 339rpx;
  431. background: #FFFFFF;
  432. border: 2rpx solid #495B93;
  433. border-radius: 15rpx;
  434. margin: 25rpx auto 40rpx;
  435. }
  436. // .border-style {
  437. // border-top: 1rpx dashed #F98803;
  438. // margin: 0 auto;
  439. // }
  440. }
  441. }
  442. .custom-style5 {
  443. // box-shadow: 0px 2rpx 13rpx 0rpx rgba(27, 43, 95, 0.25);
  444. // border-radius: 28rpx;
  445. font-size: 28rpx;
  446. font-weight: bold;
  447. color: #FFFFFF;
  448. margin: 27rpx 0 36rpx;
  449. height: 65rpx;
  450. }
  451. .bg-color-green {
  452. background: #36C372 !important;
  453. }
  454. .mb {
  455. margin-bottom: 11rpx !important;
  456. }
  457. .mt31 {
  458. margin-top: 31rpx;
  459. }
  460. .mb43 {
  461. margin-bottom: 43rpx;
  462. }
  463. .add-button {
  464. height: 85rpx;
  465. // background: linear-gradient(0deg, #FFD334 0%, #F59A02 100%);
  466. // box-shadow: 0rpx 2rpx 13rpx 0rpx rgba(27, 43, 95, 0.25);
  467. // border-radius: 28rpx;
  468. font-size: 30rpx;
  469. font-weight: bold;
  470. color: #FFFFFF;
  471. border: 0;
  472. margin-top: 27rpx;
  473. }
  474. // 弹框样式
  475. /deep/ .u-popup__content {
  476. background-color: rgba(0, 0, 0, 0);
  477. }
  478. .model {
  479. width: 683rpx;
  480. // height: 441rpx;
  481. background: rgba(255, 255, 255, 0.64);
  482. border: 2rpx solid #77A8FF;
  483. box-shadow: 0px 0px 24rpx 6rpx rgba(109, 160, 251, 0.6);
  484. border-radius: 34rpx;
  485. display: flex;
  486. flex-direction: column;
  487. align-items: center;
  488. }
  489. .modelTitle {
  490. width: 683rpx;
  491. height: 80rpx;
  492. background: #7FB5FF;
  493. border-radius: 28rpx 28rpx 0px 0px;
  494. font-size: 28rpx;
  495. line-height: 80rpx;
  496. font-weight: bold;
  497. text-align: center;
  498. color: #FFFFFF;
  499. position: relative;
  500. }
  501. .close {
  502. width: 30rpx;
  503. height: 30rpx;
  504. // border: 1px salmon solid;
  505. position: absolute;
  506. right: 25rpx;
  507. top: 50%;
  508. transform: translateY(-50%);
  509. background-image: url('@/static/images/close.png');
  510. background-size: 100% 100%;
  511. }
  512. .widthButton {
  513. width: 150rpx;
  514. margin-bottom: 53rpx;
  515. }
  516. /deep/ .block-box1 .u-form-item__body__right__content__slot {
  517. display: block;
  518. }
  519. /deep/ .block-box1 .u-form-item__body {
  520. display: block;
  521. .u-form-item__body__right {
  522. // margin-top: 29rpx;
  523. .u-form-item__body__right__content__slot {
  524. align-items: start;
  525. .u-upload {
  526. display: block;
  527. flex: 0;
  528. // margin-right: 8rpx;
  529. .u-upload__wrap {
  530. flex-direction: row;
  531. flex-wrap: nowrap;
  532. justify-content: space-between;
  533. // width: 400rpx;
  534. .u-upload__wrap__preview {
  535. border-radius: 15rpx;
  536. overflow: visible;
  537. margin: 0 52rpx 0 0;
  538. &:nth-child(2) {
  539. margin-right: 26rpx !important;
  540. }
  541. .u-upload__wrap__preview__image {
  542. // border-radius: 15rpx !important;
  543. width: 167rpx !important;
  544. height: 167rpx !important;
  545. // border: 2rpx solid #495B93;
  546. }
  547. }
  548. .u-upload__button {
  549. background: rgba(255, 255, 255, 0.1);
  550. border: 1px solid #495B93;
  551. border-radius: 15px;
  552. }
  553. }
  554. }
  555. }
  556. }
  557. }
  558. // 车辆状态上传图片
  559. .flex-start {
  560. justify-content: start;
  561. /deep/.xfx-image-upload-list {
  562. // border: 2rpx solid #495B93;
  563. // border-radius: 15rpx;
  564. // // width: 160rpx;
  565. // height: 160rpx;
  566. .xfx-image-upload-Item {
  567. width: 180rpx;
  568. height: 180rpx;
  569. margin-right: 0;
  570. margin-bottom: 0;
  571. border: 2rpx solid #495B93;
  572. border-radius: 15rpx;
  573. // background-color: rgba(255, 255, 255, 0.1);
  574. &:not(:first-child) {
  575. margin-left: 20rpx;
  576. }
  577. &:nth-child(1) {
  578. background-color: rgba(255, 255, 255, 0.1);
  579. }
  580. }
  581. .xfx-image-upload-Item-add {
  582. padding-top: 36rpx;
  583. .text-upload {
  584. margin-top: 0;
  585. }
  586. }
  587. }
  588. }
  589. .textBox {
  590. display: flex;
  591. align-items: center;
  592. margin-left: 10px;
  593. width: 100%;
  594. }
  595. .mt29 {
  596. margin-top: 29rpx;
  597. }
  598. .ml29 {
  599. margin-left: 20rpx;
  600. }
  601. // .topMap{
  602. // height: 513rpx;
  603. // background: #FFFFFF;
  604. // border: 2rpx solid #77A8FF;
  605. // box-shadow: 0px 2rpx 13rpx 0px rgba(27, 43, 95, 0.25), 0px 0px 24rpx 6rpx rgba(109, 160, 251, 0.6);
  606. // border-radius: 28rpx;
  607. // }
  608. // .modelBox > .u-transition > .u-popup__content {
  609. // position: absolute;
  610. // top: 700rpx;
  611. // }
  612. //处理当前页面弹框
  613. /deep/ .modelBox .u-transition .u-popup__content {
  614. position: fixed;
  615. top: 700rpx;
  616. }
  617. //处理当前组件弹框
  618. /deep/ .boxUplod .u-transition .u-popup__content {
  619. position: fixed;
  620. display: flex;
  621. bottom: 0px;
  622. left: 0px;
  623. right: 0px;
  624. top: auto;
  625. background: rgba(255, 255, 255, 0.7);
  626. }
  627. .itemText {
  628. margin-right: 14rpx;
  629. }
  630. </style>