import { getUserInfo, setFans } from '~/api/user' Page({ /** * 页面的初始数据 */ data: { userInfo: {} }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { console.log(options.uid); this.getUserInfo(options.uid) }, async getUserInfo(uid) { let res = await getUserInfo({ uid }) console.log(res); this.setData({ userInfo: res }) }, // 关注 async setFans() { let newLike = !this.data.userInfo.like await setFans({ uid: this.data.userInfo.user.uid }, 'put') this.setData({ ['userInfo.like']: newLike }) wx.showToast({ title: newLike ? '已关注' : '取消关注', icon: 'none' }) }, toPkPage({ currentTarget }) { wx.navigateTo({ url: `/pages/pkPage/index?videoId=${currentTarget.dataset.id}` }) }, })