五个页面按 h5/css 的 style.css → ui-20261009 → ui-20261012 覆盖顺序逐条重排, 换算规则固定为 calc(N * var(--u)) → 2N rpx,固定 px 的字号保持 px。 - app.acss:换回 H5 设计 token(方角小倒角按钮 10rpx、卡片 14rpx、.chev 折线箭头) - splash/profile/history:底图与按钮文字图改用 H5 资源,隐私/政策弹窗按 H5 重排 - report:环形分用 conic-gradient、人脸裁切窗口叠加 face_maps、标记点百分比盒、 侧脸皱纹 pending/unavailable 文案;用 Playwright 抓 H5 94 个选择器几何比对, 整页高 2438.7 vs 2438.67 - camera:淘宝 <camera> 组件在真机整页崩溃(嵌了微信专有的 <cover-view>), 改为默认系统相机 + `config.nativeCamera` 开关 + pages/camtest 冒烟页验证组件 - permissions:淘宝用带前缀的 scope.camera(裸名返回 5022 Scope:camera信息不存在), 先试带前缀再退回裸名,拒绝后不再重复弹窗 - voice:非 HTTPS 资源导致的异常不再冒泡成整页崩溃;app.js 加开发版错误 toast - 开发版入口:权限诊断(启动页/相机页)、相机组件测试 - 测试 20/20(新增权限与相机能力用例)
120 lines
4.7 KiB
JavaScript
120 lines
4.7 KiB
JavaScript
/* ═════ 启动页:品牌底图 + Slogan + 开始检测/我的报告 + 隐私授权弹窗
|
|
对照 H5 index.html #s-splash(L43-58)、#p-privacy(L294-307)、#p-policy(L335-466)
|
|
交互保持:登录(必须勾选协议)、restore、历史入口、退出登录、政策全文、开发版入口。 ═════ */
|
|
var api = require('../../utils/api.js');
|
|
var development = require('../../utils/development');
|
|
var config = require('../../config');
|
|
|
|
Page({
|
|
data: {
|
|
// 图片全部走 api.assetUrl(与 H5 h5/assets/ 同相对路径)
|
|
bgUrl: api.assetUrl('img/ui-20261009/bg-splash-h5.jpg'),
|
|
logoUrl: api.assetUrl('img/ui-20261012/brand-lockup.png'),
|
|
sloganUrl: api.assetUrl('img/ui-20261012/splash-slogan.png'),
|
|
startLabelUrl: api.assetUrl('img/ui-20261012/button-start-label.png'),
|
|
historyLabelUrl: api.assetUrl('img/ui-20261012/button-history-label.png'),
|
|
closeIconUrl: api.assetUrl('img/ui-20261009/icon-close.png'),
|
|
|
|
showPrivacy: false, // 隐私授权弹窗
|
|
agreed: false, // 隐私协议勾选
|
|
showPolicy: false,
|
|
busy: false,
|
|
signedIn: 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: ''
|
|
},
|
|
onShow: function () {
|
|
var that = this;
|
|
api.restore().then(function (user) { that.setData({ signedIn: !!user, accountLabel: user ? '淘宝已登录' : '尚未登录' }); })
|
|
.catch(function () {});
|
|
},
|
|
|
|
// H5 .toast(自定义轻提示,替代系统 toast 以获得一致的视觉)
|
|
toast: function (msg) {
|
|
var that = this;
|
|
this.setData({ toastText: msg, toastOn: true });
|
|
clearTimeout(this.toastTimer);
|
|
this.toastTimer = setTimeout(function () {
|
|
that.setData({ toastOn: false });
|
|
}, Math.max(1800, String(msg).length * 130));
|
|
},
|
|
|
|
// 「开始检测」→ 隐私授权弹窗(H5 data-action="open-privacy")
|
|
onOpenPrivacy: function () {
|
|
if (api.user()) { my.navigateTo({ url: '/pages/profile/profile' }); return; }
|
|
this.setData({ showPrivacy: true });
|
|
},
|
|
onClosePrivacy: function () {
|
|
this.setData({ showPrivacy: false });
|
|
},
|
|
|
|
// 勾选/取消隐私协议(点链接不触发,由 catchTap 分隔)
|
|
onToggleAgree: function () {
|
|
this.setData({ agreed: !this.data.agreed });
|
|
},
|
|
|
|
onOpenPolicy: function () {
|
|
this.setData({ showPolicy: true });
|
|
},
|
|
onClosePolicy: function () {
|
|
this.setData({ showPolicy: false });
|
|
},
|
|
|
|
// 「继续」:必须已勾选协议
|
|
onAgreeContinue: function () {
|
|
var that = this;
|
|
if (this.data.busy) return;
|
|
if (!this.data.agreed) {
|
|
this.toast('请先阅读并同意隐私协议');
|
|
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 }); });
|
|
},
|
|
// H5 data-action="history" / 「我的报告」
|
|
onHistory: function () {
|
|
if (!api.user()) { this.onOpenPrivacy(); return; }
|
|
my.navigateTo({ url: '/pages/history/history' });
|
|
},
|
|
onLogout: function () {
|
|
var that = this;
|
|
api.logout().then(function () {
|
|
that.setData({ signedIn: false, agreed: false, accountLabel: '尚未登录' });
|
|
}).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' }); },
|
|
|
|
noop: function () {} // 弹窗卡片内点击拦截冒泡用
|
|
});
|