Преглед на файлове

feature:增加设备列表界面

zeng.chen преди 8 месеца
родител
ревизия
2a289771cf
променени са 4 файла, в които са добавени 151 реда и са изтрити 0 реда
  1. 102 0
      pages/deviceList/devices.js
  2. 6 0
      pages/deviceList/devices.json
  3. 10 0
      pages/deviceList/devices.wxml
  4. 33 0
      pages/deviceList/devices.wxss

+ 102 - 0
pages/deviceList/devices.js

@@ -0,0 +1,102 @@
+// 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() {
+
+  }
+})

+ 6 - 0
pages/deviceList/devices.json

@@ -0,0 +1,6 @@
+{
+  "usingComponents": {
+    "nav-bar": "./../components/navbar/navbar"
+
+  }
+}

+ 10 - 0
pages/deviceList/devices.wxml

@@ -0,0 +1,10 @@
+<!-- pages/deviceList/devices.wxml -->
+<nav-bar bind:goBack="_goBack" nav-bgc-class="ex-nav-bgc-class" nav-title-class="ex-nav-title-class" ex-back-pre="ex-back-pre" navbar-data='{{nvabarData}}'></nav-bar>
+<view class="container grid-container">
+    <block wx:for="{{deviceList}}" wx:key="index" wx:for-item="item" wx:for-index="index">
+        <view class="cell">
+            <image class="device_img" src="{{item.img}}" mode="aspectFill" />
+            <text class="device_text">{{item.name}}</text>
+        </view>
+    </block>
+</view>

+ 33 - 0
pages/deviceList/devices.wxss

@@ -0,0 +1,33 @@
+.container {
+    display: flex;
+    flex-wrap: wrap;
+}
+
+.grid-container {
+    display: grid;
+    grid-template-columns: repeat(2, 1fr);
+    grid-column-gap: 16rpx;
+	padding-inline: 16rpx;
+padding-top: 16rpx;
+}
+
+.cell {
+    border-radius: 10rpx;
+    overflow: hidden;
+    margin-bottom: 16rpx;
+    display: flex;
+    flex-direction: column;
+    align-items: center;
+
+}
+
+.device_img {
+    width: 100%;
+    height: 200rpx;
+}
+
+.device_text {
+	margin-top: 16rpx;
+    text-align: center;
+    width: 100%;
+}