123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287 |
- //logs.js
- let util = require('../../../utils/util.js');
- let wechat = require("../../../utils/wechat");
- let amap = require("../../../utils/amap");
- Page({
- timer: null,
- data: {
- userInfo: {},
- isLogin: false,
- searchString: null,
- chargpiles: [],
- pageNum: 1,
- total: 0,
- showAll: false,
- showTop: true,
- scrollTop: 0
- },
- onLoad(e) {
- wx.showLoading({
- title: '加载中',
- mask: true
- });
- let userInfo = wx.getStorageSync('userInfo');
- let isLogin = wx.getStorageSync('isLogin');
- let that = this;
- // 页面显示
- if (userInfo && isLogin) {
- this.setData({
- userInfo: userInfo,
- isLogin: isLogin
- });
- wx.request({
- url: getApp().globalData.postHeadAgreement + '/restapi/wechat/chargpileList',
- data: {
- pams: userInfo.userId,
- params: {
- pageSize: 10,
- pageNum: 1
- //orderByColumn:
- //isAsc: asc
- }
- },
- method: 'POST',
- success(res) {
- //console.log(res);
- if (res.data && res.data.code == 0) {
- let {
- rows: chargpiles
- } = res.data;
- var show_chargpiles = [];
- chargpiles.forEach((item, index) => {
- show_chargpiles.push({
- chargStationId: item.chargStationId,
- chargPileName: item.chargPileName,
- chargPileId: item.chargPileId,
- chargStationName: item.chargStationName,
- chargmode: item.chargmode,//name = "充电模式", readConverterExp = "1=自动,2=手动"
- chargway: item.chargway,//name = "充电方式", readConverterExp = "1=直流,2=交流"
- chargstatus: item.chargstatus//充电状态0:离线、1:故障、2:空闲中、3:充电中、4:欠压故障、5:过压故障、6:过电流故障、8:预约、9:在线升级、10:操作中、11:已插枪等
- });
- });
- //充电状态0:离线、1:故障、2:空闲中、3:充电中、4:欠压故障、5:过压故障、6:过电流故障、8:预约、9:在线升级、10:操作中、11:已插枪等
- // 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) {
- // //充电桩故障
- // wx.showModal({
- // showCancel: false,
- // content: '终端故障,维修中'
- // });
- // } else if (res.data.chargstatus == 3 || res.data.chargstatus == 8 || res.data.chargstatus == 10) {
- // wx.showModal({
- // showCancel: false,
- // content: '正在充电中'
- // });
- // } else if (res.data.chargstatus == 2 || res.data.chargstatus == 11) {
- // wx.setStorage({
- // key: "scan_chargpile",
- // data: res.data
- // });
- // log.info('[首页]', '[扫一扫充电桩空闲跳转去充电界面]');
- // let url = `/pages/scan_result/scan_result`;
- // wx.navigateTo({
- // url
- // });
- // }
- if (res.data.total <= 10) {
- that.setData({
- chargpiles: show_chargpiles,
- total: res.data.total,
- showAll: true,
- pageNum: 1,
- scrollTop: 24
- });
- } else {
- that.setData({
- chargpiles: show_chargpiles,
- total: res.data.total,
- showAll: false,
- pageNum: 1,
- scrollTop: 24
- });
- }
- wx.hideLoading();
- }
- }
- });
- }
- },
- bindInput(e) {
- this.setData({
- searchString: e.detail.value
- });
- },
- bindSearch(e) {
- let {
- searchString: keywords
- } = this.data;
- if (keywords) {
- let url = `/pages/ucenter/chargpilemonitor/chargpilemonitorsearch?keywords=${keywords}`;
- wx.navigateTo({
- url
- });
- }
- },
- scrollFn(e) {
- // 防抖,优化性能
- // 当滚动时,滚动条位置距离页面顶部小于设定值时,触发下拉刷新
- // 通过将设定值尽可能小,并且初始化scroll-view组件竖向滚动条位置为设定值。来实现下拉刷新功能,但没有官方的体验好
- // clearTimeout(this.timer)
- // if (e.detail.scrollTop < this.data.scrollTop) {
- // this.timer = setTimeout(() => {
- // this.loadInitData()
- // }, 350)
- // }
-
- if (e.detail.scrollTop > 24) {
- //clearTimeout(this.timer);
- this.setData({
- showTop: false
- });
- }
- // if (e.detail.scrollTop == 0) {
- // this.timer = setTimeout(() => {
- // if (!this.data.showTop) {
- // this.setData({
- // showTop: true
- // });
- // }
- // }, 350)
- // }
- },
- loadInitData(e) {
- if (!this.data.showTop) {
- //clearTimeout(this.timer);
- //this.timer = setTimeout(() => {
- this.setData({
- showTop: true,
- scrollTop: 24
- });
- //}, 50)
- } else {
- wx.showLoading({
- title: '刷新中',
- mask: true
- });
- let that = this;
- // 页面显示
- if (that.data.userInfo && that.data.isLogin) {
- wx.request({
- url: getApp().globalData.postHeadAgreement + '/restapi/wechat/chargpileList',
- data: {
- pams: that.data.userInfo.userId,
- params: {
- pageSize: 10,
- pageNum: 1
- //orderByColumn:
- //isAsc: asc
- }
- },
- method: 'POST',
- success(res) {
- //console.log(res);
- if (res.data && res.data.code == 0) {
- let {
- rows: chargpiles
- } = res.data;
- var show_chargpiles = [];
- chargpiles.forEach((item, index) => {
- show_chargpiles.push({
- chargStationId: item.chargStationId,
- chargPileName: item.chargPileName,
- chargPileId: item.chargPileId,
- chargStationName: item.chargStationName,
- chargmode: item.chargmode,//name = "充电模式", readConverterExp = "1=自动,2=手动"
- chargway: item.chargway,//name = "充电方式", readConverterExp = "1=直流,2=交流"
- chargstatus: item.chargstatus//充电状态0:离线、1:故障、2:空闲中、3:充电中、4:欠压故障、5:过压故障、6:过电流故障、8:预约、9:在线升级、10:操作中、11:已插枪等
- });
- });
- if (res.data.total <= 10) {
- that.setData({
- chargpiles: show_chargpiles,
- total: res.data.total,
- showAll: true,
- pageNum: 1,
- scrollTop: 24
- });
- } else {
- that.setData({
- chargpiles: show_chargpiles,
- total: res.data.total,
- showAll: false,
- pageNum: 1,
- scrollTop: 24
- });
- }
- wx.hideLoading();
- }
- }
- });
- }
- }
- },
- loadMoreData(e) {
- var totalPage = parseInt((this.data.total + 10 - 1) / 10);
- if ((this.data.pageNum + 1) > totalPage) {
- this.setData({
- showAll: true
- });
- return;
- }
- wx.showLoading({
- title: '加载中',
- mask: true
- });
- let that = this;
- let pageNum = this.data.pageNum + 1;
- this.setData({
- pageNum
- });
- // 页面显示
- if (that.data.userInfo && that.data.isLogin) {
- wx.request({
- url: getApp().globalData.postHeadAgreement + '/restapi/wechat/chargpileList',
- data: {
- pams: that.data.userInfo.userId,
- params: {
- pageSize: 10,
- pageNum: pageNum
- //orderByColumn:
- //isAsc: asc
- }
- },
- method: 'POST',
- success(res) {
- //console.log(res);
- if (res.data && res.data.code == 0) {
- let {
- rows: chargpiles
- } = res.data;
- var show_chargpiles = that.data.chargpiles;
- chargpiles.forEach((item, index) => {
- show_chargpiles.push({
- chargStationId: item.chargStationId,
- chargPileName: item.chargPileName,
- chargPileId: item.chargPileId,
- chargStationName: item.chargStationName,
- chargmode: item.chargmode,//name = "充电模式", readConverterExp = "1=自动,2=手动"
- chargway: item.chargway,//name = "充电方式", readConverterExp = "1=直流,2=交流"
- chargstatus: item.chargstatus//充电状态0:离线、1:故障、2:空闲中、3:充电中、4:欠压故障、5:过压故障、6:过电流故障、8:预约、9:在线升级、10:操作中、11:已插枪等
- });
- });
- that.setData({
- chargpiles: show_chargpiles
- });
- if (pageNum * 10 >= that.data.total) {
- that.setData({
- showAll: true
- });
- }
- wx.hideLoading();
- }
- }
- });
- }
- }
- });
|