// miniprogram/pages/home_center/device_list/index.js.js require('regenerator-runtime') import { getDeviceList } from '../../../utils/api/device-api'; import { getHomeDeviceList, getFamilyList } from '../../../utils/api/family-api'; Page({ /** * 页面的初始数据 */ data: { active: 0, deviceList: [] }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: async function () { const deviceList = await getDeviceList() // let res = await getFamilyList(); // let homeId = res[0]? res[0].home_id : ''; // const homeId = wx.getStorageSync("homeId"); // console.log('11111111111', homeId) // const deviceList = await getHomeDeviceList('69151027'); deviceList.forEach(item => { item.icon = `https://images.tuyacn.com/${item.icon}` }) this.setData({ deviceList }) }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, jumpToPanel({currentTarget}) { console.log('点击设备') const { dataset: { device } } = currentTarget const { id, category, name } = device switch (category) { case 'kg': break; default: { wx.navigateTo({ url: `/packageA/home_center/common_panel/index?device_id=${id}&device_name=${name}`, }) } } } })