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