bayi 2 yıl önce
ebeveyn
işleme
c109dc98f0

+ 50 - 56
pages/childClassify/index.js

@@ -1,15 +1,8 @@
-import {
-  getCategoryWorks,
-  searchWorks
-} from '~/api/works'
-import reachBottom from '~/mixins/reachBottom'
-import {
-  createStoreBindings
-} from 'mobx-miniprogram-bindings'
-import {
-  store
-} from '~/store/index'
-let storeBindings
+import { getCategoryWorks, searchWorks } from '~/api/works';
+import reachBottom from '~/mixins/reachBottom';
+import { createStoreBindings } from 'mobx-miniprogram-bindings';
+import { store } from '~/store/index';
+let storeBindings;
 Page({
   behaviors: [reachBottom],
   data: {
@@ -32,41 +25,41 @@ Page({
     if (options.id) {
       this.setData({
         childType: options.id
-      })
-      this.resetData()
+      });
+      this.resetData();
     } else if (options.list) {
-      let categoryList = JSON.parse(decodeURIComponent(options.list))
+      let categoryList = JSON.parse(decodeURIComponent(options.list));
       this.setData({
         categoryList
-      })
-      this.resetData()
+      });
+      this.resetData();
     }
-    wx.setNavigationBarTitle({
+    tt.setNavigationBarTitle({
       title: options.title || '搜索'
-    })
+    });
     this.setData({
       type: options.type,
-      historySearch: wx.getStorageSync('search'),
+      historySearch: tt.getStorageSync('search'),
       navBarTitle: options.title
-    })
+    });
     this.storeBindings = createStoreBindings(this, {
       store,
       fields: {
         userInfo: 'userInfo'
-      },
-    })
+      }
+    });
     // 立刻更新
-    this.storeBindings.updateStoreBindings()
+    this.storeBindings.updateStoreBindings();
   },
   // 获取分类的内容
   loadMore() {
     if (this.data.type == 'search') {
-      return
+      return;
     }
-    let columnId = this.data.childType ? this.data.childType : this.data.categoryList[this.data.currentIndex].id
+    let columnId = this.data.childType ? this.data.childType : this.data.categoryList[this.data.currentIndex].id;
     this.getData(getCategoryWorks, {
       columnId
-    })
+    });
   },
   setClass({
     currentTarget
@@ -76,84 +69,85 @@ Page({
       navBarTitle: currentTarget.dataset.title,
       currentIndex: currentTarget.dataset.index,
       currentId: `class${currentTarget.dataset.index}`
-    })
-    this.resetData()
+    });
+    this.resetData();
   },
   setSearch({
     detail
   }) {
     if (!detail.value) {
       this.setData({
-        nullList: false
-      })
+        nullList: false,
+        list: []
+      });
     }
     this.setData({
       text: detail.value
-    })
+    });
   },
   async search() {
     if (!this.data.text) {
       this.setData({
         list: []
-      })
-      return
+      });
+      return;
     }
     let list = await searchWorks({
       title: this.data.text,
       grade: this.data.userInfo.grade
-    })
+    });
     if (!this.data.historySearch.includes(this.data.text)) {
       this.setData({
         historySearch: [this.data.text, ...this.data.historySearch].slice(0, 20)
-      })
-      wx.setStorageSync('search', this.data.historySearch)
+      });
+      tt.setStorageSync('search', this.data.historySearch);
     }
     this.setData({
       list,
       nullList: list.length == 0
-    })
+    });
   },
   historySearch({
     currentTarget
   }) {
     this.setData({
-      text: currentTarget.dataset.text,
-    })
-    this.search()
+      text: currentTarget.dataset.text
+    });
+    this.search();
   },
   deleteHistory({
     currentTarget
   }) {
     let newList = this.data.historySearch.filter(item => {
-      return item != currentTarget.dataset.text
-    })
+      return item != currentTarget.dataset.text;
+    });
     this.setData({
       historySearch: newList.slice(0, 20)
-    })
-    wx.setStorageSync('search', this.data.historySearch)
+    });
+    tt.setStorageSync('search', this.data.historySearch);
   },
   clearHistory() {
-    wx.showModal({
+    tt.showModal({
       title: '温馨提示',
       content: '历史记录清除后无法恢复,是否清除全部记录',
-      success: (res) => {
+      success: res => {
         if (res.confirm) {
           this.setData({
             historySearch: []
-          })
-          wx.setStorageSync('search', this.data.historySearch)
+          });
+          tt.setStorageSync('search', this.data.historySearch);
         }
       }
-    })
+    });
   },
   goRead({
     currentTarget
   }) {
-    wx.navigateTo({
-      url: `/pages/reading/index?videoId=${currentTarget.dataset.id}&navBarTitle=${this.data.navBarTitle||''}`
-    })
+    tt.navigateTo({
+      url: `/pages/reading/index?videoId=${currentTarget.dataset.id}&navBarTitle=${this.data.navBarTitle || ''}`
+    });
   },
   onUnload() {
-    this.storeBindings.destroyStoreBindings()
-  },
-})
+    this.storeBindings.destroyStoreBindings();
+  }
+});

+ 2 - 1
pages/childClassify/index.less

@@ -34,8 +34,9 @@
     top: 0px;
     left: 0px;
     width: 100%;
-    padding: 4rpx 20rpx;
+    padding: 4rpx 20rpx 18rpx;
     box-sizing: border-box;
+    background-color: #F2F6FC;
     z-index: 9;
 
     .input {

+ 1 - 1
pages/childClassify/index.wxml

@@ -9,7 +9,7 @@
   </scroll-view>
   <view class="searchBox" wx:if="{{type=='search'}}">
     <input class="input" placeholder="请输入搜索内容" bindconfirm='search' confirm-type='send' bindinput="setSearch"
-      value="{{text}}" />
+      value="{{text}}" maxlength='20'/>
     <view class="searchBtn" catchtap="search">
       <image src="/static/search-2.png" class="img" />
     </view>

+ 2 - 1
pages/childClassify/index.wxss

@@ -31,8 +31,9 @@
   top: 0px;
   left: 0px;
   width: 100%;
-  padding: 4rpx 20rpx;
+  padding: 4rpx 20rpx 18rpx;
   box-sizing: border-box;
+  background-color: #F2F6FC;
   z-index: 9;
 }
 .classBox .searchBox .input {

+ 41 - 43
pages/searchFriend/index.js

@@ -1,8 +1,5 @@
-import {
-  getOtherUser,
-  setFans
-} from '~/api/user'
-import reachBottom from '~/mixins/reachBottom'
+import { getOtherUser, setFans } from '~/api/user';
+import reachBottom from '~/mixins/reachBottom';
 Page({
   behaviors: [reachBottom],
   data: {
@@ -11,21 +8,22 @@ Page({
   },
   onShow() {
     this.setData({
-      historySearch: wx.getStorageSync('userSearch')
-    })
-    this.resetData()
+      historySearch: tt.getStorageSync('userSearch')
+    });
+    this.resetData();
   },
   setSearch({
     detail
   }) {
     if (!detail.value) {
       this.setData({
-        nullList: false
-      })
+        nullList: false,
+        list: []
+      });
     }
     this.setData({
       text: detail.value
-    })
+    });
   },
   searchUser({
     currentTarget
@@ -33,62 +31,62 @@ Page({
     if (currentTarget.dataset.text) {
       this.setData({
         text: currentTarget.dataset.text
-      })
+      });
     }
     if (!this.data.text) {
       this.setData({
-        list: [],
-      })
-      return
+        list: []
+      });
+      return;
     }
-    this.resetData()
+    this.resetData();
     if (!this.data.historySearch.includes(this.data.text)) {
       this.setData({
         historySearch: [this.data.text, ...this.data.historySearch].slice(0, 20)
-      })
+      });
     }
-    wx.setStorageSync('userSearch', this.data.historySearch)
+    tt.setStorageSync('userSearch', this.data.historySearch);
   },
   deleteHistory({
     currentTarget
   }) {
     let newList = this.data.historySearch.filter(item => {
-      return item != currentTarget.dataset.text
-    })
+      return item != currentTarget.dataset.text;
+    });
     this.setData({
       historySearch: newList.slice(0, 20)
-    })
-    wx.setStorageSync('userSearch', this.data.historySearch)
+    });
+    tt.setStorageSync('userSearch', this.data.historySearch);
   },
   clearHistory() {
-    wx.showModal({
+    tt.showModal({
       title: '温馨提示',
       content: '历史记录清除后无法恢复,是否清除全部记录',
-      success: (res) => {
+      success: res => {
         if (res.confirm) {
           this.setData({
             historySearch: []
-          })
-          wx.setStorageSync('search', this.data.historySearch)
+          });
+          tt.setStorageSync('search', this.data.historySearch);
         }
       }
-    })
+    });
   },
   loadMore() {
     if (!this.data.text) {
-      return
+      return;
     }
     this.getData(getOtherUser, {
-      query: this.data.text,
-    })
+      query: this.data.text
+    });
   },
   jumpUserInfo({
     currentTarget
   }) {
-    let uid = currentTarget.dataset.uid
-    wx.navigateTo({
-      url: `/pages/personal/index?uid=${uid}`,
-    })
+    let uid = currentTarget.dataset.uid;
+    tt.navigateTo({
+      url: `/pages/personal/index?uid=${uid}`
+    });
   },
   async setFans({
     currentTarget
@@ -96,23 +94,23 @@ Page({
     if (!currentTarget.dataset.iseachother) {
       await setFans({
         uid: currentTarget.dataset.uid
-      })
-      let listCopy = JSON.parse(JSON.stringify(this.data.list))
+      });
+      let listCopy = JSON.parse(JSON.stringify(this.data.list));
       listCopy.forEach(item => {
         if (item.uid == currentTarget.dataset.uid) {
-          item.isEachOther = true
+          item.isEachOther = true;
         }
-      })
+      });
       this.setData({
         list: listCopy
-      })
-      wx.showToast({
+      });
+      tt.showToast({
         title: '已关注',
         icon: 'none'
-      })
+      });
     }
   },
   onReachBottom() {
-    this.loadMore()
+    this.loadMore();
   }
-})
+});

+ 1 - 1
pages/searchFriend/index.wxml

@@ -3,7 +3,7 @@
 <view class="searchFriend">
   <view class="searchBox">
     <input class="input" confirm-type='send' placeholder="查找昵称/学号/手机号" bindinput="setSearch" bindconfirm='searchUser'
-      value="{{text}}" />
+      maxlength='20' value="{{text}}" />
     <view class="searchBtn" catchtap="searchUser">
       <image src="/static/search-2.png" class="img" />
     </view>