findstation.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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. chargStationNameClearFlag:false,
  73. worksheetinfo
  74. });
  75. }
  76. //let url = `/pages/index/index`;
  77. //wx.navigateBack({
  78. // url
  79. // });
  80. wx.navigateBack({
  81. delta: 1
  82. });
  83. },
  84. bindSearch(e) {
  85. let {
  86. searchString: keywords
  87. } = this.data;
  88. console.info(keywords)
  89. this.setData({
  90. keywords,
  91. pagenum:1,
  92. chargList: []
  93. })
  94. this.getNextPage();
  95. },
  96. cancel(e) {
  97. console.log(e);
  98. wx.navigateBack();
  99. },
  100. getNextPage(){
  101. let userInfo = wx.getStorageSync('userInfo');
  102. let isLogin = wx.getStorageSync('isLogin');
  103. if(this.data.chargList.length == this.data.total){
  104. this.setData({
  105. finishedLoadTap:this.data.finishedLoadTap+1
  106. })
  107. if(this.data.finishedLoadTap>0 && this.data.finishedLoadShowTimes==0){
  108. this.setData({
  109. finishedLoadShowTimes:this.data.finishedLoadShowTimes+1
  110. })
  111. wx.showToast({
  112. title: '全部加载完毕',
  113. icon: 'success',
  114. duration: 2000
  115. })
  116. }
  117. return
  118. }
  119. if(this.data.dataLoading){
  120. return
  121. }
  122. this.setData({
  123. dataLoading: true
  124. })
  125. wx.showLoading({
  126. title: '数据加载中....',
  127. })
  128. let that = this;
  129. if (userInfo && isLogin) {
  130. wx.request({
  131. url: getApp().globalData.postHeadAgreement + '/restapi/wechat/userChargStationsWeb',
  132. data: {
  133. userId: userInfo.userId,
  134. searchString:that.data.keywords,
  135. pagenum: this.data.pagenum++,
  136. pagesize: this.data.pagesize,
  137. },
  138. method: 'POST',
  139. success(res) {
  140. let chargList = res.data.rows;
  141. // console.log(chargList);
  142. // that.rechargeTimeOrder(chargemoneylogs);
  143. wx.hideLoading()
  144. that.setData({
  145. chargList: that.data.chargList.concat(chargList),
  146. total: res.data.total,
  147. dataLoading: false,
  148. });
  149. }
  150. });
  151. }
  152. },
  153. });