feat: 完善淘宝小程序拍照、报告与登录流程

接入本地实时识别和自动三连拍,调整报告裁切、商品跳转、分享标题及居中页眉;完善游客会话、后台渠道隔离、部署脚本与回归测试。
This commit is contained in:
xsl
2026-11-04 15:07:51 +08:00
parent 381da60ae4
commit 774376fa16
147 changed files with 17420 additions and 597 deletions
+29 -45
View File
@@ -1,11 +1,10 @@
/* ═════ 启动页:品牌底图 + Slogan + 开始检测/我的报告 + 隐私授权弹窗
对照 H5 index.html #s-splash(L43-58)、#p-privacy(L294-307)、#p-policy(L335-466)
交互保持:登录(必须勾选协议)、restore、历史入口、退出登录、政策全文、开发版入口。 ═════ */
交互保持:登录(必须勾选协议)、restore、历史入口、退出登录、政策全文。 ═════ */
var api = require('../../utils/api.js');
var development = require('../../utils/development');
var config = require('../../config');
Page({
Page(require('../../utils/page-header').page({
onShareAppMessage: function () { return require('../../utils/share').message(); },
data: {
// 图片全部走 api.assetUrl(与 H5 h5/assets/ 同相对路径)
bgUrl: api.assetUrl('img/ui-20261009/bg-splash-h5.jpg'),
@@ -20,20 +19,27 @@ Page({
showPolicy: false,
busy: false,
signedIn: false,
guest: false,
accountLabel: '尚未登录', // H5 renderAccountStatus()
toastText: '', toastOn: false,
showCameraDebug: development.cameraDebugEnabled(),
showMvpDebug: config.mvpLocal === true || (config.transport === 'cloud' && config.environment !== 'production'),
showDiagnose: config.environment !== 'production',
diagText: ''
toastText: '', toastOn: false
},
onShow: function () {
var that = this;
api.restore().then(function (user) { that.setData({ signedIn: !!user, accountLabel: user ? '淘宝已登录' : '尚未登录' }); })
.catch(function () {});
this.alive = true;
api.restore().then(function (user) {
if (!that.alive) return;
if (!user) { my.redirectTo({ url: '/pages/login/login' }); return; }
var guest = user.kind === 'taobao_guest';
that.setData({ signedIn: !guest, guest: guest, accountLabel: guest ? '游客模式' : '淘宝已登录' });
}).catch(function (err) {
if (!that.alive) return;
that.setData({ signedIn: false, guest: false, accountLabel: '登录状态待确认' });
if (err.status === 401) my.redirectTo({ url: '/pages/login/login' });
else that.toast('网络异常,请重新登录或稍后重试');
});
},
onUnload: function () { this.alive = false; clearTimeout(this.toastTimer); },
// H5 .toast(自定义轻提示,替代系统 toast 以获得一致的视觉)
toast: function (msg) {
@@ -47,7 +53,8 @@ Page({
// 「开始检测」→ 隐私授权弹窗(H5 data-action="open-privacy")
onOpenPrivacy: function () {
if (api.user()) { my.navigateTo({ url: '/pages/profile/profile' }); return; }
if (!api.user()) { my.redirectTo({ url: '/pages/login/login' }); return; }
this.setData({ agreed: false });
this.setData({ showPrivacy: true });
},
onClosePrivacy: function () {
@@ -75,45 +82,22 @@ Page({
return;
}
this.setData({ busy: true });
api.login(true).then(function () {
that.setData({ showPrivacy: false, signedIn: true, accountLabel: '淘宝已登录' });
my.navigateTo({ url: '/pages/profile/profile' });
}).catch(function (err) {
that.toast(err.message);
}).then(function () { that.setData({ busy: false }); });
if (!api.user()) { this.setData({ busy: false }); my.redirectTo({ url: '/pages/login/login' }); return; }
this.setData({ showPrivacy: false, busy: false });
my.navigateTo({ url: '/pages/profile/profile' });
},
// H5 data-action="history" / 「我的报告」
onHistory: function () {
if (!api.user()) { this.onOpenPrivacy(); return; }
if (!api.user()) { my.redirectTo({ url: '/pages/login/login' }); return; }
my.navigateTo({ url: '/pages/history/history' });
},
onLogout: function () {
var that = this;
api.logout().then(function () {
that.setData({ signedIn: false, agreed: false, accountLabel: '尚未登录' });
(api.isGuest() ? api.endGuest() : api.logout()).then(function () {
that.setData({ signedIn: false, guest: false, agreed: false, accountLabel: '尚未登录' });
my.redirectTo({ url: '/pages/login/login' });
}).catch(function (err) { that.toast(err.message); });
},
onCameraDebug: function () {
if (!development.cameraDebugEnabled()) return;
my.navigateTo({ url: '/pages/camera/camera?debug=camera' });
},
onMvpDebug: function () {
if (!config.mvpLocal && !(config.transport === 'cloud' && config.environment !== 'production')) return;
my.navigateTo({ url: '/pages/mvp/mvp' });
},
// 相机/相册权限诊断:相机页可能整页崩掉,所以在启动页也能点
onDiagnose: function () {
var that = this;
this.setData({ diagText: '检测中…' });
require('../../utils/permissions').diagnose().then(function (info) {
that.setData({ diagText: info.join('\n') });
}).catch(function (err) {
that.setData({ diagText: 'diagnose error: ' + (err && err.message ? err.message : String(err)) });
});
},
onCloseDiagnose: function () { this.setData({ diagText: '' }); },
// 相机组件冒烟测试:单独一页只放 <camera>,用来判断淘宝真机是否支持该组件
onCamTest: function () { my.navigateTo({ url: '/pages/camtest/camtest' }); },
onLogin: function () { my.navigateTo({ url: '/pages/login/login?switch=1' }); },
noop: function () {} // 弹窗卡片内点击拦截冒泡用
});
}, typeof my === 'undefined' ? {} : my));