index.vue 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084
  1. <!-- 货源 -->
  2. <template>
  3. <view class="content">
  4. <!-- <fh-no-network></fh-no-network> -->
  5. <view class="banner">
  6. <image class="banner-img" src="@/static/images/goodSource/banner@2x.png" mode='widthFix'></image>
  7. <view class="head flex s-row paddingr35">
  8. <view class="flex flex-space-between">
  9. <view class="flex s-row item1" @click="goCity(0)">
  10. <view class="fontsize-28 gray">装车</view>
  11. <view class="fontsize-46 fontweight-500 text">{{startPlace.selected}}</view>
  12. </view>
  13. <image class="change-btn item2" src="@/static/images/goodSource/change.png" mode='widthFix'
  14. @click="changeCity"></image>
  15. <view class="flex s-row item3" @click="goCity(1)">
  16. <view class="fontsize-28 gray text-align-right">卸车</view>
  17. <view class="fontsize-46 fontweight-500 text">{{endPlace.selected}}</view>
  18. </view>
  19. </view>
  20. <view>
  21. <u-button type="" class="btn-color fontsize-36 m-top20" @click="upCallback({size:10,num:1})"> 查询
  22. </u-button>
  23. </view>
  24. </view>
  25. </view>
  26. <view :class="scrollTop>1200?'fixed1':''"></view>
  27. <view class="tab-view">
  28. <u-tabs :list="tabList" @click="clickTab" :lineColor="scrollTop>1200?'white':'#303133'" :current='tabIndex'
  29. :inactiveStyle="{color: scrollTop>1200?'white':'',}" :activeStyle="{
  30. color: scrollTop>1200?'white':'',
  31. fontWeight: 'bold',
  32. transform: 'scale(1.05)'
  33. }" :class="scrollTop>1200?'fixed':''"></u-tabs>
  34. <view class="tab-right" @click="selectType">
  35. <view>{{pickerSelect}}</view>
  36. <u-icon name="arrow-down" size="20"></u-icon>
  37. </view>
  38. </view>
  39. <u-picker :show="show" :columns="columns" :closeOnClickOverlay='true' @close='selectTypeClose'
  40. @cancel='selectTypeClose' @confirm='confirmSelectType'></u-picker>
  41. <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback">
  42. <view v-for="(good,index) in goods" :key="index" @click="toDetail(good.id)">
  43. <view v-if="good.peripheralInfo==1&&isFirstIndex==index" class="other-goods">周边货源</view>
  44. <view class="good-list">
  45. <view style="padding: 0 35rpx 20rpx 35rpx;position: relative;">
  46. <image src="@/static/images/goodSource/xf.png" mode="widthFix" class="xf-iamge"
  47. v-if="good.freightAdvance==1"></image>
  48. <view class="flex align-center">
  49. <view class="item1">
  50. <view class="ssx">{{$helper.getProvinceAbbreviation(good.sendPrivate?good.sendPrivate:good.sendCity)}}</view>
  51. <view class="level2-title">{{$helper.filterUrban(good.sendCity)}}
  52. {{$helper.filterArea(good.sendArea)}}
  53. </view>
  54. </view>
  55. <image class="jt-icon item2" src="@/static/images/goodSource/jt.png" mode='widthFix'>
  56. </image>
  57. <view class="item3">
  58. <view class="ssx">{{$helper.getProvinceAbbreviation(good.unloadPrivate?good.unloadPrivate:good.unloadCity)}}</view>
  59. <view class="level2-title">{{$helper.filterUrban(good.unloadCity)}}
  60. {{$helper.filterArea(good.unloadArea)}}
  61. </view>
  62. </view>
  63. </view>
  64. <view class="right gray">
  65. {{$helper.changeTime(good.updateDate)}}
  66. </view>
  67. <view class="flex flex-space-between yf-style">
  68. <view class="left">
  69. <view class="flex">
  70. <view class="gray mr20" v-if="good.cargoDistance">货距 {{good.cargoDistance}}km</view>
  71. <view class="gray " v-if="good.distance">运距 {{good.distance}}km</view>
  72. </view>
  73. <view class="u-flex-wrap flex gray row ">
  74. <view>{{good.goodsName}} | </view>
  75. <!-- <u-line direction="col"></u-line> -->
  76. <view v-if="carLength(good)"> {{carLength(good)}} | </view>
  77. <view v-if="carType(good)">{{carType(good)}} | </view>
  78. <view v-if="carWeight(good)">{{carWeight(good)}}</view>
  79. </view>
  80. <view class="flex row">
  81. <view class="row-tips" v-if="good.taskDescription">{{good.taskDescription}}</view>
  82. </view>
  83. </view>
  84. <view class="right flex h-color">
  85. <view class="fontsize-46">
  86. {{good.freightPrice}}
  87. </view>
  88. <view class="flex dw">元/吨</view>
  89. </view>
  90. </view>
  91. </view>
  92. <view class="flex flex-space-between item-bottom">
  93. <view class="left flex row" @click.stop="cargoOwner(good)">
  94. <u--image
  95. :src="good.cargoOwnerPortrait?good.cargoOwnerPortrait:'../../static/images/mine/tx.png'"
  96. width='100rpx' height='100rpx' shape="circle" >
  97. </u--image>
  98. <view class="name">{{good.cargoOwnerName}}</view>
  99. <!-- <view class="hp flex fontsize-24">
  100. <view class="gray">评分</view>
  101. <view class="number-color">99%</view>
  102. </view>
  103. <view class="sum flex fontsize-24">
  104. <view class="gray">发运次数</view>
  105. <view class="number-color">106</view>
  106. </view> -->
  107. </view>
  108. <view class="right">
  109. <view @click.stop="grabOrders(good)" class="qd" v-if='hasLogin'>抢单</view>
  110. </view>
  111. </view>
  112. </view>
  113. </view>
  114. </mescroll-body>
  115. <u-toast ref="uToast"></u-toast>
  116. <u-modal :show="isShowAlert" :title="alertTitle" :closeOnClickOverlay='true' :confirmText='confirmText'
  117. :showCancelButton='showCancelButton' confirmColor='#2772FB' @confirm="confirmClick" @close="cancelClick"
  118. @cancel="cancelClick"></u-modal>
  119. </view>
  120. </template>
  121. <script>
  122. var that
  123. import permision from "@/js_sdk/wa-permission/permission.js"
  124. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  125. import {
  126. mapState
  127. } from 'vuex';
  128. import {
  129. apiGoods
  130. } from "@/api/mock.js"
  131. export default {
  132. mixins: [MescrollMixin], // 使用mixin
  133. data() {
  134. return {
  135. confirmText: '确定',
  136. showCancelButton: true,
  137. isFirstIndex: null,
  138. ObjSelect: {},
  139. isShowAlert: false,
  140. alertTitle: '确定抢单?',
  141. show: false,
  142. columns: [
  143. ['全部类型', '运费先付']
  144. ],
  145. startPlace: {},
  146. endPlace: {},
  147. otherGoods: [], // 数据列表
  148. goods: [], // 数据列表
  149. src: 'https://cdn.uviewui.com/uview/album/1.jpg',
  150. height: "", // 需要固定swiper的高度
  151. tabList: [
  152. // {
  153. // name: '全部'
  154. // },
  155. {
  156. name: '推荐'
  157. }, {
  158. name: '按时间'
  159. }, {
  160. name: '按距离'
  161. },
  162. // {
  163. // name: '运费先付'
  164. // },
  165. ],
  166. pickerSelect: '全部类型',
  167. tabIndex: 0,
  168. scrollTop: 0,
  169. count: 0,
  170. lng: '',
  171. lat: '',
  172. bool: false,
  173. }
  174. },
  175. onTabItemTap(e) {
  176. // tab 点击时执行,此处直接接收单击事件
  177. uni.pageScrollTo({
  178. scrollTop: 0,
  179. duration: 300
  180. });
  181. },
  182. created() {
  183. },
  184. computed: {
  185. ...mapState(['hasLogin', 'userInfo', 'firstAuthentication'])
  186. },
  187. watch:{
  188. // startPlace(){
  189. // console.log(this.startPlace)
  190. // this.upCallback({page});
  191. // },
  192. },
  193. onLoad() {
  194. this.checkOpenGPSServiceByAndroidIOS()
  195. },
  196. onShow() {
  197. var that= this
  198. setTimeout(()=>{
  199. // var photol=await permision.checkSystemEnableLocation()
  200. if(uni.getStorageSync('confirm_location')){
  201. that.get_localtion_permission()
  202. }
  203. //获取上一次点击起装卸地
  204. if (uni.getStorageSync('fPlaceObj')) {
  205. that.startPlace = uni.getStorageSync('fPlaceObj');
  206. }
  207. if (uni.getStorageSync('sPlaceObj')) {
  208. that.endPlace = uni.getStorageSync('sPlaceObj');
  209. }
  210. that.upCallback({size:10,num:1})
  211. },1500)
  212. that.$request.baseRequest('get', '/newsInfo/unreadMessage', {
  213. reCommonId: this.userInfo.id,
  214. }).then(res3 => {
  215. if (res3.data||res3.data==0) {
  216. let name = 'myTip';
  217. let value = res3.data
  218. if (value == 0) {
  219. uni.removeTabBarBadge({
  220. index: 3
  221. })
  222. }
  223. that.$store.commit('$uStore', {
  224. name,
  225. value
  226. });
  227. if (value != 0 && value) {
  228. uni.setTabBarBadge({
  229. index: 3,
  230. text: value + ""
  231. })
  232. }
  233. }
  234. })
  235. // this.mescroll.resetUpScroll()
  236. },
  237. // async onLoad() {
  238. // that = this
  239. // // #ifdef APP-PLUS
  240. // let _status = await that.$request.baseRequest('get', '/driverInfo/firstAuthentication', {
  241. // driverPhone: this.userInfo.phone,
  242. // }).then(res => {
  243. // return res.data.authenticationStatus
  244. // })
  245. // // if (_status == '已禁用') {
  246. // // this.isShowAlert = true
  247. // // this.alertTitle = '账号审核中'
  248. // // this.confirmText = '退出APP'
  249. // // this.showCancelButton = false
  250. // // } else {
  251. // // console.log(1231233212332312312213)
  252. // // }
  253. // // #endif
  254. // },
  255. onPageScroll(res) {
  256. this.scrollTop = res.scrollTop
  257. // console.log("页面滚动了", res.scrollTop)
  258. if (this.scrollTop > 1200) {
  259. uni.setTabBarItem({
  260. index: 0,
  261. text: '返回顶部',
  262. iconPath: 'static/images/common/top@2x.png',
  263. selectedIconPath: 'static/images/common/top@2x.png'
  264. })
  265. } else {
  266. uni.setTabBarItem({
  267. index: 0,
  268. text: '货源',
  269. iconPath: 'static/images/common/huoyuan@2x(1).png',
  270. selectedIconPath: 'static/images/common/huoyuan@2x.png'
  271. })
  272. }
  273. },
  274. methods: {
  275. async get_localtion_permission() {
  276. var photol=await permision.checkSystemEnableLocation()
  277. if(photol == true){
  278. uni.removeStorageSync('confirm_location')
  279. // uni.showToast({
  280. // title: '只有文字弹窗',
  281. // icon: 'none', //如果要纯文本,不要icon,将值设为'none'
  282. // duration: 2000 //持续时间为 2秒
  283. // })
  284. this.getLngLat()
  285. }else{
  286. if(uni.getStorageSync('confirm_location')){
  287. uni.removeStorageSync('confirm_location')
  288. }
  289. uni.setStorageSync('fPlaceObj',{
  290. fchoosearea:'全部',
  291. fchoosecity:'市辖区',
  292. fchooseprovince:'北京',
  293. selected:'东城'
  294. })
  295. uni.setStorageSync('sPlaceObj',{
  296. schoosearea:'请选择区',
  297. schoosecity:'请选择市',
  298. schooseprovince:'全国',
  299. selected:'全国'
  300. })
  301. uni.setStorageSync('longitudeAndLatitude','116.3972,39.9096')
  302. }
  303. },
  304. async getLngLat(){
  305. await uni.getLocation({
  306. type: 'gcj02',
  307. geocode: true,
  308. success: res => {
  309. if (res.latitude) {
  310. if(res.address.city){
  311. if(res.address.city.indexOf('市')!=-1){
  312. res.address.city=res.address.city.substring(0,res.address.city.length-1)
  313. }
  314. }
  315. if(res.address.province){
  316. if(res.address.province.indexOf('省')!=-1){
  317. res.address.province=res.address.province.substring(0,res.address.province.length-1)
  318. }
  319. }
  320. uni.setStorageSync('fPlaceObj',{
  321. fchoosearea:'全部',
  322. fchoosecity:res.address.city,
  323. fchooseprovince:res.address.province,
  324. selected:res.address.city
  325. })
  326. uni.setStorageSync('sPlaceObj',{
  327. schoosearea:'请选择区',
  328. schoosecity:'请选择市',
  329. schooseprovince:'全国',
  330. selected:'全国'
  331. })
  332. uni.setStorageSync('longitudeAndLatitude',res.longitude+','+res.latitude)
  333. }
  334. }
  335. })
  336. },
  337. checkOpenGPSServiceByAndroidIOS() {
  338. let system = uni.getSystemInfoSync(); // 获取系统信息
  339. // console.log(system);
  340. if (system.platform === 'android') { // 判断平台
  341. var context = plus.android.importClass("android.content.Context");
  342. var locationManager = plus.android.importClass("android.location.LocationManager");
  343. var main = plus.android.runtimeMainActivity();
  344. var mainSvr = main.getSystemService(context.LOCATION_SERVICE);
  345. if (!mainSvr.isProviderEnabled(locationManager.GPS_PROVIDER)) {
  346. uni.showModal({
  347. title: '提示',
  348. content: '请打开定位服务功能',
  349. // showCancel: false, // 不显示取消按钮
  350. success(res) {
  351. if(res.confirm){
  352. uni.setStorageSync('confirm_location',1)
  353. if (!mainSvr.isProviderEnabled(locationManager.GPS_PROVIDER)) {
  354. var Intent = plus.android.importClass('android.content.Intent');
  355. var Settings = plus.android.importClass('android.provider.Settings');
  356. var intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
  357. main.startActivity(intent); // 打开系统设置GPS服务页面
  358. } else {
  359. uni.setStorageSync('fPlaceObj',{
  360. fchoosearea:'全部',
  361. fchoosecity:'市辖区',
  362. fchooseprovince:'北京',
  363. selected:'东城'
  364. })
  365. uni.setStorageSync('sPlaceObj',{
  366. schoosearea:'请选择区',
  367. schoosecity:'请选择市',
  368. schooseprovince:'全国',
  369. selected:'全国'
  370. })
  371. uni.setStorageSync('longitudeAndLatitude','116.3972,39.9096')
  372. }
  373. }else{
  374. uni.setStorageSync('fPlaceObj',{
  375. fchoosearea:'全部',
  376. fchoosecity:'市辖区',
  377. fchooseprovince:'北京',
  378. selected:'东城'
  379. })
  380. uni.setStorageSync('sPlaceObj',{
  381. schoosearea:'请选择区',
  382. schoosecity:'请选择市',
  383. schooseprovince:'全国',
  384. selected:'全国'
  385. })
  386. uni.setStorageSync('longitudeAndLatitude','116.3972,39.9096')
  387. }
  388. }
  389. });
  390. }else{
  391. this.getLngLat()
  392. }
  393. } else if (system.platform === 'ios') {
  394. // console.log("苹果");
  395. var cllocationManger = plus.ios.import("CLLocationManager");
  396. var enable = cllocationManger.locationServicesEnabled();
  397. var status = cllocationManger.authorizationStatus();
  398. plus.ios.deleteObject(cllocationManger);
  399. if (enable && status != 2) {
  400. this.getLngLat()
  401. console.log("手机系统的定位已经打开");
  402. } else {
  403. console.log("手机系统的定位没有打开");
  404. uni.showModal({
  405. title: '提示',
  406. content: '请前往设置-隐私-定位服务打开定位服务功能',
  407. // showCancel: false, // 不显示取消按钮
  408. success(res) {
  409. if(res.confirm){
  410. var UIApplication = plus.ios.import("UIApplication");
  411. var application2 = UIApplication.sharedApplication();
  412. var NSURL2 = plus.ios.import("NSURL");
  413. // var setting2 = NSURL2.URLWithString("prefs:root=LOCATION_SERVICES");
  414. // var setting2 = NSURL2.URLWithString("App-Prefs:root=LOCATION_SERVICES");
  415. // var setting2 = NSURL2.URLWithString("app-settings");
  416. var setting2 = NSURL2.URLWithString("App-Prefs:root=Privacy&path=LOCATION");
  417. // var setting2 = NSURL2.URLWithString("App-Prefs:root=Privacy&path=LOCATION_SERVICES");
  418. application2.openURL(setting2);
  419. plus.ios.deleteObject(setting2);
  420. plus.ios.deleteObject(NSURL2);
  421. plus.ios.deleteObject(application2);
  422. this.getLngLat()
  423. }
  424. }
  425. });
  426. }
  427. }
  428. },
  429. cargoOwner(_obj){
  430. // uni.$u.route('/pages/order/evaluateList');
  431. // console.log("查看---------------",_obj)
  432. uni.$u.route('/pages/goodSource/cargoOwnerSee',_obj)
  433. },
  434. mescrollInit(mescroll) {
  435. this.mescroll = mescroll;
  436. },
  437. confirmClick() {
  438. let item = this.ObjSelect
  439. var that=this
  440. this.$request.baseRequest('get', '/driverInfo/firstAuthentication', {
  441. driverPhone: this.userInfo.phone,
  442. }).then(res2 => {
  443. let _obj = {
  444. driverCommonId: res2.data.commonId,
  445. commonId: item.commonId,
  446. cargoOwnerName: item.cargoOwnerName,
  447. cargoOwner: item.cargoOwner,
  448. sendPrivate: item.sendPrivate,
  449. sendCity: item.sendCity,
  450. sendArea: item.sendArea,
  451. sendDetailedAddress: item.sendDetailedAddress,
  452. unloadPrivate: item.unloadPrivate,
  453. unloadCity: item.unloadCity,
  454. unloadArea: item.unloadArea,
  455. unloadDetailedAddress: item.unloadDetailedAddress,
  456. goodsName: item.goodsName,
  457. distance: item.distance,
  458. freightPrice: item.freightPrice,
  459. driverName: res2.data.driverName,
  460. driverPhone: res2.data.driverPhone,
  461. cargoOwnerPhone: item.cargoOwnerPhone,
  462. id:item.id,
  463. billingMethod:item.billingMethod,
  464. freightAdvance:item.freightAdvance,
  465. goodsType:item.goodsType,
  466. goodsTypeKey:item.goodsTypeKey
  467. }
  468. that.$request.baseRequest('post', '/publishTaskInfo/api/addOrder', _obj).then(res => {
  469. if (res.code == 200) {
  470. that.$refs.uToast.show({
  471. type: 'success',
  472. message: "抢单成功!",
  473. complete() {
  474. uni.switchTab({
  475. url: "/pages/order/index"
  476. })
  477. }
  478. })
  479. } else {
  480. that.$refs.uToast.show({
  481. type: 'error',
  482. message: res.message,
  483. })
  484. }
  485. })
  486. .catch(res => {
  487. uni.$u.toast(res.message);
  488. });
  489. });
  490. this.isShowAlert = false
  491. },
  492. cancelClick() {
  493. this.isShowAlert = false
  494. },
  495. carLength(good) {
  496. let length = ''
  497. if (good.carLengthSmall && good.carLength) {
  498. length = good.carLengthSmall + '~' + good.carLength + '米'
  499. } else if (good.carLengthSmall && !good.carLength) {
  500. length = "大于" + good.carLengthSmall + '米'
  501. } else if (good.carLength && !good.carLengthSmall) {
  502. length = "小于" + good.carLength + '米'
  503. }
  504. return length
  505. },
  506. carType(good) {
  507. let _val = '';
  508. if (good.carModel == 1) {
  509. _val = ''
  510. } else {
  511. if (good.carModel.includes(2)) {
  512. _val += '高栏 '
  513. }
  514. if (good.carModel.includes(3)) {
  515. _val += '集装箱 '
  516. }
  517. if (good.carModel.includes(4)) {
  518. _val += '自卸车 '
  519. }
  520. }
  521. return _val
  522. },
  523. carWeight(good) {
  524. good.loadWeightSmall
  525. good.loadWeight
  526. let weight = ''
  527. if (good.loadWeightSmall && good.loadWeight) {
  528. weight = good.loadWeightSmall + '~' + good.loadWeight + '吨'
  529. } else if (good.loadWeightSmall) {
  530. weight = "大于" + good.loadWeightSmall + '吨'
  531. } else if (good.loadWeight) {
  532. weight = "小于" + good.loadWeight + '吨'
  533. }
  534. return weight
  535. },
  536. getdate() {
  537. var date = new Date()
  538. var year = date.getFullYear() //获取完整的年份(4位)
  539. var mouth = date.getMonth() + 1 //获取当前月份(0-11,0代表1月)
  540. var datetime = date.getDate() //获取当前日(1-31)
  541. if (mouth < 10) {
  542. mouth = '0' + mouth
  543. }
  544. if (datetime < 10) {
  545. datetime = '0' + datetime
  546. }
  547. return String(year) + String(mouth) + String(datetime)
  548. },
  549. grabOrders(item) {
  550. this.isShowAlert = true
  551. this.ObjSelect = item
  552. },
  553. confirmSelectType(val) {
  554. this.pickerSelect = val.value[0]
  555. this.show = false
  556. this.upCallback({size:10,num:1})
  557. },
  558. selectTypeClose() {
  559. this.show = false
  560. },
  561. selectType() {
  562. this.show = true
  563. },
  564. // getLngLat() {
  565. // var that=this
  566. // // uni.showLoading({
  567. // // title: '获取定位信息'
  568. // // })
  569. // uni.getLocation({
  570. // type: 'gcj02',
  571. // geocode: true,
  572. // success: res => {
  573. // if (res.latitude) {
  574. // console.log(res)
  575. // if(res.address.city){
  576. // if(res.address.city.indexOf('市')!=-1){
  577. // res.address.city=res.address.city.substring(0,res.address.city.length-1)
  578. // }
  579. // }
  580. // if(res.address.province){
  581. // if(res.address.province.indexOf('省')!=-1){
  582. // res.address.province=res.address.province.substring(0,res.address.province.length-1)
  583. // }
  584. // }
  585. // uni.setStorageSync('fPlaceObj',{
  586. // fchoosearea:'全部',
  587. // fchoosecity:res.address.city,
  588. // fchooseprovince:res.address.province,
  589. // selected:res.address.city
  590. // })
  591. // uni.setStorageSync('sPlaceObj',{
  592. // schoosearea:'请选择区',
  593. // schoosecity:'请选择市',
  594. // schooseprovince:'全国',
  595. // selected:'全国'
  596. // })
  597. // let _pickerSelect;
  598. // if (that.pickerSelect == '运费先付') {
  599. // _pickerSelect = 1
  600. // } else {
  601. // _pickerSelect = 0
  602. // }
  603. // that.startPlace.selected=res.address.city
  604. // that.startPlace.fchoosecity=res.address.city
  605. // let _data = {
  606. // searchKeyWord: this.tabIndex + 1,
  607. // searchType: _pickerSelect,
  608. // pageSize: 10,
  609. // currentPage: 1,
  610. // loadingPlaceCity: that.startPlace.fchoosecity,
  611. // // unLoadingPlaceCity: this.endPlace.schoosecity
  612. // }
  613. // that.$forceUpdate()
  614. // // that.$set(that.startPlace,'selected',res.address.city)
  615. // // that.lng = res.longitude;
  616. // // that.lat = res.latitude;
  617. // that.$request.baseRequest('get', '/publishTaskInfo/selectGoodsSource', _data).then(res => {
  618. // if (res.code == 200) {
  619. // console.log(res.data.records)
  620. // uni.hideLoading()
  621. // that.mescroll.endBySize(res.data.records.length, res.data.total);
  622. // if(res.data.records){
  623. // that.goods = res.data.records
  624. // for (let i = 0; i < that.goods.length; i++) {
  625. // if (that.goods[i].peripheralInfo == 1) {
  626. // that.isFirstIndex = i
  627. // return
  628. // }
  629. // }
  630. // }else{
  631. // that.goods=[]
  632. // }
  633. // }
  634. // uni.hideLoading()
  635. // })
  636. // .catch(res => {
  637. // uni.$u.toast(res.message);
  638. // that.mescroll.endErr();
  639. // });
  640. // } else {
  641. // if (uni.getSystemInfoSync().platform == 'android') {
  642. // var context = plus.android.importClass("android.content.Context");
  643. // var locationManager = plus.android.importClass(
  644. // "android.location.LocationManager");
  645. // var main = plus.android.runtimeMainActivity();
  646. // var mainSvr = main.getSystemService(context.LOCATION_SERVICE);
  647. // that.bool = mainSvr.isProviderEnabled(locationManager.GPS_PROVIDER)
  648. // }
  649. // if (that.bool === false) {
  650. // uni.showModal({
  651. // title: '提示',
  652. // content: '请打开定位服务',
  653. // success: ({
  654. // confirm,
  655. // cancel
  656. // }) => {
  657. // if (confirm) {
  658. // if (uni.getSystemInfoSync().platform == 'android') {
  659. // var Intent = plus.android.importClass(
  660. // 'android.content.Intent');
  661. // var Settings = plus.android.importClass(
  662. // 'android.provider.Settings');
  663. // var intent = new Intent(Settings
  664. // .ACTION_LOCATION_SOURCE_SETTINGS);
  665. // var main = plus.android.runtimeMainActivity();
  666. // main.startActivity(intent); // 打开系统设置GPS服务页面
  667. // }
  668. // }
  669. // }
  670. // });
  671. // }
  672. // uni.hideLoading()
  673. // }
  674. // }
  675. // });
  676. // },
  677. toDetail(id) {
  678. var that=this
  679. that.$request.baseRequest('get', '/driverInfo/firstAuthentication', {
  680. driverPhone: this.userInfo.phone,
  681. }).then(res2 => {
  682. // console.log('跳转',1111111)
  683. uni.setStorageSync('firstAuthentication', res2.data)
  684. that.firstAuthentication=uni.getStorageSync('firstAuthentication')
  685. // console.log(that.firstAuthentication)
  686. //司机是否认证身份
  687. // 保留uni.getStorageSync('firstAuthentication'),thisfirstAuthentication有缓存问题
  688. if (uni.getStorageSync('firstAuthentication').authenticationStatus == '已认证') {
  689. uni.$u.route('/pages/goodSource/shippingDetails', {
  690. id: id,
  691. });
  692. } else if (uni.getStorageSync('firstAuthentication').authenticationStatus == '已过期') {
  693. that.$refs.uToast.show({
  694. type: 'error',
  695. message: "证件已过期,请上传新证件!",
  696. })
  697. } else {
  698. that.$refs.uToast.show({
  699. type: 'error',
  700. message: "请先完成司机认证!",
  701. })
  702. }
  703. })
  704. },
  705. /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
  706. upCallback(page) {
  707. var that =this
  708. let _pickerSelect;
  709. if (this.pickerSelect == '运费先付') {
  710. _pickerSelect = 1
  711. } else {
  712. _pickerSelect = 0
  713. }
  714. //选择省市区
  715. let _data = {
  716. searchKeyWord: this.tabIndex + 1,
  717. searchType: _pickerSelect,
  718. // loadingPlace: this.startPlace.selected,
  719. // unLoadingPlace: this.endPlace.selected=="全国"?'':this.endPlace.selected,
  720. pageSize: page.size,
  721. currentPage: page.num,
  722. // loadingPlaceCity: this.startPlace.fchoosecity,
  723. // unLoadingPlaceCity: this.endPlace.schoosecity
  724. }
  725. console.log(uni.getStorageSync('longitudeAndLatitude'))
  726. // if (this.tabIndex == 2) {
  727. if(uni.getStorageSync('longitudeAndLatitude')){
  728. this.lng=uni.getStorageSync('longitudeAndLatitude').split(',')[0]
  729. this.lat=uni.getStorageSync('longitudeAndLatitude').split(',')[1]
  730. }
  731. _data.driverLongitude = this.lng
  732. _data.driverLatitude = this.lat
  733. // }
  734. console.log('------')
  735. console.log(_data)
  736. if (uni.getStorageSync('fPlaceObj')) {
  737. if (this.startPlace.fchoosearea && this.startPlace.fchoosearea == '全部' && this.startPlace
  738. .fchoosearea != '请选择区') {
  739. // _data.loadingPlaceCity = this.startPlace.fchoosecity
  740. if(this.startPlace.fchoosecity=='市辖区'){
  741. _data.loadingPlaceCity = this.startPlace.fchooseprovince
  742. }else{
  743. _data.loadingPlaceCity = this.startPlace.fchoosecity
  744. }
  745. } else if (this.startPlace.fchoosecity == '全部') {
  746. _data.loadingPlace = this.startPlace.selected
  747. } else {
  748. _data.loadingPlaceCity = this.startPlace.fchoosecity
  749. _data.loadingPlace = this.startPlace.fchoosearea
  750. }
  751. } else {
  752. _data.loadingPlaceCity = this.startPlace.fchoosecity
  753. }
  754. if (uni.getStorageSync('sPlaceObj')) {
  755. if (this.endPlace.schoosearea && this.endPlace.schoosearea == '全部' && this.endPlace.schoosearea !=
  756. '请选择区') {
  757. if(this.endPlace.schoosecity=='市辖区'){
  758. _data.unLoadingPlaceCity = this.endPlace.schooseprovince
  759. }else{
  760. _data.unLoadingPlaceCity = this.endPlace.schoosecity
  761. }
  762. } else if (this.endPlace.schoosearea) {
  763. _data.unLoadingPlace = this.endPlace.selected == "全国" ? '' : this.endPlace.selected
  764. } else {
  765. _data.unLoadingPlace = this.endPlace.selected == "全国" ? '' : this.endPlace.selected
  766. _data.unLoadingPlaceCity = this.endPlace.schoosecity
  767. }
  768. } else {
  769. _data.unLoadingPlace = this.endPlace.selected == "全国" ? '' : this.endPlace.selected
  770. }
  771. if (this.lng) {
  772. _data.longitude = this.lng
  773. _data.latitude = this.lat
  774. }
  775. uni.showLoading({
  776. mask: true,
  777. title: '加载中'
  778. })
  779. console.log(_data)
  780. this.$request.baseRequest('get', '/publishTaskInfo/selectGoodsSource', _data).then(res => {
  781. if (res.code == 200) {
  782. uni.hideLoading()
  783. if (page.num == 1) {
  784. this.goods = [];
  785. // this.otherGoods = []
  786. };
  787. if(res.data.records){
  788. for(var i=0;i<res.data.records.length;i++){
  789. if(res.data.records[i].cargoDistance){
  790. if(res.data.records[i].cargoDistance>10){
  791. res.data.records[i].cargoDistance=res.data.records[i].cargoDistance.toFixed(0)
  792. }else{
  793. res.data.records[i].cargoDistance=res.data.records[i].cargoDistance.toFixed(1)
  794. }
  795. }
  796. if(res.data.records[i].distance){
  797. if(res.data.records[i].distance>10){
  798. res.data.records[i].distance=res.data.records[i].distance.toFixed(0)
  799. }else{
  800. res.data.records[i].distance=res.data.records[i].distance.toFixed(1)
  801. }
  802. }
  803. }
  804. }
  805. this.mescroll.endBySize(res.data.records.length, res.data.total);
  806. // for (var i = 0; i < res.data.records.length; i++) {
  807. // res.data.records[i].cargoOwnerName1=
  808. // }
  809. //如果是第一页需手动制空列表
  810. if(res.data.records){
  811. that.goods = that.goods.concat(res.data.records);
  812. for (let i = 0; i < that.goods.length; i++) {
  813. if (that.goods[i].peripheralInfo == 1) {
  814. that.isFirstIndex = i
  815. return
  816. }
  817. }
  818. }else{
  819. that.goods=[]
  820. }
  821. }
  822. })
  823. .catch(res => {
  824. uni.$u.toast(res.message);
  825. this.mescroll.endErr();
  826. });
  827. },
  828. clickTab(val) {
  829. this.tabIndex = val.index
  830. this.upCallback({
  831. size: 10,
  832. num: 1,
  833. })
  834. },
  835. changeCity() {
  836. if (this.endPlace.selected == '全国') {
  837. this.$refs.uToast.show({
  838. type: 'error',
  839. message: "装车地不能为全国!",
  840. })
  841. return
  842. }
  843. [this.startPlace.fchooseprovince, this.endPlace.schooseprovince] = [this.endPlace.schooseprovince, this
  844. .startPlace.fchooseprovince
  845. ];
  846. [this.startPlace.fchoosecity, this.endPlace.schoosecity] = [this.endPlace.schoosecity, this.startPlace
  847. .fchoosecity
  848. ];
  849. [this.startPlace.fchoosearea, this.endPlace.schoosearea] = [this.endPlace.schoosearea, this.startPlace
  850. .fchoosearea
  851. ];
  852. [this.startPlace.selected, this.endPlace.selected] = [this.endPlace.selected, this.startPlace.selected];
  853. // [this.startPlace, this.endPlace] = [this.endPlace, this.startPlace];
  854. uni.setStorageSync('fPlaceObj', this.startPlace);
  855. uni.setStorageSync('sPlaceObj', this.endPlace);
  856. },
  857. goCity(type) {
  858. uni.$u.route('/pages/goodSource/selectCity', {
  859. startPlace: JSON.stringify(this.startPlace),
  860. endPlace: JSON.stringify(this.endPlace),
  861. type: type
  862. });
  863. },
  864. swiperChange(e) {
  865. this.tabIndex = e.detail.current
  866. }
  867. }
  868. }
  869. </script>
  870. <style scoped lang="scss">
  871. .content {
  872. background: #F2F4F7;
  873. }
  874. .banner {
  875. width: 100%;
  876. position: relative;
  877. }
  878. .u-flex-wrap{
  879. flex-wrap: wrap;
  880. }
  881. .fixed,
  882. .fixed1 {
  883. background: linear-gradient(97deg, #4FABFD 0%, #2772FB 100%);
  884. position: fixed;
  885. top: var(--status-bar-height);
  886. z-index: 999;
  887. // width: calc(100% - 40rpx);
  888. width: 100%;
  889. // margin:0 20rpx;
  890. }
  891. .fixed1 {
  892. top: 0;
  893. height: var(--status-bar-height);
  894. background: linear-gradient(97deg, #4FABFD 0%, #2772FB 100%);
  895. }
  896. .banner-img {
  897. width: 100%;
  898. }
  899. .head {
  900. position: absolute;
  901. width: calc(100% - 108rpx);
  902. bottom: 0;
  903. background: white;
  904. margin: 0 20rpx;
  905. border-radius: 20rpx;
  906. .item1,
  907. .item3 {
  908. width: 40%;
  909. .text {
  910. text-overflow: ellipsis;
  911. overflow: hidden;
  912. white-space: nowrap;
  913. }
  914. }
  915. .item1 .text {
  916. text-align: left;
  917. }
  918. .item3 .text {
  919. text-align: right;
  920. }
  921. }
  922. .change-btn {
  923. width: 86rpx;
  924. height: 86rpx;
  925. }
  926. .good-list {
  927. background-color: white;
  928. margin: 10px 10px 15px 10px;
  929. padding: 10px 0px 0px 0;
  930. border-radius: 30rpx;
  931. box-shadow: 0px 5rpx 20rpx #E3E3E3;
  932. .item1,
  933. .item3 {
  934. // width: 40%;
  935. display: flex;
  936. .text {
  937. text-overflow: ellipsis;
  938. overflow: hidden;
  939. white-space: nowrap;
  940. }
  941. }
  942. .item1 .text {
  943. text-align: left;
  944. }
  945. .item3 .text {
  946. text-align: right;
  947. }
  948. }
  949. .jt-icon {
  950. position: relative;
  951. top: 6rpx;
  952. width: 60rpx;
  953. margin: 0 20rpx;
  954. }
  955. .row {
  956. margin: 10rpx 0;
  957. align-items: center;
  958. }
  959. .item-bottom {
  960. background: #F0F5FF;
  961. padding: 0 30rpx;
  962. border-radius: 0 0 30rpx 30rpx;
  963. .name {
  964. font-size: 26rpx;
  965. font-weight: 700;
  966. color: #000000;
  967. margin-left: 30rpx;
  968. }
  969. .hp {
  970. margin: 30rpx;
  971. }
  972. .number-color {
  973. margin: 0 10rpx;
  974. }
  975. .qd {
  976. background: linear-gradient(97deg, #4FABFD 0%, #2772FB 100%);
  977. border-radius: 13px;
  978. font-size: 29rpx;
  979. font-weight: 400;
  980. color: #FFFFFF;
  981. padding: 10rpx 35rpx;
  982. }
  983. }
  984. .dw {
  985. align-items: center;
  986. }
  987. .place {
  988. height: var(--status-bar-height);
  989. }
  990. .tab-view {
  991. display: flex;
  992. align-items: center;
  993. justify-content: space-between;
  994. }
  995. .tab-right {
  996. display: flex;
  997. margin-right: 20rpx;
  998. align-items: center;
  999. }
  1000. .other-goods {
  1001. // background: red;
  1002. color:#999999;
  1003. margin: 40rpx 0;
  1004. display: flex;
  1005. justify-content: center;
  1006. font-size: 36rpx;
  1007. }
  1008. .level2-title {
  1009. font-size: 28rpx;
  1010. }
  1011. .yf-style {
  1012. position: relative;
  1013. .h-color {
  1014. position: absolute;
  1015. right: 0;
  1016. top: -30rpx;
  1017. }
  1018. }
  1019. .xf-iamge {
  1020. width: 74rpx;
  1021. height: 43rpx;
  1022. position: absolute;
  1023. top: -20rpx;
  1024. right: 0;
  1025. }
  1026. </style>