confirmUnloading.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510
  1. <!-- 确认装车 -->
  2. <template>
  3. <view class="content">
  4. <view class="content2">
  5. <view class="level2-title">基本信息</view>
  6. <view class='row-between'>
  7. <view class="row-left-text">订单编号</view>
  8. <view class="row-right-text">{{detailData.orderNo}}</view>
  9. </view>
  10. <view class='row-between'>
  11. <view class="row-left-text">货主</view>
  12. <view class="row-right-text">{{detailData.cargoOwner}}</view>
  13. </view>
  14. <view class='row-between'>
  15. <view class="row-left-text">货主单位</view>
  16. <view class="row-right-text">{{detailData.compName?detailData.compName:'个人货主'}}</view>
  17. </view>
  18. <view class='row-between'>
  19. <view class="row-left-text">发货地</view>
  20. <view class="row-right-text place">
  21. {{detailData.sendPrivate}}{{detailData.sendCity}}{{detailData.sendArea}}{{detailData.sendDetailedAddress}}
  22. </view>
  23. </view>
  24. <view class='row-between'>
  25. <view class="row-left-text">卸货地</view>
  26. <view class="row-right-text place">
  27. {{detailData.unloadPrivate}}{{detailData.unloadCity}}{{detailData.unloadArea}}{{detailData.unloadDetailedAddress}}
  28. </view>
  29. </view>
  30. <view class='row-between'>
  31. <view class="row-left-text">货名</view>
  32. <view class="row-right-text">{{detailData.goodsName}}</view>
  33. </view>
  34. <view class='row-between'>
  35. <view class="row-left-text">运费</view>
  36. <view class="row-right-text">{{detailData.freight}}{{detailData.billingMethod==0?'元/吨':'元/车'}}</view>
  37. </view>
  38. </view>
  39. <view class="content2">
  40. <view class="level2-title">卸车信息</view>
  41. <view class='row-between'>
  42. <view class="row-left-text">车牌号</view>
  43. <view class="row-right-text">{{detailData.carNumber}}</view>
  44. </view>
  45. <!-- <view class='row-between'>
  46. <view class="row-left-text">卸车日期</view>
  47. <view class="row-right-text">{{detailData.carrierInfo.unloadingDate}}</view>
  48. </view> -->
  49. <view class="row-between">
  50. <view class="left-text">卸车日期</view>
  51. <view class="" @click="selectUnloadingDate">
  52. {{detailData.carrierInfo.unloadingDate?detailData.carrierInfo.unloadingDate:'选择卸车日期'}}
  53. </view>
  54. </view>
  55. <view class='row-between'>
  56. <view class="row-left-text">合计运费(元)</view>
  57. <input class="totalFreight-input" placeholder="输入合计运费" v-model="detailData.totalFreight"
  58. type="number" />
  59. </view>
  60. <view class='row-between'>
  61. <view class="row-left-text">定位</view>
  62. <view class="flex align-center">
  63. {{detailData.carrierInfo.unloadCity}}{{detailData.carrierInfo.unloadArea}}
  64. <view class="sx-style" @click.stop="getLngLat()">刷新</view>
  65. </view>
  66. </view>
  67. <view class='s-flex'>
  68. <view class="row-left-text" style="margin:20rpx 0;">上传卸车照片(1-3张)</view>
  69. <u-upload class="uview-upload" :fileList="fileList1" @afterRead="afterRead($event)" @delete="deletePic"
  70. name="1" multiple :maxCount="3"></u-upload>
  71. </view>
  72. </view>
  73. <view class="bottom-btn">
  74. <view class="store" @click="submit(1)">暂存</view>
  75. <view class="submit" @click="submit(3)">提交</view>
  76. </view>
  77. <u-modal :show="isShowAlert" :title="alertTitle" :content='alertContent' :closeOnClickOverlay='true'
  78. :showCancelButton='true' confirmColor='#2772FB' @confirm="confirmClick" @close="cancelClick"
  79. @cancel="cancelClick"></u-modal>
  80. <u-picker :show="isShowValidity" ref="uPicker" :columns="validityPeriod" @confirm="confirmValidityPeriod"
  81. :closeOnClickOverlay='true' @close='isShowValidity=false' @cancel='isShowValidity=false'>
  82. </u-picker>
  83. <u-toast ref="uToast"></u-toast>
  84. </view>
  85. </template>
  86. <script>
  87. let that;
  88. import uploadImage from '@/components/ossutil/uploadFile.js';
  89. export default {
  90. data() {
  91. return {
  92. imgList: [],
  93. fileList1: [],
  94. isShowValidity: false,
  95. validityPeriod: [],
  96. sourceType: ['camera'],
  97. detailData: {
  98. addressUrl: '',
  99. hyCarrierInfo:{}
  100. },
  101. action: this.$helper.ossUploadUrl,
  102. maxSize: 50 * 1024 * 1024, //限制文件大小 50M
  103. isAdd: true,
  104. isShowAlert: false,
  105. alertContent: '',
  106. alertTitle: '',
  107. localtion:{},
  108. }
  109. },
  110. onLoad(options) {
  111. this.detailData = JSON.parse(options.obj)
  112. console.log(this.detailData)
  113. this.fileList1=[]
  114. if(this.detailData.hyCarrierInfo.unloadingImg){
  115. this.imgList=this.detailData.hyCarrierInfo.unloadingImg.split(',')
  116. var data=this.detailData.hyCarrierInfo.unloadingImg.split(',')
  117. for (var i = 0; i < data.length; i++) {
  118. if(data[i]!=''){
  119. this.fileList1.push({url:data[i]})
  120. }
  121. }
  122. }
  123. this.detailData.totalFreight=this.detailData.hyCarrierInfo.totalFreight
  124. this.detailData.carrierInfo = {
  125. // unloadingDate: '',
  126. // estimatedFreight: '',
  127. // unloadingAreaLongitude: '',
  128. // unloadingAreaLatitude: '',
  129. // unloadCity: '',
  130. // unloadArea: '',
  131. // unloadingImg: '',
  132. // totalFreight: '',
  133. unloadingImg:this.detailData.hyCarrierInfo.unloadingImg,
  134. id: this.detailData.carrierId,
  135. }
  136. this.validityPeriod = this.$helper.makeValidityPeriod()
  137. // #ifdef APP-PLUS
  138. this.getLngLat();
  139. // #endif
  140. this.getNowTime()
  141. },
  142. methods: {
  143. deletePic(event) {
  144. this[`fileList${event.name}`].splice(event.index, 1)
  145. },
  146. getNowTime() {
  147. let now = new Date();
  148. let year = now.getFullYear(); //得到年份
  149. let month = now.getMonth(); //得到月份
  150. let date = now.getDate(); //得到日期
  151. month = month + 1;
  152. month = month.toString().padStart(2, "0");
  153. date = date.toString().padStart(2, "0");
  154. let defaultDate = `${year}-${month}-${date}`
  155. this.detailData.carrierInfo.unloadingDate = defaultDate
  156. // this.$forceUpdate()
  157. },
  158. selectUnloadingDate() {
  159. this.isShowValidity = true
  160. },
  161. getLngLat() {
  162. let that = this
  163. uni.showLoading({
  164. title: '获取定位中',
  165. mask: true
  166. })
  167. // this.$helper.fUN_AmapLocation.start({
  168. // intervalTime: 1000 * 3,
  169. // isReport: false,
  170. // },
  171. // res => {
  172. // //见下方定位返回示例
  173. // console.log('====fUN_AmapLocation定位====', JSON.stringify(res));
  174. // if (res.latitude) {
  175. // this.detailData.carrierInfo.loadingAreaLongitude = res.longitude;
  176. // this.detailData.carrierInfo.loadingAreaLatitude = res.latitude;
  177. // this.detailData.carrierInfo.sendCity = this.$helper.filterUrban(res.city)
  178. // this.detailData.carrierInfo.sendArea = this.$helper.filterArea(res.district);
  179. // console.log(this.detailData.carrierInfo.sendCity)
  180. // console.log(this.detailData.carrierInfo.sendArea)
  181. // this.$forceUpdate()
  182. // }
  183. // this.$helper.fUN_AmapLocation.stop({}, result => {
  184. // uni.hideLoading()
  185. // console.log('====fUN_AmapLocation定位stop====', JSON.stringify(result));
  186. // });
  187. // }
  188. // );
  189. uni.getLocation({
  190. type: 'gcj02',
  191. geocode: true,
  192. success: res => {
  193. if (res.latitude) {
  194. // that.detailData.hyCarrierInfo.loadingAreaLongitude = res.longitude;
  195. // that.detailData.hyCarrierInfo.loadingAreaLatitude = res.latitude;
  196. that.detailData.carrierInfo.unloadingAreaLongitude = res.longitude;
  197. that.detailData.carrierInfo.unloadingAreaLatitude = res.latitude;
  198. console.log("1234567890")
  199. that.detailData.carrierInfo.unloadCity = that.$helper.filterUrban(res.address.city)
  200. that.detailData.carrierInfo.unloadArea = that.$helper.filterUrban(res.address.district)
  201. that.localtion.city = that.$helper.filterUrban(res.address.city)
  202. that.localtion.sendArea = that.$helper.filterUrban(res.address.district)
  203. that.detailData.carrierInfo.unloadingCity = that.$helper.filterUrban(res.address.city)
  204. that.detailData.carrierInfo.unloadingArea = that.$helper.filterUrban(res.address.district)
  205. that.detailData.carrierInfo.unloadingLongitude = res.longitude;
  206. that.detailData.carrierInfo.unloadingLatitude = res.latitude;
  207. that.$forceUpdate()
  208. uni.hideLoading()
  209. } else {
  210. if (uni.getSystemInfoSync().platform == 'android') {
  211. var context = plus.android.importClass("android.content.Context");
  212. var locationManager = plus.android.importClass(
  213. "android.location.LocationManager");
  214. var main = plus.android.runtimeMainActivity();
  215. var mainSvr = main.getSystemService(context.LOCATION_SERVICE);
  216. that.bool = mainSvr.isProviderEnabled(locationManager.GPS_PROVIDER)
  217. }
  218. if (that.bool === false) {
  219. uni.showModal({
  220. title: '提示',
  221. content: '请打开定位服务',
  222. success: ({
  223. confirm,
  224. cancel
  225. }) => {
  226. if (confirm) {
  227. if (uni.getSystemInfoSync().platform == 'android') {
  228. var Intent = plus.android.importClass(
  229. 'android.content.Intent');
  230. var Settings = plus.android.importClass(
  231. 'android.provider.Settings');
  232. var intent = new Intent(Settings
  233. .ACTION_LOCATION_SOURCE_SETTINGS);
  234. var main = plus.android.runtimeMainActivity();
  235. main.startActivity(intent); // 打开系统设置GPS服务页面
  236. }
  237. }
  238. }
  239. });
  240. uni.hideLoading()
  241. }
  242. }
  243. },
  244. fail: res => {
  245. console.log('定位失败')
  246. console.log(res)
  247. uni.hideLoading()
  248. }
  249. });
  250. },
  251. alertBtn() {
  252. // uni.navigateTo({
  253. // url: '/pages/public/login'
  254. // })
  255. },
  256. cancelClick() {
  257. this.isShowAlert = false
  258. },
  259. getImgUrl(res) {
  260. this.detailData.carrierInfo.unloadingImg += res + ','
  261. console.log(res)
  262. console.log('------------res-----------')
  263. },
  264. onError(error) {
  265. alert(error)
  266. console.log('------------error-----------')
  267. console.log(error)
  268. },
  269. onRemove(index) {},
  270. filterFileType(index, lists) {
  271. if (lists[index].fileType != 'jpg' && lists[index].fileType != 'png' && lists[index].fileType != 'gif') {
  272. lists.splice(index, 1);
  273. // 当前文件不支持
  274. uni.showModal({
  275. title: '暂不支持当前图片类型',
  276. showCancel: false
  277. });
  278. } else {
  279. this.isAdd = false;
  280. }
  281. },
  282. // 新增图片
  283. async afterRead(event) {
  284. // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
  285. let lists = [].concat(event.file)
  286. let fileListLen = this[`fileList${event.name}`].length
  287. lists.map((item) => {
  288. this[`fileList${event.name}`].push({
  289. ...item,
  290. status: 'uploading',
  291. message: '上传中'
  292. })
  293. })
  294. for (let i = 0; i < lists.length; i++) {
  295. const result = await this.uploadFilePromise(lists[i].url)
  296. let item = this[`fileList${event.name}`][fileListLen]
  297. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  298. status: 'success',
  299. message: '',
  300. url: result
  301. }))
  302. fileListLen++
  303. }
  304. },
  305. uploadFilePromise(url) {
  306. uploadImage('image', url, 'appData/',
  307. result => {
  308. // 上传成功回调函数
  309. console.log('图片地址', result)
  310. this.imgList.push(result)
  311. }
  312. )
  313. },
  314. onProgress(e) {
  315. console.log(e)
  316. },
  317. submit(type) {
  318. if (type == 1) {
  319. this.alertContent = '确定暂存卸车信息?'
  320. } else {
  321. this.alertContent = '确定提交卸车信息?'
  322. }
  323. if(!this.detailData.totalFreight){
  324. this.$refs.uToast.show({
  325. type: 'error',
  326. message: "请输入合计运费!",
  327. })
  328. return
  329. }
  330. this.isShowAlert = true
  331. this.detailData.statusFlag = type
  332. },
  333. confirmClick() {
  334. var that=this
  335. if (this.detailData.statusFlag == 1) {
  336. delete this.detailData.carrierInfo.unloadingAreaLongitude;
  337. delete this.detailData.carrierInfo.unloadingAreaLatitude;
  338. delete this.detailData.carrierInfo.unloadCity;
  339. delete this.detailData.carrierInfo.unloadArea;
  340. }
  341. this.detailData.carrierInfo.statusFlag = this.detailData.statusFlag
  342. this.detailData.carrierInfo.unloadingImg = this.imgList.toString()
  343. // if (!this.detailData.carrierInfo.totalFreight) {
  344. // uni.showToast({
  345. // title: '运费不能为空!',
  346. // duration: 2000,
  347. // icon: "none",
  348. // });
  349. // return
  350. // }
  351. if (
  352. this.detailData.carrierInfo.totalFreight < 0 || this.detailData.carrierInfo.totalFreight > 100000 || (
  353. String(this.detailData.carrierInfo.totalFreight).indexOf('.') != -1 && String(this.detailData
  354. .carrierInfo.totalFreight).length - (String(this.detailData.carrierInfo.totalFreight).indexOf(
  355. '.') + 1) > 2)
  356. ) {
  357. uni.showToast({
  358. title: '运费输入错误!',
  359. duration: 2000,
  360. icon: "none",
  361. });
  362. return
  363. }
  364. if (!this.detailData.carrierInfo.unloadingImg) {
  365. uni.showToast({
  366. title: '卸车照片不能为空!',
  367. icon: "none",
  368. duration: 2000
  369. });
  370. return
  371. }
  372. this.isShowAlert = false
  373. uni.showLoading({
  374. title:'加载中'
  375. })
  376. let time = new Date() //卸车时间 去当前时间的时分秒
  377. let h = time.getHours();
  378. if (h < 10) {
  379. h = "0" + h
  380. }
  381. let f = time.getMinutes();
  382. if (f < 10) {
  383. f = "0" + f
  384. }
  385. let m = time.getSeconds();
  386. if (m < 10) {
  387. m = "0" + m
  388. }
  389. if(this.detailData.carrierInfo.unloadingDate){//卸车时间 去当前时间的时分秒
  390. this.detailData.carrierInfo.unloadingDate= this.detailData.carrierInfo.unloadingDate.split(" ")[0] + " " + h + ":" + f + ":" + m
  391. }
  392. this.detailData.carrierInfo.totalFreight = this.detailData.totalFreight
  393. this.detailData.carrierInfo.carNo = this.detailData.carNumber
  394. this.$request.baseRequest('post', '/carrierInfo/unLoadingAdd', this.detailData.carrierInfo).then(res => {
  395. if (res.code == 200) {
  396. let _title = ''
  397. if (this.detailData.statusFlag == 1) {
  398. _title = '暂存成功!'
  399. } else {
  400. _title = '提交成功!'
  401. }
  402. uni.hideLoading()
  403. this.$refs.uToast.show({
  404. type: 'success',
  405. message: _title,
  406. complete() {
  407. uni.hideLoading()
  408. uni.switchTab({
  409. url: '/pages/order/index'
  410. })
  411. that.$helper.fUN_AmapLocation.stop({}, result => {
  412. console.log('====fUN_AmapLocation定位stop====', JSON.stringify(result));
  413. });
  414. }
  415. })
  416. }
  417. })
  418. .catch(res => {
  419. uni.$u.toast(res.message);
  420. });
  421. },
  422. confirmValidityPeriod(e) {
  423. this.detailData.carrierInfo.unloadingDate = e.value[0] + '-' + e.value[1] + '-' + e.value[2]
  424. this.isShowValidity = false
  425. },
  426. },
  427. }
  428. </script>
  429. <style scoped lang="scss">
  430. .content {
  431. .row-left-text {
  432. color: #333333;
  433. }
  434. }
  435. .level2-title {
  436. margin: 0 0 20rpx 0;
  437. }
  438. .content1,
  439. .content2 {
  440. background: white;
  441. margin: 20rpx;
  442. border-radius: 20rpx;
  443. padding: 20rpx;
  444. .place {
  445. width: 80%;
  446. text-align: right;
  447. }
  448. }
  449. .upload {}
  450. .bottom-btn {
  451. display: flex;
  452. justify-content: space-around;
  453. // margin-bottom: 50rpx;
  454. background: #FFFFFF;
  455. padding: 40rpx 0;
  456. }
  457. .store {
  458. padding: 20rpx 30rpx;
  459. color: #2772FB;
  460. width: 40%;
  461. background: #EEF4FF;
  462. border-radius: 40rpx;
  463. font-size: 36rpx;
  464. text-align: center;
  465. }
  466. .submit {
  467. font-size: 36rpx;
  468. padding: 20rpx 30rpx;
  469. color: white;
  470. width: 40%;
  471. background: #2772FB;
  472. border-radius: 40rpx;
  473. text-align: center;
  474. }
  475. .row-between {
  476. margin: 20rpx 0;
  477. }
  478. .sx-style {
  479. background: #2772FB;
  480. color: white;
  481. padding: 2rpx 16rpx;
  482. box-sizing: border-box;
  483. border-radius: 10rpx;
  484. margin-left: 20rpx;
  485. }
  486. .totalFreight-input {
  487. text-align: right;
  488. }
  489. </style>