取名小程序开发
This commit is contained in:
38
NamingAssistant/pages/favorites/index.js
Normal file
38
NamingAssistant/pages/favorites/index.js
Normal file
@@ -0,0 +1,38 @@
|
||||
const namingStore = require("../../store/namingStore");
|
||||
|
||||
function formatDisplayTime(isoString) {
|
||||
if (!isoString) {
|
||||
return "";
|
||||
}
|
||||
try {
|
||||
const date = new Date(isoString);
|
||||
const yyyy = date.getFullYear();
|
||||
const mm = `${date.getMonth() + 1}`.padStart(2, "0");
|
||||
const dd = `${date.getDate()}`.padStart(2, "0");
|
||||
const hh = `${date.getHours()}`.padStart(2, "0");
|
||||
const mi = `${date.getMinutes()}`.padStart(2, "0");
|
||||
return `${yyyy}-${mm}-${dd} ${hh}:${mi}`;
|
||||
} catch (error) {
|
||||
return isoString;
|
||||
}
|
||||
}
|
||||
|
||||
Page({
|
||||
data: {
|
||||
favorites: []
|
||||
},
|
||||
onShow() {
|
||||
namingStore.loadFavorites();
|
||||
const { favorites } = namingStore.getState();
|
||||
const enriched = favorites.map((item) => ({
|
||||
...item,
|
||||
displayTime: formatDisplayTime(item.createdAt)
|
||||
}));
|
||||
this.setData({ favorites: enriched });
|
||||
},
|
||||
handleDelete(event) {
|
||||
const { id } = event.currentTarget.dataset;
|
||||
namingStore.removeFavorite(id);
|
||||
this.onShow();
|
||||
}
|
||||
});
|
||||
3
NamingAssistant/pages/favorites/index.json
Normal file
3
NamingAssistant/pages/favorites/index.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"navigationBarTitleText": "我的收藏"
|
||||
}
|
||||
37
NamingAssistant/pages/favorites/index.ttml
Normal file
37
NamingAssistant/pages/favorites/index.ttml
Normal file
@@ -0,0 +1,37 @@
|
||||
<view class="page">
|
||||
<view class="glow-layer">
|
||||
<view class="glow glow-one"></view>
|
||||
<view class="glow glow-two"></view>
|
||||
</view>
|
||||
|
||||
<scroll-view class="content" scroll-y="true">
|
||||
<view class="headline">
|
||||
<text class="title">珍藏阁</text>
|
||||
<text class="subtitle">收录曾经触动心弦的灵感姓名,可随时回望取舍</text>
|
||||
</view>
|
||||
|
||||
<view class="empty" tt:if="{{!favorites.length}}">
|
||||
<text>尚未收藏姓名,去玄名殿占卜一卦吧。</text>
|
||||
</view>
|
||||
|
||||
<block tt:for="{{favorites}}" tt:for-item="item" tt:for-index="index" tt:key="id">
|
||||
<view class="favorite-card">
|
||||
<view class="card-glow"></view>
|
||||
<view class="favorite-header">
|
||||
<text class="name">{{item.name}}</text>
|
||||
<button
|
||||
size="mini"
|
||||
type="default"
|
||||
data-id="{{item.id}}"
|
||||
bindtap="handleDelete"
|
||||
class="delete-button"
|
||||
>
|
||||
移除
|
||||
</button>
|
||||
</view>
|
||||
<text class="meaning">{{item.meaning}}</text>
|
||||
<text class="timestamp">收藏于 {{item.displayTime}}</text>
|
||||
</view>
|
||||
</block>
|
||||
</scroll-view>
|
||||
</view>
|
||||
146
NamingAssistant/pages/favorites/index.ttss
Normal file
146
NamingAssistant/pages/favorites/index.ttss
Normal file
@@ -0,0 +1,146 @@
|
||||
.page {
|
||||
position: relative;
|
||||
min-height: 100vh;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.glow-layer {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.glow {
|
||||
position: absolute;
|
||||
border-radius: 50%;
|
||||
filter: blur(90px);
|
||||
opacity: 0.5;
|
||||
animation: float 18s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.glow-one {
|
||||
width: 320px;
|
||||
height: 320px;
|
||||
top: -120px;
|
||||
left: 10px;
|
||||
background: radial-gradient(circle, rgba(255, 210, 160, 0.85), rgba(255, 210, 160, 0));
|
||||
}
|
||||
|
||||
.glow-two {
|
||||
width: 280px;
|
||||
height: 280px;
|
||||
bottom: -120px;
|
||||
right: -40px;
|
||||
background: radial-gradient(circle, rgba(125, 214, 255, 0.8), rgba(125, 214, 255, 0));
|
||||
animation-delay: 5s;
|
||||
}
|
||||
|
||||
@keyframes float {
|
||||
0% {
|
||||
transform: translate3d(0, 0, 0);
|
||||
}
|
||||
50% {
|
||||
transform: translate3d(30px, -25px, 0);
|
||||
}
|
||||
100% {
|
||||
transform: translate3d(0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
.content {
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
height: 100vh;
|
||||
padding: 48px 32px 120px;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 24px;
|
||||
}
|
||||
|
||||
.headline {
|
||||
text-align: center;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 28px;
|
||||
letter-spacing: 10px;
|
||||
text-indent: 10px;
|
||||
color: #fce8d2;
|
||||
text-shadow: 0 0 16px rgba(255, 208, 145, 0.4);
|
||||
}
|
||||
|
||||
.subtitle {
|
||||
font-size: 13px;
|
||||
color: rgba(255, 244, 227, 0.75);
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.empty {
|
||||
margin-top: 120px;
|
||||
text-align: center;
|
||||
color: rgba(255, 244, 227, 0.74);
|
||||
font-size: 14px;
|
||||
letter-spacing: 2px;
|
||||
}
|
||||
|
||||
.favorite-card {
|
||||
position: relative;
|
||||
background: linear-gradient(135deg, rgba(22, 28, 54, 0.85), rgba(32, 38, 68, 0.75));
|
||||
border-radius: 24px;
|
||||
padding: 26px 24px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.08);
|
||||
overflow: hidden;
|
||||
box-shadow: 0 12px 28px rgba(10, 14, 28, 0.45);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
.card-glow {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background: radial-gradient(circle at 20% 20%, rgba(255, 210, 160, 0.45), transparent 60%);
|
||||
opacity: 0.6;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.favorite-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.name {
|
||||
font-size: 22px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 6px;
|
||||
color: #fdf0da;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.delete-button {
|
||||
border-radius: 20px;
|
||||
padding: 0 18px;
|
||||
background: rgba(255, 255, 255, 0.12);
|
||||
color: #fbe6ce;
|
||||
border: 1px solid rgba(255, 255, 255, 0.18);
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.meaning {
|
||||
font-size: 14px;
|
||||
color: rgba(255, 244, 227, 0.8);
|
||||
line-height: 1.8;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.timestamp {
|
||||
font-size: 12px;
|
||||
color: rgba(255, 244, 227, 0.5);
|
||||
letter-spacing: 2px;
|
||||
z-index: 1;
|
||||
}
|
||||
Reference in New Issue
Block a user