chore: 首次纳入版本控制(审查前基线,v1.2.0)
This commit is contained in:
@@ -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); }
|
||||
Reference in New Issue
Block a user