首次提交

This commit is contained in:
zeronline
2026-06-25 08:39:47 +08:00
parent 20a93c703a
commit c5cccd346b
169 changed files with 24720 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
const api = require('../../../services/api')
Page({
data: { name: '', category: 'study', cycleType: 'daily', dailyGoal: '', privacy: 2, submitting: false },
onNameInput(e) { this.setData({ name: e.detail.value }) },
onGoalInput(e) { this.setData({ dailyGoal: e.detail.value }) },
setCategory(e) { this.setData({ category: e.currentTarget.dataset.cat }) },
setCycle(e) { this.setData({ cycleType: e.currentTarget.dataset.cycle }) },
setPrivacy(e) { this.setData({ privacy: parseInt(e.currentTarget.dataset.val) }) },
async onSubmit() {
if (!this.data.name.trim()) { wx.showToast({ title: '请输入名称', icon: 'none' }); return }
this.setData({ submitting: true })
try {
await api.post('/api/checkin/items', {
name: this.data.name.trim(), category: this.data.category,
cycleType: this.data.cycleType, dailyGoal: this.data.dailyGoal || undefined, privacy: this.data.privacy
})
wx.showToast({ title: '创建成功' })
wx.navigateBack()
} catch(e) { wx.showToast({ title: e.message || '创建失败', icon: 'none' }) }
this.setData({ submitting: false })
}
})
+1
View File
@@ -0,0 +1 @@
{ "navigationBarTitleText": "创建打卡项", "usingComponents": {} }
+32
View File
@@ -0,0 +1,32 @@
<view class="form">
<text class="label">名称 *</text>
<input class="input-field" value="{{name}}" bindinput="onNameInput" placeholder="如「每天背单词」" style="margin-bottom:20px" />
<text class="label">分类</text>
<view class="category-grid">
<view class="cat-item {{category==='study'?'active':''}}" data-cat="study" bindtap="setCategory">📚 学习</view>
<view class="cat-item {{category==='health'?'active':''}}" data-cat="health" bindtap="setCategory">❤️ 健康</view>
<view class="cat-item {{category==='habit'?'active':''}}" data-cat="habit" bindtap="setCategory">🔄 习惯</view>
<view class="cat-item {{category==='hobby'?'active':''}}" data-cat="hobby" bindtap="setCategory">⭐ 兴趣</view>
<view class="cat-item {{category==='goal'?'active':''}}" data-cat="goal" bindtap="setCategory">🎯 目标</view>
</view>
<text class="label" style="margin-top:20px">打卡周期</text>
<view class="cycle-row">
<view class="cycle-item {{cycleType==='daily'?'active':''}}" data-cycle="daily" bindtap="setCycle">每日</view>
<view class="cycle-item {{cycleType==='weekly'?'active':''}}" data-cycle="weekly" bindtap="setCycle">每周</view>
<view class="cycle-item {{cycleType==='every_other_day'?'active':''}}" data-cycle="every_other_day" bindtap="setCycle">隔日</view>
</view>
<text class="label" style="margin-top:20px">每日目标(选填)</text>
<input class="input-field" value="{{dailyGoal}}" bindinput="onGoalInput" placeholder="如「背 50 个单词」" style="margin-bottom:20px" />
<text class="label">隐私设置</text>
<view class="privacy-row">
<view class="privacy-item {{privacy===1?'active':''}}" data-val="1" bindtap="setPrivacy">公开</view>
<view class="privacy-item {{privacy===2?'active':''}}" data-val="2" bindtap="setPrivacy">好友可见</view>
<view class="privacy-item {{privacy===3?'active':''}}" data-val="3" bindtap="setPrivacy">私密</view>
</view>
<button class="btn-primary" style="margin-top:32px" loading="{{submitting}}" disabled="{{submitting}}" bindtap="onSubmit">创建打卡项</button>
</view>
+11
View File
@@ -0,0 +1,11 @@
.form { padding: 16px; }
.label { font-size: 13px; color: #86868B; margin-bottom: 6px; display: block; }
.category-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.cat-item { padding: 12px 8px; border-radius: 10px; border: 2px solid #E5E5EA; background: #f8f8fa; text-align: center; font-size: 14px; }
.cat-item.active { border-color: #FF6B35; background: #FFF0EB; font-weight: 600; }
.cycle-row { display: flex; gap: 8px; }
.cycle-item { padding: 8px 16px; border-radius: 8px; border: 1.5px solid #E5E5EA; background: #f8f8fa; font-size: 14px; }
.cycle-item.active { border-color: #FF6B35; background: #FFF0EB; font-weight: 600; }
.privacy-row { display: flex; gap: 8px; }
.privacy-item { padding: 8px 16px; border-radius: 8px; border: 1.5px solid #E5E5EA; background: #f8f8fa; font-size: 14px; }
.privacy-item.active { border-color: #FF6B35; background: #FFF0EB; font-weight: 600; }