Files
juzi/taobao/app.js
T
xsl 774376fa16 feat: 完善淘宝小程序拍照、报告与登录流程
接入本地实时识别和自动三连拍,调整报告裁切、商品跳转、分享标题及居中页眉;完善游客会话、后台渠道隔离、部署脚本与回归测试。
2026-11-04 15:07:51 +08:00

40 lines
1.5 KiB
JavaScript

/* ═════ 1'me 肌肤状态检测 · 淘宝小程序 ═════
* 复用 H5 版业务逻辑与后端接口(POST /api/skin-analyze),channel 固定为 'taobao' */
App({
globalData: {
// 档案(profile 页填写):{ real_age, gender, region, daily_skin_type }
profile: null,
// 三连拍 dataURL,送检口径固定为 [正脸, 左脸, 右脸](与 H5 photosByView 一致)
photos: null,
// 检测接口返回:{ result, side, face_rectangle }
payload: null
},
onShareAppMessage: function () {
return require('./utils/share').message();
},
onLaunch: function () {
require('./utils/api.js').resetForLaunch();
// The login screen needs no native audio player. voice.play() creates its
// context lazily when spoken guidance is actually needed.
},
onShow: function () {
var api = require('./utils/api.js');
if (api.hasSession() && !api.isGuest()) api.restore().catch(function () {});
},
onHide: function () {
require('./utils/api.js').suspendSession();
require('./utils/voice.js').stop(true);
},
// 真机上看不到 console:开发版里把未捕获异常弹出到屏幕上,方便截图定位。
onError: function (error) {
try {
var config = require('./config');
if (config.environment === 'production') return;
var text = String((error && (error.message || error.stack)) || error);
my.showToast({ content: 'JS错误: ' + text.slice(0, 120), type: 'none', duration: 8000 });
} catch (_) {}
}
});