Explorar o código

调整搜索历史记录相关

bayi %!s(int64=2) %!d(string=hai) anos
pai
achega
7cf3cd848d

+ 4 - 1
components/uploadFile/index.js

@@ -25,7 +25,10 @@ Component({
    * 组件的属性列表
    */
   properties: {
-    readingType: '',
+    readingType: {
+      type: String,
+      value: ""
+    },
     activityId: ''
   },
   /**

+ 9 - 4
pages/childClassify/index.js

@@ -82,6 +82,11 @@ Page({
   setSearch({
     detail
   }) {
+    if (!detail.value) {
+      this.setData({
+        nullList: false
+      })
+    }
     this.setData({
       text: detail.value
     })
@@ -99,14 +104,14 @@ Page({
     })
     if (!this.data.historySearch.includes(this.data.text)) {
       this.setData({
-        historySearch: [...this.data.historySearch, this.data.text].slice(-10)
+        historySearch: [this.data.text, ...this.data.historySearch].slice(0, 10)
       })
+      wx.setStorageSync('search', this.data.historySearch)
     }
     this.setData({
       list,
       nullList: list.length == 0
     })
-    wx.setStorageSync('search', this.data.historySearch.slice(-10))
   },
   historySearch({
     currentTarget
@@ -123,9 +128,9 @@ Page({
       return item != currentTarget.dataset.text
     })
     this.setData({
-      historySearch: newList.slice(-10)
+      historySearch: newList.slice(0, 10)
     })
-    wx.setStorageSync('search', newList.slice(-10))
+    wx.setStorageSync('search', this.data.historySearch)
   },
   goRead({
     currentTarget

+ 1 - 1
pages/friend/index.js

@@ -76,7 +76,7 @@ Page({
           list: listCopy
         })
         wx.showToast({
-          title: '已关',
+          title: '已关',
           icon: 'none'
         })
       }

+ 1 - 1
pages/friend/index.wxml

@@ -10,7 +10,7 @@
     </view>
   </view>
   <view class="box">
-    <view class="follow" wx:for="{{list}}" wx:key="index">
+    <view class="follow" wx:for="{{list}}" wx:key="index" bindtap="jumpUserInfo" data-uid='{{item.user.uid}}'>
       <view class="left">
         <image class='avatar' src="{{ item.user.avatar }}" />
         <view class="profession">{{item.user.profession}}</view>

+ 33 - 5
pages/searchFriend/index.js

@@ -1,5 +1,6 @@
 import {
-  getOtherUser
+  getOtherUser,
+  setFans
 } from '~/api/user'
 import reachBottom from '~/mixins/reachBottom'
 Page({
@@ -17,6 +18,11 @@ Page({
   setSearch({
     detail
   }) {
+    if (!detail.value) {
+      this.setData({
+        nullList: false
+      })
+    }
     this.setData({
       text: detail.value
     })
@@ -38,7 +44,7 @@ Page({
     this.resetData()
     if (!this.data.historySearch.includes(this.data.text)) {
       this.setData({
-        historySearch: [...this.data.historySearch, this.data.text].slice(-10)
+        historySearch: [this.data.text, ...this.data.historySearch].slice(0, 10)
       })
     }
     wx.setStorageSync('userSearch', this.data.historySearch)
@@ -50,9 +56,9 @@ Page({
       return item != currentTarget.dataset.text
     })
     this.setData({
-      historySearch: newList.slice(-10)
+      historySearch: newList.slice(0, 10)
     })
-    wx.setStorageSync('userSearch', newList.slice(-10))
+    wx.setStorageSync('userSearch', this.data.historySearch)
   },
   loadMore() {
     if (!this.data.text) {
@@ -62,7 +68,7 @@ Page({
       query: this.data.text,
     })
   },
-  async setFans({
+  jumpUserInfo({
     currentTarget
   }) {
     let uid = currentTarget.dataset.uid
@@ -70,6 +76,28 @@ Page({
       url: `/pages/personal/index?uid=${uid}`,
     })
   },
+  async setFans({
+    currentTarget
+  }) {
+    if (!currentTarget.dataset.iseachother) {
+      await setFans({
+        uid: currentTarget.dataset.uid
+      })
+      let listCopy = JSON.parse(JSON.stringify(this.data.list))
+      listCopy.forEach(item => {
+        if (item.uid == currentTarget.dataset.uid) {
+          item.isEachOther = true
+        }
+      })
+      this.setData({
+        list: listCopy
+      })
+      wx.showToast({
+        title: '已关注',
+        icon: 'none'
+      })
+    }
+  },
   onReachBottom() {
     this.loadMore()
   }

+ 6 - 6
pages/searchFriend/index.wxml

@@ -20,7 +20,7 @@
     </view>
   </view>
   <view class="box">
-    <view class="follow" wx:for="{{list}}" wx:key="index" data-uid='{{item.uid}}' bindtap="setFans">
+    <view class="follow" wx:for="{{list}}" wx:key="index" bindtap="jumpUserInfo" data-uid='{{item.uid}}'>
       <view class="left">
         <image class='avatar' src="{{ item.avatar }}" />
         <view class="profession">{{item.profession}}</view>
@@ -29,12 +29,12 @@
         <view class="infoBox">
           <view class="top">
             <view class="nickName"> {{item.nickName||item.eid}}</view>
-            <view class="state" data-uid='{{item.uid}}' data-isEachOther="{{item.isEachOther}}" bindtap="setFans">
-              <view class="stateText already" wx:if="{{currentType==1}}">
-                {{item.isEachOther?'互相关注':'已关注'}}
+            <view class="state" data-uid='{{item.uid}}' data-isEachOther="{{item.isEachOther}}" catchtap="setFans">
+              <view class="stateText already" wx:if="{{item.isEachOther}}">
+                {{item.isFans?'互相关注':'已关注'}}
               </view>
-              <view class="stateText {{item.isEachOther?'already':'yet'}}" wx:else>
-                {{item.isEachOther?'互相关注':'回关'}}
+              <view class="stateText yet" wx:else>
+                {{item.isFans?'回关':'关注'}}
               </view>
             </view>
           </view>

+ 5 - 5
utils/request.js

@@ -6,13 +6,13 @@ const {
     envVersion
   }
 } = wx.getAccountInfoSync();
-if (envVersion == 'develop') {
+// if (envVersion == 'develop') {
   baseUrl = 'https://reader-api.efunbox.cn/wx'
   oldUrl = 'https://reader-api.efunbox.cn'
-} else {
-  baseUrl = 'https://reader-api.ai160.com/wx'
-  oldUrl = 'https://reader-api.ai160.com'
-}
+// } else {
+//   baseUrl = 'https://reader-api.ai160.com/wx'
+//   oldUrl = 'https://reader-api.ai160.com'
+// }
 
 function request(url, method, data, oldBaseUrl = false) {
   let header = {