index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  1. <!-- 货源 -->
  2. <template>
  3. <view class="content">
  4. <view class="banner">
  5. <image class="banner-img" src="@/static/images/goodSource/banner@2x.png" mode='widthFix'></image>
  6. <view class="head flex s-row paddingr35">
  7. <view class="flex flex-space-between">
  8. <view class="flex s-row item1">
  9. <view class="fontsize-28 gray">装车</view>
  10. <view class="fontsize-46 fontweight-500 text" @click="goCity(0)">{{startPlace}}</view>
  11. </view>
  12. <image class="change-btn item2" src="@/static/images/goodSource/change.png" mode='widthFix'
  13. @click="changeCity"></image>
  14. <view class="flex s-row item3">
  15. <view class="fontsize-28 gray text-align-right">卸车</view>
  16. <view class="fontsize-46 fontweight-500 text" @click="goCity(1)">{{endPlace}}</view>
  17. </view>
  18. </view>
  19. <view>
  20. <u-button type="" class="btn-color fontsize-36 m-top20"> 查询</u-button>
  21. </view>
  22. </view>
  23. </view>
  24. <view :class="scrollTop>1200?'fixed1':''"></view>
  25. <u-tabs :list="tabList" @click="clickTab" :lineColor="scrollTop>1200?'white':'#303133'" :current='tabIndex'
  26. :inactiveStyle="{color: scrollTop>1200?'white':'',}" :activeStyle="{
  27. color: scrollTop>1200?'white':'',
  28. fontWeight: 'bold',
  29. transform: 'scale(1.05)'
  30. }" :class="scrollTop>1200?'fixed':''"></u-tabs>
  31. <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback">
  32. <view :id="'good'+good.id" class="good-list" v-for="good in goods" :key="good.id"
  33. @click="toDetail(good.id)">
  34. <view style="padding: 0 35rpx 20rpx 35rpx;">
  35. <view class="flex flex-space-between">
  36. <view class="left flex flex-space-between">
  37. <view class="ssx">辽</view>
  38. <view class="level2-title">营口 鲅鱼圈</view>
  39. <view>
  40. <image class="jt-icon" src="@/static/images/goodSource/jt.png" mode='widthFix'></image>
  41. </view>
  42. <view class="ssx">
  43. </view>
  44. <view class="level2-title">北京 通州</view>
  45. </view>
  46. <view class="right gray">
  47. 01.10
  48. </view>
  49. </view>
  50. <view class="flex flex-space-between">
  51. <view class="left">
  52. <view class="flex">
  53. <view class="fontsize-25 gray mr20">货距 10km</view>
  54. <view class="fontsize-25 gray ">运距 35km</view>
  55. </view>
  56. <view class="flex fontsize-25 gray row">
  57. <view>玉米 | </view>
  58. <view>3.8-5米 | </view>
  59. <view>厢式/平板/高栏 | </view>
  60. <view>10吨</view>
  61. </view>
  62. <view class="flex row">
  63. <view class="row-tips">运输过程中其他费用,发货方承担。</view>
  64. </view>
  65. </view>
  66. <view class="right flex h-color">
  67. <view class="fontsize-46">
  68. 300
  69. </view>
  70. <view class="flex dw">元/吨</view>
  71. </view>
  72. </view>
  73. </view>
  74. <view class="flex flex-space-between item-bottom">
  75. <view class="left flex row">
  76. <u--image :showLoading="true" :src="good.goodImg" width="70rpx" height="70rpx" shape="circle">
  77. </u--image>
  78. <view class="name">张颖</view>
  79. <view class="hp flex fontsize-24">
  80. <view class="gray">评分</view>
  81. <view class="number-color">99%</view>
  82. </view>
  83. <view class="sum flex fontsize-24">
  84. <view class="gray">发运次数</view>
  85. <view class="number-color">106</view>
  86. </view>
  87. </view>
  88. <view class="right">
  89. <view @click.stop="grabOrders(good.id)" class="qd">抢单</view>
  90. </view>
  91. </view>
  92. </view>
  93. </mescroll-body>
  94. <u-toast ref="uToast"></u-toast>
  95. </view>
  96. </template>
  97. <script>
  98. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  99. import {
  100. apiGoods
  101. } from "@/api/mock.js"
  102. export default {
  103. mixins: [MescrollMixin], // 使用mixin
  104. data() {
  105. return {
  106. startPlace: '齐齐哈尔',
  107. endPlace: '全国',
  108. goods: [], // 数据列表
  109. src: 'https://cdn.uviewui.com/uview/album/1.jpg',
  110. height: "", // 需要固定swiper的高度
  111. tabList: [{
  112. name: '全部'
  113. }, {
  114. name: '推荐'
  115. }, {
  116. name: '按时间'
  117. }, {
  118. name: '按距离'
  119. }, {
  120. name: '运费先付'
  121. }],
  122. tabIndex: 0,
  123. scrollTop: 0
  124. }
  125. },
  126. onTabItemTap(e) {
  127. // tab 点击时执行,此处直接接收单击事件
  128. uni.pageScrollTo({
  129. scrollTop: 0,
  130. duration: 300
  131. });
  132. console.log(e)
  133. },
  134. created() {
  135. },
  136. onLoad() {
  137. //#ifdef APP-PLUS
  138. this.getLngLat();
  139. //#endif
  140. // let _isHave = this.$utils.getRoles('aaa')
  141. // console.log(_isHave)
  142. // var Ip=returnCitySN['cip']
  143. // var cityname=returnCitySN['cname']
  144. // localStorage.setItem('Ip', Ip)
  145. // console.log(localStorage.getItem('Ip', Ip))
  146. // localStorage.setItem('cityname', cityname)
  147. // console.log(localStorage.getItem('cityname', cityname))
  148. },
  149. onPageScroll(res) {
  150. this.scrollTop = res.scrollTop
  151. console.log("页面滚动了", res.scrollTop)
  152. if (this.scrollTop > 1200) {
  153. uni.setTabBarItem({
  154. index: 0,
  155. text: '返回顶部',
  156. iconPath: 'static/images/common/top@2x.png',
  157. selectedIconPath: 'static/images/common/top@2x.png'
  158. })
  159. } else {
  160. uni.setTabBarItem({
  161. index: 0,
  162. text: '货源',
  163. iconPath: 'static/images/common/huoyuan@2x(1).png',
  164. selectedIconPath: 'static/images/common/huoyuan@2x.png'
  165. })
  166. }
  167. },
  168. methods: {
  169. getLngLat() {
  170. console.log(11111111111111111111111111111111111111111111111111111)
  171. uni.getLocation({
  172. type: 'gcj02',
  173. geocode: true,
  174. success: res => {
  175. console.log('--------------------------------')
  176. console.log(res)
  177. if (res.latitude) {
  178. this.lat = res.latitude + ',' + res.longitude;
  179. this.startPlace = res.address.city
  180. // this.lng = res.longitude;
  181. } else {
  182. console.log(uni.getSystemInfoSync().platform)
  183. if (uni.getSystemInfoSync().platform == 'android') {
  184. var context = plus.android.importClass("android.content.Context");
  185. var locationManager = plus.android.importClass(
  186. "android.location.LocationManager");
  187. var main = plus.android.runtimeMainActivity();
  188. var mainSvr = main.getSystemService(context.LOCATION_SERVICE);
  189. this.bool = mainSvr.isProviderEnabled(locationManager.GPS_PROVIDER)
  190. }
  191. if (this.bool === false) {
  192. uni.showModal({
  193. title: '提示',
  194. content: '请打开定位服务',
  195. success: ({
  196. confirm,
  197. cancel
  198. }) => {
  199. if (confirm) {
  200. if (uni.getSystemInfoSync().platform == 'android') {
  201. var Intent = plus.android.importClass(
  202. 'android.content.Intent');
  203. var Settings = plus.android.importClass(
  204. 'android.provider.Settings');
  205. var intent = new Intent(Settings
  206. .ACTION_LOCATION_SOURCE_SETTINGS);
  207. var main = plus.android.runtimeMainActivity();
  208. main.startActivity(intent); // 打开系统设置GPS服务页面
  209. }
  210. }
  211. }
  212. });
  213. }
  214. }
  215. }
  216. });
  217. },
  218. toDetail(id) {
  219. uni.$u.route('/pages/goodSource/shippingDetails', {
  220. id: id,
  221. });
  222. },
  223. /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
  224. upCallback(page) {
  225. // 此处可以继续请求其他接口
  226. // if(page.num == 1){
  227. // // 请求其他接口...
  228. // }
  229. // 如果希望先请求其他接口,再触发upCallback,可参考以下写法
  230. // if(!this.isInitxx){
  231. // apiGetxx().then(res=>{
  232. // this.isInitxx = true
  233. // this.mescroll.resetUpScroll() // 重新触发upCallback
  234. // }).catch(()=>{
  235. // this.mescroll.endErr()
  236. // })
  237. // return // 此处return,先获取xx
  238. // }
  239. //联网加载数据
  240. apiGoods(page.num, page.size).then(res => {
  241. //联网成功的回调,隐藏下拉刷新和上拉加载的状态;
  242. //mescroll会根据传的参数,自动判断列表如果无任何数据,则提示空;列表无下一页数据,则提示无更多数据;
  243. //方法一(推荐): 后台接口有返回列表的总页数 totalPage
  244. //this.mescroll.endByPage(res.list.length, totalPage); //必传参数(当前页的数据个数, 总页数)
  245. //方法二(推荐): 后台接口有返回列表的总数据量 totalSize
  246. //this.mescroll.endBySize(res.list.length, totalSize); //必传参数(当前页的数据个数, 总数据量)
  247. //方法三(推荐): 您有其他方式知道是否有下一页 hasNext
  248. //this.mescroll.endSuccess(res.list.length, hasNext); //必传参数(当前页的数据个数, 是否有下一页true/false)
  249. //方法四 (不推荐),会存在一个小问题:比如列表共有20条数据,每页加载10条,共2页.如果只根据当前页的数据个数判断,则需翻到第三页才会知道无更多数据
  250. this.mescroll.endSuccess(res.list.length);
  251. //设置列表数据
  252. if (page.num == 1) this.goods = []; //如果是第一页需手动制空列表
  253. this.goods = this.goods.concat(res.list); //追加新数据
  254. }).catch(() => {
  255. //联网失败, 结束加载
  256. this.mescroll.endErr();
  257. })
  258. },
  259. clickTab(val) {
  260. console.log(val)
  261. },
  262. changeCity() {
  263. if(this.endPlace=='全国') {
  264. this.$refs.uToast.show({
  265. type: 'error',
  266. message: "卸车地为全国不允许切换!",
  267. })
  268. return
  269. }
  270. [this.startPlace, this.endPlace] = [this.endPlace, this.startPlace];
  271. },
  272. goCity(type) {
  273. uni.$u.route('/pages/goodSource/selectCity', {
  274. startPlace: this.startPlace,
  275. endPlace: this.endPlace,
  276. type: type
  277. });
  278. console.log(type)
  279. },
  280. swiperChange(e) {
  281. this.tabIndex = e.detail.current
  282. }
  283. }
  284. }
  285. </script>
  286. <style scoped lang="scss">
  287. .banner {
  288. width: 100%;
  289. position: relative;
  290. }
  291. .fixed,
  292. .fixed1 {
  293. background: linear-gradient(97deg, #4FABFD 0%, #2772FB 100%);
  294. position: fixed;
  295. top: var(--status-bar-height);
  296. z-index: 999;
  297. // width: calc(100% - 40rpx);
  298. width: 100%;
  299. // margin:0 20rpx;
  300. }
  301. .fixed1 {
  302. top: 0;
  303. height: var(--status-bar-height);
  304. background: linear-gradient(97deg, #4FABFD 0%, #2772FB 100%);
  305. }
  306. .banner-img {
  307. width: 100%;
  308. }
  309. .head {
  310. position: absolute;
  311. width: calc(100% - 108rpx);
  312. bottom: 0;
  313. background: white;
  314. margin: 0 20rpx;
  315. border-radius: 20rpx;
  316. .item1,
  317. .item3 {
  318. width: 40%;
  319. .text {
  320. text-overflow: ellipsis;
  321. overflow: hidden;
  322. white-space: nowrap;
  323. }
  324. }
  325. .item1 .text {
  326. text-align: left;
  327. }
  328. .item3 .text {
  329. text-align: right;
  330. }
  331. }
  332. .change-btn {
  333. width: 86rpx;
  334. height: 86rpx;
  335. }
  336. .good-list {
  337. background-color: white;
  338. margin: 20rpx;
  339. padding: 20rpx 0rpx 0 0;
  340. border-radius: 20rpx;
  341. }
  342. .jt-icon {
  343. position: relative;
  344. top: 6rpx;
  345. width: 60rpx;
  346. margin: 0 20rpx;
  347. }
  348. .row {
  349. margin: 10rpx 0;
  350. align-items: center;
  351. }
  352. .item-bottom {
  353. background: #F0F5FF;
  354. padding: 0 30rpx;
  355. .name {
  356. font-size: 26rpx;
  357. font-weight: 700;
  358. color: #000000;
  359. margin-left: 30rpx;
  360. }
  361. .hp {
  362. margin: 30rpx;
  363. }
  364. .number-color {
  365. margin: 0 10rpx;
  366. }
  367. .qd {
  368. background: linear-gradient(97deg, #4FABFD 0%, #2772FB 100%);
  369. border-radius: 13px;
  370. font-size: 29rpx;
  371. font-weight: 400;
  372. color: #FFFFFF;
  373. padding: 10rpx 35rpx;
  374. }
  375. }
  376. .dw {
  377. align-items: center;
  378. }
  379. .place {
  380. height: var(--status-bar-height);
  381. }
  382. </style>