1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- import {
- getUserInfo,
- setFans
- } from '~/api/user'
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- userInfo: {}
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- this.getUserInfo()
- },
- async getUserInfo() {
- let res = await getUserInfo({
- uid: '16c02342a44f45d78bb25b52ae6082ae'
- })
- 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}`
- })
- },
- })
|