mirror of
https://gitee.com/qingqing-coconut-tea/RcKtFezyRAZX
synced 2026-07-21 10:32:32 +08:00
init
This commit is contained in:
58
wechat/components/user-card/user-card.js
Normal file
58
wechat/components/user-card/user-card.js
Normal file
@@ -0,0 +1,58 @@
|
||||
// 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,查看完整运行演示。
|
||||
*/
|
||||
10
wechat/components/user-card/user-card.json
Normal file
10
wechat/components/user-card/user-card.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
|
||||
/**
|
||||
* @联系作者:16768118056
|
||||
* @描述:(此项目非免费分享)源码百分百可用,搞定毕设不发愁,支持远程调试安装、二次开发、定制、讲解、文档类。
|
||||
* @访问:https://www.notmaker.com/detail/8326a897119d4542896c863a69d7bbe7/gtt20260415,查看完整运行演示。
|
||||
*/
|
||||
24
wechat/components/user-card/user-card.wxml
Normal file
24
wechat/components/user-card/user-card.wxml
Normal file
@@ -0,0 +1,24 @@
|
||||
<!-- components/user-card/user-card.wxml -->
|
||||
<!-- 用户卡片组件 -->
|
||||
|
||||
<view class="user-card" bindtap="onTap">
|
||||
<image class="avatar" src="{{user.avatar || '/static/images/default-avatar.png'}}" />
|
||||
<view class="info">
|
||||
<text class="nickname">{{user.nickname}}</text>
|
||||
<text class="bio" wx:if="{{user.bio}}">{{user.bio}}</text>
|
||||
<view class="stats" wx:if="{{user.articleCount || user.favoriteCount || user.followerCount}}">
|
||||
<text class="stat">文章 {{user.articleCount || 0}}</text>
|
||||
<text class="stat">粉丝 {{user.followerCount || 0}}</text>
|
||||
<text class="stat">获赞 {{user.likeCount || 0}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<button class="follow-btn {{isFollowing ? 'following' : ''}}" wx:if="{{showFollow}}" bindtap="onFollow">
|
||||
{{isFollowing ? '已关注' : '关注'}}
|
||||
</button>
|
||||
</view>
|
||||
|
||||
/**
|
||||
* @联系作者:16768118056
|
||||
* @描述:(此项目非免费分享)源码百分百可用,搞定毕设不发愁,支持远程调试安装、二次开发、定制、讲解、文档类。
|
||||
* @访问:https://www.notmaker.com/detail/8326a897119d4542896c863a69d7bbe7/gtt20260415,查看完整运行演示。
|
||||
*/
|
||||
70
wechat/components/user-card/user-card.wxss
Normal file
70
wechat/components/user-card/user-card.wxss
Normal file
@@ -0,0 +1,70 @@
|
||||
/* components/user-card/user-card.wxss */
|
||||
/* 用户卡片样式 */
|
||||
|
||||
.user-card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 24rpx;
|
||||
background-color: #fff;
|
||||
border-radius: 16rpx;
|
||||
}
|
||||
|
||||
.avatar {
|
||||
width: 96rpx;
|
||||
height: 96rpx;
|
||||
border-radius: 48rpx;
|
||||
margin-right: 20rpx;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.info {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.nickname {
|
||||
font-size: 30rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
margin-bottom: 8rpx;
|
||||
}
|
||||
|
||||
.bio {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
margin-bottom: 12rpx;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.stats {
|
||||
display: flex;
|
||||
gap: 20rpx;
|
||||
}
|
||||
|
||||
.stat {
|
||||
font-size: 22rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.follow-btn {
|
||||
padding: 12rpx 28rpx;
|
||||
font-size: 26rpx;
|
||||
color: #fff;
|
||||
background-color: #667eea;
|
||||
border-radius: 32rpx;
|
||||
}
|
||||
|
||||
.follow-btn.following {
|
||||
color: #999;
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
/**
|
||||
* @联系作者:16768118056
|
||||
* @描述:(此项目非免费分享)源码百分百可用,搞定毕设不发愁,支持远程调试安装、二次开发、定制、讲解、文档类。
|
||||
* @访问:https://www.notmaker.com/detail/8326a897119d4542896c863a69d7bbe7/gtt20260415,查看完整运行演示。
|
||||
*/
|
||||
Reference in New Issue
Block a user