chore: 首次纳入版本控制(审查前基线,v1.2.0)

This commit is contained in:
errortopic
2026-11-18 20:13:37 +08:00
commit f7b28e1740
441 changed files with 31220 additions and 0 deletions
+112
View File
@@ -0,0 +1,112 @@
const api = require("../../utils/api");
Page({
data: {
loading: true,
items: [],
index: 0,
item: null,
total: 0,
answer: "",
submitting: false,
result: null,
},
onLoad(query) {
if (!api.requireChild()) return;
this.setData({ index: Number(query.i || 0) });
this.load();
},
load() {
const child = getApp().globalData.child;
api
.get("/api/today?child_id=" + child.id)
.then((d) => {
const items = d.items || [];
const index = Math.min(this.data.index, Math.max(items.length - 1, 0));
this.setData({
items,
index,
total: items.length,
item: items[index] || null,
loading: false,
answer: "",
result: null,
});
})
.catch((e) => {
api.toastError(e);
this.setData({ loading: false });
});
},
onInput(e) {
this.setData({ answer: e.detail.value });
},
onSubmit() {
const { item, answer, submitting } = this.data;
if (!item || submitting) return;
if (!(answer || "").trim()) {
wx.showToast({ title: "先写个答案", icon: "none" });
return;
}
this.setData({ submitting: true });
api
.post("/api/mistakes/" + item.id + "/attempt", {
child_id: getApp().globalData.child.id,
answer: answer.trim(),
})
.then((r) => {
this.setData({ result: r, submitting: false });
})
.catch((e) => {
api.toastError(e);
this.setData({ submitting: false });
});
},
onNext() {
const next = this.data.index + 1;
if (next >= this.data.total) {
wx.showModal({
title: "今天的 5 道做完了",
content: "不再追加。明天见。",
showCancel: false,
success: () => wx.reLaunch({ url: "/pages/home/home" }),
});
return;
}
const items = this.data.items;
this.setData({
index: next,
item: items[next],
answer: "",
result: null,
});
},
/** 没标准答案的题(拍照切出来的应用题/语文题):孩子自己判。 */
onSelfJudge(e) {
const { item, submitting } = this.data;
if (!item || submitting) return;
const correct = e.currentTarget.dataset.ok === "1";
this.setData({ submitting: true });
api
.post("/api/mistakes/" + item.id + "/self-judge", {
child_id: getApp().globalData.child.id,
correct,
})
.then((r) => this.setData({ result: r, submitting: false }))
.catch((err) => {
api.toastError(err);
this.setData({ submitting: false });
});
},
onExplainNow() {
const mid = this.data.result && this.data.result.mistake_id;
wx.redirectTo({ url: "/pages/explain/explain?mid=" + (mid || this.data.item.id) });
},
});
+3
View File
@@ -0,0 +1,3 @@
{
"navigationBarTitleText": "做题"
}
+53
View File
@@ -0,0 +1,53 @@
<view class="wrap" wx:if="{{item}}">
<view class="bar">
<text class="prog">第 {{index + 1}} / {{total}} 道</text>
<text class="tag {{item.status}}">{{item.status_zh}}</text>
</view>
<view class="stem {{item.subject === 'chinese' ? 'chn' : 'math'}}">
<view class="sub">{{item.subject === 'chinese' ? '语文' : '数学'}}</view>
<view class="text">{{item.stem}}</view>
</view>
<block wx:if="{{item.judge_type !== 'manual'}}">
<view class="answer">
<input class="ipt" type="text" placeholder="把答案写这儿" value="{{answer}}" bindinput="onInput" confirm-type="done" />
</view>
<button class="btn" bindtap="onSubmit" disabled="{{submitting}}">
{{submitting ? "判分中…" : "交卷"}}
</button>
</block>
<view class="selfjudge" wx:else>
<view class="sj-t">这题机器没有标准答案,你说了算</view>
<view class="sj-row">
<button class="btn plain" data-ok="1" bindtap="onSelfJudge" disabled="{{submitting}}">我做对了</button>
<button class="btn plain" data-ok="0" bindtap="onSelfJudge" disabled="{{submitting}}">我做错了</button>
</view>
<view class="sj-n">自己判不算放水:复习时间照样按规则排。</view>
</view>
<view class="result" wx:if="{{result}}">
<view class="rh {{result.correct === true ? 'ok' : (result.correct === false ? 'no' : 'skip')}}">
{{result.correct === true ? "对了" : (result.correct === false ? "再想想" : "这次不判")}}
</view>
<view class="rd" wx:if="{{result.detail}}">{{result.detail}}</view>
<view class="rs">这道题现在是:<text class="tag {{result.status}}">{{result.status_zh}}</text></view>
<view class="hint" wx:if="{{result.status === 'careless'}}">
24 小时内做对 → 记成「粗心」,不进复习队列,只进「粗心小记」。
</view>
<view class="hint" wx:if="{{result.status === 'to_explain'}}">
连对两次了,但要讲一遍才算毕业。
</view>
<button class="btn" style="margin-top:16px" bindtap="onNext">
{{index + 1 >= total ? "今天到此为止" : "下一道"}}
</button>
<button class="btn plain" style="margin-top:10px" wx:if="{{result.status === 'to_explain'}}" bindtap="onExplainNow">
现在就讲一遍
</button>
</view>
<view class="foot">第 {{total}} 道做完就结束,不追加。</view>
</view>
<view class="empty" wx:else>今天没有要做的题了</view>
+32
View File
@@ -0,0 +1,32 @@
.bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.prog { font-size: 12px; color: var(--muted); }
.stem { border-radius: 16px; padding: 22px 18px; margin-bottom: 18px; border: 1px solid var(--line); }
.stem.math {
background: var(--paper-math) repeating-linear-gradient(0deg, rgba(169, 118, 26, 0.07) 0 1px, transparent 1px 13px);
}
.stem.chn {
background: var(--paper-chn) repeating-linear-gradient(0deg, rgba(47, 107, 87, 0.07) 0 1px, transparent 1px 14px);
}
.stem .sub { font-size: 11px; color: #9a938c; margin-bottom: 8px; letter-spacing: 1px; }
.stem .text { font-size: 24px; font-weight: 700; line-height: 1.5; word-break: break-all; }
.answer { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 6px 14px; margin-bottom: 16px; }
.ipt { height: 48px; font-size: 18px; }
.result { margin-top: 22px; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.rh { font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.rh.ok { color: var(--bamboo); }
.rh.no { color: var(--brand); }
.rh.skip { color: var(--ochre); }
.rd { font-size: 13px; color: #4a4440; line-height: 1.7; }
.rs { margin-top: 8px; font-size: 13px; color: var(--muted); }
.hint { margin-top: 10px; padding: 9px 11px; background: var(--paper); border-radius: 10px; font-size: 11px; color: #7a6440; line-height: 1.6; }
.foot { margin-top: 22px; text-align: center; font-size: 11px; color: #b9b1a9; }
.selfjudge { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.sj-t { font-size: 14px; font-weight: 700; margin-bottom: 12px; }
.sj-row { display: flex; gap: 10px; }
.sj-row .btn { flex: 1; margin: 0; }
.sj-n { margin-top: 10px; font-size: 11px; color: var(--muted); }