1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- import {
- getFansList,
- setFans
- } from '~/api/user'
- import reachBottom from '~/mixins/reachBottom'
- Page({
- behaviors: [reachBottom],
- data: {
- // 1我的关注;2我的粉丝
- currentType: 1
- },
- onShow() {
- this.resetData()
- },
- setType({
- currentTarget
- }) {
- this.setData({
- currentType: currentTarget.dataset.type
- })
- this.resetData()
- },
- // 获取分类的内容
- loadMore() {
- let type = this.data.currentType
- this.getData(getFansList, {
- pageSize: 20,
- type
- })
- },
- jumpUserInfo({
- currentTarget
- }) {
- let uid = currentTarget.dataset.uid
- wx.navigateTo({
- url: `/pages/personal/index?uid=${uid}`,
- })
- },
- async setFans({
- currentTarget
- }) {
- if (this.data.currentType == '1') {
- this.jumpUserInfo({
- currentTarget
- })
- } else {
- if (currentTarget.dataset.iseachother) {
- this.jumpUserInfo({
- currentTarget
- })
- } else {
- await setFans({
- uid: currentTarget.dataset.uid
- })
- let listCopy = JSON.parse(JSON.stringify(this.data.list))
- listCopy.forEach(item => {
- if (item.user.uid == currentTarget.dataset.uid) {
- item.isEachOther = true
- }
- })
- this.setData({
- list: listCopy
- })
- wx.showToast({
- title: '已回关',
- icon: 'none'
- })
- }
- }
- }
- })
|