init: initial commit

This commit is contained in:
2026-10-07 09:28:43 +08:00
commit a68a4ef411
251 changed files with 38279 additions and 0 deletions
+106
View File
@@ -0,0 +1,106 @@
const { getLayout } = require('../../utils/layout');
// pages/history/history.js
const { api } = require('../../utils/request');
// 操作类型对应的图标和颜色
var ACTION_CONFIG = {
login: { icon: '🔓', color: '#82B1FF', label: '登录' },
timeline_create: { icon: '📅', color: '#FF8A65', label: '记忆日' },
timeline_update: { icon: '✏️', color: '#FF8A65', label: '记忆日' },
album_create: { icon: '📷', color: '#66BB6A', label: '相册' },
photo_upload: { icon: '🖼️', color: '#66BB6A', label: '照片' },
diary_create: { icon: '📝', color: '#FF6B9D', label: '日记' },
diary_update: { icon: '✏️', color: '#FF6B9D', label: '日记' },
song_add: { icon: '🎵', color: '#AB47BC', label: '歌曲' },
checkin_do: { icon: '✅', color: '#42A5F5', label: '打卡' },
profile_edit: { icon: '👤', color: '#FFA726', label: '资料' },
partner_edit: { icon: '💑', color: '#FFA726', label: '资料' },
couple_edit: { icon: '💕', color: '#EC407A', label: '纪念日' },
unbind_request: { icon: '💔', color: '#EF5350', label: '解绑' },
unbind_agreed: { icon: '💔', color: '#EF5350', label: '解绑' },
unbind_rejected: { icon: '💖', color: '#EF5350', label: '解绑' },
unbind_cancelled: { icon: '↩️', color: '#EF5350', label: '解绑' },
};
Page({
onResize: function() { this.setData(getLayout()); },
data: { loadError: false, list: [], page: 1, totalPages: 0, pages: [], loading: true },
onLoad: function() {
this.setData(getLayout()); this.loadLogs(); },
onPullDownRefresh: async function() {
this.setData({ page: 1, list: [] });
await this.loadLogs();
wx.stopPullDownRefresh();
},
loadLogs: async function() {
if (this._pageLoading) return;
this._pageLoading = true;
this.setData({loading:true, loadError:false});
var cp = this.data.page;
this.setData({ loading: true });
try {
const res = await api.activityLogList({ page: cp, page_size: 20 });
var items = (res.items || []).map(function(item) {
item.created_at = item.created_at ? item.created_at.substring(0, 16).replace('T', ' ') : '';
var cfg = ACTION_CONFIG[item.action_type] || { icon: '📌', color: '#999', label: '' };
item.action_icon = cfg.icon;
item.action_color = cfg.color;
item.action_label = cfg.label;
return item;
});
var tp = res.total_pages || 1;
var pages = [];
if (tp <= 7) {
for (var i = 1; i <= tp; i++) { pages.push({ num: i, dot: false }); }
} else {
pages.push({ num: 1, dot: false });
pages.push({ num: 2, dot: false });
pages.push({ num: 3, dot: false });
if (cp > 4) pages.push({ num: 0, dot: true });
pages.push({ num: tp - 2, dot: false });
pages.push({ num: tp - 1, dot: false });
pages.push({ num: tp, dot: false });
}
var pageData = {
list: items,
page: cp,
totalPages: tp,
pages: pages,
loading: false
};
this.setData(pageData);
} catch (e) {
this.setData({loadError:true});
this.setData({ loading: false });
wx.showToast({ title: '加载失败', icon: 'none' });
}
finally { this._pageLoading = false; this.setData({loading:false}); }
},
goPage: function(e) {
var p = parseInt(e.currentTarget.dataset.page);
if (p === this.data.page) return;
this.setData({ page: p });
this.loadLogs();
},
goPrev: function() {
if (this.data.page <= 1) return;
this.setData({ page: this.data.page - 1 });
this.loadLogs();
},
goNext: function() {
if (this.data.page >= this.data.totalPages) return;
this.setData({ page: this.data.page + 1 });
this.loadLogs();
},
goToSettings: function() { wx.navigateTo({ url: '/pages/settings/settings' }); },
goHome: function() { wx.redirectTo({ url: '/pages/index/index' }); },
goToProfile: function() { wx.redirectTo({ url: '/pages/profile/profile' }); }
});
+7
View File
@@ -0,0 +1,7 @@
{
"disableScroll": true,
"usingComponents": {
"app-nav": "/components/app-nav/app-nav",
"page-state": "/components/page-state/page-state"
}
}
+51
View File
@@ -0,0 +1,51 @@
<view class="app-shell app-shell--secondary" style="{{layoutStyle}}">
<launch-transition />
<!-- pages/history/history.wxml - 情侣操作记录(优化版) -->
<app-nav title="操作记录" back="{{true}}" />
<scroll-view class="page-bg" scroll-y show-scrollbar="{{false}}" bounces="{{true}}" style="height:100vh;">
<view class="container">
<!-- 加载状态 -->
<page-state wx:if="{{loading}}" kind="loading" title="正在加载操作记录" /><page-state wx:elif="{{loadError}}" kind="error" title="操作记录加载失败" action="重试" bind:action="loadLogs" />
<block wx:elif="{{list.length > 0}}">
<view class="log-list">
<view class="log-item" wx:for="{{list}}" wx:key="id">
<view class="log-icon-wrap" style="background:{{item.action_color}}20;">
<text class="log-icon">{{item.action_icon}}</text>
</view>
<view class="log-card">
<view class="log-header">
<view class="log-user-row">
<text class="log-label" style="color:{{item.action_color}};">{{item.action_label}}</text>
<text class="log-user" style="color:{{item.gender == 'male' ? '#82B1FF' : '#FF8A80'}};">{{item.nickname}}</text>
</view>
<text class="log-time">{{item.created_at}}</text>
</view>
<view class="log-body">{{item.description}}</view>
</view>
</view>
</view>
<view class="pagination" wx:if="{{totalPages > 1}}">
<text class="page-btn {{page <= 1 ? 'disabled' : ''}}" bindtap="goPrev">‹</text>
<block wx:for="{{pages}}" wx:key="num">
<text class="page-dot" wx:if="{{item.dot}}">…</text>
<text class="page-num {{page == item.num ? 'active' : ''}}" wx:else bindtap="goPage" data-page="{{item.num}}">{{item.num}}</text>
</block>
<text class="page-btn {{page >= totalPages ? 'disabled' : ''}}" bindtap="goNext">›</text>
</view>
</block>
<block wx:else>
<view class="empty-state">
<text class="empty-icon">📋</text>
<text class="empty-text">暂无操作记录</text>
<text class="empty-desc">双方的操作都会记录在这里 ✨</text>
</view>
</block>
</view>
</scroll-view>
</view>
+77
View File
@@ -0,0 +1,77 @@
/* pages/history/history.wxss - 操作记录优化版 */
@import '../../styles/common.wxss';
page { background: linear-gradient(180deg, #F4E2E3 0%, #FAF5EE 55%, #FAF5EE 100%); height: 100vh; overflow: hidden; }
.container { padding-top: 16rpx; padding-bottom: 300rpx; }
scroll-view.page-bg { height: 100vh; overflow-y: scroll; -webkit-overflow-scrolling: touch; }
/* ===== 加载状态 ===== */
.loading-state { text-align:center; padding:160rpx 40rpx; }
.loading-icon { font-size:60rpx; display:block; margin-bottom:16rpx; }
.loading-text { font-size:26rpx; color:#bbb; }
/* ===== 操作列表(卡片式) ===== */
.log-list { padding: 0 8rpx; }
.log-item {
display: flex;
align-items: flex-start;
gap: 20rpx;
margin-bottom: 24rpx;
}
.log-icon-wrap {
width: 64rpx;
height: 64rpx;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
margin-top: 4rpx;
}
.log-icon { font-size: 28rpx; }
.log-card {
flex: 1;
background: #fff;
border-radius: 16rpx;
padding: 18rpx 20rpx;
box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.04);
}
.log-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 6rpx;
}
.log-user-row {
display: flex;
align-items: center;
gap: 8rpx;
}
.log-label {
font-size: 20rpx;
padding: 2rpx 12rpx;
border-radius: 8rpx;
font-weight: 500;
}
.log-user { font-size: 24rpx; font-weight: 600; }
.log-time { font-size: 20rpx; color: #bbb; flex-shrink: 0; }
.log-body { font-size: 26rpx; color: #555; line-height: 1.6; }
/* ===== 分页 ===== */
.pagination { display:flex; justify-content:center; align-items:center; gap:8rpx; padding:32rpx 0; flex-wrap:wrap; }
.page-btn { width:56rpx; height:56rpx; line-height:56rpx; text-align:center; border-radius:50%; background:#fff; color:#FF6B81; font-size:28rpx; font-weight:700; }
.page-btn.disabled { color:#ddd; }
.page-num { width:56rpx; height:56rpx; line-height:56rpx; text-align:center; border-radius:50%; background:#fff; color:#888; font-size:24rpx; }
.page-num.active { background:linear-gradient(135deg,#B74768,#B388FF); color:#fff; font-weight:700; }
.page-dot { width:56rpx; height:56rpx; line-height:56rpx; text-align:center; color:#ccc; font-size:24rpx; }
/* ===== 空状态 ===== */
.empty-state { text-align:center; padding:120rpx 40rpx; }
.empty-icon { font-size:80rpx; display:block; margin-bottom:24rpx; }
.empty-text { font-size:30rpx; color:#888; display:block; margin-bottom:8rpx; }
.empty-desc { font-size:24rpx; color:#bbb; }
@import '../../styles/design.wxss';
@import '../../styles/journal.wxss';