| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- // pages/powerstation/index.js
- const api = require('../../api/index.js');
-
- Page({
-
- /**
- * 页面的初始数据
- */
- data: {
- infolist:{},
- options:{},
- msg:''
- },
-
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- console.log(options);
- this.setData({
- options:options
- })
- this.getinfo()
- },
- getinfo(){
- let _this =this
- api.request(`/station/${this.data.options.id}/info`, 'POST')
- .then((res) => {
- wx.showToast({
- title: res.msg,
- icon: 'none',
- });
- this.setData({
- msg:res.msg,
- infolist:res.data
- })
- if (res.msg =='成功') {
- api.request('/station/list/stationName', 'POST')
- .then((ress) => {
- for (let index = 0; index < ress.data.length; index++) {
- if (_this.data.options.id == ress.data[index].id) {
- wx.setStorage({
- key: 'station', // 本地缓存中指定的 key
- data: ress.data[index],
- success: function () {
-
- }
- });
- }
-
- }
-
-
- })
- }
- })
- .catch((err) => {
- console.error('请求失败:', err);
- // 在这里处理请求失败的情况
- });
- },
- // 绑定
- signout(){
- let data ={
- deviceId:this.data.options.id,
- UnbindStart:1
- }
- api.request('/system/tenantpower/APP/bind', 'POST',data )
- .then((res) => {
- wx.showToast({
- title: res.msg,
- icon: 'none',
- });
- this.getinfo()
-
- })
- .catch((err) => {
- console.error('请求失败:', err);
- // 在这里处理请求失败的情况
- });
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
-
- },
-
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
-
- },
-
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
-
- },
-
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
-
- },
-
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
-
- },
-
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
-
- },
-
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
-
- }
- })
|