confirmUnloading.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  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.freightInfo.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.carrierInfo.carNo}}</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.freightInfo.freight"
  58. type="number" v-if="detailData.billingMethod==1"/>
  59. <input class="totalFreight-input" placeholder="输入合计应付运费" v-model="detailData.carrierInfo.totalFreight"
  60. type="number" v-if="detailData.billingMethod==0"/>
  61. </view>
  62. <view class='row-between'>
  63. <view class="row-left-text">定位</view>
  64. <view class="flex align-center">
  65. {{detailData.carrierInfo.unloadCity}}{{detailData.carrierInfo.unloadArea}}
  66. <view class="sx-style" @click.stop="getLngLat()">刷新</view>
  67. </view>
  68. </view>
  69. <view class='s-flex'>
  70. <view class="row-left-text" style="margin:20rpx 0;">上传卸车照片(1-3张)</view>
  71. <u-upload class="uview-upload" :fileList="fileList1" @afterRead="afterRead($event)" @delete="deletePic"
  72. name="1" multiple :maxCount="3"></u-upload>
  73. </view>
  74. </view>
  75. <view class="bottom-btn">
  76. <view class="store" @click="submit(1)">暂存</view>
  77. <view class="submit" @click="submit(3)">提交</view>
  78. </view>
  79. <u-modal :show="isShowAlert" :title="alertTitle" :content='alertContent' :closeOnClickOverlay='true'
  80. :showCancelButton='true' confirmColor='#2772FB' @confirm="confirmClick" @close="cancelClick"
  81. @cancel="cancelClick"></u-modal>
  82. <u-picker :show="isShowValidity" ref="uPicker" :columns="validityPeriod" @confirm="confirmValidityPeriod"
  83. :closeOnClickOverlay='true' @close='isShowValidity=false' @cancel='isShowValidity=false'>
  84. </u-picker>
  85. <u-toast ref="uToast"></u-toast>
  86. </view>
  87. </template>
  88. <script>
  89. let that;
  90. import uploadImage from '@/components/ossutil/uploadFile.js';
  91. export default {
  92. data() {
  93. return {
  94. imgList: [],
  95. fileList1: [],
  96. isShowValidity: false,
  97. validityPeriod: [],
  98. sourceType: ['camera'],
  99. detailData: {
  100. addressUrl: ''
  101. },
  102. action: this.$helper.ossUploadUrl,
  103. maxSize: 50 * 1024 * 1024, //限制文件大小 50M
  104. isAdd: true,
  105. isShowAlert: false,
  106. alertContent: '',
  107. alertTitle: '',
  108. }
  109. },
  110. onLoad(options) {
  111. console.log('------------')
  112. console.log(options)
  113. this.detailData = JSON.parse(options.obj)
  114. this.detailData.carrierInfo = {
  115. carNo: '',
  116. unloadingDate: '',
  117. estimatedFreight: '',
  118. unloadingAreaLongitude: '',
  119. unloadingAreaLatitude: '',
  120. unloadCity: '',
  121. unloadArea: '',
  122. unloadingImg: '',
  123. totalFreight: '',
  124. id: this.detailData.carrierId,
  125. }
  126. this.validityPeriod = this.$helper.makeValidityPeriod()
  127. // #ifdef APP-PLUS
  128. this.getLngLat();
  129. // #endif
  130. this.getNowTime()
  131. },
  132. methods: {
  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. uni.showLoading({
  150. title: '获取定位中',
  151. mask: true
  152. })
  153. uni.getLocation({
  154. type: 'gcj02',
  155. geocode: true,
  156. success: res => {
  157. console.log('定位地址')
  158. console.log(res)
  159. if (res.latitude) {
  160. this.detailData.carrierInfo.loadingAreaLongitude = res.longitude;
  161. this.detailData.carrierInfo.loadingAreaLatitude = res.latitude;
  162. this.detailData.carrierInfo.sendCity = this.$helper.filterUrban(res.address.city)
  163. this.detailData.carrierInfo.sendArea = this.$helper.filterArea(res.address
  164. .district);
  165. console.log(this.detailData.carrierInfo.sendCity)
  166. console.log(this.detailData.carrierInfo.sendArea)
  167. this.$forceUpdate()
  168. uni.hideLoading()
  169. } else {
  170. if (uni.getSystemInfoSync().platform == 'android') {
  171. var context = plus.android.importClass("android.content.Context");
  172. var locationManager = plus.android.importClass(
  173. "android.location.LocationManager");
  174. var main = plus.android.runtimeMainActivity();
  175. var mainSvr = main.getSystemService(context.LOCATION_SERVICE);
  176. this.bool = mainSvr.isProviderEnabled(locationManager.GPS_PROVIDER)
  177. }
  178. if (this.bool === false) {
  179. uni.showModal({
  180. title: '提示',
  181. content: '请打开定位服务',
  182. success: ({
  183. confirm,
  184. cancel
  185. }) => {
  186. if (confirm) {
  187. if (uni.getSystemInfoSync().platform == 'android') {
  188. var Intent = plus.android.importClass(
  189. 'android.content.Intent');
  190. var Settings = plus.android.importClass(
  191. 'android.provider.Settings');
  192. var intent = new Intent(Settings
  193. .ACTION_LOCATION_SOURCE_SETTINGS);
  194. var main = plus.android.runtimeMainActivity();
  195. main.startActivity(intent); // 打开系统设置GPS服务页面
  196. }
  197. }
  198. }
  199. });
  200. }
  201. }
  202. }
  203. });
  204. },
  205. alertBtn() {
  206. // uni.navigateTo({
  207. // url: '/pages/public/login'
  208. // })
  209. },
  210. cancelClick() {
  211. this.isShowAlert = false
  212. },
  213. getImgUrl(res) {
  214. this.detailData.carrierInfo.unloadingImg += res + ','
  215. console.log(res)
  216. console.log('------------res-----------')
  217. },
  218. onError(error) {
  219. alert(error)
  220. console.log('------------error-----------')
  221. console.log(error)
  222. },
  223. onRemove(index) {},
  224. filterFileType(index, lists) {
  225. if (lists[index].fileType != 'jpg' && lists[index].fileType != 'png' && lists[index].fileType != 'gif') {
  226. lists.splice(index, 1);
  227. // 当前文件不支持
  228. uni.showModal({
  229. title: '暂不支持当前图片类型',
  230. showCancel: false
  231. });
  232. } else {
  233. this.isAdd = false;
  234. }
  235. },
  236. // 新增图片
  237. async afterRead(event) {
  238. // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
  239. let lists = [].concat(event.file)
  240. let fileListLen = this[`fileList${event.name}`].length
  241. lists.map((item) => {
  242. this[`fileList${event.name}`].push({
  243. ...item,
  244. status: 'uploading',
  245. message: '上传中'
  246. })
  247. })
  248. for (let i = 0; i < lists.length; i++) {
  249. const result = await this.uploadFilePromise(lists[i].url)
  250. let item = this[`fileList${event.name}`][fileListLen]
  251. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  252. status: 'success',
  253. message: '',
  254. url: result
  255. }))
  256. fileListLen++
  257. }
  258. },
  259. uploadFilePromise(url) {
  260. uploadImage('image', url, 'appData/',
  261. result => {
  262. // 上传成功回调函数
  263. console.log('图片地址', result)
  264. this.imgList.push(result)
  265. }
  266. )
  267. },
  268. onProgress(e) {
  269. console.log(e)
  270. },
  271. submit(type) {
  272. console.log(type)
  273. if (type == 1) {
  274. this.alertContent = '确定暂存卸车信息?'
  275. } else {
  276. this.alertContent = '确定提交卸车信息?'
  277. }
  278. this.isShowAlert = true
  279. this.detailData.statusFlag = type
  280. },
  281. confirmClick() {
  282. if (this.detailData.statusFlag == 1) {
  283. delete this.detailData.carrierInfo.unloadingAreaLongitude;
  284. delete this.detailData.carrierInfo.unloadingAreaLatitude;
  285. delete this.detailData.carrierInfo.unloadCity;
  286. delete this.detailData.carrierInfo.unloadArea;
  287. }
  288. this.detailData.carrierInfo.statusFlag = this.detailData.statusFlag
  289. this.detailData.carrierInfo.unloadingImg = this.imgList.toString()
  290. if (!this.detailData.carrierInfo.totalFreight) {
  291. uni.showToast({
  292. title: '运费不能为空!',
  293. duration: 2000,
  294. icon: "none",
  295. });
  296. return
  297. }
  298. if (
  299. this.detailData.carrierInfo.totalFreight < 0 || this.detailData.carrierInfo.totalFreight > 100000 || (
  300. String(this.detailData.carrierInfo.totalFreight).indexOf('.') != -1 && String(this.detailData
  301. .carrierInfo.totalFreight).length - (String(this.detailData.carrierInfo.totalFreight).indexOf(
  302. '.') + 1) > 2)
  303. ) {
  304. uni.showToast({
  305. title: '运费输入错误!',
  306. duration: 2000,
  307. icon: "none",
  308. });
  309. return
  310. }
  311. if (!this.detailData.carrierInfo.unloadingImg) {
  312. uni.showToast({
  313. title: '卸车照片不能为空!',
  314. icon: "none",
  315. duration: 2000
  316. });
  317. return
  318. }
  319. this.isShowAlert = false
  320. uni.showLoading({
  321. title:'加载中'
  322. })
  323. this.$request.baseRequest('post', '/carrierInfo/unLoadingAdd', this.detailData.carrierInfo).then(res => {
  324. if (res.code == 200) {
  325. let _title = ''
  326. if (this.detailData.statusFlag == 1) {
  327. _title = '暂存成功!'
  328. } else {
  329. _title = '提交成功!'
  330. }
  331. uni.hideLoading()
  332. this.$refs.uToast.show({
  333. type: 'success',
  334. message: _title,
  335. complete() {
  336. uni.hideLoading()
  337. uni.switchTab({
  338. url: '/pages/order/index'
  339. })
  340. }
  341. })
  342. }
  343. })
  344. .catch(res => {
  345. uni.$u.toast(res.message);
  346. });
  347. console.log('提交')
  348. },
  349. confirmValidityPeriod(e) {
  350. console.log('confirm', e)
  351. this.detailData.carrierInfo.unloadingDate = e.value[0] + '-' + e.value[1] + '-' + e.value[2]
  352. this.isShowValidity = false
  353. },
  354. },
  355. }
  356. </script>
  357. <style scoped lang="scss">
  358. .content {
  359. .row-left-text {
  360. color: #333333;
  361. }
  362. }
  363. .level2-title {
  364. margin: 0 0 20rpx 0;
  365. }
  366. .content1,
  367. .content2 {
  368. background: white;
  369. margin: 20rpx;
  370. border-radius: 20rpx;
  371. padding: 20rpx;
  372. .place {
  373. width: 80%;
  374. text-align: right;
  375. }
  376. }
  377. .upload {}
  378. .bottom-btn {
  379. display: flex;
  380. justify-content: space-around;
  381. margin-bottom: 50rpx;
  382. background: #FFFFFF;
  383. padding: 40rpx 0;
  384. }
  385. .store {
  386. padding: 20rpx 30rpx;
  387. color: #2772FB;
  388. width: 40%;
  389. background: #EEF4FF;
  390. border-radius: 40rpx;
  391. font-size: 36rpx;
  392. text-align: center;
  393. }
  394. .submit {
  395. font-size: 36rpx;
  396. padding: 20rpx 30rpx;
  397. color: white;
  398. width: 40%;
  399. background: #2772FB;
  400. border-radius: 40rpx;
  401. text-align: center;
  402. }
  403. .row-between {
  404. margin: 20rpx 0;
  405. }
  406. .sx-style {
  407. background: #2772FB;
  408. color: white;
  409. padding: 2rpx 16rpx;
  410. box-sizing: border-box;
  411. border-radius: 10rpx;
  412. margin-left: 20rpx;
  413. }
  414. .totalFreight-input {
  415. text-align: right;
  416. }
  417. </style>