findstation.js 3.6 KB

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