123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 |
- //logs.js
- let util = require('../../utils/util.js');
- let wechat = require("../../utils/wechat");
- let amap = require("../../utils/amap");
- Page({
- data: {
- lonlat: "",
- city: "",
- longitude: null,
- latitude: null,
- tips: [],
- searchString: '',
- keywords: '',
- pagesize:30,
- pagenum:1,
- total:-1,
- loadTotal: 0,
- dataLoading: false,
- finishedLoadTap: 0,
- finishedLoadShowTimes: 0,
- chargList: [],
- },
- onLoad(e) {
- this.getNextPage()
- },
- bindScrollTolowerEvent: function(){
- this.getNextPage();
- },
- bindInput2(e) {
- let {
- value
- } = e.detail;
- let {
- lonlat,
- city
- } = this.data;
- amap.getInputtips(city, lonlat, value)
- .then(d => {
- //console.log(d);
- if (d && d.tips) {
- this.setData({
- tips: d.tips
- });
- }
- })
- .catch(e => {
- console.log(e);
- })
- },
- bindInput(e) {
- this.setData({
- searchString: e.detail.value
- });
- },
- bindSearch2(e) {
- let {
- keywords
- } = e.currentTarget.dataset;
- let pages = getCurrentPages();
- //console.log(pages);
- //console.log(e);
- // console.log(keywords);
- if (keywords) {
- let pages = getCurrentPages();
- let prevPage = pages[pages.length - 2]; //上一个页面
- let worksheetinfo = prevPage.data.worksheetinfo;
- let chargStationName = keywords.chargStationName
- worksheetinfo.chargStationId = keywords.id;
- worksheetinfo.mainLocation = keywords.address;
- worksheetinfo.accendant = '';
- worksheetinfo.pams = [];
- prevPage.setData({
- chargStationName,
- chargStationNameClearFlag:false,
- worksheetinfo,
- accendantids:[],
-
- });
- }
- //let url = `/pages/index/index`;
- //wx.navigateBack({
- // url
- // });
- wx.navigateBack({
- delta: 1
- });
- },
- bindSearch(e) {
- let {
- searchString: keywords
- } = this.data;
- console.info(keywords)
- this.setData({
- keywords,
- pagenum:1,
- chargList: []
- })
- this.getNextPage();
- },
- cancel(e) {
- console.log(e);
- wx.navigateBack();
- },
- getNextPage(){
- let userInfo = wx.getStorageSync('userInfo');
- let isLogin = wx.getStorageSync('isLogin');
- if(this.data.chargList.length == this.data.total){
- this.setData({
- finishedLoadTap:this.data.finishedLoadTap+1
- })
- if(this.data.finishedLoadTap>0 && this.data.finishedLoadShowTimes==0){
- this.setData({
- finishedLoadShowTimes:this.data.finishedLoadShowTimes+1
- })
- wx.showToast({
- title: '全部加载完毕',
- icon: 'success',
- duration: 2000
- })
- }
- return
- }
- if(this.data.dataLoading){
- return
- }
- this.setData({
- dataLoading: true
- })
- wx.showLoading({
- title: '数据加载中....',
- })
- let that = this;
- if (userInfo && isLogin) {
- wx.request({
- url: getApp().globalData.postHeadAgreement + '/restapi/wechat/userChargStationsWeb',
- data: {
- userId: userInfo.userId,
- searchString:that.data.keywords,
- pagenum: this.data.pagenum++,
- pagesize: this.data.pagesize,
- },
- method: 'POST',
- success(res) {
- let chargList = res.data.rows;
- // console.log(chargList);
- // that.rechargeTimeOrder(chargemoneylogs);
- wx.hideLoading()
- that.setData({
- chargList: that.data.chargList.concat(chargList),
- total: res.data.total,
- dataLoading: false,
- });
- }
- });
- }
- },
- });
|