五个页面按 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(新增权限与相机能力用例)
51 lines
2.3 KiB
JavaScript
51 lines
2.3 KiB
JavaScript
var config = require('../config');
|
|
var cloudReady;
|
|
|
|
function unwrap(result) {
|
|
if (typeof result === 'string') result = JSON.parse(result);
|
|
if (result && typeof result.success === 'boolean') {
|
|
if (!result.success) throw new Error(result.errorMessage || '服务暂不可用');
|
|
return typeof result.data === 'string' ? JSON.parse(result.data) : result.data;
|
|
}
|
|
return result;
|
|
}
|
|
function initCloud() {
|
|
if (!cloudReady) {
|
|
var sdk = require('@tbmp/mp-cloud-sdk'), cloud = sdk.default || sdk;
|
|
cloudReady = Promise.resolve(cloud.init({ env: config.cloudEnv })).then(function (ok) {
|
|
if (!ok) throw new Error('淘宝云服务初始化失败');
|
|
return cloud;
|
|
}).catch(function (err) { cloudReady = null; throw err; });
|
|
}
|
|
return cloudReady;
|
|
}
|
|
function request(path, body, token) {
|
|
var headers = { 'Content-Type': 'application/json;charset=UTF-8' };
|
|
if (token) headers.Authorization = 'Bearer ' + token;
|
|
if (config.transport === 'direct') {
|
|
if (!/^http:\/\/(localhost|127\.0\.0\.1)(:\d+)?$/.test(config.baseUrl)) return Promise.reject(new Error('直连接口仅用于本机联调'));
|
|
return new Promise(function (resolve, reject) {
|
|
my.request({ url: config.baseUrl + config.basePath + path, method: 'POST', headers: headers, data: JSON.stringify(body),
|
|
dataType: 'json', timeout: 10000,
|
|
success: function (res) {
|
|
try {
|
|
if ((res.status || res.statusCode) !== 200) throw new Error('服务暂不可用');
|
|
resolve(unwrap(res.data));
|
|
} catch (e) { reject(e); }
|
|
}, fail: function () { reject(new Error('网络异常,请稍后重试')); } });
|
|
});
|
|
}
|
|
var cloudType = config.cloudType || 'empty';
|
|
if (cloudType === 'empty' && (!config.cloudAppId || !/^https:\/\//.test(config.baseUrl))) {
|
|
return Promise.reject(new Error('请先配置淘宝云应用和 HTTPS 服务地址'));
|
|
}
|
|
return initCloud().then(function (cloud) {
|
|
var exts = { timeout: 10000 };
|
|
if (config.cloudAppId) exts.cloudAppId = config.cloudAppId;
|
|
if (cloudType === 'empty') exts.domain = config.baseUrl;
|
|
return cloud.application.httpRequest({ path: config.basePath + path, method: 'POST', headers: headers,
|
|
params: {}, body: body, exts: exts });
|
|
}).then(unwrap);
|
|
}
|
|
module.exports = { request: request, unwrap: unwrap };
|