Browse Source

增加萌娃相册功能

Limengbo 6 years ago
parent
commit
a948a8d4e2
3 changed files with 32 additions and 4 deletions
  1. 29 1
      pages/childMatch/childMatch.js
  2. 1 1
      pages/childMatch/childMatch.wxml
  3. 2 2
      utils/APIRequest.js

+ 29 - 1
pages/childMatch/childMatch.js

@@ -6,7 +6,8 @@ Page({
    * 页面的初始数据
    */
   data: {
-    photoBoxList: []
+    photoBoxList: [],
+    hiddenFlag: true
   },
 
   //点击跳转到相册
@@ -16,6 +17,33 @@ Page({
       url: `/pages/access/access?id=${currentTarget.id}`
     })
   },
+  //萌娃相册的搜素
+  focus: function ({detail}) {
+    if (detail.value) {
+      httpRequestApi.getPhotoBoxList({
+        name: detail.value
+      }).success((res) => {
+        console.log('萌娃相册搜索结果', res)
+        this.setData({
+          photoBoxList: res.data.data.list
+        })
+        if(res.data.data.list.length == 0) {
+          this.setData({
+            hiddenFlag: false
+          })
+        }else {
+          this.setData({
+            hiddenFlag: true
+          })
+        }
+      })
+    }else {
+      this.getPhotoBoxList();
+      this.setData({
+        hiddenFlag: true
+      })
+    }
+  },
   /**
    * 生命周期函数--监听页面加载
    */

+ 1 - 1
pages/childMatch/childMatch.wxml

@@ -15,7 +15,7 @@
                 </view> 
             </view>
         </scroll-view>
-        <view class="no-find" hidden="true">
+        <view class="no-find" hidden="{{hiddenFlag}}">
             <text>没有找到相关的内容</text>
             <text>换个关键字再试试吧</text>
         </view>

+ 2 - 2
utils/APIRequest.js

@@ -111,11 +111,11 @@ class httpRequestApi {
     }).method('PUT').send();
   }
   //萌娃相册列表
-  static getPhotoBoxList() {
+  static getPhotoBoxList(data) {
     const url = httpApiUrl('wx/photoBox/cuteBaby/list');
     return getInstance().header({
       uid: wx.getStorageSync('uid'),
-    }).url(url).send();
+    }).url(url).data(data).send();
   }
   //根据用户id获取用户相册信息
   static getPhotoBoxInfoById(data) {