|
@@ -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()
|
|
|
}
|