// pages/tabber/news/index.js const app=getApp() Page({ /** * 页面的初始数据 */ data: { taskInfo:[], columns: ['北京','杭州', '宁波', '温州', '嘉兴', '湖州'], show:false, vtype:'北京', ktype:'0', keyword:"", pageindex: 1 }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.gettasklist(); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { // this.setData({pageindex:this.data.pageindex+=1}) // this.gettasklist() }, bindinput(e){ this.setData({ inputValue: e.detail.value }) }, city(){ this.setData({ show:!this.data.show }) }, onClose() { this.setData({ show: false }); }, onChange(event) { const { picker, value, index } = event.detail; this.setData({ vtype:value, show:!this.data.show, ktype:index }) console.log(`当前值:${value}, 当前索引:${index}`); }, deWeightThree(arr){ let map = new Map(); for (let item of arr) { if (!map.has(item.id)) { map.set(item.id, item); } } return [...map.values()]; }, gettasklist(){ var that=this var lng=wx.getStorageSync('longitude'); var lat=wx.getStorageSync('latitude'); var id=this.data.ktype; var key=this.data.keyword app.api.useApi(app.globalData.baseAppUrl + "api/admin/GetNetworker", { city_id:id, key:key, lng:lng, lat:lat, page: that.data.pageindex }, "get").then(function (res) { console.log(res); if (res.code != 200) { wx.showLoading({ title: res.message.msg, }) // that.setData({pageindex: that.data.pageindex -= 1}) setTimeout(function () { wx.hideLoading(); }, 1000); } else { wx.hideLoading(); let arrtask = that.deWeightThree(res.message.data) that.setData({taskInfo: arrtask}) // if (that.data.pageindex == 1) { // that.setData({taskInfo: []}) // } // if (res.message.data.length > 0) { // that.setData({taskInfo: that.data.taskInfo.concat(res.message.data)}) // } else { // that.setData({pageindex: that.data.pageindex -= 1}) // } } }).catch(function (err) { console.log(222); }) } })