123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- import {
- getFansList,
- getMyInfo,
- setFans
- } from '~/api/user'
- import event from '~/mixins/event'
- import reachBottom from '~/mixins/reachBottom'
- Page({
- behaviors: [reachBottom,event],
- data: {
- // 1我的关注;2我的粉丝
- currentType: 1,
- c1: 0,
- c2: 0,
- userInfo: {},
- localUid: wx.getStorageSync('uid')
- },
- async onShow() {
- this.resetData()
- let c1 = await getFansList({
- pageSize: 1,
- type: 1
- })
- let c2 = await getFansList({
- pageSize: 1,
- type: 2
- })
- let userInfo = await getMyInfo()
- this.setData({
- c1: c1.totalSize,
- c2: c2.totalSize,
- userInfo
- })
- },
- 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'
- })
- }
- }
- },
- searchFriend() {
- wx.navigateTo({
- url: '/pages/searchFriend/index',
- })
- },
- clipboar({
- currentTarget
- }) {
- wx.setClipboardData({
- data: currentTarget.dataset.eid,
- success: function (res) { //成功回调函数
- wx.showToast({
- title: '已复制',
- icon: "none"
- })
- }
- })
- },
- sendMsg({
- currentTarget
- }) {
- let user = currentTarget.dataset.user
- let {
- nickName,
- eid,
- uid
- } = user
- if (this.data.localUid == uid) {
- return wx.showToast({
- title: '不可以给自己发私信哦~',
- icon: 'none'
- })
- }
- wx.navigateTo({
- url: `/pages/chat/index?title=${nickName||eid}&uid=${uid}`,
- })
- },
- onReachBottom() {
- this.loadMore()
- },
- })
|