| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224 |
- <template>
- <view class="container">
- <view class="page-header">
- <text class="page-title">感恩记录</text>
- <text class="page-sub">管理你的感恩时刻与成效记录</text>
- </view>
- <!-- 记录列表 -->
- <view class="record-list" v-if="records && records.length > 0">
- <view class="record-item" v-for="r in records" :key="r.id">
- <view class="record-main">
- <view class="record-amount">{{ formatAmount(r.effectAmount) }} 元</view>
- <view class="record-tags">
- <text class="tag" v-for="t in (r.effectTypeList || [])" :key="t">{{ t }}</text>
- </view>
- </view>
- <view class="record-date">{{ formatTime(r.createdAt) }}</view>
- <view class="record-desc" v-if="r.effectDesc">{{ r.effectDesc }}</view>
- <view class="record-actions">
- <text class="action-btn-del" @tap="onDelete(r.id)">删除</text>
- </view>
- </view>
- </view>
- <!-- 空状态 -->
- <view class="empty-state" v-else>
- <text class="empty-icon">🙏</text>
- <text class="empty-text">暂无感恩记录</text>
- <text class="empty-hint">记录你的感恩时刻,画出章鱼图</text>
- </view>
- <!-- 添加按钮 -->
- <view class="fab" @tap="goAddEffect">
- <text class="fab-icon">+</text>
- </view>
- </view>
- </template>
- <script>
- import { getOctopusEffects, deleteOctopusEffect } from '../../utils/api.js'
- export default {
- data() {
- return {
- records: [],
- _onLoadFired: false
- }
- },
- onLoad() {
- this.loadRecords()
- this._onLoadFired = true
- },
- onShow() {
- if (this._onLoadFired) {
- this._onLoadFired = false
- } else {
- this.loadRecords()
- }
- },
- methods: {
- async loadRecords() {
- try {
- var res = await getOctopusEffects()
- if (res.code === 200 && res.data && res.data.list) {
- this.records = res.data.list
- } else {
- this.records = []
- }
- } catch (e) { /* 静默 */ }
- },
- formatAmount: function(val) {
- if (val == null) return '0'
- return String(val)
- },
- formatTime: function(ts) {
- if (!ts) return ''
- return String(ts).substring(0, 10)
- },
- onDelete: function(id) {
- var self = this
- uni.showModal({
- title: '提示',
- content: '确定删除这条感恩记录吗?',
- success: function(res) {
- if (!res.confirm) return
- deleteOctopusEffect({ effectId: id }).then(function(r) {
- if (r.code === 200) {
- uni.showToast({ title: '已删除', icon: 'success' })
- self.loadRecords()
- } else {
- uni.showToast({ title: r.message || '删除失败', icon: 'none' })
- }
- }).catch(function(e) {
- uni.showToast({ title: '删除失败', icon: 'none' })
- })
- }
- })
- },
- goAddEffect: function() {
- uni.navigateTo({ url: '/pages/action-detail/octopus-add-effect' })
- }
- }
- }
- </script>
- <style scoped>
- .container {
- min-height: 100vh;
- background: #f5f7fa;
- padding: 24rpx;
- padding-bottom: 120rpx;
- }
- .page-header {
- padding: 20rpx 0 30rpx;
- }
- .page-title {
- font-size: 36rpx;
- font-weight: bold;
- color: #333;
- display: block;
- }
- .page-sub {
- font-size: 24rpx;
- color: #999;
- margin-top: 4rpx;
- display: block;
- }
- .record-list {
- display: flex;
- flex-direction: column;
- gap: 20rpx;
- }
- .record-item {
- background: #fff;
- border-radius: 16rpx;
- padding: 24rpx;
- box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.04);
- position: relative;
- }
- .record-main {
- display: flex;
- justify-content: space-between;
- align-items: center;
- }
- .record-amount {
- font-size: 32rpx;
- font-weight: bold;
- color: #F97316;
- }
- .record-tags {
- display: flex;
- gap: 8rpx;
- }
- .tag {
- font-size: 20rpx;
- padding: 4rpx 12rpx;
- background: #FFF7ED;
- color: #F97316;
- border-radius: 8rpx;
- }
- .record-date {
- font-size: 24rpx;
- color: #94A3B8;
- margin-top: 12rpx;
- }
- .record-desc {
- font-size: 26rpx;
- color: #666;
- margin-top: 8rpx;
- }
- .record-actions {
- position: absolute;
- top: 24rpx;
- right: 24rpx;
- }
- .action-btn-del {
- font-size: 24rpx;
- color: #CBD5E1;
- padding: 4rpx 12rpx;
- border-radius: 8rpx;
- }
- .action-btn-del:active {
- color: #EF4444;
- background: #FEF2F2;
- }
- .empty-state {
- display: flex;
- flex-direction: column;
- align-items: center;
- padding: 80rpx 20rpx;
- }
- .empty-icon {
- font-size: 80rpx;
- margin-bottom: 16rpx;
- }
- .empty-text {
- font-size: 28rpx;
- color: #333;
- font-weight: 500;
- margin-bottom: 8rpx;
- }
- .empty-hint {
- font-size: 24rpx;
- color: #999;
- }
- .fab {
- position: fixed;
- bottom: 80rpx;
- right: 40rpx;
- width: 100rpx;
- height: 100rpx;
- border-radius: 50%;
- background: linear-gradient(135deg, #F97316, #FB923C);
- box-shadow: 0 4rpx 20rpx rgba(249,115,22,0.35);
- display: flex;
- align-items: center;
- justify-content: center;
- }
- .fab-icon {
- font-size: 48rpx;
- color: #fff;
- font-weight: 300;
- }
- </style>
|