chore: 首次纳入版本控制(审查前基线,v1.2.0)
This commit is contained in:
@@ -0,0 +1,104 @@
|
||||
const api = require("../../utils/api");
|
||||
|
||||
const GRADES = ["一年级", "二年级", "三年级", "四年级", "五年级", "六年级"];
|
||||
|
||||
Page({
|
||||
data: {
|
||||
list: [],
|
||||
nickname: "",
|
||||
gradeIndex: 1,
|
||||
grades: GRADES,
|
||||
math: true,
|
||||
chinese: true,
|
||||
saving: false,
|
||||
},
|
||||
|
||||
onShow() {
|
||||
if (!api.requireLogin()) return;
|
||||
this.load();
|
||||
},
|
||||
|
||||
load() {
|
||||
api
|
||||
.get("/api/children")
|
||||
.then((d) => {
|
||||
this.setData({ list: d.items || [] });
|
||||
if (!d.items || !d.items.length) {
|
||||
// 登录成功但还没有档案、也没做过同意 → 先去同意页
|
||||
api
|
||||
.get("/api/consent")
|
||||
.then((c) => {
|
||||
if (!c.consented) wx.reLaunch({ url: "/pages/consent/consent" });
|
||||
})
|
||||
.catch(() => {});
|
||||
}
|
||||
})
|
||||
.catch(api.toastError);
|
||||
},
|
||||
|
||||
onNick(e) {
|
||||
this.setData({ nickname: e.detail.value });
|
||||
},
|
||||
|
||||
onGrade(e) {
|
||||
this.setData({ gradeIndex: Number(e.detail.value) });
|
||||
},
|
||||
|
||||
toggleSubject(e) {
|
||||
const k = e.currentTarget.dataset.k;
|
||||
const next = {};
|
||||
next[k] = !this.data[k];
|
||||
this.setData(next);
|
||||
},
|
||||
|
||||
onSave() {
|
||||
const nickname = (this.data.nickname || "").trim();
|
||||
if (!nickname) {
|
||||
wx.showToast({ title: "给他起个昵称(不用真名)", icon: "none" });
|
||||
return;
|
||||
}
|
||||
if (!this.data.math && !this.data.chinese) {
|
||||
wx.showToast({ title: "至少开一科", icon: "none" });
|
||||
return;
|
||||
}
|
||||
if (this.data.saving) return;
|
||||
this.setData({ saving: true });
|
||||
|
||||
const subjects = [];
|
||||
if (this.data.math) subjects.push("math");
|
||||
if (this.data.chinese) subjects.push("chinese");
|
||||
|
||||
api
|
||||
.post("/api/children", { nickname, grade: this.data.gradeIndex + 1, subjects })
|
||||
.then((child) => {
|
||||
getApp().setChild(child);
|
||||
wx.reLaunch({ url: "/pages/home/home" });
|
||||
})
|
||||
.catch((e) => {
|
||||
api.toastError(e);
|
||||
this.setData({ saving: false });
|
||||
});
|
||||
},
|
||||
|
||||
onPick(e) {
|
||||
const child = this.data.list[Number(e.currentTarget.dataset.i)];
|
||||
getApp().setChild(child);
|
||||
wx.reLaunch({ url: "/pages/home/home" });
|
||||
},
|
||||
|
||||
onDemo() {
|
||||
wx.showLoading({ title: "装演示数据…" });
|
||||
api
|
||||
.post("/api/dev/demo-data", {})
|
||||
.then((d) => {
|
||||
getApp().setChild(d.child);
|
||||
wx.hideLoading();
|
||||
wx.showToast({ title: "已装好 " + d.mistakes + " 道", icon: "success" });
|
||||
setTimeout(() => wx.reLaunch({ url: "/pages/home/home" }), 700);
|
||||
})
|
||||
.catch((e) => {
|
||||
wx.hideLoading();
|
||||
api.toastError(e);
|
||||
});
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"navigationBarTitleText": "孩子档案"
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<view class="wrap">
|
||||
<block wx:if="{{list.length}}">
|
||||
<view class="card">
|
||||
<view class="card-title">已建档</view>
|
||||
<view class="li" wx:for="{{list}}" wx:key="id" data-i="{{index}}" bindtap="onPick">
|
||||
<text class="l">{{item.nickname}} · {{item.grade}} 年级</text>
|
||||
<text class="r">{{item.subjects.length === 2 ? "数学 / 语文" : (item.subjects[0] === "math" ? "数学" : "语文")}} ›</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="muted" style="margin:4px 0 22px">点一行就切过去,两个孩子的错题本互不相通。</view>
|
||||
</block>
|
||||
|
||||
<view class="h">新建一个孩子</view>
|
||||
<view class="lead">昵称就好,别写真名。一年级起就能用。</view>
|
||||
|
||||
<view class="card">
|
||||
<view class="li">
|
||||
<text class="l">昵称</text>
|
||||
<input class="ipt" placeholder="皮皮" value="{{nickname}}" bindinput="onNick" maxlength="12" />
|
||||
</view>
|
||||
<view class="li">
|
||||
<text class="l">年级</text>
|
||||
<picker mode="selector" range="{{grades}}" value="{{gradeIndex}}" bindchange="onGrade">
|
||||
<view class="r">{{grades[gradeIndex]}} ›</view>
|
||||
</picker>
|
||||
</view>
|
||||
<view class="li">
|
||||
<text class="l">数学</text>
|
||||
<switch checked="{{math}}" data-k="math" bindchange="toggleSubject" color="#b3272d" />
|
||||
</view>
|
||||
<view class="li">
|
||||
<text class="l">语文</text>
|
||||
<switch checked="{{chinese}}" data-k="chinese" bindchange="toggleSubject" color="#2f6b57" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<button class="btn" bindtap="onSave" disabled="{{saving}}">
|
||||
{{saving ? "创建中…" : "建好,进去看看"}}
|
||||
</button>
|
||||
|
||||
<button class="btn plain" style="margin-top:10px" bindtap="onDemo">填充演示数据(看效果用)</button>
|
||||
<view class="muted" style="margin-top:10px;text-align:center">
|
||||
演示数据会建一个「皮皮 · 二年级」,带 6 道不同状态的错题。
|
||||
</view>
|
||||
</view>
|
||||
@@ -0,0 +1,3 @@
|
||||
.h { font-size: 20px; font-weight: 700; margin-top: 6px; }
|
||||
.lead { margin: 8px 0 16px; color: var(--muted); font-size: 13px; }
|
||||
.ipt { flex: 1; text-align: right; font-size: 15px; color: var(--ink); }
|
||||
@@ -0,0 +1,28 @@
|
||||
const api = require("../../utils/api");
|
||||
|
||||
Page({
|
||||
data: { a: false, b: false, ok: false, loading: false },
|
||||
|
||||
onLoad() {
|
||||
if (!api.requireLogin()) return;
|
||||
},
|
||||
|
||||
toggle(e) {
|
||||
const key = e.currentTarget.dataset.k;
|
||||
const next = {};
|
||||
next[key] = !this.data[key];
|
||||
this.setData(next, () => this.setData({ ok: this.data.a && this.data.b }));
|
||||
},
|
||||
|
||||
onOk() {
|
||||
if (!this.data.ok || this.data.loading) return;
|
||||
this.setData({ loading: true });
|
||||
api
|
||||
.post("/api/consent", { version: "v1" })
|
||||
.then(() => wx.reLaunch({ url: "/pages/children/children" }))
|
||||
.catch((e) => {
|
||||
api.toastError(e);
|
||||
this.setData({ loading: false });
|
||||
});
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"navigationBarTitleText": "监护人同意"
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<view class="wrap">
|
||||
<view class="h">在开始之前,孩子的事要你点头</view>
|
||||
<view class="lead">下面三件事写清楚,你勾选之后我们才建档。</view>
|
||||
|
||||
<view class="card">
|
||||
<view class="card-title">我们会收什么</view>
|
||||
<view class="li"><text class="l">孩子昵称</text><text class="r">你自己起,不写真名</text></view>
|
||||
<view class="li"><text class="l">年级</text><text class="r">用来配题目难度</text></view>
|
||||
<view class="li"><text class="l">作业/试卷照片</text><text class="r">只用于切题和判对错</text></view>
|
||||
<view class="li"><text class="l">做题记录</text><text class="r">哪道对、哪道错、什么时候</text></view>
|
||||
</view>
|
||||
|
||||
<view class="card">
|
||||
<view class="card-title">我们不会做什么</view>
|
||||
<view class="li"><text class="l">不采集姓名、学校、班级</text><text class="r">没有输入口</text></view>
|
||||
<view class="li"><text class="l">不要求家长批改作业</text><text class="r">这里叫「亲子复盘」</text></view>
|
||||
<view class="li"><text class="l">不把数据给老师或第三方</text><text class="r">老师永远不在系统里</text></view>
|
||||
<view class="li"><text class="l">不用孩子的数据训练模型</text><text class="r">写进协议</text></view>
|
||||
</view>
|
||||
|
||||
<view class="card">
|
||||
<view class="card-title">存多久,怎么删</view>
|
||||
<view class="li"><text class="l">原图</text><text class="r">90 天自动删除</text></view>
|
||||
<view class="li"><text class="l">作答记录</text><text class="r">存到毕业后 6 个月</text></view>
|
||||
<view class="li"><text class="l">随时操作</text><text class="r">「我的」里可导出、可删除</text></view>
|
||||
</view>
|
||||
|
||||
<view class="chk {{a ? 'on' : ''}}" data-k="a" bindtap="toggle">
|
||||
<view class="box">{{a ? "✓" : ""}}</view>
|
||||
<text>我已阅读并同意《儿童个人信息处理规则》,我是孩子的监护人。</text>
|
||||
</view>
|
||||
<view class="chk {{b ? 'on' : ''}}" data-k="b" bindtap="toggle">
|
||||
<view class="box">{{b ? "✓" : ""}}</view>
|
||||
<text>我理解这是给孩子用的学习工具,不承诺提分。</text>
|
||||
</view>
|
||||
|
||||
<button class="btn" bindtap="onOk" disabled="{{!ok || loading}}">
|
||||
{{ok ? "同意并继续" : "请勾选上面两项"}}
|
||||
</button>
|
||||
</view>
|
||||
@@ -0,0 +1,13 @@
|
||||
.h { font-size: 21px; font-weight: 700; line-height: 1.4; }
|
||||
.lead { margin: 8px 0 18px; color: var(--muted); font-size: 13px; }
|
||||
|
||||
.chk { display: flex; gap: 10px; align-items: flex-start; padding: 12px 0; font-size: 13px; color: #4a4440; line-height: 1.6; }
|
||||
.chk .box {
|
||||
flex: 0 0 20px; width: 20px; height: 20px; margin-top: 2px;
|
||||
border: 2px solid #ddd3c9; border-radius: 6px; background: #fff;
|
||||
color: #fff; font-size: 13px; text-align: center; line-height: 17px;
|
||||
}
|
||||
.chk.on .box { background: var(--brand); border-color: var(--brand); }
|
||||
.chk.on { color: var(--ink); }
|
||||
|
||||
.btn { margin-top: 18px; }
|
||||
@@ -0,0 +1,82 @@
|
||||
const api = require("../../utils/api");
|
||||
|
||||
/** 估算时长:口算 30 秒、选择题 40 秒、应用题/自评 60 秒。 */
|
||||
function estimate(items) {
|
||||
const sec = (items || []).reduce((s, q) => {
|
||||
if (q.judge_type === "calc") return s + 30;
|
||||
if (q.judge_type === "choice") return s + 40;
|
||||
return s + 60;
|
||||
}, 0);
|
||||
return Math.max(1, Math.round(sec / 60));
|
||||
}
|
||||
|
||||
Page({
|
||||
data: {
|
||||
child: null,
|
||||
date: "",
|
||||
cap: 5,
|
||||
items: [],
|
||||
preview: [],
|
||||
rest: 0,
|
||||
minutes: 0,
|
||||
toExplain: [],
|
||||
week: { graduated: 0, days: 0, rate: 0, line: "" },
|
||||
rule: "",
|
||||
loading: true,
|
||||
},
|
||||
|
||||
onShow() {
|
||||
if (!api.requireChild()) return;
|
||||
this.setData({ child: getApp().globalData.child });
|
||||
this.load();
|
||||
},
|
||||
|
||||
load() {
|
||||
const child = getApp().globalData.child;
|
||||
this.setData({ loading: true });
|
||||
Promise.all([
|
||||
api.get("/api/today?child_id=" + child.id),
|
||||
api.get("/api/report/weekly?child_id=" + child.id).catch(() => null),
|
||||
])
|
||||
.then(([d, w]) => {
|
||||
const items = d.items || [];
|
||||
this.setData({
|
||||
date: d.date,
|
||||
cap: d.cap,
|
||||
items,
|
||||
preview: items.slice(0, 3),
|
||||
rest: Math.max(0, items.length - 3),
|
||||
minutes: estimate(items),
|
||||
toExplain: d.to_explain || [],
|
||||
rule: d.rule,
|
||||
week: w
|
||||
? {
|
||||
graduated: (w.numbers && w.numbers.graduated_this_week) || 0,
|
||||
days: (w.numbers && w.numbers.review_days) || 0,
|
||||
rate: Math.round(((w.numbers && w.numbers.kill_rate) || 0) * 100),
|
||||
line: w.one_line || "",
|
||||
}
|
||||
: this.data.week,
|
||||
loading: false,
|
||||
});
|
||||
})
|
||||
.catch((e) => {
|
||||
api.toastError(e);
|
||||
this.setData({ loading: false });
|
||||
});
|
||||
},
|
||||
|
||||
onWorkbench() {
|
||||
wx.navigateTo({ url: "/pages/wb/wb" });
|
||||
},
|
||||
|
||||
/** 排题是 tab,必须用 switchTab */
|
||||
onQueue() {
|
||||
wx.switchTab({ url: "/pages/queue/queue" });
|
||||
},
|
||||
|
||||
onPullDownRefresh() {
|
||||
this.load();
|
||||
wx.stopPullDownRefresh();
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"navigationBarTitleText": "今天",
|
||||
"enablePullDownRefresh": true
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
<view class="wrap">
|
||||
<view class="top">
|
||||
<view>
|
||||
<view class="hey">{{child.nickname || ""}},今天这几道</view>
|
||||
<view class="day">{{date}} · 每天 {{cap}} 道,做完就结束</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- ① 今日 -->
|
||||
<view class="card main" wx:if="{{items.length}}">
|
||||
<view class="mainhead">
|
||||
<text class="big">{{items.length}}</text>
|
||||
<text class="unit">道 · 约 {{minutes}} 分钟</text>
|
||||
</view>
|
||||
<view class="qlist">
|
||||
<view class="q" wx:for="{{preview}}" wx:key="id">
|
||||
<text class="qidx">{{index + 1}}</text>
|
||||
<text class="qstem">{{item.stem}}</text>
|
||||
<text class="tag {{item.status}}">{{item.status_zh}}</text>
|
||||
</view>
|
||||
<view class="more" wx:if="{{rest > 0}}">还有 {{rest}} 道在工作台里</view>
|
||||
</view>
|
||||
<button class="btn" bindtap="onWorkbench">去工作台做题</button>
|
||||
<view class="rule">{{rule}}</view>
|
||||
</view>
|
||||
|
||||
<view class="card empty" wx:elif="{{!loading}}">
|
||||
<view class="emptyh">今天没有到期的题</view>
|
||||
<view class="muted">明天再来,或者现在去拍一张今天做错的作业。</view>
|
||||
<button class="btn ghost" style="margin-top:14px" bindtap="onQueue">去排题</button>
|
||||
</view>
|
||||
|
||||
<!-- ② 提醒 -->
|
||||
<view class="card todo" wx:if="{{toExplain.length}}" bindtap="onWorkbench">
|
||||
<view class="todo-l">
|
||||
<view class="card-title">还有 {{toExplain.length}} 道要讲一遍</view>
|
||||
<view class="muted">连对两次不算毕业,讲清楚才算</view>
|
||||
</view>
|
||||
<view class="arrow">›</view>
|
||||
</view>
|
||||
|
||||
<!-- ③ 本周 -->
|
||||
<view class="card week" bindtap="onWorkbench">
|
||||
<view class="card-title">这周</view>
|
||||
<view class="wk">
|
||||
<view class="wkc"><text class="wkn">{{week.graduated}}</text><text class="wkl">道毕业</text></view>
|
||||
<view class="wkc"><text class="wkn">{{week.days}}</text><text class="wkl">天做过</text></view>
|
||||
<view class="wkc"><text class="wkn">{{week.rate}}%</text><text class="wkl">消灭率</text></view>
|
||||
</view>
|
||||
<view class="muted" style="margin-top:8px">{{week.line || "周日会在工作台生成一张能打印的纸。"}}</view>
|
||||
</view>
|
||||
|
||||
<!-- ④ 说明 -->
|
||||
<view class="card note">
|
||||
<view class="card-title">这个手机版只做两件事</view>
|
||||
<view class="muted">拍照录题 · 到点提醒。做题、讲一遍、看解析、打那张纸,都在电脑或平板的工作台上。</view>
|
||||
<view class="row">
|
||||
<view class="mini" bindtap="onQueue">
|
||||
<view class="mini-h">拍一张</view>
|
||||
<view class="mini-s">整页拍或手输</view>
|
||||
</view>
|
||||
<view class="mini" bindtap="onWorkbench">
|
||||
<view class="mini-h">工作台</view>
|
||||
<view class="mini-s">在电脑上做题</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -0,0 +1,42 @@
|
||||
.top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 16px; }
|
||||
.hey { font-size: 21px; font-weight: 700; }
|
||||
.day { margin-top: 4px; color: var(--muted); font-size: 12px; }
|
||||
.me { padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; font-size: 12px; color: #6b6560; background: #fff; }
|
||||
|
||||
.main { padding: 16px 16px 18px; }
|
||||
.mainhead { display: flex; align-items: baseline; gap: 6px; margin-bottom: 12px; }
|
||||
.big { font-size: 34px; font-weight: 700; color: var(--brand); }
|
||||
.unit { font-size: 13px; color: var(--muted); }
|
||||
|
||||
.qlist { margin-bottom: 14px; }
|
||||
.q { display: flex; align-items: center; gap: 8px; padding: 9px 0; border-bottom: 1px solid #f5efe8; }
|
||||
.q:last-child { border-bottom: none; }
|
||||
.qidx { width: 18px; color: #b9b1a9; font-size: 12px; }
|
||||
.qstem { flex: 1; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
|
||||
.rule { margin-top: 10px; text-align: center; color: #b0a89f; font-size: 11px; }
|
||||
|
||||
.emptyh { font-size: 15px; font-weight: 700; margin-bottom: 6px; color: var(--ink); }
|
||||
|
||||
.todo { display: flex; align-items: center; justify-content: space-between; background: var(--paper-math); border-color: #ecd9b6; }
|
||||
.todo-l { flex: 1; }
|
||||
.todo .card-title { margin-bottom: 2px; }
|
||||
.arrow { font-size: 22px; color: var(--ochre); }
|
||||
|
||||
.row { display: flex; gap: 12px; }
|
||||
.mini { flex: 1; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
|
||||
.mini-h { font-size: 15px; font-weight: 700; }
|
||||
.mini-s { margin-top: 3px; font-size: 11px; color: var(--muted); }
|
||||
|
||||
.note { background: #FBF6EC; border-color: #EFE2CC; }
|
||||
.note .card-title { margin-bottom: 6px; }
|
||||
.note .row { margin-top: 12px; }
|
||||
|
||||
.more { padding-top: 8px; font-size: 11px; color: #b0a89f; }
|
||||
|
||||
/* 本周三格 */
|
||||
.week { padding: 15px 16px; }
|
||||
.wk { display: flex; gap: 10px; margin-top: 10px; }
|
||||
.wkc { flex: 1; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 8px; text-align: center; }
|
||||
.wkn { display: block; font-size: 21px; font-weight: 800; color: var(--brand); line-height: 1.1; }
|
||||
.wkl { display: block; margin-top: 3px; font-size: 11px; color: var(--muted); }
|
||||
@@ -0,0 +1,48 @@
|
||||
const api = require("../../utils/api");
|
||||
|
||||
Page({
|
||||
data: { loading: false, apiBase: "" },
|
||||
|
||||
onLoad() {
|
||||
const app = getApp();
|
||||
this.setData({ apiBase: app.globalData.apiBase });
|
||||
if (app.globalData.token) {
|
||||
wx.reLaunch({ url: "/pages/home/home" });
|
||||
}
|
||||
},
|
||||
|
||||
onLogin() {
|
||||
if (this.data.loading) return;
|
||||
this.setData({ loading: true });
|
||||
wx.login({
|
||||
success: (res) => {
|
||||
if (!res.code) {
|
||||
this.setData({ loading: false });
|
||||
wx.showToast({ title: "没拿到登录 code", icon: "none" });
|
||||
return;
|
||||
}
|
||||
api
|
||||
.post("/api/auth/wx-login", { code: res.code })
|
||||
.then((d) => {
|
||||
getApp().setToken(d.token, d.guardian);
|
||||
wx.showToast({ title: "登录成功", icon: "success", duration: 800 });
|
||||
setTimeout(() => {
|
||||
if (d.needs_consent) {
|
||||
wx.reLaunch({ url: "/pages/consent/consent" });
|
||||
} else {
|
||||
wx.reLaunch({ url: "/pages/home/home" });
|
||||
}
|
||||
}, 500);
|
||||
})
|
||||
.catch((e) => {
|
||||
api.toastError(e);
|
||||
this.setData({ loading: false });
|
||||
});
|
||||
},
|
||||
fail: () => {
|
||||
this.setData({ loading: false });
|
||||
wx.showToast({ title: "微信登录失败", icon: "none" });
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"navigationBarTitleText": "",
|
||||
"navigationStyle": "default"
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<view class="login">
|
||||
<view class="brand">
|
||||
<view class="mark">毕</view>
|
||||
<view class="name">错题毕业</view>
|
||||
<view class="slogan">每天 5 分钟,把错题做到毕业</view>
|
||||
</view>
|
||||
|
||||
<view class="mech">
|
||||
<view class="mech-item"><text class="n">1</text><text>拍一整页,系统只挑 5 道</text></view>
|
||||
<view class="mech-item"><text class="n">2</text><text>连对两次,还要讲清一次</text></view>
|
||||
<view class="mech-item"><text class="n">3</text><text>毕业一道,档案里就少一道</text></view>
|
||||
</view>
|
||||
|
||||
<button class="btn" bindtap="onLogin" disabled="{{loading}}">
|
||||
{{loading ? "登录中…" : "微信一键登录"}}
|
||||
</button>
|
||||
|
||||
<view class="agree">
|
||||
孩子不用注册。我们只存昵称和年级,不存学校和真名;照片 90 天自动删除。
|
||||
</view>
|
||||
|
||||
<view class="dev">后端:{{apiBase}}(开发时请在开发者工具里勾「不校验合法域名」)</view>
|
||||
</view>
|
||||
@@ -0,0 +1,22 @@
|
||||
.login { min-height: 100vh; padding: 60px 26px 30px; display: flex; flex-direction: column; }
|
||||
|
||||
.brand { text-align: center; margin-bottom: 34px; }
|
||||
.mark {
|
||||
width: 84px; height: 84px; margin: 0 auto 14px;
|
||||
border-radius: 22px; background: var(--paper);
|
||||
color: #e4634a; font-size: 44px; font-weight: 700; line-height: 84px;
|
||||
box-shadow: 0 6px 0 rgba(228, 99, 74, 0.18);
|
||||
}
|
||||
.name { font-size: 27px; font-weight: 700; letter-spacing: 3px; }
|
||||
.slogan { margin-top: 8px; color: var(--muted); font-size: 13px; }
|
||||
|
||||
.mech { margin-bottom: 34px; }
|
||||
.mech-item { display: flex; align-items: center; gap: 10px; padding: 9px 0; font-size: 14px; color: #4a4440; }
|
||||
.mech-item .n {
|
||||
width: 22px; height: 22px; border-radius: 50%; background: #fff;
|
||||
border: 1px solid #ecd9b6; color: var(--ochre);
|
||||
font-size: 12px; text-align: center; line-height: 22px;
|
||||
}
|
||||
|
||||
.agree { margin-top: 18px; font-size: 11px; color: #9a938c; line-height: 1.7; text-align: center; }
|
||||
.dev { margin-top: auto; padding-top: 18px; font-size: 10px; color: #b9b1a9; text-align: center; word-break: break-all; }
|
||||
@@ -0,0 +1,175 @@
|
||||
const api = require("../../utils/api");
|
||||
|
||||
Page({
|
||||
data: {
|
||||
guardian: null,
|
||||
child: null,
|
||||
wx: null,
|
||||
quota: 0,
|
||||
ent: null,
|
||||
entState: { text: "—", hint: "", active: false, cls: "" },
|
||||
deletion: null,
|
||||
code: "",
|
||||
},
|
||||
|
||||
onShow() {
|
||||
if (!api.requireLogin()) return;
|
||||
const app = getApp();
|
||||
this.setData({
|
||||
guardian: wx.getStorageSync("ql_guardian") || null,
|
||||
child: app.globalData.child,
|
||||
});
|
||||
this.load();
|
||||
},
|
||||
|
||||
load() {
|
||||
Promise.all([
|
||||
api.get("/api/wx/config").catch(() => null),
|
||||
api.get("/api/notify/quota").catch(() => null),
|
||||
api.get("/api/entitlement").catch(() => null),
|
||||
api.get("/api/me").catch(() => null),
|
||||
]).then(([wxcfg, q, e, me]) => {
|
||||
this.setData({
|
||||
wx: wxcfg,
|
||||
quota: q ? q.quota : 0,
|
||||
ent: e || null,
|
||||
entState: this.entState(e),
|
||||
deletion: (me && me.deletion) || null,
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
/** 开通四态:试用中 / 有效 / 已过期 / 没用过 —— 每种都要说清「还能做什么」 */
|
||||
entState(e) {
|
||||
const left = e && typeof e.days_left === "number" ? e.days_left : null;
|
||||
if (!e || !e.kind) {
|
||||
return { text: "未开通", hint: "先免费用 3 天。到期后已入库的错题仍然能复习,只是不能拍新卷子。", active: false, cls: "" };
|
||||
}
|
||||
if (left !== null && left <= 0) {
|
||||
return {
|
||||
text: "已过期",
|
||||
hint: "已入库的错题还能继续做,拍不了新卷子。兑换激活码即可继续。",
|
||||
active: false,
|
||||
cls: "red",
|
||||
};
|
||||
}
|
||||
const kind = e.kind_zh || e.kind;
|
||||
const day = String(e.expires_at || "").slice(0, 10);
|
||||
return {
|
||||
text: `${kind} · ${day} 到期${left !== null ? " · 剩 " + left + " 天" : ""}`,
|
||||
hint: "有效期内不限题数、不限孩子个数(2 个)。",
|
||||
active: true,
|
||||
cls: "green",
|
||||
};
|
||||
},
|
||||
|
||||
onSubscribe() {
|
||||
const cfg = this.data.wx || {};
|
||||
const tmpl = cfg.daily_template;
|
||||
if (!tmpl) {
|
||||
wx.showModal({
|
||||
title: "还差模板 ID",
|
||||
content: "订阅消息模板要在微信公众平台「功能 → 订阅消息」里建,然后把 ID 配到后端环境变量 WX_TMPL_DAILY,这里才能拉起授权弹窗。",
|
||||
showCancel: false,
|
||||
});
|
||||
return;
|
||||
}
|
||||
wx.requestSubscribeMessage({
|
||||
tmplIds: [tmpl],
|
||||
success: (res) => {
|
||||
const ids = Object.keys(res).filter((k) => res[k] === "accept");
|
||||
if (!ids.length) {
|
||||
wx.showToast({ title: "没同意,明天不会提醒", icon: "none" });
|
||||
return;
|
||||
}
|
||||
api
|
||||
.post("/api/notify/subscribe", { template_ids: ids })
|
||||
.then(() => {
|
||||
wx.showToast({ title: "已记下一条额度", icon: "success" });
|
||||
this.load();
|
||||
})
|
||||
.catch(api.toastError);
|
||||
},
|
||||
fail: () => wx.showToast({ title: "授权没成功", icon: "none" }),
|
||||
});
|
||||
},
|
||||
|
||||
onCode(e) {
|
||||
this.setData({ code: e.detail.value });
|
||||
},
|
||||
|
||||
onRedeem() {
|
||||
const code = (this.data.code || "").trim();
|
||||
if (!code) return;
|
||||
api
|
||||
.post("/api/entitlement/redeem", { code })
|
||||
.then((r) => {
|
||||
wx.showToast({ title: "已开通 " + (r.days || 0) + " 天", icon: "success" });
|
||||
this.setData({ code: "" });
|
||||
this.load();
|
||||
})
|
||||
.catch(api.toastError);
|
||||
},
|
||||
|
||||
onSwitch() {
|
||||
wx.navigateTo({ url: "/pages/children/children" });
|
||||
},
|
||||
|
||||
onWorkbench() {
|
||||
wx.navigateTo({ url: "/pages/wb/wb" });
|
||||
},
|
||||
|
||||
/** 删号:进 7 天冷静期,期间随时能撤销 */
|
||||
onDelete() {
|
||||
wx.showModal({
|
||||
title: "删除账号?",
|
||||
content:
|
||||
"会删掉:孩子档案、全部题目与错题、作答记录、周报。\n\n不是你点了就删——先进入 7 天冷静期,这 7 天里重新登录点「撤销删号」就能全部恢复。7 天后才真删,且不可恢复。",
|
||||
confirmText: "申请删号",
|
||||
confirmColor: "#C8362D",
|
||||
success: (r) => {
|
||||
if (!r.confirm) return;
|
||||
api
|
||||
.del("/api/me", { reason: "家长主动删除" }) .then((res) => {
|
||||
wx.showModal({
|
||||
title: "已提交",
|
||||
content: `${res.purge_after} 之后删除,这之前随时可以撤销。`,
|
||||
showCancel: false,
|
||||
success: () => {
|
||||
getApp().clearAuth();
|
||||
wx.reLaunch({ url: "/pages/login/login" });
|
||||
},
|
||||
});
|
||||
})
|
||||
.catch(api.toastError);
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
onCancelDelete() {
|
||||
api
|
||||
.post("/api/me/cancel-deletion", {})
|
||||
.then(() => {
|
||||
wx.showToast({ title: "已撤销", icon: "success" });
|
||||
this.load();
|
||||
})
|
||||
.catch(api.toastError);
|
||||
},
|
||||
|
||||
onComputer() {
|
||||
wx.navigateTo({ url: "/pages/scan/scan" });
|
||||
},
|
||||
|
||||
onLogout() {
|
||||
wx.showModal({
|
||||
title: "退出登录",
|
||||
content: "只是退出这台设备,数据还在。",
|
||||
success: (r) => {
|
||||
if (!r.confirm) return;
|
||||
api.post("/api/auth/logout", {}).catch(() => {});
|
||||
getApp().clearAuth();
|
||||
wx.reLaunch({ url: "/pages/login/login" });
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"navigationBarTitleText": "我的"
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
<view class="wrap">
|
||||
<!-- 一、孩子 -->
|
||||
<view class="card">
|
||||
<view class="card-title">孩子</view>
|
||||
<view class="li" wx:if="{{child}}" bindtap="onSwitch">
|
||||
<text class="l">{{child.nickname}} · {{child.grade}} 年级</text>
|
||||
<text class="r">切换 / 新建 ›</text>
|
||||
</view>
|
||||
<view class="li" wx:else bindtap="onSwitch">
|
||||
<text class="l">还没有建档</text>
|
||||
<text class="r">去建一个 ›</text>
|
||||
</view>
|
||||
<view class="muted small" style="margin-top:6px">一个家长可以带多个孩子,错题各记各的。</view>
|
||||
</view>
|
||||
|
||||
<!-- 二、科目 -->
|
||||
<view class="card">
|
||||
<view class="card-title">科目</view>
|
||||
<view class="li">
|
||||
<text class="l">语文 · 数学</text>
|
||||
<text class="r" bindtap="onSwitch">修改 ›</text>
|
||||
</view>
|
||||
<view class="muted small">V1 只开这两科,判得准才做。英语要等发音评测,先不上。</view>
|
||||
</view>
|
||||
|
||||
<!-- 三、提醒 -->
|
||||
<view class="card">
|
||||
<view class="card-title">提醒</view>
|
||||
<view class="li">
|
||||
<text class="l">每天</text>
|
||||
<text class="r">{{child.remind_at || "19:30"}}</text>
|
||||
</view>
|
||||
<view class="li">
|
||||
<text class="l">明天的额度</text>
|
||||
<text class="r">{{quota}} 条</text>
|
||||
</view>
|
||||
<button class="btn ghost" style="margin-top:12px" bindtap="onSubscribe">顺手订明天的提醒</button>
|
||||
<view class="muted small" style="margin-top:8px">微信只给一条:今天订的只能发明天那条,发完要再订一次。</view>
|
||||
</view>
|
||||
|
||||
<!-- 四、开通 -->
|
||||
<view class="card">
|
||||
<view class="card-title">开通</view>
|
||||
<view class="li">
|
||||
<text class="l">状态</text>
|
||||
<text class="r {{entState.cls}}">{{entState.text}}</text>
|
||||
</view>
|
||||
<view class="muted small" style="margin-top:6px">{{entState.hint}}</view>
|
||||
|
||||
<view class="row-in" wx:if="{{!entState.active}}">
|
||||
<input class="ipt" placeholder="QL-XXXXXX" value="{{code}}" bindinput="onCode" />
|
||||
<view class="go" bindtap="onRedeem">兑换</view>
|
||||
</view>
|
||||
<view class="muted small" style="margin-top:10px">69 元 / 学期,一次付清不限题数,含两个孩子的名额。</view>
|
||||
</view>
|
||||
|
||||
<!-- 五、数据 -->
|
||||
<view class="card">
|
||||
<view class="card-title">数据</view>
|
||||
<view class="li"><text class="l">原图</text><text class="r">90 天自动删除</text></view>
|
||||
<view class="li"><text class="l">导出</text><text class="r" bindtap="onWorkbench">在工作台导出 PDF / CSV ›</text></view>
|
||||
<view class="li"><text class="l">不锁数据</text><text class="r">随时能全量导出</text></view>
|
||||
|
||||
<block wx:if="{{deletion}}">
|
||||
<view class="danger-box">
|
||||
<view class="db-h">已提交删号</view>
|
||||
<view class="db-s">{{deletion.purge_after}} 之后会删除全部数据(孩子、题目、作答记录)。这之前你都可以撤销。</view>
|
||||
<button class="btn plain" style="margin-top:10px" bindtap="onCancelDelete">撤销删号</button>
|
||||
</view>
|
||||
</block>
|
||||
<view class="li danger" wx:else bindtap="onDelete">
|
||||
<text class="l">删除账号</text>
|
||||
<text class="r">7 天内可撤销 ›</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 六、关于 -->
|
||||
<view class="card">
|
||||
<view class="card-title">关于</view>
|
||||
<view class="li" bindtap="onComputer"><text class="l">电脑上登录</text><text class="r">显示登录码 ›</text></view>
|
||||
|
||||
<view class="li"><text class="l">错题毕业</text><text class="r">小学版 v1.0</text></view>
|
||||
<view class="li"><text class="l">一句话</text><text class="r">每天 5 分钟,把错题做到毕业</text></view>
|
||||
<view class="muted small" style="margin-top:6px">手机只负责拍照录题和提醒;做题、解析、打印在电脑或平板的 workbench 上。</view>
|
||||
</view>
|
||||
|
||||
<button class="btn plain" bindtap="onLogout">退出登录</button>
|
||||
</view>
|
||||
@@ -0,0 +1,21 @@
|
||||
.row-in { display: flex; gap: 10px; align-items: center; margin-top: 6px; }
|
||||
.ipt {
|
||||
flex: 1; height: 44px; padding: 0 12px; background: #faf6f1;
|
||||
border: 1px solid var(--line); border-radius: 10px; font-size: 15px;
|
||||
}
|
||||
.go {
|
||||
padding: 0 18px; height: 44px; line-height: 44px; border-radius: 10px;
|
||||
background: var(--brand); color: #fff; font-size: 14px; font-weight: 700;
|
||||
}
|
||||
|
||||
.red { color: var(--red, #C8362D); }
|
||||
.green { color: var(--green); }
|
||||
.danger .l,
|
||||
.danger .r { color: #C8362D; }
|
||||
|
||||
.danger-box {
|
||||
margin-top: 12px; padding: 12px 13px; border-radius: 12px;
|
||||
background: #FFF5F3; border: 1px solid #F3CFC7;
|
||||
}
|
||||
.db-h { font-size: 13px; font-weight: 700; color: #B3322A; }
|
||||
.db-s { margin-top: 5px; font-size: 11px; color: #8B5A52; line-height: 1.6; }
|
||||
@@ -0,0 +1,299 @@
|
||||
const api = require("../../utils/api");
|
||||
|
||||
/** 估算一道题要多久:口算 30 秒、字词 40 秒、应用题/自评 60 秒,够用了。 */
|
||||
function estimate(queue) {
|
||||
const items = (queue && queue.items) || [];
|
||||
const sec = items.reduce((s, q) => {
|
||||
if (q.judge_type === "calc") return s + 30;
|
||||
if (q.judge_type === "choice") return s + 40;
|
||||
return s + 60;
|
||||
}, 0);
|
||||
return Math.max(1, Math.round(sec / 60));
|
||||
}
|
||||
|
||||
Page({
|
||||
data: {
|
||||
mode: "photo",
|
||||
images: [],
|
||||
subject: "math",
|
||||
subjects: [
|
||||
{ k: "math", name: "数学" },
|
||||
{ k: "chinese", name: "语文" },
|
||||
],
|
||||
questions: [],
|
||||
cutInfo: "",
|
||||
cutting: false,
|
||||
importing: false,
|
||||
// 手输
|
||||
stem: "",
|
||||
answer: "",
|
||||
isChoice: false,
|
||||
optionsText: "",
|
||||
saving: false,
|
||||
// 题单预览
|
||||
queue: { n: 0, minutes: 0 },
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
if (!api.requireChild()) return;
|
||||
},
|
||||
|
||||
onShow() {
|
||||
if (getApp().globalData.child) this.loadQueue();
|
||||
},
|
||||
|
||||
onSubject(e) {
|
||||
this.setData({ subject: e.currentTarget.dataset.k, questions: [] });
|
||||
},
|
||||
|
||||
onToggleMode() {
|
||||
this.setData({ mode: this.data.mode === "photo" ? "manual" : "photo", cutInfo: "" });
|
||||
},
|
||||
|
||||
/** 排完看一眼今天几道、大概几分钟 */
|
||||
loadQueue() {
|
||||
const child = getApp().globalData.child;
|
||||
if (!child) return Promise.resolve();
|
||||
return api
|
||||
.get("/api/today?child_id=" + child.id)
|
||||
.then((d) => this.setData({ queue: { n: (d.items || []).length, minutes: estimate(d) } }))
|
||||
.catch(() => {});
|
||||
},
|
||||
|
||||
// ---------------- 拍一张
|
||||
|
||||
onPick() {
|
||||
wx.chooseMedia({
|
||||
count: 3,
|
||||
mediaType: ["image"],
|
||||
sourceType: ["camera", "album"],
|
||||
camera: "back",
|
||||
success: (res) => {
|
||||
const images = (res.tempFiles || []).map((f) => f.tempFilePath);
|
||||
if (!images.length) return;
|
||||
this.checkSize(images).then((ok) => {
|
||||
if (ok) this.setData({ images });
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 太小的图先拦一下再上传。
|
||||
* 微信转发的图长边常被压到 400px,一行字只剩十几像素——OCR 认出来全是错字,
|
||||
* 与其等它在后面莫名其妙地失败,不如在这里就说清楚。
|
||||
*/
|
||||
checkSize(images) {
|
||||
const info = (p) =>
|
||||
new Promise((resolve) => {
|
||||
wx.getImageInfo({
|
||||
src: p,
|
||||
success: (r) => resolve({ w: r.width || 0, h: r.height || 0 }),
|
||||
fail: () => resolve({ w: 0, h: 0 }),
|
||||
});
|
||||
});
|
||||
return Promise.all(images.map(info)).then((sizes) => {
|
||||
const bad = sizes.filter((s) => s.w && Math.min(s.w, s.h) < 1200);
|
||||
if (!bad.length) return true;
|
||||
const s = bad[0];
|
||||
return new Promise((resolve) => {
|
||||
wx.showModal({
|
||||
title: "这张图太小了",
|
||||
content:
|
||||
"只有 " + s.w + "×" + s.h + " 像素,一行字只剩十几像素,识别出来大概率是错字。" +
|
||||
"\n\n建议:在微信里选「原图」重发,或重新拍一张(一次拍半页)。",
|
||||
confirmText: "还是上传",
|
||||
cancelText: "重拍",
|
||||
success: (r) => resolve(!!r.confirm),
|
||||
fail: () => resolve(false),
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
onCut() {
|
||||
if (!this.data.images.length) {
|
||||
wx.showToast({ title: "先拍一张", icon: "none" });
|
||||
return;
|
||||
}
|
||||
if (this.data.cutting) return;
|
||||
this.setData({ cutting: true });
|
||||
|
||||
const child = getApp().globalData.child;
|
||||
const fs = wx.getFileSystemManager();
|
||||
wx.showLoading({ title: "识别中", mask: true });
|
||||
|
||||
// 手机拍出来 3–8MB,直接 base64 会撞 wx.request 的包体上限,先压到长边 1600、质量 72。
|
||||
const send = (filePath) => {
|
||||
fs.readFile({
|
||||
filePath,
|
||||
encoding: "base64",
|
||||
success: (f) => {
|
||||
api
|
||||
.post("/api/papers/ocr", {
|
||||
child_id: child.id,
|
||||
subject: this.data.subject,
|
||||
image_b64: f.data,
|
||||
filename: "page.jpg",
|
||||
fallback_demo: false,
|
||||
})
|
||||
.then((p) => this.afterCut(p))
|
||||
.catch((e) => this.onCutFail(e))
|
||||
.then(() => wx.hideLoading());
|
||||
},
|
||||
fail: () => {
|
||||
wx.hideLoading();
|
||||
wx.showToast({ title: "读不到这张图", icon: "none" });
|
||||
this.setData({ cutting: false });
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
wx.compressImage({
|
||||
src: this.data.images[0],
|
||||
quality: 72,
|
||||
compressedWidth: 1600,
|
||||
success: (r) => send(r.tempFilePath || this.data.images[0]),
|
||||
fail: () => send(this.data.images[0]),
|
||||
});
|
||||
},
|
||||
|
||||
afterCut(p) {
|
||||
const questions = (p.questions || []).map((q) => ({
|
||||
...q,
|
||||
checked: true,
|
||||
tag: (q.judge_type === "manual" ? "你自己判" : "机器判") + " · " + (q.subject === "chinese" ? "语文" : "数学"),
|
||||
}));
|
||||
const ocr = p.ocr || {};
|
||||
let info = "";
|
||||
if (ocr.ok) {
|
||||
info = "识别到 " + ocr.lines + " 行,切出 " + questions.length + " 道题";
|
||||
if (ocr.warn) info += "\n" + ocr.warn;
|
||||
} else {
|
||||
info = "没认出题,可以手动拍清楚一点,或者改成手输";
|
||||
// 小图 / 太糊时,后端会带一句「这张图只有 400×520」——比「没认出题」有用得多
|
||||
if (ocr.warn) info = ocr.warn + "\n" + info;
|
||||
}
|
||||
this.setData({ questions, cutting: false, cutInfo: info });
|
||||
},
|
||||
|
||||
/** 识别失败:给「用演示题库」这条后路,而不是卡死在这儿。 */
|
||||
onCutFail(e) {
|
||||
this.setData({ cutting: false });
|
||||
wx.hideLoading();
|
||||
const msg = (e && e.message) || "没认出来";
|
||||
wx.showModal({
|
||||
title: "这次没认出来",
|
||||
content: msg + "\n\n可以:① 把卷子放平、光线亮一点重拍;② 这道题改成手输;③ 先用演示题库走一遍流程。",
|
||||
confirmText: "用演示题库",
|
||||
cancelText: "重新拍",
|
||||
success: (r) => {
|
||||
if (!r.confirm) return;
|
||||
this.setData({ cutting: true });
|
||||
api
|
||||
.post("/api/papers/ocr", {
|
||||
child_id: getApp().globalData.child.id,
|
||||
subject: this.data.subject,
|
||||
image_b64: "ZGVtbw==",
|
||||
filename: "demo.jpg",
|
||||
fallback_demo: true,
|
||||
})
|
||||
.then((p) => this.afterCut(p))
|
||||
.catch((err) => api.toastError(err))
|
||||
.then(() => this.setData({ cutting: false }));
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
toggleQ(e) {
|
||||
const i = Number(e.currentTarget.dataset.i);
|
||||
const questions = this.data.questions.slice();
|
||||
questions[i].checked = !questions[i].checked;
|
||||
this.setData({ questions });
|
||||
},
|
||||
|
||||
onImport() {
|
||||
const ids = this.data.questions.filter((q) => q.checked).map((q) => q.id);
|
||||
if (!ids.length) {
|
||||
wx.showToast({ title: "一道都没选", icon: "none" });
|
||||
return;
|
||||
}
|
||||
if (this.data.importing) return;
|
||||
this.setData({ importing: true });
|
||||
|
||||
api
|
||||
.post("/api/mistakes/import", {
|
||||
child_id: getApp().globalData.child.id,
|
||||
question_ids: ids,
|
||||
})
|
||||
.then((r) => {
|
||||
const n = (r.created || []).length;
|
||||
this.setData({ importing: false, questions: [] });
|
||||
wx.showToast({ title: "入库 " + n + " 道", icon: "success" });
|
||||
this.loadQueue();
|
||||
})
|
||||
.catch((e) => {
|
||||
api.toastError(e);
|
||||
this.setData({ importing: false });
|
||||
});
|
||||
},
|
||||
|
||||
// ---------------- 手输一道
|
||||
|
||||
onStem(e) {
|
||||
this.setData({ stem: e.detail.value });
|
||||
},
|
||||
onAnswer(e) {
|
||||
this.setData({ answer: e.detail.value });
|
||||
},
|
||||
onChoice(e) {
|
||||
this.setData({ isChoice: e.detail.value });
|
||||
},
|
||||
onOptions(e) {
|
||||
this.setData({ optionsText: e.detail.value });
|
||||
},
|
||||
|
||||
onManualAdd() {
|
||||
const stem = (this.data.stem || "").trim();
|
||||
if (!stem) {
|
||||
wx.showToast({ title: "题干还没填", icon: "none" });
|
||||
return;
|
||||
}
|
||||
if (this.data.saving) return;
|
||||
|
||||
const body = {
|
||||
child_id: getApp().globalData.child.id,
|
||||
subject: this.data.subject,
|
||||
stem,
|
||||
answer: (this.data.answer || "").trim() || null,
|
||||
};
|
||||
if (this.data.isChoice) {
|
||||
const opts = (this.data.optionsText || "")
|
||||
.split(/[、,,;;\s]+/)
|
||||
.map((s) => s.trim())
|
||||
.filter(Boolean);
|
||||
if (opts.length < 2) {
|
||||
wx.showToast({ title: "选择题至少两个选项", icon: "none" });
|
||||
return;
|
||||
}
|
||||
body.options = opts;
|
||||
}
|
||||
|
||||
this.setData({ saving: true });
|
||||
api
|
||||
.post("/api/mistakes/manual", body)
|
||||
.then(() => {
|
||||
this.setData({ saving: false, stem: "", answer: "", optionsText: "", isChoice: false });
|
||||
wx.showToast({ title: "已加入", icon: "success" });
|
||||
this.loadQueue();
|
||||
})
|
||||
.catch((e) => {
|
||||
api.toastError(e);
|
||||
this.setData({ saving: false });
|
||||
});
|
||||
},
|
||||
|
||||
onWorkbench() {
|
||||
wx.navigateTo({ url: "/pages/wb/wb" });
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"navigationBarTitleText": "排题",
|
||||
"enablePullDownRefresh": false
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
<view class="wrap">
|
||||
<view class="pick">
|
||||
<view class="chip {{subject === item.k ? 'on' : ''}}" wx:for="{{subjects}}" wx:key="k" data-k="{{item.k}}" bindtap="onSubject">{{item.name}}</view>
|
||||
<view class="chip mode" bindtap="onToggleMode">{{mode === "photo" ? "改成手输" : "改成拍一张"}}</view>
|
||||
</view>
|
||||
|
||||
<!-- ① 拍一张 -->
|
||||
<block wx:if="{{mode === 'photo'}}">
|
||||
<view class="shot {{subject === 'chinese' ? 'chn' : 'math'}}" bindtap="onPick">
|
||||
<block wx:if="{{images.length}}">
|
||||
<image class="thumb" src="{{images[0]}}" mode="aspectFill" />
|
||||
<view class="shot-n">已选 {{images.length}} 张,点一下重拍</view>
|
||||
</block>
|
||||
<block wx:else>
|
||||
<view class="plus">+</view>
|
||||
<view class="shot-t">整页拍一张</view>
|
||||
<view class="shot-s">卷子放平、光打亮,一次拍半页(5–8 道)最准</view>
|
||||
</block>
|
||||
</view>
|
||||
|
||||
<button class="btn" bindtap="onCut" disabled="{{cutting}}">
|
||||
{{cutting ? "识别中…" : "识别这一页"}}
|
||||
</button>
|
||||
|
||||
<view class="cutinfo" wx:if="{{cutInfo}}">{{cutInfo}}</view>
|
||||
</block>
|
||||
|
||||
<!-- ② 手输一道 -->
|
||||
<block wx:else>
|
||||
<view class="card">
|
||||
<view class="card-title">手输一道错题</view>
|
||||
<textarea class="ta" placeholder="把题干抄进来,比如:36 + 47 =( )" value="{{stem}}" bindinput="onStem" maxlength="400" auto-height />
|
||||
<view class="muted small" style="margin-top:6px">{{stem.length}} / 400</view>
|
||||
|
||||
<view class="line">
|
||||
<text class="lk">正确答案</text>
|
||||
<input class="ipt" placeholder="不填就让孩子自己判" value="{{answer}}" bindinput="onAnswer" />
|
||||
</view>
|
||||
|
||||
<view class="line">
|
||||
<text class="lk">是选择题</text>
|
||||
<switch checked="{{isChoice}}" bindchange="onChoice" color="#E4634A" />
|
||||
</view>
|
||||
|
||||
<block wx:if="{{isChoice}}">
|
||||
<view class="line">
|
||||
<text class="lk">选项</text>
|
||||
<input class="ipt" placeholder="用顿号或逗号分开,如:48、54、56、64" value="{{optionsText}}" bindinput="onOptions" />
|
||||
</view>
|
||||
<view class="muted small">答案填字母(A/B/C/D);不填字母就让孩子自己做对错判断。</view>
|
||||
</block>
|
||||
|
||||
<button class="btn" style="margin-top:14px" bindtap="onManualAdd" disabled="{{saving}}">
|
||||
{{saving ? "加入中…" : "加入错题本"}}
|
||||
</button>
|
||||
<view class="muted small" style="margin-top:8px">手输的题和拍照的题走同一条路:第一次错先进「观察中」,明天开始复习。</view>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<!-- ③ 切出来的题:勾选 -->
|
||||
<view class="card" style="margin-top:18px" wx:if="{{questions.length}}">
|
||||
<view class="card-title">切出 {{questions.length}} 道,把做错的勾上</view>
|
||||
<view class="muted" style="margin-bottom:6px">默认全选,你只需要取消勾选「做对了」的。</view>
|
||||
<view class="q" wx:for="{{questions}}" wx:key="id" data-i="{{index}}" bindtap="toggleQ">
|
||||
<view class="box {{item.checked ? 'on' : ''}}">{{item.checked ? "✓" : ""}}</view>
|
||||
<view class="qmain">
|
||||
<view class="qstem">{{item.stem}}</view>
|
||||
<view class="muted small">{{item.tag}}</view>
|
||||
</view>
|
||||
</view>
|
||||
<button class="btn" style="margin-top:14px" bindtap="onImport" disabled="{{importing}}">
|
||||
{{importing ? "入库中…" : "加入错题本"}}
|
||||
</button>
|
||||
</view>
|
||||
|
||||
<!-- ④ 题单预览:排完就地显示今天的量 -->
|
||||
<view class="card queue" wx:if="{{queue.n > 0}}">
|
||||
<view class="card-title">排好了</view>
|
||||
<view class="qbig">
|
||||
<text class="qnum">{{queue.n}}</text>
|
||||
<text class="qunit">道 · 约 {{queue.minutes}} 分钟</text>
|
||||
</view>
|
||||
<view class="muted">按遗忘曲线排的,错的多的先做。做完这两件事就结束:连对两次、讲一遍。</view>
|
||||
<button class="btn" style="margin-top:12px" bindtap="onWorkbench">去工作台做题</button>
|
||||
<view class="muted small" style="margin-top:8px">手机上只排题,做题在电脑或平板上——题目和解析要横着看。</view>
|
||||
</view>
|
||||
|
||||
<view class="note">
|
||||
{{mode === "photo" ? "识别用的是本机的 Windows 中文 OCR(不联网、不上传第三方)。算式的答案会自己算出来;应用题、看拼音写词这类没有标准答案的,标成「你自己判」。" : "手输适合几种情况:卷子已经扔了、老师口头报的题、错题想马上记一道。题干抄关键词就行,不用一字不差。"}}
|
||||
</view>
|
||||
</view>
|
||||
@@ -0,0 +1,54 @@
|
||||
.pick { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
|
||||
.chip { padding: 7px 15px; 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; }
|
||||
.chip.mode { margin-left: auto; color: var(--brand); border-color: #f0cfc4; background: #fff7f4; }
|
||||
|
||||
.shot {
|
||||
position: relative; height: 210px; border-radius: 16px; border: 2px dashed #e0d5c9;
|
||||
display: flex; flex-direction: column; align-items: center; justify-content: center;
|
||||
background: #fff; margin-bottom: 16px; overflow: hidden;
|
||||
}
|
||||
.shot.math { background: var(--paper-math) repeating-linear-gradient(0deg, rgba(169,118,26,.07) 0 1px, transparent 1px 13px); }
|
||||
.shot.chn { background: var(--paper-chn) repeating-linear-gradient(0deg, rgba(47,107,87,.07) 0 1px, transparent 1px 14px); }
|
||||
.plus { font-size: 40px; color: #c9bda9; line-height: 1; }
|
||||
.shot-t { margin-top: 8px; font-size: 15px; font-weight: 700; }
|
||||
.shot-s { margin-top: 4px; font-size: 12px; color: var(--muted); }
|
||||
.thumb { width: 100%; height: 100%; }
|
||||
.shot-n { position: absolute; bottom: 10px; font-size: 11px; color: #6b6560; background: rgba(255,255,255,.9); padding: 3px 10px; border-radius: 999px; }
|
||||
|
||||
/* 手输 */
|
||||
.ta {
|
||||
width: 100%; box-sizing: border-box; min-height: 74px; margin-top: 10px; padding: 10px 12px;
|
||||
border: 1px solid var(--line); border-radius: 12px; background: #fff; font-size: 15px; line-height: 1.6;
|
||||
}
|
||||
.line { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
|
||||
.lk { flex: 0 0 72px; font-size: 13px; color: #5f5852; }
|
||||
.ipt {
|
||||
flex: 1; height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px;
|
||||
background: #fff; font-size: 15px;
|
||||
}
|
||||
|
||||
.q { display: flex; gap: 10px; align-items: flex-start; padding: 11px 0; border-bottom: 1px solid #f5efe8; }
|
||||
.q:last-of-type { border-bottom: none; }
|
||||
.box {
|
||||
flex: 0 0 20px; width: 20px; height: 20px; margin-top: 2px;
|
||||
border: 2px solid #ddd3c9; border-radius: 6px; background: #fff; color: #fff;
|
||||
font-size: 12px; text-align: center; line-height: 17px;
|
||||
}
|
||||
.box.on { background: var(--brand); border-color: var(--brand); }
|
||||
.qmain { flex: 1; }
|
||||
.qstem { font-size: 14px; line-height: 1.5; }
|
||||
|
||||
/* 题单预览 */
|
||||
.queue { border: 1px solid #f0cfc4; background: #fffaf7; }
|
||||
.qbig { display: flex; align-items: baseline; gap: 8px; margin: 6px 0 8px; }
|
||||
.qnum { font-size: 34px; font-weight: 800; color: var(--brand); line-height: 1; }
|
||||
.qunit { font-size: 13px; color: #6b6560; }
|
||||
|
||||
.note { margin-top: 18px; padding: 11px 13px; background: #fff; border: 1px solid var(--line); border-radius: 12px; font-size: 11px; color: #9a938c; line-height: 1.7; }
|
||||
|
||||
.cutinfo {
|
||||
margin-top: 10px; padding: 8px 12px; border-radius: 10px;
|
||||
background: #fbf2e1; border: 1px solid #ecd9b6; color: #7a6440; font-size: 12px;
|
||||
white-space: pre-line; line-height: 1.6;
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
const api = require("../../utils/api");
|
||||
const app = getApp();
|
||||
|
||||
function readCode(options) {
|
||||
if (options.code) return String(options.code).toUpperCase();
|
||||
// 小程序码带的 scene 是 "login:XXXXXXXX" 或纯 8 位码
|
||||
if (options.scene) {
|
||||
const raw = decodeURIComponent(options.scene);
|
||||
const m = raw.match(/[A-Z0-9]{8}/i);
|
||||
return m ? m[0].toUpperCase() : "";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
Page({
|
||||
data: { code: "", input: "", busy: false },
|
||||
|
||||
onLoad(options) {
|
||||
const code = readCode(options || {});
|
||||
this.setData({ code, input: code });
|
||||
if (!app.globalData.token && !wx.getStorageSync("ql_token")) {
|
||||
wx.showToast({ title: "请先登录小程序", icon: "none" });
|
||||
}
|
||||
},
|
||||
|
||||
onInput(e) {
|
||||
this.setData({ input: String(e.detail.value || "").toUpperCase().slice(0, 8) });
|
||||
},
|
||||
|
||||
onScan() {
|
||||
wx.scanCode({
|
||||
onlyFromCamera: false,
|
||||
scanType: ["qrCode"],
|
||||
success: (res) => {
|
||||
const m = String(res.result || "").match(/[A-Z0-9]{8}/i);
|
||||
if (m) this.setData({ input: m[0].toUpperCase() });
|
||||
else wx.showToast({ title: "这不是登录码", icon: "none" });
|
||||
},
|
||||
fail: () => {},
|
||||
});
|
||||
},
|
||||
|
||||
async onConfirm() {
|
||||
if (!api.requireLogin()) return;
|
||||
const code = (this.data.input || this.data.code || "").trim().toUpperCase();
|
||||
if (code.length !== 8) {
|
||||
wx.showToast({ title: "登录码是 8 位", icon: "none" });
|
||||
return;
|
||||
}
|
||||
this.setData({ busy: true });
|
||||
try {
|
||||
const r = await api.request("POST", "/api/auth/scan-confirm", { code });
|
||||
wx.showToast({ title: r.hint || "已确认,看电脑", icon: "none" });
|
||||
setTimeout(() => wx.navigateBack({ fail: () => wx.switchTab({ url: "/pages/home/home" }) }), 900);
|
||||
} catch (e) {
|
||||
wx.showToast({ title: e.message || "确认失败", icon: "none" });
|
||||
} finally {
|
||||
this.setData({ busy: false });
|
||||
}
|
||||
},
|
||||
|
||||
onLater() {
|
||||
wx.navigateBack({ fail: () => wx.switchTab({ url: "/pages/home/home" }) });
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"navigationBarTitleText": "确认登录",
|
||||
"usingComponents": {}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<view class="wrap">
|
||||
<view class="brand">
|
||||
<image class="mark" src="../../images/mark.png" mode="aspectFit" wx:if="{{false}}"></image>
|
||||
<view class="mk">毕</view>
|
||||
<view class="t">错题毕业</view>
|
||||
</view>
|
||||
|
||||
<view class="card">
|
||||
<view class="h">在电脑上登录工作台?</view>
|
||||
<view class="s" wx:if="{{code}}">电脑那边显示的是登录码 <text class="code">{{code}}</text>。确认后,电脑立刻用你现在的账户进去。</view>
|
||||
<view class="s" wx:else>没读到登录码。回到电脑上刷新那个码,或者把码输在下面。</view>
|
||||
|
||||
<input wx:if="{{!code}}" class="ipt" value="{{input}}" maxlength="8" placeholder="输入电脑上那 8 位登录码" bindinput="onInput" />
|
||||
<button wx:if="{{!code}}" class="btn ghost" bindtap="onScan">扫一扫电脑上的码</button>
|
||||
|
||||
<view class="note">确认的是同一份数据:电脑上看到的错题、周报、已毕业,和手机里是同一套。</view>
|
||||
|
||||
<button class="btn" bindtap="onConfirm" disabled="{{busy}}">{{busy ? "确认中…" : "确认登录"}}</button>
|
||||
<button class="btn ghost" bindtap="onLater">先不登录</button>
|
||||
</view>
|
||||
|
||||
<view class="tip">这个页面只在扫码时出现,平时不会打扰你。</view>
|
||||
</view>
|
||||
@@ -0,0 +1,16 @@
|
||||
.wrap{padding:36rpx 28rpx 60rpx;min-height:100vh;background:#FBF7F2;box-sizing:border-box}
|
||||
.brand{display:flex;align-items:center;gap:14rpx;justify-content:center;margin:30rpx 0 34rpx}
|
||||
.mk{width:72rpx;height:72rpx;border-radius:18rpx;background:#E4634A;color:#FFF3DF;
|
||||
display:flex;align-items:center;justify-content:center;font-size:40rpx;font-weight:600}
|
||||
.t{font-size:30rpx;color:#24211F;font-weight:600;letter-spacing:2rpx}
|
||||
.card{background:#fff;border:1rpx solid #EADFD0;border-radius:24rpx;padding:30rpx 28rpx}
|
||||
.h{font-size:32rpx;color:#24211F;font-weight:600}
|
||||
.s{font-size:25rpx;color:#6F6252;line-height:1.75;margin-top:14rpx}
|
||||
.code{font-family:Consolas,monospace;font-size:28rpx;color:#B3272D;letter-spacing:3rpx}
|
||||
.ipt{margin-top:20rpx;border:1rpx solid #E7DAC6;border-radius:14rpx;padding:20rpx 22rpx;
|
||||
font-size:30rpx;letter-spacing:4rpx;background:#FFFDF8;text-align:center}
|
||||
.note{margin-top:22rpx;padding:18rpx 20rpx;background:#FBF6EC;border:1rpx solid #EFE2CC;
|
||||
border-radius:14rpx;font-size:23rpx;color:#7A6440;line-height:1.7}
|
||||
.btn{margin-top:26rpx;background:#E4634A;color:#fff;border-radius:16rpx;font-size:29rpx;padding:22rpx 0}
|
||||
.btn.ghost{background:transparent;color:#8A7B68;border:1rpx solid #E7DAC6;margin-top:14rpx}
|
||||
.tip{margin-top:26rpx;text-align:center;font-size:22rpx;color:#A2947F}
|
||||
@@ -0,0 +1,18 @@
|
||||
const cfg = require("../../utils/config");
|
||||
const api = require("../../utils/api");
|
||||
|
||||
Page({
|
||||
data: { url: "", err: "" },
|
||||
onLoad() {
|
||||
const base = (cfg.apiBase || "").replace(/\/$/, "");
|
||||
wx.setNavigationBarTitle({ title: "做题工作台" });
|
||||
// 一次性门票:2 分钟、只能换一次,比在 URL 里长期带 token 安全
|
||||
api.request("POST", "/api/auth/web-ticket", { base_url: base })
|
||||
.then(r => this.setData({ url: (r && r.url) || (base + "/workbench?ticket=" + (r && r.ticket)) }))
|
||||
.catch(e => this.setData({ err: (e && e.message) || "打不开工作台" }));
|
||||
},
|
||||
onRetry() {
|
||||
this.setData({ url: "", err: "" });
|
||||
this.onLoad();
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"navigationBarTitleText": "做题工作台",
|
||||
"usingComponents": {}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<web-view wx:if="{{url}}" src="{{url}}"></web-view>
|
||||
<view class="err" wx:if="{{err}}">
|
||||
<view class="t">打不开工作台</view>
|
||||
<view class="s">{{err}}</view>
|
||||
<button class="b" bindtap="onRetry">重新打开</button>
|
||||
<view class="n">如果一直不行:① 手机和电脑连同一个网 ② 小程序的业务域名里加上这个地址(https)③ 回首页用「拍一张」先录题,做题不耽误</view>
|
||||
</view>
|
||||
@@ -0,0 +1,6 @@
|
||||
/* web-view 占满整屏 */
|
||||
.err{padding:80rpx 56rpx;text-align:center}
|
||||
.err .t{font-size:34rpx;font-weight:600;color:#24211f}
|
||||
.err .s{margin-top:16rpx;font-size:26rpx;color:#9a8c7a;word-break:break-all}
|
||||
.err .b{margin-top:36rpx;background:#e4634a;color:#fff;border-radius:14rpx;font-size:30rpx}
|
||||
.err .n{margin-top:36rpx;font-size:24rpx;color:#9a8c7a;line-height:1.7;text-align:left}
|
||||
Reference in New Issue
Block a user