import { getUserInfo, setFans, getUserRead } from '~/api/user' import share from '~/mixins/share' import reachBottom from '~/mixins/reachBottom' Page({ behaviors: [reachBottom, share], /** * 页面的初始数据 */ data: { uid: '', userInfo: {}, // type为pk,顶部显示为pk时样式,user为默认样式 type: 'user' }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { this.setData({ type: options.type || 'user', uid: options.uid }) }, onShow() { this.getUserInfo() }, async getUserInfo() { let res = await getUserInfo({ uid: this.data.uid }) this.setData({ userInfo: res }) this.resetData() }, loadMore() { this.getData(getUserRead, { uid: this.data.userInfo.user.uid }) }, // 关注 async setFans() { let newLike = !this.data.userInfo.like let res = await setFans({ uid: this.data.userInfo.user.uid, // fanId: }, 'put') console.log(res); this.setData({ ['userInfo.like']: newLike }) wx.showToast({ title: newLike ? '已关注' : '取消关注', icon: 'none' }) }, toPkPage({ currentTarget }) { wx.navigateTo({ url: `/pages/pkPage/index?videoId=${currentTarget.dataset.id}` }) }, })