浏览代码

feature: 处理滚动效果

Damon 8 月之前
父节点
当前提交
a167ff1759
共有 6 个文件被更改,包括 121 次插入37 次删除
  1. 68 11
      pages/index/index.js
  2. 0 1
      pages/index/index.json
  3. 4 4
      pages/index/index.wxml
  4. 1 1
      pages/index/index.wxss
  5. 1 0
      pages/indexCopy/indexCopy.js
  6. 47 20
      utils/api.js

+ 68 - 11
pages/index/index.js

@@ -1,6 +1,7 @@
 // 获取应用实例
 const app = getApp();
 const {
+  getDevices,
   login,
   listByDevice
 } = require('../../utils/api.js');
@@ -20,16 +21,16 @@ Page({
       showCapsule: 0, //是否显示左上角图标   1表示显示    0表示不显示
       title: 'OhPlay', //导航栏 中间的标题
     },
-    bannerList: [{
-        imgUrl: 'http://img1.baidu.com/it/u=2343623234,438083234&fm=253&app=138&f=JPEG?w=684&h=1216'
-      },
-      {
-        imgUrl: 'http://img1.baidu.com/it/u=2343623234,438083234&fm=253&app=138&f=JPEG?w=684&h=1216'
-      },
-      {
-        imgUrl: 'http://img1.baidu.com/it/u=2343623234,438083234&fm=253&app=138&f=JPEG?w=684&h=1216'
-      }
-      // 添加更多图片对象
+    bannerList: [
+      // {
+      //   imgUrl: 'http://img1.baidu.com/it/u=2343623234,438083234&fm=253&app=138&f=JPEG?w=684&h=1216'
+      // },
+      // {
+      //   imgUrl: 'http://img1.baidu.com/it/u=2343623234,438083234&fm=253&app=138&f=JPEG?w=684&h=1216'
+      // },
+      // {
+      //   imgUrl: 'http://img1.baidu.com/it/u=2343623234,438083234&fm=253&app=138&f=JPEG?w=684&h=1216'
+      // }
     ],
     autoplay: true,
     interval: 3000, // 切换时间间隔
@@ -45,7 +46,55 @@ Page({
     actionIndex: null,
     luoma: ["Ⅰ", "Ⅱ", "Ⅲ", "Ⅳ", "Ⅴ", "Ⅵ", " Ⅶ", "Ⅷ", "Ⅸ", "Ⅹ", "Ⅺ", "Ⅻ"],
     channelData: [],
-    deviceList: [],
+    deviceList: [{
+      "deviceId": "BLUFI_7cdfa1fcbb24",
+      "name": "BLUFI_7cdfa1fcbb24",
+      "state": "online",
+      "ProdModel": "MW-2AX(WIFI-N)",
+      "devName": "猫王小王子OTR-X"
+    }, {
+      "deviceId": "BLUFI_7cdfa1fcbb24",
+      "name": "BLUFI_7cdfa1fcbb24",
+      "state": "online",
+      "ProdModel": "MW-2AX(WIFI-N)",
+      "devName": "猫王小王子OTR-X"
+    }, {
+      "deviceId": "BLUFI_7cdfa1fcbb24",
+      "name": "BLUFI_7cdfa1fcbb24",
+      "state": "online",
+      "ProdModel": "MW-2AX(WIFI-N)",
+      "devName": "猫王小王子OTR-X"
+    }, {
+      "deviceId": "BLUFI_7cdfa1fcbb24",
+      "name": "BLUFI_7cdfa1fcbb24",
+      "state": "online",
+      "ProdModel": "MW-2AX(WIFI-N)",
+      "devName": "猫王小王子OTR-X"
+    }, {
+      "deviceId": "BLUFI_7cdfa1fcbb24",
+      "name": "BLUFI_7cdfa1fcbb24",
+      "state": "online",
+      "ProdModel": "MW-2AX(WIFI-N)",
+      "devName": "猫王小王子OTR-X"
+    }, {
+      "deviceId": "BLUFI_7cdfa1fcbb24",
+      "name": "BLUFI_7cdfa1fcbb24",
+      "state": "online",
+      "ProdModel": "MW-2AX(WIFI-N)",
+      "devName": "猫王小王子OTR-X"
+    }, {
+      "deviceId": "BLUFI_7cdfa1fcbb24",
+      "name": "BLUFI_7cdfa1fcbb24",
+      "state": "online",
+      "ProdModel": "MW-2AX(WIFI-N)",
+      "devName": "猫王小王子OTR-X"
+    }, {
+      "deviceId": "BLUFI_7cdfa1fcbb24",
+      "name": "BLUFI_7cdfa1fcbb24",
+      "state": "online",
+      "ProdModel": "MW-2AX(WIFI-N)",
+      "devName": "猫王小王子OTR-X"
+    }],
     deviceListIndex: null,
     showLogin: false,
     isOneLoading: true,
@@ -72,6 +121,14 @@ Page({
     var that = this;
     that.onHomeShow();
     that.onMeShow();
+
+    getDevices({}).then((res) => {
+      console.log("gadfadfqwwerqewqr===" + JSON.stringify(res));
+      // wx.setStorage({
+      //   key: "channelData",
+      //   data: res
+      // });
+    })
   },
 
   onHomeLoad() {

+ 0 - 1
pages/index/index.json

@@ -1,5 +1,4 @@
 {
-  "enablePullDownRefresh": false,
   "usingComponents": {
     "nav-bar": "./../components/navbar/navbar"
   }

+ 4 - 4
pages/index/index.wxml

@@ -9,7 +9,7 @@
     <view style="font-size: 32rpx; color: #333333; margin-top: 14rpx;">下午好,Demon</view>
 
     <!-- banner-->
-    <view class="banner_container">
+    <view wx:if="{{bannerList.length>0}}" class="banner_container">
       <swiper class="swiper" indicator-dots="{{bannerList.length>1}}" autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}" circular="{{circular}}" indicator-active-color="#FFFFFF" indicator-color="#999999">
         <block wx:for="{{bannerList}}" wx:key="index">
           <swiper-item>
@@ -24,11 +24,11 @@
       <view style="color: white; margin-left: 8rpx; font-size: 32rpx;">添加设备</view>
     </view>
 
-    <view style="height: calc(100vh - 118rpx - 14rpx - 20rpx - 32rpx - 264rpx - 88rpx - 64rpx - 58rpx -  {{navBarHeight}}px);margin-top: 10rpx;padding-top: 22rpx; ">
+    <scroll-view scroll-y="true" style="height: calc(100vh - 118rpx - 14rpx - 20rpx - 32rpx - 88rpx - 64rpx - 58rpx -  {{navBarHeight}}px);margin-top: 22rpx;padding-top: 10rpx; ">
 
       <view wx:if="{{deviceList}}">
         <block wx:key="key" wx:for-item="item" wx:for-index="index" wx:for="{{deviceList}}">
-          <view class="item_public" style="border: {{item.state && item.state === 'online'&&deviceListIndex === index  ? '4rpx solid #6546A3' : item.state && item.state === 'online'?'2rpx solid #6546A3':'2rpx solid #F2F5F7'}};" data-item="{{item}}" bind:tap="{{item.state && item.state === 'online' ? 'onTapIem' : ''}}">
+          <view class="item_public" style="width: calc(100vw - 68rpx);border: {{item.state && item.state === 'online'&&deviceListIndex === index  ? '4rpx solid #6546A3' : item.state && item.state === 'online'?'2rpx solid #6546A3':'2rpx solid #F2F5F7'}};" data-item="{{item}}" bind:tap="{{item.state && item.state === 'online' ? 'onTapIem' : ''}}">
             <image class="item_public_image" src="./../../img/min.png" style="opacity: {{item.state && item.state === 'online' ? '1' : '0.5'}};"></image>
             <view class="item_public_right" style="margin-right: 26rpx; opacity: {{item.state && item.state === 'online' ? '1' : '0.5'}};">
               <view style="height: 190rpx; margin-top: 37rpx; margin-left: 32rpx; flex-direction: column; display: flex;">
@@ -47,7 +47,7 @@
           </view>
         </block>
       </view>
-    </view>
+    </scroll-view>
   </view>
 
   <view wx:else>

+ 1 - 1
pages/index/index.wxss

@@ -788,11 +788,11 @@
  }
 
  .item_public {
-   width: 100%;
    height: 264rpx;
    border: 2rpx solid #6546A3;
    border-radius: 24rpx;
    display: flex;
+   margin-bottom: 10rpx;
  }
 
  .item_public_image {

+ 1 - 0
pages/indexCopy/indexCopy.js

@@ -448,6 +448,7 @@ Page({
     if (this.data.deviceListIndex === null) {
       return;
     };
+
     listByDevice({ clientType }).then((res) => {
       _this.setData({
         channelData: res

+ 47 - 20
utils/api.js

@@ -1,39 +1,66 @@
-const {request} = require('./util.js')
-module.exports={
+const {
+  request
+} = require('./util.js')
+module.exports = {
+  // 首页设备列表
+  getDevices: (data) => {
+    return request("/mini/wx/device/base/deviceList", data, "GET", {
+      "content-type": "application/x-www-form-urlencoded"
+    })
+  },
+
   // 登录
-  login:(data)=>{
-    return request("/mini/wx/user/login", data, "POST", {"content-type":"application/json"}, false)
+  login: (data) => {
+    return request("/mini/wx/user/login", data, "POST", {
+      "content-type": "application/json"
+    }, false)
   },
   // 注册
-  register:(data)=>{
-    return request("/mini/wx/user/registerV2", data, "POST", {"content-type":"application/json"}, false)
+  register: (data) => {
+    return request("/mini/wx/user/registerV2", data, "POST", {
+      "content-type": "application/json"
+    }, false)
   },
   // 频道列表
-  listByDevice:(data)=>{
-    return request("/mini/wx/channelDefault/listByDevice", data, "GET", {"content-type":"application/x-www-form-urlencoded"})
+  listByDevice: (data) => {
+    return request("/mini/wx/channelDefault/listByDevice", data, "GET", {
+      "content-type": "application/x-www-form-urlencoded"
+    })
   },
   // 一级频道详情列表
-  pageByDevice:(data)=>{
-    return request("/mini/wx/channelDefault/pageByDevice", data, "GET", {"content-type":"application/x-www-form-urlencoded"})
+  pageByDevice: (data) => {
+    return request("/mini/wx/channelDefault/pageByDevice", data, "GET", {
+      "content-type": "application/x-www-form-urlencoded"
+    })
   },
   // 查询设备绑定的唤醒音信息
-  deviceWakedetail:(data)=>{
-    return request("/mini/wx/deviceWake/detail", data, "GET", {"content-type":"application/x-www-form-urlencoded"})
+  deviceWakedetail: (data) => {
+    return request("/mini/wx/deviceWake/detail", data, "GET", {
+      "content-type": "application/x-www-form-urlencoded"
+    })
   },
   // 查询设备的唤醒音音频列表
-  deviceWakeList:(data)=>{
-    return request("/mini/wx/deviceWake/list", data, "GET", {"content-type":"application/x-www-form-urlencoded"})
+  deviceWakeList: (data) => {
+    return request("/mini/wx/deviceWake/list", data, "GET", {
+      "content-type": "application/x-www-form-urlencoded"
+    })
   },
   // 设备设置唤醒音
-  deviceWakeadd:(data)=>{
-    return request("/mini/wx/deviceWake/add", data, "POST", {"content-type":"application/x-www-form-urlencoded"})
+  deviceWakeadd: (data) => {
+    return request("/mini/wx/deviceWake/add", data, "POST", {
+      "content-type": "application/x-www-form-urlencoded"
+    })
   },
   // 查询设备的唤醒音下的音频列表
-  radioList:(data)=>{
-    return request("/mini/wx/deviceWake/radioList", data, "GET", {"content-type":"application/json"})
+  radioList: (data) => {
+    return request("/mini/wx/deviceWake/radioList", data, "GET", {
+      "content-type": "application/json"
+    })
   },
   // 初始化
-  init:()=>{
-    return request("/mini/wx/user/init", {}, "GET", {"content-type":"application/x-www-form-urlencoded"})
+  init: () => {
+    return request("/mini/wx/user/init", {}, "GET", {
+      "content-type": "application/x-www-form-urlencoded"
+    })
   },
 }