// pages/home/home.js const app = getApp(); Page({ /** * 页面的初始数据 */ data: { navBarHeight: app.globalData.navBarHeight, MenuButtonheight: app.globalData.MenuButtonheight, MenuButtonTop: app.globalData.MenuButtonTop, rightId:wx.getStorageSync('rightId') || 0, nvabarData: { nvabarData: { showCapsule: 1, //是否显示左上角图标 1表示显示 0表示不显示 title: 'Oh Play', //导航栏 中间的标题 callback() { wx.navigateBack({ delta: 1, }) } }, isNotruter: false, deviceList: [], bannerList: [], isLoginWx: false, selectIndex: -1, } }, changeRole() { app.changeUserRight() }, // 删除设备 deleteDeviceTap: function () { }, // 设备详情页 devieDetailPageTap: function () { }, deviceItemTap: function () { this.setData({ // selectIndex = index }); }, changeDeviceTap: function () { }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { if (typeof this.getTabBar === 'function' && this.getTabBar()) { this.getTabBar().setData({ selected: 0 }) } app.eventBus.on('rightChange', data => { if (data !== this.data.rightId) { this.setData({ rightId: data }) } }) this.setData({ deviceList: [ { "devName": "名称1", "state": "online", "pic": "url", "power": 40, }, { "devName": "名称2", "state": "online", "pic": "url", "power": 50, }, { "devName": "名称3", "state": "online", "pic": "url", "power": 60, }, ], selectIndex: 0, isLoginWx: true, bannerList: ["https://img1.baidu.com/it/u=2003442481,2528062378&fm=253&fmt=auto&app=138&f=JPG?w=499&h=182", "https://hbimg.huabanimg.com/0ff93215a6d8d1c5f80117fdbfa24936dbd9097026ad99-CNduY8_fw658", "https://img.zcool.cn/community/0177ed5f365bdaa801215aa0a0c1c3.jpg@1280w_1l_2o_100sh.jpg"], }); }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })