chore: 首次纳入版本控制(审查前基线,v1.2.0)
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
const api = require("../../utils/api");
|
||||
|
||||
const CHANNELS = [
|
||||
{ k: "three_lines", name: "三句话", tip: "这题错在… 关键是… 下次遇到先…" },
|
||||
{ k: "ai_voice", name: "讲给 AI 听", tip: "假装我是你同桌,我没听懂" },
|
||||
{ k: "steps", name: "写步骤", tip: "一步一步写下来" },
|
||||
{ k: "find_error", name: "找错", tip: "别人这么做错了,你挑出来" },
|
||||
{ k: "make_question", name: "出题", tip: "自己出一道同类型的" },
|
||||
];
|
||||
|
||||
// 换行用字符码拼:WXML 的属性值里写不了 \n(会被编译器当成非法转义)。
|
||||
const NL = String.fromCharCode(10);
|
||||
|
||||
const PLACEHOLDER = {
|
||||
three_lines: "这题错在…" + NL + "关键是…" + NL + "下次遇到先…",
|
||||
ai_voice: "假装我是你同桌:你为什么要先算这一步?",
|
||||
steps: "第一步…" + NL + "第二步…" + NL + "所以我最后得出的答案是…",
|
||||
find_error: "先说他在哪一步错了,再说你会怎么改",
|
||||
make_question: "出一道同类型的题,写上答案和最关键的那一步",
|
||||
};
|
||||
|
||||
Page({
|
||||
data: {
|
||||
mid: "",
|
||||
item: null,
|
||||
channels: CHANNELS,
|
||||
channel: "three_lines",
|
||||
ph: PLACEHOLDER.three_lines,
|
||||
text: "",
|
||||
submitting: false,
|
||||
result: null,
|
||||
loading: true,
|
||||
},
|
||||
|
||||
onLoad(query) {
|
||||
if (!api.requireChild()) return;
|
||||
this.setData({ mid: query.mid || "" });
|
||||
this.load();
|
||||
},
|
||||
|
||||
load() {
|
||||
const child = getApp().globalData.child;
|
||||
api
|
||||
.get("/api/mistakes?child_id=" + child.id)
|
||||
.then((d) => {
|
||||
const item = (d.items || []).find((m) => m.id === this.data.mid) || null;
|
||||
this.setData({ item, loading: false });
|
||||
})
|
||||
.catch((e) => {
|
||||
api.toastError(e);
|
||||
this.setData({ loading: false });
|
||||
});
|
||||
},
|
||||
|
||||
pickChannel(e) {
|
||||
const k = e.currentTarget.dataset.k;
|
||||
this.setData({ channel: k, ph: PLACEHOLDER[k] || "", result: null });
|
||||
},
|
||||
|
||||
onInput(e) {
|
||||
this.setData({ text: e.detail.value });
|
||||
},
|
||||
|
||||
onSubmit() {
|
||||
const text = (this.data.text || "").trim();
|
||||
if (text.length < 8) {
|
||||
wx.showToast({ title: "太短了,多说两句", icon: "none" });
|
||||
return;
|
||||
}
|
||||
if (this.data.submitting) return;
|
||||
this.setData({ submitting: true });
|
||||
|
||||
api
|
||||
.post("/api/mistakes/" + this.data.mid + "/explain", {
|
||||
child_id: getApp().globalData.child.id,
|
||||
channel: this.data.channel,
|
||||
text,
|
||||
})
|
||||
.then((r) => this.setData({ result: r, submitting: false }))
|
||||
.catch((e) => {
|
||||
api.toastError(e);
|
||||
this.setData({ submitting: false });
|
||||
});
|
||||
},
|
||||
|
||||
onBack() {
|
||||
wx.reLaunch({ url: "/pages/home/home" });
|
||||
},
|
||||
|
||||
onRetry() {
|
||||
this.setData({ result: null, text: "" });
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"navigationBarTitleText": "讲一遍"
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<view class="wrap">
|
||||
<view class="card" wx:if="{{item}}">
|
||||
<view class="card-title">这道题</view>
|
||||
<view class="stem">{{item.stem}}</view>
|
||||
<view class="muted">连对两次了。讲清楚这一遍,它就从队列里毕业。</view>
|
||||
</view>
|
||||
|
||||
<view class="pick">
|
||||
<view
|
||||
class="chip {{channel === item.k ? 'on' : ''}}"
|
||||
wx:for="{{channels}}"
|
||||
wx:key="k"
|
||||
data-k="{{item.k}}"
|
||||
bindtap="pickChannel"
|
||||
>{{item.name}}</view>
|
||||
</view>
|
||||
|
||||
<view class="tip" wx:for="{{channels}}" wx:key="k" wx:if="{{item.k === channel}}">{{item.tip}}</view>
|
||||
|
||||
<view class="box">
|
||||
<textarea
|
||||
class="ta"
|
||||
placeholder="{{ph}}"
|
||||
value="{{text}}"
|
||||
bindinput="onInput"
|
||||
maxlength="300"
|
||||
auto-height
|
||||
/>
|
||||
<view class="count">{{text.length}} / 300</view>
|
||||
</view>
|
||||
|
||||
<button class="btn" bindtap="onSubmit" disabled="{{submitting}}">
|
||||
{{submitting ? "判中…" : "说完了"}}
|
||||
</button>
|
||||
|
||||
<view class="result" wx:if="{{result}}">
|
||||
<view class="rh {{result.passed ? 'ok' : 'no'}}">{{result.passed ? "通过,毕业" : "还差一点"}}</view>
|
||||
<view class="rd" wx:if="{{result.missing}}">缺的是:{{result.missing}}</view>
|
||||
<view class="rd" wx:if="{{result.detail}}">{{result.detail}}</view>
|
||||
<view class="rs">现在状态:<text class="tag {{result.status}}">{{result.status_zh}}</text></view>
|
||||
<button class="btn" style="margin-top:16px" bindtap="{{result.passed ? 'onBack' : 'onRetry'}}">
|
||||
{{result.passed ? "回今天" : "再说一遍"}}
|
||||
</button>
|
||||
</view>
|
||||
|
||||
<view class="foot">7 天内可以讲 3 次,讲不过会回到队列,明天再做一次。</view>
|
||||
</view>
|
||||
@@ -0,0 +1,23 @@
|
||||
.stem { font-size: 17px; font-weight: 700; line-height: 1.6; margin-bottom: 6px; }
|
||||
|
||||
.pick { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 10px; }
|
||||
.chip {
|
||||
padding: 7px 13px; border-radius: 999px; background: #fff;
|
||||
border: 1px solid var(--line); font-size: 13px; color: #5f5852;
|
||||
}
|
||||
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
|
||||
|
||||
.tip { font-size: 12px; color: var(--ochre); margin-bottom: 10px; }
|
||||
|
||||
.box { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px 6px; margin-bottom: 16px; }
|
||||
.ta { width: 100%; min-height: 110px; font-size: 15px; line-height: 1.7; }
|
||||
.count { text-align: right; font-size: 11px; color: #b9b1a9; padding-bottom: 6px; }
|
||||
|
||||
.result { margin-top: 20px; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
|
||||
.rh { font-size: 19px; font-weight: 700; margin-bottom: 6px; }
|
||||
.rh.ok { color: var(--bamboo); }
|
||||
.rh.no { color: var(--brand); }
|
||||
.rd { font-size: 13px; color: #4a4440; line-height: 1.7; }
|
||||
.rs { margin-top: 8px; font-size: 13px; color: var(--muted); }
|
||||
|
||||
.foot { margin-top: 20px; text-align: center; font-size: 11px; color: #b9b1a9; line-height: 1.6; }
|
||||
Reference in New Issue
Block a user