index.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <template>
  2. <div>
  3. <van-nav-bar title="油站列表" fixed placeholder safe-area-inset-top />
  4. <van-search placeholder="请输入搜索关键词" />
  5. <van-pull-refresh v-model="refreshing" @refresh="onRefresh">
  6. <van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="onLoad">
  7. <van-card :desc="item.stationAddress" :title="item.stationName" :thumb="item.mno" centered v-for="item in list"
  8. :key="item.stationId">
  9. <template #footer>
  10. <van-row>
  11. <van-col span="8" offset="1">
  12. <van-button plain round block size="small" type="primary" @click="goHere">去这里</van-button>
  13. </van-col>
  14. <van-col span="8" offset="5">
  15. <!-- <router-link :to="{path:'/order/create',query: {stationId: item.stationId,stationName:item.stationName}}"> -->
  16. <van-button round block size="small" type="primary" @click="goPay(item.stationId,item.stationName)">去买单</van-button>
  17. </van-col>
  18. </van-row>
  19. </template>
  20. </van-card>
  21. </van-list>
  22. </van-pull-refresh>
  23. </div>
  24. </template>
  25. <script type="text/javascript">
  26. import Vue from 'vue';
  27. import {
  28. NavBar,
  29. PullRefresh,
  30. List,
  31. Card,
  32. Col,
  33. Row,
  34. Button
  35. } from 'vant';
  36. import {
  37. Search
  38. } from 'vant';
  39. Vue.use(NavBar);
  40. Vue.use(PullRefresh);
  41. Vue.use(List);
  42. Vue.use(Card);
  43. Vue.use(Col);
  44. Vue.use(Row);
  45. Vue.use(Button);
  46. Vue.use(Search);
  47. export default ({
  48. head() {
  49. return {
  50. title: '油站列表'
  51. }
  52. },
  53. data() {
  54. return {
  55. list: [],
  56. loading: false, //加载状态
  57. finished: false, //是否加载
  58. refreshing: false, //是否正在上拉刷新
  59. page: 1, //页数
  60. limit: 5, //每页几条记录
  61. openId: ""
  62. };
  63. },
  64. created() {
  65. },
  66. mounted() {
  67. },
  68. methods: {
  69. goHere(){
  70. let from = ["116.478346","39.997361","startpoint"].join(",")
  71. let to = ["116.3246","39.966577","endpoint"].join(",")
  72. window.location=`//uri.amap.com/navigation?from=${from}&to=${to}&mode=car&policy=1&coordinate=gaode&callnative=0`
  73. },
  74. onLoad() {
  75. var r = this.$axios.get('/getStationInfoList', {
  76. params: {
  77. stationLongitude: '117.12011',
  78. stationLatitude: '36.65188',
  79. pageNum: 0,
  80. pageSize: 0
  81. },
  82. });
  83. r.then(res => {
  84. if (res.data.retCode == 0) {
  85. // 加载状态结束
  86. this.loading = false;
  87. this.list = this.list.concat(res.data.data.stationInfoResponseList); //追加数据
  88. if (res.data.data.page == res.data.data.stationInfoResponseList.pageNum ||
  89. res.data.data.stationInfoResponseList
  90. .length == 0) { //数据全部加载完成
  91. this.finished = true;
  92. } else {
  93. this.finished = false;
  94. }
  95. }
  96. })
  97. },
  98. //去买单按钮方法
  99. goPay: function(stationId, stationName) {
  100. let openId=this.$route.query.openid;
  101. this.$router.push({
  102. path: '/order/create',
  103. query: {
  104. stationId: stationId,
  105. stationName: stationName,
  106. openId: openId
  107. }
  108. });
  109. },
  110. onRefresh() {
  111. // 清空列表数据
  112. this.finished = false;
  113. // 重新加载数据
  114. // 将 loading 设置为 true,表示处于加载状态
  115. this.loading = true;
  116. this.onLoad();
  117. },
  118. }
  119. })
  120. </script>
  121. <style lang="less">
  122. body {
  123. background-color: #f8f8f8;
  124. }
  125. .van-card {
  126. border-bottom: 1px solid #ebedf0;
  127. background-color: #ffffff !important;
  128. }
  129. </style>