// pages/station/index.js const api = require('../../api/index.js'); Page({ /** * 页面的初始数据 */ data: { stickyProps:"", }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { this.getlist() }, onTabsChange(event) { this.setData({ stickyProps:event.detail.value }) this.getlist() }, getlist(){ let data ={ onlineStatus:this.data.stickyProps } api.request('/muitiStation/APP/baseInfo', 'POST',data ) .then((res) => { this.setData({ baseInfo:res.data }) }) .catch((err) => { console.error('请求失败:', err); // 在这里处理请求失败的情况 }); }, onUnbind1(e){ console.log(e.target.dataset.id); let data ={ deviceId:e.target.dataset.id, UnbindStart:1 } api.request('/system/tenantpower/APP/bind', 'POST',data ) .then((res) => { wx.showToast({ title: res.msg, icon: 'none', }); this.getlist() }) .catch((err) => { console.error('请求失败:', err); // 在这里处理请求失败的情况 }); }, onUnbind2(e){ console.log(e.target.dataset.id); let data ={ deviceId:e.target.dataset.id, UnbindStart:0 } api.request('/system/tenantpower/APP/bind', 'POST',data ) .then((res) => { wx.showToast({ title: res.msg, icon: 'none', }); this.getlist() }) .catch((err) => { console.error('请求失败:', err); // 在这里处理请求失败的情况 }); }, ondetails(id){ console.log(id.currentTarget.dataset.id); wx.navigateTo({ url: `/pages/powerstation/index?id=${id.currentTarget.dataset.id}&source=xq`, // 登录页面的路径,注意路径前面加上 '/' 表示从根目录开始 }); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })