index.vue 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083
  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. if (that.firstAuthentication.authenticationStatus == '已认证') {
  688. uni.$u.route('/pages/goodSource/shippingDetails', {
  689. id: id,
  690. });
  691. } else if (that.firstAuthentication.authenticationStatus == '已过期') {
  692. that.$refs.uToast.show({
  693. type: 'error',
  694. message: "证件已过期,请上传新证件!",
  695. })
  696. } else {
  697. that.$refs.uToast.show({
  698. type: 'error',
  699. message: "请先完成司机认证!",
  700. })
  701. }
  702. })
  703. },
  704. /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
  705. upCallback(page) {
  706. var that =this
  707. let _pickerSelect;
  708. if (this.pickerSelect == '运费先付') {
  709. _pickerSelect = 1
  710. } else {
  711. _pickerSelect = 0
  712. }
  713. //选择省市区
  714. let _data = {
  715. searchKeyWord: this.tabIndex + 1,
  716. searchType: _pickerSelect,
  717. // loadingPlace: this.startPlace.selected,
  718. // unLoadingPlace: this.endPlace.selected=="全国"?'':this.endPlace.selected,
  719. pageSize: page.size,
  720. currentPage: page.num,
  721. // loadingPlaceCity: this.startPlace.fchoosecity,
  722. // unLoadingPlaceCity: this.endPlace.schoosecity
  723. }
  724. console.log(uni.getStorageSync('longitudeAndLatitude'))
  725. // if (this.tabIndex == 2) {
  726. if(uni.getStorageSync('longitudeAndLatitude')){
  727. this.lng=uni.getStorageSync('longitudeAndLatitude').split(',')[0]
  728. this.lat=uni.getStorageSync('longitudeAndLatitude').split(',')[1]
  729. }
  730. _data.driverLongitude = this.lng
  731. _data.driverLatitude = this.lat
  732. // }
  733. console.log('------')
  734. console.log(_data)
  735. if (uni.getStorageSync('fPlaceObj')) {
  736. if (this.startPlace.fchoosearea && this.startPlace.fchoosearea == '全部' && this.startPlace
  737. .fchoosearea != '请选择区') {
  738. // _data.loadingPlaceCity = this.startPlace.fchoosecity
  739. if(this.startPlace.fchoosecity=='市辖区'){
  740. _data.loadingPlaceCity = this.startPlace.fchooseprovince
  741. }else{
  742. _data.loadingPlaceCity = this.startPlace.fchoosecity
  743. }
  744. } else if (this.startPlace.fchoosecity == '全部') {
  745. _data.loadingPlace = this.startPlace.selected
  746. } else {
  747. _data.loadingPlaceCity = this.startPlace.fchoosecity
  748. _data.loadingPlace = this.startPlace.fchoosearea
  749. }
  750. } else {
  751. _data.loadingPlaceCity = this.startPlace.fchoosecity
  752. }
  753. if (uni.getStorageSync('sPlaceObj')) {
  754. if (this.endPlace.schoosearea && this.endPlace.schoosearea == '全部' && this.endPlace.schoosearea !=
  755. '请选择区') {
  756. if(this.endPlace.schoosecity=='市辖区'){
  757. _data.unLoadingPlaceCity = this.endPlace.schooseprovince
  758. }else{
  759. _data.unLoadingPlaceCity = this.endPlace.schoosecity
  760. }
  761. } else if (this.endPlace.schoosearea) {
  762. _data.unLoadingPlace = this.endPlace.selected == "全国" ? '' : this.endPlace.selected
  763. } else {
  764. _data.unLoadingPlace = this.endPlace.selected == "全国" ? '' : this.endPlace.selected
  765. _data.unLoadingPlaceCity = this.endPlace.schoosecity
  766. }
  767. } else {
  768. _data.unLoadingPlace = this.endPlace.selected == "全国" ? '' : this.endPlace.selected
  769. }
  770. if (this.lng) {
  771. _data.longitude = this.lng
  772. _data.latitude = this.lat
  773. }
  774. uni.showLoading({
  775. mask: true,
  776. title: '加载中'
  777. })
  778. console.log(_data)
  779. this.$request.baseRequest('get', '/publishTaskInfo/selectGoodsSource', _data).then(res => {
  780. if (res.code == 200) {
  781. uni.hideLoading()
  782. if (page.num == 1) {
  783. this.goods = [];
  784. // this.otherGoods = []
  785. };
  786. if(res.data.records){
  787. for(var i=0;i<res.data.records.length;i++){
  788. if(res.data.records[i].cargoDistance){
  789. if(res.data.records[i].cargoDistance>10){
  790. res.data.records[i].cargoDistance=res.data.records[i].cargoDistance.toFixed(0)
  791. }else{
  792. res.data.records[i].cargoDistance=res.data.records[i].cargoDistance.toFixed(1)
  793. }
  794. }
  795. if(res.data.records[i].distance){
  796. if(res.data.records[i].distance>10){
  797. res.data.records[i].distance=res.data.records[i].distance.toFixed(0)
  798. }else{
  799. res.data.records[i].distance=res.data.records[i].distance.toFixed(1)
  800. }
  801. }
  802. }
  803. }
  804. this.mescroll.endBySize(res.data.records.length, res.data.total);
  805. // for (var i = 0; i < res.data.records.length; i++) {
  806. // res.data.records[i].cargoOwnerName1=
  807. // }
  808. //如果是第一页需手动制空列表
  809. if(res.data.records){
  810. that.goods = that.goods.concat(res.data.records);
  811. for (let i = 0; i < that.goods.length; i++) {
  812. if (that.goods[i].peripheralInfo == 1) {
  813. that.isFirstIndex = i
  814. return
  815. }
  816. }
  817. }else{
  818. that.goods=[]
  819. }
  820. }
  821. })
  822. .catch(res => {
  823. uni.$u.toast(res.message);
  824. this.mescroll.endErr();
  825. });
  826. },
  827. clickTab(val) {
  828. this.tabIndex = val.index
  829. this.upCallback({
  830. size: 10,
  831. num: 1,
  832. })
  833. },
  834. changeCity() {
  835. if (this.endPlace.selected == '全国') {
  836. this.$refs.uToast.show({
  837. type: 'error',
  838. message: "装车地不能为全国!",
  839. })
  840. return
  841. }
  842. [this.startPlace.fchooseprovince, this.endPlace.schooseprovince] = [this.endPlace.schooseprovince, this
  843. .startPlace.fchooseprovince
  844. ];
  845. [this.startPlace.fchoosecity, this.endPlace.schoosecity] = [this.endPlace.schoosecity, this.startPlace
  846. .fchoosecity
  847. ];
  848. [this.startPlace.fchoosearea, this.endPlace.schoosearea] = [this.endPlace.schoosearea, this.startPlace
  849. .fchoosearea
  850. ];
  851. [this.startPlace.selected, this.endPlace.selected] = [this.endPlace.selected, this.startPlace.selected];
  852. // [this.startPlace, this.endPlace] = [this.endPlace, this.startPlace];
  853. uni.setStorageSync('fPlaceObj', this.startPlace);
  854. uni.setStorageSync('sPlaceObj', this.endPlace);
  855. },
  856. goCity(type) {
  857. uni.$u.route('/pages/goodSource/selectCity', {
  858. startPlace: JSON.stringify(this.startPlace),
  859. endPlace: JSON.stringify(this.endPlace),
  860. type: type
  861. });
  862. },
  863. swiperChange(e) {
  864. this.tabIndex = e.detail.current
  865. }
  866. }
  867. }
  868. </script>
  869. <style scoped lang="scss">
  870. .content {
  871. background: #F2F4F7;
  872. }
  873. .banner {
  874. width: 100%;
  875. position: relative;
  876. }
  877. .u-flex-wrap{
  878. flex-wrap: wrap;
  879. }
  880. .fixed,
  881. .fixed1 {
  882. background: linear-gradient(97deg, #4FABFD 0%, #2772FB 100%);
  883. position: fixed;
  884. top: var(--status-bar-height);
  885. z-index: 999;
  886. // width: calc(100% - 40rpx);
  887. width: 100%;
  888. // margin:0 20rpx;
  889. }
  890. .fixed1 {
  891. top: 0;
  892. height: var(--status-bar-height);
  893. background: linear-gradient(97deg, #4FABFD 0%, #2772FB 100%);
  894. }
  895. .banner-img {
  896. width: 100%;
  897. }
  898. .head {
  899. position: absolute;
  900. width: calc(100% - 108rpx);
  901. bottom: 0;
  902. background: white;
  903. margin: 0 20rpx;
  904. border-radius: 20rpx;
  905. .item1,
  906. .item3 {
  907. width: 40%;
  908. .text {
  909. text-overflow: ellipsis;
  910. overflow: hidden;
  911. white-space: nowrap;
  912. }
  913. }
  914. .item1 .text {
  915. text-align: left;
  916. }
  917. .item3 .text {
  918. text-align: right;
  919. }
  920. }
  921. .change-btn {
  922. width: 86rpx;
  923. height: 86rpx;
  924. }
  925. .good-list {
  926. background-color: white;
  927. margin: 10px 10px 15px 10px;
  928. padding: 10px 0px 0px 0;
  929. border-radius: 30rpx;
  930. box-shadow: 0px 5rpx 20rpx #E3E3E3;
  931. .item1,
  932. .item3 {
  933. // width: 40%;
  934. display: flex;
  935. .text {
  936. text-overflow: ellipsis;
  937. overflow: hidden;
  938. white-space: nowrap;
  939. }
  940. }
  941. .item1 .text {
  942. text-align: left;
  943. }
  944. .item3 .text {
  945. text-align: right;
  946. }
  947. }
  948. .jt-icon {
  949. position: relative;
  950. top: 6rpx;
  951. width: 60rpx;
  952. margin: 0 20rpx;
  953. }
  954. .row {
  955. margin: 10rpx 0;
  956. align-items: center;
  957. }
  958. .item-bottom {
  959. background: #F0F5FF;
  960. padding: 0 30rpx;
  961. border-radius: 0 0 30rpx 30rpx;
  962. .name {
  963. font-size: 26rpx;
  964. font-weight: 700;
  965. color: #000000;
  966. margin-left: 30rpx;
  967. }
  968. .hp {
  969. margin: 30rpx;
  970. }
  971. .number-color {
  972. margin: 0 10rpx;
  973. }
  974. .qd {
  975. background: linear-gradient(97deg, #4FABFD 0%, #2772FB 100%);
  976. border-radius: 13px;
  977. font-size: 29rpx;
  978. font-weight: 400;
  979. color: #FFFFFF;
  980. padding: 10rpx 35rpx;
  981. }
  982. }
  983. .dw {
  984. align-items: center;
  985. }
  986. .place {
  987. height: var(--status-bar-height);
  988. }
  989. .tab-view {
  990. display: flex;
  991. align-items: center;
  992. justify-content: space-between;
  993. }
  994. .tab-right {
  995. display: flex;
  996. margin-right: 20rpx;
  997. align-items: center;
  998. }
  999. .other-goods {
  1000. // background: red;
  1001. color:#999999;
  1002. margin: 40rpx 0;
  1003. display: flex;
  1004. justify-content: center;
  1005. font-size: 36rpx;
  1006. }
  1007. .level2-title {
  1008. font-size: 28rpx;
  1009. }
  1010. .yf-style {
  1011. position: relative;
  1012. .h-color {
  1013. position: absolute;
  1014. right: 0;
  1015. top: -30rpx;
  1016. }
  1017. }
  1018. .xf-iamge {
  1019. width: 74rpx;
  1020. height: 43rpx;
  1021. position: absolute;
  1022. top: -20rpx;
  1023. right: 0;
  1024. }
  1025. </style>