123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- // pages/deviceList/deviceList.js
- import dRequest from '../../request/deviceListRequest'
- import routeUtil from '../../utils/route_util'
- import route_constant from '../../utils/route_constant.js'
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- deviceList: [
- ],
- nvabarData: {
- showCapsule: 1, //是否显示左上角图标 1表示显示 0表示不显示
- title: '设备列表', //导航栏 中间的标题
- },
- },
- deviceTap(e) {
- console.log(e)
- let device = e.currentTarget.dataset.device
- if (!device) {
- console.log("设备为空")
- return;
- }
- let param = JSON.stringify(device)
- routeUtil.jumpParam(route_constant.connectMode, param)
- },
- /**
- * 生命周期函数--监听页面加载
- */
- 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);
- // })
- },
- })
|