目录结构调整

This commit is contained in:
2026-02-04 23:47:45 +08:00
parent 6938c911c3
commit 6b22238c6e
8780 changed files with 15333 additions and 574 deletions

View File

@@ -0,0 +1,4 @@
{
"usingComponents": {},
"navigationBarTitleText": "谁去拿外卖"
}

View File

@@ -0,0 +1,84 @@
Page({
data: {
names: [] as string[],
newName: '',
result: '',
isRolling: false
},
onLoad() {
// Initialize with some default placeholder data optionally, or keep empty
// this.setData({ names: ['张三', '李四', '王五'] });
},
onInput(e: any) {
this.setData({ newName: e.detail.value });
},
addName() {
const name = this.data.newName.trim();
if (!name) {
wx.showToast({ title: '请输入名字', icon: 'none' });
return;
}
// Check duplication
if (this.data.names.includes(name)) {
wx.showToast({ title: '名字已存在', icon: 'none' });
return;
}
const names = [...this.data.names, name];
this.setData({ names, newName: '' });
},
removeName(e: any) {
if (this.data.isRolling) return;
const index = e.currentTarget.dataset.index;
const names = [...this.data.names];
names.splice(index, 1);
this.setData({ names });
// If deleted the current result, clear result
if (this.data.names.indexOf(this.data.result) === -1) {
// actually result is a string copy, but if logic requires reset:
// this.setData({ result: '' });
}
},
startDraw() {
if (this.data.isRolling) return;
const names = this.data.names;
if (names.length < 2) {
wx.showToast({ title: '至少需要两个人才能抽取哦', icon: 'none' });
return;
}
this.setData({ isRolling: true, result: '' });
let count = 0;
// Speed up first then slow down? Or simple uniform interval.
// Let's do a simple one first.
let baseInterval = 50;
let totalRolls = 30;
const roll = () => {
const randomIndex = Math.floor(Math.random() * names.length);
this.setData({ result: names[randomIndex] });
count++;
if (count < totalRolls) {
// dynamic interval could be fun, but keeping it simple for now
setTimeout(roll, baseInterval + (count * 5)); // slowing down
} else {
this.setData({ isRolling: false });
wx.vibrateShort({ type: 'heavy' });
}
};
roll();
}
});

View File

@@ -0,0 +1,39 @@
<view class="container">
<view class="header-tip">
<view class="title">🎲 天选打工人</view>
<text class="subtitle">输入名字,看看今天谁去拿外卖</text>
</view>
<view class="input-area">
<input class="input" placeholder="输入名字 (如: 小明)" value="{{newName}}" bindinput="onInput" bindconfirm="addName" />
<view class="btn-add" bindtap="addName">添加</view>
</view>
<view class="list-container">
<view class="list-header">候选名单 ({{names.length}})</view>
<scroll-view scroll-y class="list-area">
<view class="name-list">
<block wx:for="{{names}}" wx:key="*this">
<view class="name-item color-{{index % 5}}">
<text class="name-text">{{item}}</text>
<view class="btn-delete" bindtap="removeName" data-index="{{index}}">×</view>
</view>
</block>
<view wx:if="{{names.length === 0}}" class="empty-tip">
<text class="empty-icon">🍃</text>
<text>还没有候选人,快去添加吧~</text>
</view>
</view>
</scroll-view>
</view>
<view class="result-area">
<view class="result-box {{isRolling ? 'rolling' : ''}}">
<text class="result-label">🎉 天选之人</text>
<text class="result-text">{{result || '?'}}</text>
</view>
<button class="btn-start" hover-class="btn-start-hover" bindtap="startDraw" disabled="{{isRolling || names.length < 2}}">
{{isRolling ? '🤞 随机抽取中...' : '🚀 开始抽取'}}
</button>
</view>
</view>

View File

@@ -0,0 +1,235 @@
page {
background: linear-gradient(180deg, #fce4ec 0%, #f3e5f5 100%);
height: 100%;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}
.container {
display: flex;
flex-direction: column;
height: 100vh;
padding: 20px;
box-sizing: border-box;
}
.header-tip {
text-align: center;
margin-bottom: 24px;
}
.title {
font-size: 24px;
font-weight: bold;
color: #880e4f;
margin-bottom: 4px;
}
.subtitle {
font-size: 14px;
color: #ad1457;
opacity: 0.7;
}
.input-area {
display: flex;
margin-bottom: 20px;
background: #fff;
border-radius: 50px;
padding: 6px;
box-shadow: 0 4px 12px rgba(173, 20, 87, 0.1);
border: 2px solid rgba(255,255,255,0.5);
}
.input {
flex: 1;
height: 44px;
padding: 0 20px;
font-size: 16px;
color: #333;
}
.btn-add {
min-width: 80px;
height: 44px;
line-height: 44px;
text-align: center;
background: linear-gradient(135deg, #ec407a, #d81b60);
color: #fff;
border-radius: 40px;
font-size: 15px;
font-weight: bold;
box-shadow: 0 4px 8px rgba(216, 27, 96, 0.3);
transition: opacity 0.2s;
}
.btn-add:active {
opacity: 0.8;
}
.list-container {
flex: 1;
display: flex;
flex-direction: column;
background: rgba(255, 255, 255, 0.6);
border-radius: 20px;
padding: 15px 15px 5px 15px; /* bottom padding smaller because scrollview */
margin-bottom: 20px;
backdrop-filter: blur(10px);
min-height: 0; /* Important for flex child to scroll */
}
.list-header {
font-size: 14px;
color: #888;
margin-bottom: 10px;
padding-left: 5px;
}
.list-area {
flex: 1;
overflow: hidden;
}
.name-list {
display: flex;
flex-wrap: wrap;
align-content: flex-start; /* 防止换行后拉伸 */
gap: 10px;
padding-bottom: 10px;
}
.name-item {
padding: 8px 16px 8px 12px;
border-radius: 20px;
font-size: 14px;
display: flex;
align-items: center;
position: relative;
font-weight: 500;
box-shadow: 0 2px 5px rgba(0,0,0,0.05);
animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes popIn {
from { transform: scale(0.8); opacity: 0; }
to { transform: scale(1); opacity: 1; }
}
/* 伪随机颜色,根据 .color-0 到 .color-4 */
.color-0 { background: #e3f2fd; color: #1565c0; }
.color-1 { background: #e8f5e9; color: #2e7d32; }
.color-2 { background: #fff3e0; color: #ef6c00; }
.color-3 { background: #f3e5f5; color: #7b1fa2; }
.color-4 { background: #ffebee; color: #c62828; }
.name-text {
margin-right: 18px; /* 给关闭按钮留空间 */
}
.btn-delete {
position: absolute;
right: 6px;
top: 50%;
transform: translateY(-50%);
width: 20px;
height: 20px;
line-height: 18px;
text-align: center;
border-radius: 50%;
background: rgba(0,0,0,0.08);
font-size: 16px;
font-weight: normal;
}
.btn-delete:active {
background: rgba(0,0,0,0.2);
}
.color-0 .btn-delete { color: #1565c0; }
.color-1 .btn-delete { color: #2e7d32; }
.color-2 .btn-delete { color: #ef6c00; }
.color-3 .btn-delete { color: #7b1fa2; }
.color-4 .btn-delete { color: #c62828; }
.empty-tip {
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
color: #999;
padding-top: 40px;
}
.empty-icon {
font-size: 40px;
margin-bottom: 10px;
opacity: 0.5;
}
.result-area {
display: flex;
flex-direction: column;
align-items: center;
padding-bottom: 20px;
}
.result-box {
width: 100%;
background: #fff;
border-radius: 20px;
padding: 20px;
text-align: center;
margin-bottom: 20px;
box-shadow: 0 10px 30px rgba(0,0,0,0.1);
display: flex;
flex-direction: column;
justify-content: center;
min-height: 120px;
transition: transform 0.1s;
}
.result-box.rolling {
transform: scale(0.98);
background: #fff8e1;
}
.result-label {
font-size: 13px;
color: #999;
margin-bottom: 5px;
text-transform: uppercase;
letter-spacing: 1px;
}
.result-text {
font-size: 32px;
font-weight: 800;
color: #333;
/* Prevent long names from overflowing */
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.btn-start {
width: 100% !important;
background: linear-gradient(135deg, #7b1fa2 0%, #4a148c 100%);
color: #fff;
border-radius: 50px;
padding: 14px 0;
font-size: 18px;
font-weight: bold;
box-shadow: 0 8px 20px rgba(74, 20, 140, 0.4);
transition: all 0.2s;
}
.btn-start-hover {
transform: translateY(2px);
box-shadow: 0 4px 10px rgba(74, 20, 140, 0.3);
}
.btn-start[disabled] {
opacity: 0.6;
background: #9e9e9e;
box-shadow: none;
transform: none;
}