findstation.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. //logs.js
  2. let util = require('../../utils/util.js');
  3. let wechat = require("../../utils/wechat");
  4. let amap = require("../../utils/amap");
  5. Page({
  6. data: {
  7. lonlat: "",
  8. city: "",
  9. longitude: null,
  10. latitude: null,
  11. tips: [],
  12. searchString: '',
  13. keywords: '',
  14. pagesize:30,
  15. pagenum:1,
  16. total:-1,
  17. loadTotal: 0,
  18. dataLoading: false,
  19. finishedLoadTap: 0,
  20. finishedLoadShowTimes: 0,
  21. chargList: [],
  22. },
  23. onLoad(e) {
  24. this.getNextPage()
  25. },
  26. bindScrollTolowerEvent: function(){
  27. this.getNextPage();
  28. },
  29. bindInput2(e) {
  30. let {
  31. value
  32. } = e.detail;
  33. let {
  34. lonlat,
  35. city
  36. } = this.data;
  37. amap.getInputtips(city, lonlat, value)
  38. .then(d => {
  39. //console.log(d);
  40. if (d && d.tips) {
  41. this.setData({
  42. tips: d.tips
  43. });
  44. }
  45. })
  46. .catch(e => {
  47. console.log(e);
  48. })
  49. },
  50. bindInput(e) {
  51. this.setData({
  52. searchString: e.detail.value
  53. });
  54. },
  55. bindSearch2(e) {
  56. let {
  57. keywords
  58. } = e.currentTarget.dataset;
  59. let pages = getCurrentPages();
  60. //console.log(pages);
  61. //console.log(e);
  62. // console.log(keywords);
  63. if (keywords) {
  64. let pages = getCurrentPages();
  65. let prevPage = pages[pages.length - 2]; //上一个页面
  66. let worksheetinfo = prevPage.data.worksheetinfo;
  67. let chargStationName = keywords.chargStationName
  68. worksheetinfo.chargStationId = keywords.id;
  69. worksheetinfo.mainLocation = keywords.address;
  70. prevPage.setData({
  71. chargStationName,
  72. worksheetinfo
  73. });
  74. }
  75. //let url = `/pages/index/index`;
  76. //wx.navigateBack({
  77. // url
  78. // });
  79. wx.navigateBack({
  80. delta: 1
  81. });
  82. },
  83. bindSearch(e) {
  84. let {
  85. searchString: keywords
  86. } = this.data;
  87. console.info(keywords)
  88. this.setData({
  89. keywords,
  90. pagenum:1,
  91. chargList: []
  92. })
  93. this.getNextPage();
  94. },
  95. cancel(e) {
  96. console.log(e);
  97. wx.navigateBack();
  98. },
  99. getNextPage(){
  100. let userInfo = wx.getStorageSync('userInfo');
  101. let isLogin = wx.getStorageSync('isLogin');
  102. if(this.data.chargList.length == this.data.total){
  103. this.setData({
  104. finishedLoadTap:this.data.finishedLoadTap+1
  105. })
  106. if(this.data.finishedLoadTap>0 && this.data.finishedLoadShowTimes==0){
  107. this.setData({
  108. finishedLoadShowTimes:this.data.finishedLoadShowTimes+1
  109. })
  110. wx.showToast({
  111. title: '全部加载完毕',
  112. icon: 'success',
  113. duration: 2000
  114. })
  115. }
  116. return
  117. }
  118. if(this.data.dataLoading){
  119. return
  120. }
  121. this.setData({
  122. dataLoading: true
  123. })
  124. wx.showLoading({
  125. title: '数据加载中....',
  126. })
  127. let that = this;
  128. if (userInfo && isLogin) {
  129. wx.request({
  130. url: getApp().globalData.postHeadAgreement + '/restapi/wechat/userChargStationsWeb',
  131. data: {
  132. userId: userInfo.userId,
  133. searchString:that.data.keywords,
  134. pagenum: this.data.pagenum++,
  135. pagesize: this.data.pagesize,
  136. },
  137. method: 'POST',
  138. success(res) {
  139. let chargList = res.data.rows;
  140. // console.log(chargList);
  141. // that.rechargeTimeOrder(chargemoneylogs);
  142. wx.hideLoading()
  143. that.setData({
  144. chargList: that.data.chargList.concat(chargList),
  145. total: res.data.total,
  146. dataLoading: false,
  147. });
  148. }
  149. });
  150. }
  151. },
  152. });