confirmUnloading.vue 14 KB

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