123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- 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}`
- })
- },
- })
|