confirmUnloading.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  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.detailData.carrierInfo = {
  114. // unloadingDate: '',
  115. // estimatedFreight: '',
  116. // unloadingAreaLongitude: '',
  117. // unloadingAreaLatitude: '',
  118. // unloadCity: '',
  119. // unloadArea: '',
  120. // unloadingImg: '',
  121. // totalFreight: '',
  122. id: this.detailData.carrierId,
  123. }
  124. this.validityPeriod = this.$helper.makeValidityPeriod()
  125. // #ifdef APP-PLUS
  126. this.getLngLat();
  127. // #endif
  128. this.getNowTime()
  129. },
  130. methods: {
  131. deletePic(){
  132. },
  133. getNowTime() {
  134. let now = new Date();
  135. let year = now.getFullYear(); //得到年份
  136. let month = now.getMonth(); //得到月份
  137. let date = now.getDate(); //得到日期
  138. month = month + 1;
  139. month = month.toString().padStart(2, "0");
  140. date = date.toString().padStart(2, "0");
  141. let defaultDate = `${year}-${month}-${date}`
  142. this.detailData.carrierInfo.unloadingDate = defaultDate
  143. // this.$forceUpdate()
  144. },
  145. selectUnloadingDate() {
  146. this.isShowValidity = true
  147. },
  148. getLngLat() {
  149. let that = this
  150. uni.showLoading({
  151. title: '获取定位中',
  152. mask: true
  153. })
  154. // this.$helper.fUN_AmapLocation.start({
  155. // intervalTime: 1000 * 3,
  156. // isReport: false,
  157. // },
  158. // res => {
  159. // //见下方定位返回示例
  160. // console.log('====fUN_AmapLocation定位====', JSON.stringify(res));
  161. // if (res.latitude) {
  162. // this.detailData.carrierInfo.loadingAreaLongitude = res.longitude;
  163. // this.detailData.carrierInfo.loadingAreaLatitude = res.latitude;
  164. // this.detailData.carrierInfo.sendCity = this.$helper.filterUrban(res.city)
  165. // this.detailData.carrierInfo.sendArea = this.$helper.filterArea(res.district);
  166. // console.log(this.detailData.carrierInfo.sendCity)
  167. // console.log(this.detailData.carrierInfo.sendArea)
  168. // this.$forceUpdate()
  169. // }
  170. // this.$helper.fUN_AmapLocation.stop({}, result => {
  171. // uni.hideLoading()
  172. // console.log('====fUN_AmapLocation定位stop====', JSON.stringify(result));
  173. // });
  174. // }
  175. // );
  176. uni.getLocation({
  177. type: 'gcj02',
  178. geocode: true,
  179. success: res => {
  180. if (res.latitude) {
  181. // that.detailData.hyCarrierInfo.loadingAreaLongitude = res.longitude;
  182. // that.detailData.hyCarrierInfo.loadingAreaLatitude = res.latitude;
  183. that.detailData.carrierInfo.unloadingAreaLongitude = res.longitude;
  184. that.detailData.carrierInfo.unloadingAreaLatitude = res.latitude;
  185. console.log("1234567890")
  186. that.detailData.carrierInfo.unloadCity = that.$helper.filterUrban(res.address.city)
  187. that.detailData.carrierInfo.unloadArea = that.$helper.filterUrban(res.address.district)
  188. that.localtion.city = that.$helper.filterUrban(res.address.city)
  189. that.localtion.sendArea = that.$helper.filterUrban(res.address.district)
  190. that.detailData.carrierInfo.unloadingCity = that.$helper.filterUrban(res.address.city)
  191. that.detailData.carrierInfo.unloadingArea = that.$helper.filterUrban(res.address.district)
  192. that.detailData.carrierInfo.unloadingLongitude = res.longitude;
  193. that.detailData.carrierInfo.unloadingLatitude = res.latitude;
  194. that.$forceUpdate()
  195. uni.hideLoading()
  196. } else {
  197. if (uni.getSystemInfoSync().platform == 'android') {
  198. var context = plus.android.importClass("android.content.Context");
  199. var locationManager = plus.android.importClass(
  200. "android.location.LocationManager");
  201. var main = plus.android.runtimeMainActivity();
  202. var mainSvr = main.getSystemService(context.LOCATION_SERVICE);
  203. that.bool = mainSvr.isProviderEnabled(locationManager.GPS_PROVIDER)
  204. }
  205. if (that.bool === false) {
  206. uni.showModal({
  207. title: '提示',
  208. content: '请打开定位服务',
  209. success: ({
  210. confirm,
  211. cancel
  212. }) => {
  213. if (confirm) {
  214. if (uni.getSystemInfoSync().platform == 'android') {
  215. var Intent = plus.android.importClass(
  216. 'android.content.Intent');
  217. var Settings = plus.android.importClass(
  218. 'android.provider.Settings');
  219. var intent = new Intent(Settings
  220. .ACTION_LOCATION_SOURCE_SETTINGS);
  221. var main = plus.android.runtimeMainActivity();
  222. main.startActivity(intent); // 打开系统设置GPS服务页面
  223. }
  224. }
  225. }
  226. });
  227. uni.hideLoading()
  228. }
  229. }
  230. },
  231. fail: res => {
  232. console.log('定位失败')
  233. console.log(res)
  234. uni.hideLoading()
  235. }
  236. });
  237. },
  238. alertBtn() {
  239. // uni.navigateTo({
  240. // url: '/pages/public/login'
  241. // })
  242. },
  243. cancelClick() {
  244. this.isShowAlert = false
  245. },
  246. getImgUrl(res) {
  247. this.detailData.carrierInfo.unloadingImg += res + ','
  248. console.log(res)
  249. console.log('------------res-----------')
  250. },
  251. onError(error) {
  252. alert(error)
  253. console.log('------------error-----------')
  254. console.log(error)
  255. },
  256. onRemove(index) {},
  257. filterFileType(index, lists) {
  258. if (lists[index].fileType != 'jpg' && lists[index].fileType != 'png' && lists[index].fileType != 'gif') {
  259. lists.splice(index, 1);
  260. // 当前文件不支持
  261. uni.showModal({
  262. title: '暂不支持当前图片类型',
  263. showCancel: false
  264. });
  265. } else {
  266. this.isAdd = false;
  267. }
  268. },
  269. // 新增图片
  270. async afterRead(event) {
  271. // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
  272. let lists = [].concat(event.file)
  273. let fileListLen = this[`fileList${event.name}`].length
  274. lists.map((item) => {
  275. this[`fileList${event.name}`].push({
  276. ...item,
  277. status: 'uploading',
  278. message: '上传中'
  279. })
  280. })
  281. for (let i = 0; i < lists.length; i++) {
  282. const result = await this.uploadFilePromise(lists[i].url)
  283. let item = this[`fileList${event.name}`][fileListLen]
  284. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  285. status: 'success',
  286. message: '',
  287. url: result
  288. }))
  289. fileListLen++
  290. }
  291. },
  292. uploadFilePromise(url) {
  293. uploadImage('image', url, 'appData/',
  294. result => {
  295. // 上传成功回调函数
  296. console.log('图片地址', result)
  297. this.imgList.push(result)
  298. }
  299. )
  300. },
  301. onProgress(e) {
  302. console.log(e)
  303. },
  304. submit(type) {
  305. if (type == 1) {
  306. this.alertContent = '确定暂存卸车信息?'
  307. } else {
  308. this.alertContent = '确定提交卸车信息?'
  309. }
  310. if(!this.detailData.totalFreight){
  311. this.$refs.uToast.show({
  312. type: 'error',
  313. message: "请输入合计运费!",
  314. })
  315. return
  316. }
  317. this.isShowAlert = true
  318. this.detailData.statusFlag = type
  319. },
  320. confirmClick() {
  321. if (this.detailData.statusFlag == 1) {
  322. delete this.detailData.carrierInfo.unloadingAreaLongitude;
  323. delete this.detailData.carrierInfo.unloadingAreaLatitude;
  324. delete this.detailData.carrierInfo.unloadCity;
  325. delete this.detailData.carrierInfo.unloadArea;
  326. }
  327. this.detailData.carrierInfo.statusFlag = this.detailData.statusFlag
  328. this.detailData.carrierInfo.unloadingImg = this.imgList.toString()
  329. // if (!this.detailData.carrierInfo.totalFreight) {
  330. // uni.showToast({
  331. // title: '运费不能为空!',
  332. // duration: 2000,
  333. // icon: "none",
  334. // });
  335. // return
  336. // }
  337. if (
  338. this.detailData.carrierInfo.totalFreight < 0 || this.detailData.carrierInfo.totalFreight > 100000 || (
  339. String(this.detailData.carrierInfo.totalFreight).indexOf('.') != -1 && String(this.detailData
  340. .carrierInfo.totalFreight).length - (String(this.detailData.carrierInfo.totalFreight).indexOf(
  341. '.') + 1) > 2)
  342. ) {
  343. uni.showToast({
  344. title: '运费输入错误!',
  345. duration: 2000,
  346. icon: "none",
  347. });
  348. return
  349. }
  350. if (!this.detailData.carrierInfo.unloadingImg) {
  351. uni.showToast({
  352. title: '卸车照片不能为空!',
  353. icon: "none",
  354. duration: 2000
  355. });
  356. return
  357. }
  358. this.isShowAlert = false
  359. uni.showLoading({
  360. title:'加载中'
  361. })
  362. let time = new Date() //卸车时间 去当前时间的时分秒
  363. let h = time.getHours();
  364. if (h < 10) {
  365. h = "0" + h
  366. }
  367. let f = time.getMinutes();
  368. if (f < 10) {
  369. f = "0" + f
  370. }
  371. let m = time.getSeconds();
  372. if (m < 10) {
  373. m = "0" + m
  374. }
  375. if(this.detailData.carrierInfo.unloadingDate){//卸车时间 去当前时间的时分秒
  376. this.detailData.carrierInfo.unloadingDate= this.detailData.carrierInfo.unloadingDate.split(" ")[0] + " " + h + ":" + f + ":" + m
  377. }
  378. this.detailData.carrierInfo.totalFreight = this.detailData.totalFreight
  379. this.detailData.carrierInfo.carNo = this.detailData.carNumber
  380. this.$request.baseRequest('post', '/carrierInfo/unLoadingAdd', this.detailData.carrierInfo).then(res => {
  381. if (res.code == 200) {
  382. let _title = ''
  383. if (this.detailData.statusFlag == 1) {
  384. _title = '暂存成功!'
  385. } else {
  386. _title = '提交成功!'
  387. }
  388. uni.hideLoading()
  389. this.$refs.uToast.show({
  390. type: 'success',
  391. message: _title,
  392. complete() {
  393. uni.hideLoading()
  394. that.$helper.fUN_AmapLocation.stop({}, result => {
  395. console.log('====fUN_AmapLocation定位stop====', JSON.stringify(result));
  396. });
  397. uni.switchTab({
  398. url: '/pages/order/index'
  399. })
  400. }
  401. })
  402. }
  403. })
  404. .catch(res => {
  405. uni.$u.toast(res.message);
  406. });
  407. },
  408. confirmValidityPeriod(e) {
  409. this.detailData.carrierInfo.unloadingDate = e.value[0] + '-' + e.value[1] + '-' + e.value[2]
  410. this.isShowValidity = false
  411. },
  412. },
  413. }
  414. </script>
  415. <style scoped lang="scss">
  416. .content {
  417. .row-left-text {
  418. color: #333333;
  419. }
  420. }
  421. .level2-title {
  422. margin: 0 0 20rpx 0;
  423. }
  424. .content1,
  425. .content2 {
  426. background: white;
  427. margin: 20rpx;
  428. border-radius: 20rpx;
  429. padding: 20rpx;
  430. .place {
  431. width: 80%;
  432. text-align: right;
  433. }
  434. }
  435. .upload {}
  436. .bottom-btn {
  437. display: flex;
  438. justify-content: space-around;
  439. margin-bottom: 50rpx;
  440. background: #FFFFFF;
  441. padding: 40rpx 0;
  442. }
  443. .store {
  444. padding: 20rpx 30rpx;
  445. color: #2772FB;
  446. width: 40%;
  447. background: #EEF4FF;
  448. border-radius: 40rpx;
  449. font-size: 36rpx;
  450. text-align: center;
  451. }
  452. .submit {
  453. font-size: 36rpx;
  454. padding: 20rpx 30rpx;
  455. color: white;
  456. width: 40%;
  457. background: #2772FB;
  458. border-radius: 40rpx;
  459. text-align: center;
  460. }
  461. .row-between {
  462. margin: 20rpx 0;
  463. }
  464. .sx-style {
  465. background: #2772FB;
  466. color: white;
  467. padding: 2rpx 16rpx;
  468. box-sizing: border-box;
  469. border-radius: 10rpx;
  470. margin-left: 20rpx;
  471. }
  472. .totalFreight-input {
  473. text-align: right;
  474. }
  475. </style>