// pages/deviceList/devices.js import dRequest from '../../request/deviceListRequest' Page({ /** * 页面的初始数据 */ data: { deviceList: [ ], nvabarData: { showCapsule: 1, //是否显示左上角图标 1表示显示 0表示不显示 title: '设备列表', //导航栏 中间的标题 }, }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { let _this = this let app = getApp() if (app.globalData.classifyProducts.length > 0) { _this.setData({ deviceList: app.globalData.classifyProducts }) return; } dRequest.deviceList({}).then((res) => { // console.log("设备列表", res); let devices = [] res.forEach(element => { if (element.applicationType.indexOf("0") >= 0) { devices.push(element) } }); console.log("设备列表2:", devices) app.globalData.classifyProducts = devices; _this.setData({ deviceList: devices }) }) // dRequest.deviceTypeList({}).then((res)=>{ // console.log("设备类型", res); // }) // dRequest.deviceCategoryList({}).then((res)=>{ // console.log("设备分类列表", res); // }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })