Files
mzltMpfqGS e4a087e67e init
2026-04-15 19:45:16 +08:00

59 lines
1.2 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// components/user-card/user-card.js
// 用户卡片组件
Component({
properties: {
user: {
type: Object,
value: {}
},
showFollow: {
type: Boolean,
value: true
}
},
data: {
isFollowing: false
},
lifetimes: {
attached() {
if (this.data.user) {
this.setData({ isFollowing: this.data.user.isFollowing || false })
}
}
},
methods: {
onTap() {
const user = this.data.user
if (user && user.id) {
wx.navigateTo({
url: `/pages/user-profile/user-profile?userId=${user.id}`
})
}
},
onFollow(e) {
e.stopPropagation()
const user = this.data.user
if (!user || !user.id) return
const isFollowing = !this.data.isFollowing
this.setData({ isFollowing })
this.triggerEvent('follow', {
userId: user.id,
isFollowing
})
}
}
})
/**
* @联系作者16768118056
* @描述:(此项目非免费分享)源码百分百可用,搞定毕设不发愁,支持远程调试安装、二次开发、定制、讲解、文档类。
* @访问https://www.notmaker.com/detail/8326a897119d4542896c863a69d7bbe7/gtt20260415查看完整运行演示。
*/