mirror of
https://gitee.com/qingqing-coconut-tea/RcKtFezyRAZX
synced 2026-07-21 10:32:32 +08:00
init
This commit is contained in:
87
wechat/components/article-card/article-card.js
Normal file
87
wechat/components/article-card/article-card.js
Normal file
@@ -0,0 +1,87 @@
|
||||
// components/article-card/article-card.js
|
||||
// 文章卡片组件
|
||||
|
||||
Component({
|
||||
properties: {
|
||||
article: {
|
||||
type: Object,
|
||||
value: {}
|
||||
},
|
||||
showActions: {
|
||||
type: Boolean,
|
||||
value: true
|
||||
}
|
||||
},
|
||||
|
||||
data: {
|
||||
isFavorite: false,
|
||||
isLike: false
|
||||
},
|
||||
|
||||
lifetimes: {
|
||||
attached() {
|
||||
if (this.data.article) {
|
||||
this.setData({
|
||||
isFavorite: this.data.article.isFavorite || false,
|
||||
isLike: this.data.article.isLike || false
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
onTap() {
|
||||
const article = this.data.article
|
||||
if (article && article.id) {
|
||||
wx.navigateTo({
|
||||
url: `/pages/article-detail/article-detail?id=${article.id}`
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
onFavorite(e) {
|
||||
e.stopPropagation()
|
||||
const article = this.data.article
|
||||
if (!article || !article.id) return
|
||||
|
||||
const isFavorite = !this.data.isFavorite
|
||||
this.setData({ isFavorite })
|
||||
|
||||
this.triggerEvent('favorite', {
|
||||
articleId: article.id,
|
||||
isFavorite
|
||||
})
|
||||
},
|
||||
|
||||
onLike(e) {
|
||||
e.stopPropagation()
|
||||
const article = this.data.article
|
||||
if (!article || !article.id) return
|
||||
|
||||
const isLike = !this.data.isLike
|
||||
this.setData({ isLike })
|
||||
|
||||
this.triggerEvent('like', {
|
||||
articleId: article.id,
|
||||
isLike
|
||||
})
|
||||
},
|
||||
|
||||
onShare(e) {
|
||||
e.stopPropagation()
|
||||
const article = this.data.article
|
||||
if (article) {
|
||||
wx.showShareMenu({
|
||||
withShareTicket: true,
|
||||
menus: ['shareAppMessage', 'shareTimeline']
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
/**
|
||||
* @联系作者:16768118056
|
||||
* @描述:(此项目非免费分享)源码百分百可用,搞定毕设不发愁,支持远程调试安装、二次开发、定制、讲解、文档类。
|
||||
* @访问:https://www.notmaker.com/detail/8326a897119d4542896c863a69d7bbe7/gtt20260415,查看完整运行演示。
|
||||
*/
|
||||
10
wechat/components/article-card/article-card.json
Normal file
10
wechat/components/article-card/article-card.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
|
||||
/**
|
||||
* @联系作者:16768118056
|
||||
* @描述:(此项目非免费分享)源码百分百可用,搞定毕设不发愁,支持远程调试安装、二次开发、定制、讲解、文档类。
|
||||
* @访问:https://www.notmaker.com/detail/8326a897119d4542896c863a69d7bbe7/gtt20260415,查看完整运行演示。
|
||||
*/
|
||||
36
wechat/components/article-card/article-card.wxml
Normal file
36
wechat/components/article-card/article-card.wxml
Normal file
@@ -0,0 +1,36 @@
|
||||
<!-- components/article-card/article-card.wxml -->
|
||||
<!-- 文章卡片组件 -->
|
||||
|
||||
<view class="article-card" bindtap="onTap">
|
||||
<view class="card-content">
|
||||
<image class="cover" wx:if="{{article.coverImage}}" src="{{article.coverImage}}" mode="aspectFill" />
|
||||
<view class="info">
|
||||
<text class="title">{{article.title}}</text>
|
||||
<text class="summary">{{article.summary}}</text>
|
||||
<view class="meta">
|
||||
<text class="author">{{article.authorName}}</text>
|
||||
<text class="time">{{article.createTime}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="card-actions" wx:if="{{showActions}}">
|
||||
<view class="action-item {{isLike ? 'active' : ''}}" bindtap="onLike">
|
||||
<text class="iconfont {{isLike ? 'icon-like-fill' : 'icon-like'}}"></text>
|
||||
<text>{{article.likeCount || 0}}</text>
|
||||
</view>
|
||||
<view class="action-item {{isFavorite ? 'active' : ''}}" bindtap="onFavorite">
|
||||
<text class="iconfont {{isFavorite ? 'icon-favorite-fill' : 'icon-favorite'}}"></text>
|
||||
<text>{{article.favoriteCount || 0}}</text>
|
||||
</view>
|
||||
<view class="action-item" bindtap="onShare">
|
||||
<text class="iconfont icon-share"></text>
|
||||
<text>分享</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
/**
|
||||
* @联系作者:16768118056
|
||||
* @描述:(此项目非免费分享)源码百分百可用,搞定毕设不发愁,支持远程调试安装、二次开发、定制、讲解、文档类。
|
||||
* @访问:https://www.notmaker.com/detail/8326a897119d4542896c863a69d7bbe7/gtt20260415,查看完整运行演示。
|
||||
*/
|
||||
102
wechat/components/article-card/article-card.wxss
Normal file
102
wechat/components/article-card/article-card.wxss
Normal file
@@ -0,0 +1,102 @@
|
||||
/* components/article-card/article-card.wxss */
|
||||
/* 文章卡片样式 */
|
||||
|
||||
.article-card {
|
||||
background-color: #fff;
|
||||
border-radius: 16rpx;
|
||||
overflow: hidden;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.card-content {
|
||||
display: flex;
|
||||
padding: 24rpx;
|
||||
}
|
||||
|
||||
.cover {
|
||||
width: 200rpx;
|
||||
height: 150rpx;
|
||||
border-radius: 12rpx;
|
||||
margin-right: 20rpx;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.info {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 30rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
margin-bottom: 12rpx;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
}
|
||||
|
||||
.summary {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
margin-bottom: 16rpx;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.meta {
|
||||
display: flex;
|
||||
gap: 20rpx;
|
||||
}
|
||||
|
||||
.author,
|
||||
.time {
|
||||
font-size: 22rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.card-actions {
|
||||
display: flex;
|
||||
border-top: 1rpx solid #f0f0f0;
|
||||
}
|
||||
|
||||
.action-item {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 20rpx;
|
||||
gap: 8rpx;
|
||||
}
|
||||
|
||||
.action-item .iconfont {
|
||||
font-size: 32rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.action-item text {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.action-item.active .iconfont {
|
||||
color: #667eea;
|
||||
}
|
||||
|
||||
.action-item.active text {
|
||||
color: #667eea;
|
||||
}
|
||||
|
||||
/**
|
||||
* @联系作者:16768118056
|
||||
* @描述:(此项目非免费分享)源码百分百可用,搞定毕设不发愁,支持远程调试安装、二次开发、定制、讲解、文档类。
|
||||
* @访问:https://www.notmaker.com/detail/8326a897119d4542896c863a69d7bbe7/gtt20260415,查看完整运行演示。
|
||||
*/
|
||||
Reference in New Issue
Block a user