confirmUnloading.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  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.illingMethod==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.carrierInfo.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. },
  100. action: this.$helper.ossUploadUrl,
  101. maxSize: 50 * 1024 * 1024, //限制文件大小 50M
  102. isAdd: true,
  103. isShowAlert: false,
  104. alertContent: '',
  105. alertTitle: '',
  106. }
  107. },
  108. onLoad(options) {
  109. console.log('------------')
  110. console.log(options)
  111. this.detailData = options;
  112. this.detailData.carrierInfo = {
  113. carNo: '123',
  114. unloadingDate: '',
  115. estimatedFreight: '',
  116. unloadingAreaLongitude: '',
  117. unloadingAreaLatitude: '',
  118. unloadCity: '沈阳',
  119. unloadArea: '大东',
  120. unloadingImg: '',
  121. totalFreight: '100',
  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. getNowTime() {
  132. let now = new Date();
  133. let year = now.getFullYear(); //得到年份
  134. let month = now.getMonth(); //得到月份
  135. let date = now.getDate(); //得到日期
  136. month = month + 1;
  137. month = month.toString().padStart(2, "0");
  138. date = date.toString().padStart(2, "0");
  139. let defaultDate = `${year}-${month}-${date}`
  140. this.detailData.carrierInfo.unloadingDate = defaultDate
  141. // this.$forceUpdate()
  142. },
  143. selectUnloadingDate() {
  144. this.isShowValidity = true
  145. },
  146. getLngLat() {
  147. uni.showLoading({
  148. title: '获取定位中',
  149. mask: true
  150. })
  151. uni.getLocation({
  152. type: 'gcj02',
  153. geocode: true,
  154. success: res => {
  155. console.log('定位地址')
  156. console.log(res)
  157. if (res.latitude) {
  158. this.detailData.carrierInfo.loadingAreaLongitude = res.longitude;
  159. this.detailData.carrierInfo.loadingAreaLatitude = res.latitude;
  160. this.detailData.carrierInfo.sendCity = this.$helper.filterUrban(res.address.city)
  161. this.detailData.carrierInfo.sendArea = this.$helper.filterArea(res.address
  162. .district);
  163. console.log(this.detailData.carrierInfo.sendCity)
  164. console.log(this.detailData.carrierInfo.sendArea)
  165. this.$forceUpdate()
  166. uni.hideLoading()
  167. } else {
  168. if (uni.getSystemInfoSync().platform == 'android') {
  169. var context = plus.android.importClass("android.content.Context");
  170. var locationManager = plus.android.importClass(
  171. "android.location.LocationManager");
  172. var main = plus.android.runtimeMainActivity();
  173. var mainSvr = main.getSystemService(context.LOCATION_SERVICE);
  174. this.bool = mainSvr.isProviderEnabled(locationManager.GPS_PROVIDER)
  175. }
  176. if (this.bool === false) {
  177. uni.showModal({
  178. title: '提示',
  179. content: '请打开定位服务',
  180. success: ({
  181. confirm,
  182. cancel
  183. }) => {
  184. if (confirm) {
  185. if (uni.getSystemInfoSync().platform == 'android') {
  186. var Intent = plus.android.importClass(
  187. 'android.content.Intent');
  188. var Settings = plus.android.importClass(
  189. 'android.provider.Settings');
  190. var intent = new Intent(Settings
  191. .ACTION_LOCATION_SOURCE_SETTINGS);
  192. var main = plus.android.runtimeMainActivity();
  193. main.startActivity(intent); // 打开系统设置GPS服务页面
  194. }
  195. }
  196. }
  197. });
  198. }
  199. }
  200. }
  201. });
  202. },
  203. alertBtn() {
  204. // uni.navigateTo({
  205. // url: '/pages/public/login'
  206. // })
  207. },
  208. cancelClick() {
  209. this.isShowAlert = false
  210. },
  211. getImgUrl(res) {
  212. this.detailData.carrierInfo.unloadingImg += res + ','
  213. console.log(res)
  214. console.log('------------res-----------')
  215. },
  216. onError(error) {
  217. alert(error)
  218. console.log('------------error-----------')
  219. console.log(error)
  220. },
  221. onRemove(index) {},
  222. filterFileType(index, lists) {
  223. if (lists[index].fileType != 'jpg' && lists[index].fileType != 'png' && lists[index].fileType != 'gif') {
  224. lists.splice(index, 1);
  225. // 当前文件不支持
  226. uni.showModal({
  227. title: '暂不支持当前图片类型',
  228. showCancel: false
  229. });
  230. } else {
  231. this.isAdd = false;
  232. }
  233. },
  234. // 新增图片
  235. async afterRead(event) {
  236. debugger
  237. // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
  238. let lists = [].concat(event.file)
  239. let fileListLen = this[`fileList${event.name}`].length
  240. lists.map((item) => {
  241. this[`fileList${event.name}`].push({
  242. ...item,
  243. status: 'uploading',
  244. message: '上传中'
  245. })
  246. })
  247. for (let i = 0; i < lists.length; i++) {
  248. const result = await this.uploadFilePromise(lists[i].url)
  249. let item = this[`fileList${event.name}`][fileListLen]
  250. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  251. status: 'success',
  252. message: '',
  253. url: result
  254. }))
  255. fileListLen++
  256. }
  257. },
  258. uploadFilePromise(url) {
  259. uploadImage('image', url, 'appData/',
  260. result => {
  261. // 上传成功回调函数
  262. console.log('图片地址', result)
  263. this.imgList.push(result)
  264. }
  265. )
  266. },
  267. onProgress(e) {
  268. console.log(e)
  269. },
  270. submit(type) {
  271. console.log(type)
  272. if (type == 1) {
  273. this.alertContent = '确定暂存卸车信息?'
  274. } else {
  275. this.alertContent = '确定提交卸车信息?'
  276. }
  277. this.isShowAlert = true
  278. this.detailData.statusFlag = type
  279. },
  280. confirmClick() {
  281. if (this.detailData.statusFlag == 1) {
  282. delete this.detailData.carrierInfo.unloadingAreaLongitude;
  283. delete this.detailData.carrierInfo.unloadingAreaLatitude;
  284. delete this.detailData.carrierInfo.unloadCity;
  285. delete this.detailData.carrierInfo.unloadArea;
  286. }
  287. this.detailData.carrierInfo.statusFlag = this.detailData.statusFlag
  288. this.detailData.carrierInfo.unloadingImg = this.imgList.toString()
  289. if (!this.detailData.carrierInfo.totalFreight) {
  290. uni.showToast({
  291. title: '运费不能为空!',
  292. duration: 2000,
  293. icon: "none",
  294. });
  295. return
  296. }
  297. if (
  298. this.detailData.carrierInfo.totalFreight < 0 || this.detailData.carrierInfo.totalFreight > 100000 || (
  299. String(this.detailData.carrierInfo.totalFreight).indexOf('.') != -1 && String(this.detailData
  300. .carrierInfo.totalFreight).length - (String(this.detailData.carrierInfo.totalFreight).indexOf(
  301. '.') + 1) > 2)
  302. ) {
  303. uni.showToast({
  304. title: '运费输入错误!',
  305. duration: 2000,
  306. icon: "none",
  307. });
  308. return
  309. }
  310. if (!this.detailData.carrierInfo.unloadingImg) {
  311. uni.showToast({
  312. title: '卸车照片不能为空!',
  313. icon: "none",
  314. duration: 2000
  315. });
  316. return
  317. }
  318. this.$request.baseRequest('post', '/carrierInfo/unLoadingAdd', this.detailData.carrierInfo).then(res => {
  319. if (res.code == 200) {
  320. let _title = ''
  321. if (this.detailData.statusFlag == 1) {
  322. _title = '暂存成功!'
  323. } else {
  324. _title = '提交成功!'
  325. }
  326. this.$refs.uToast.show({
  327. type: 'success',
  328. message: _title,
  329. complete() {
  330. uni.switchTab({
  331. url: '/pages/order/index'
  332. })
  333. }
  334. })
  335. }
  336. })
  337. .catch(res => {
  338. uni.$u.toast(res.message);
  339. });
  340. console.log('提交')
  341. },
  342. confirmValidityPeriod(e) {
  343. console.log('confirm', e)
  344. this.detailData.carrierInfo.unloadingDate = e.value[0] + '-' + e.value[1] + '-' + e.value[2]
  345. this.isShowValidity = false
  346. },
  347. },
  348. }
  349. </script>
  350. <style scoped lang="scss">
  351. .content {
  352. .row-left-text {
  353. color: #333333;
  354. }
  355. }
  356. .level2-title {
  357. margin: 0 0 20rpx 0;
  358. }
  359. .content1,
  360. .content2 {
  361. background: white;
  362. margin: 20rpx;
  363. border-radius: 20rpx;
  364. padding: 20rpx;
  365. .place {
  366. width: 80%;
  367. text-align: right;
  368. }
  369. }
  370. .upload {}
  371. .bottom-btn {
  372. display: flex;
  373. justify-content: space-around;
  374. margin-bottom: 50rpx;
  375. background: #FFFFFF;
  376. padding: 40rpx 0;
  377. }
  378. .store {
  379. padding: 20rpx 30rpx;
  380. color: #2772FB;
  381. width: 40%;
  382. background: #EEF4FF;
  383. border-radius: 40rpx;
  384. font-size: 36rpx;
  385. text-align: center;
  386. }
  387. .submit {
  388. font-size: 36rpx;
  389. padding: 20rpx 30rpx;
  390. color: white;
  391. width: 40%;
  392. background: #2772FB;
  393. border-radius: 40rpx;
  394. text-align: center;
  395. }
  396. .row-between {
  397. margin: 20rpx 0;
  398. }
  399. .sx-style {
  400. background: #2772FB;
  401. color: white;
  402. padding: 2rpx 16rpx;
  403. box-sizing: border-box;
  404. border-radius: 10rpx;
  405. margin-left: 20rpx;
  406. }
  407. .totalFreight-input {
  408. text-align: right;
  409. }
  410. </style>