12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- import {
- getOtherUser
- } from '~/api/user'
- import reachBottom from '~/mixins/reachBottom'
- Page({
- behaviors: [reachBottom],
- data: {
- text: '',
- historySearch: []
- },
- onShow() {
- this.setData({
- historySearch: wx.getStorageSync('userSearch')
- })
- this.resetData()
- },
- setSearch({
- detail
- }) {
- this.setData({
- text: detail.value
- })
- },
- searchUser({
- currentTarget
- }) {
- if (currentTarget.dataset.text) {
- this.setData({
- text: currentTarget.dataset.text
- })
- }
- if (!this.data.text) {
- this.setData({
- list: [],
- })
- return
- }
- this.resetData()
- if (!this.data.historySearch.includes(this.data.text)) {
- this.setData({
- historySearch: [...this.data.historySearch, this.data.text].slice(-10)
- })
- }
- wx.setStorageSync('userSearch', this.data.historySearch)
- },
- deleteHistory({
- currentTarget
- }) {
- let newList = this.data.historySearch.filter(item => {
- return item != currentTarget.dataset.text
- })
- this.setData({
- historySearch: newList.slice(-10)
- })
- wx.setStorageSync('userSearch', newList.slice(-10))
- },
- loadMore() {
- if (!this.data.text) {
- return
- }
- this.getData(getOtherUser, {
- query: this.data.text,
- })
- },
- async setFans({
- currentTarget
- }) {
- let uid = currentTarget.dataset.uid
- wx.navigateTo({
- url: `/pages/personal/index?uid=${uid}`,
- })
- },
- onReachBottom() {
- this.loadMore()
- }
- })
|