findstation.js 3.2 KB

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