chargpilemonitorsearch.js 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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. userInfo: {},
  8. isLogin: false,
  9. searchString: null,
  10. chargpiles: [],
  11. pageNum: 1,
  12. total: 0,
  13. showAll: false,
  14. scrollTop: 0
  15. },
  16. onLoad(e) {
  17. wx.showLoading({
  18. title: '加载中',
  19. mask: true
  20. });
  21. let { keywords } = e ;
  22. this.setData({
  23. searchString: keywords
  24. });
  25. let userInfo = wx.getStorageSync('userInfo');
  26. let isLogin = wx.getStorageSync('isLogin');
  27. let that = this;
  28. // 页面显示
  29. if (userInfo && isLogin) {
  30. this.setData({
  31. userInfo: userInfo,
  32. isLogin: isLogin
  33. });
  34. wx.request({
  35. url: getApp().globalData.postHeadAgreement + '/restapi/wechat/chargpileList',
  36. data: {
  37. pams: userInfo.userId,
  38. chargStationName:that.data.searchString,
  39. params: {
  40. pageSize: 10,
  41. pageNum: 1
  42. //orderByColumn:
  43. //isAsc: asc
  44. }
  45. },
  46. method: 'POST',
  47. success(res) {
  48. //console.log(res);
  49. if (res.data && res.data.code == 0) {
  50. let {
  51. rows: chargpiles
  52. } = res.data;
  53. var show_chargpiles = [];
  54. chargpiles.forEach((item, index) => {
  55. show_chargpiles.push({
  56. chargStationId: item.chargStationId,
  57. chargPileName: item.chargPileName,
  58. chargPileId: item.chargPileId,
  59. chargStationName: item.chargStationName,
  60. chargmode: item.chargmode,//name = "充电模式", readConverterExp = "1=自动,2=手动"
  61. chargway: item.chargway,//name = "充电方式", readConverterExp = "1=直流,2=交流"
  62. chargstatus: item.chargstatus//充电状态0:离线、1:故障、2:空闲中、3:充电中、4:欠压故障、5:过压故障、6:过电流故障、8:预约、9:在线升级、10:操作中、11:已插枪等
  63. });
  64. });
  65. //充电状态0:离线、1:故障、2:空闲中、3:充电中、4:欠压故障、5:过压故障、6:过电流故障、8:预约、9:在线升级、10:操作中、11:已插枪等
  66. // if (!res.data.chargstatus || res.data.chargstatus == 0 || res.data.chargstatus == 1 || res.data.chargstatus == 4 || res.data.chargstatus == 5 || res.data.chargstatus == 6 || res.data.chargstatus == 9) {
  67. // //充电桩故障
  68. // wx.showModal({
  69. // showCancel: false,
  70. // content: '终端故障,维修中'
  71. // });
  72. // } else if (res.data.chargstatus == 3 || res.data.chargstatus == 8 || res.data.chargstatus == 10) {
  73. // wx.showModal({
  74. // showCancel: false,
  75. // content: '正在充电中'
  76. // });
  77. // } else if (res.data.chargstatus == 2 || res.data.chargstatus == 11) {
  78. // wx.setStorage({
  79. // key: "scan_chargpile",
  80. // data: res.data
  81. // });
  82. // log.info('[首页]', '[扫一扫充电桩空闲跳转去充电界面]');
  83. // let url = `/pages/scan_result/scan_result`;
  84. // wx.navigateTo({
  85. // url
  86. // });
  87. // }
  88. if (res.data.total <= 10) {
  89. that.setData({
  90. chargpiles: show_chargpiles,
  91. total: res.data.total,
  92. showAll: true,
  93. pageNum: 1,
  94. scrollTop: 24
  95. });
  96. } else {
  97. that.setData({
  98. chargpiles: show_chargpiles,
  99. total: res.data.total,
  100. showAll: false,
  101. pageNum: 1,
  102. scrollTop: 24
  103. });
  104. }
  105. wx.hideLoading();
  106. }
  107. }
  108. });
  109. }
  110. },
  111. loadInitData(e) {
  112. wx.showLoading({
  113. title: '刷新中',
  114. mask: true
  115. });
  116. let that = this;
  117. // 页面显示
  118. if (that.data.userInfo && that.data.isLogin) {
  119. wx.request({
  120. url: getApp().globalData.postHeadAgreement + '/restapi/wechat/chargpileList',
  121. data: {
  122. pams: that.data.userInfo.userId,
  123. chargStationName: that.data.searchString,
  124. params: {
  125. pageSize: 10,
  126. pageNum: 1
  127. //orderByColumn:
  128. //isAsc: asc
  129. }
  130. },
  131. method: 'POST',
  132. success(res) {
  133. //console.log(res);
  134. if (res.data && res.data.code == 0) {
  135. let {
  136. rows: chargpiles
  137. } = res.data;
  138. var show_chargpiles = [];
  139. chargpiles.forEach((item, index) => {
  140. show_chargpiles.push({
  141. chargStationId: item.chargStationId,
  142. chargPileName: item.chargPileName,
  143. chargPileId: item.chargPileId,
  144. chargStationName: item.chargStationName,
  145. chargmode: item.chargmode,//name = "充电模式", readConverterExp = "1=自动,2=手动"
  146. chargway: item.chargway,//name = "充电方式", readConverterExp = "1=直流,2=交流"
  147. chargstatus: item.chargstatus//充电状态0:离线、1:故障、2:空闲中、3:充电中、4:欠压故障、5:过压故障、6:过电流故障、8:预约、9:在线升级、10:操作中、11:已插枪等
  148. });
  149. });
  150. if (res.data.total <= 10) {
  151. that.setData({
  152. chargpiles: show_chargpiles,
  153. total: res.data.total,
  154. showAll: true,
  155. pageNum: 1,
  156. scrollTop: 24
  157. });
  158. } else {
  159. that.setData({
  160. chargpiles: show_chargpiles,
  161. total: res.data.total,
  162. showAll: false,
  163. pageNum: 1,
  164. scrollTop: 24
  165. });
  166. }
  167. wx.hideLoading();
  168. }
  169. }
  170. });
  171. }
  172. },
  173. loadMoreData(e) {
  174. var totalPage = parseInt((this.data.total + 10 - 1) / 10);
  175. if ((this.data.pageNum + 1) > totalPage) {
  176. this.setData({
  177. showAll: true
  178. });
  179. return;
  180. }
  181. wx.showLoading({
  182. title: '加载中',
  183. mask: true
  184. });
  185. let that = this;
  186. let pageNum = this.data.pageNum + 1;
  187. this.setData({
  188. pageNum
  189. });
  190. // 页面显示
  191. if (that.data.userInfo && that.data.isLogin) {
  192. wx.request({
  193. url: getApp().globalData.postHeadAgreement + '/restapi/wechat/chargpileList',
  194. data: {
  195. pams: that.data.userInfo.userId,
  196. chargStationName: that.data.searchString,
  197. params: {
  198. pageSize: 10,
  199. pageNum: pageNum
  200. //orderByColumn:
  201. //isAsc: asc
  202. }
  203. },
  204. method: 'POST',
  205. success(res) {
  206. //console.log(res);
  207. if (res.data && res.data.code == 0) {
  208. let {
  209. rows: chargpiles
  210. } = res.data;
  211. var show_chargpiles = that.data.chargpiles;
  212. chargpiles.forEach((item, index) => {
  213. show_chargpiles.push({
  214. chargStationId: item.chargStationId,
  215. chargPileName: item.chargPileName,
  216. chargPileId: item.chargPileId,
  217. chargStationName: item.chargStationName,
  218. chargmode: item.chargmode,//name = "充电模式", readConverterExp = "1=自动,2=手动"
  219. chargway: item.chargway,//name = "充电方式", readConverterExp = "1=直流,2=交流"
  220. chargstatus: item.chargstatus//充电状态0:离线、1:故障、2:空闲中、3:充电中、4:欠压故障、5:过压故障、6:过电流故障、8:预约、9:在线升级、10:操作中、11:已插枪等
  221. });
  222. });
  223. that.setData({
  224. chargpiles: show_chargpiles
  225. });
  226. if (pageNum * 10 >= that.data.total) {
  227. that.setData({
  228. showAll: true
  229. });
  230. }
  231. wx.hideLoading();
  232. }
  233. }
  234. });
  235. }
  236. }
  237. });