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