提交 991f7266 编写于 作者: D DCloud_LXH

fix(mp-alipay): fix returnValue default value

上级 2ec9088b
......@@ -49,8 +49,8 @@ function onAppLaunch(hook) {
my.appLaunchHooks.push(hook);
}
function getBaseSystemInfo() {
return my.getSystemInfoSync()
function getBaseSystemInfo() {
return my.getSystemInfoSync()
}
function validateProtocolFail(name, msg) {
......@@ -929,7 +929,7 @@ function handleSystemInfo(fromRes, toRes) {
}
toRes.platform = platform;
}
function returnValue(methodName, res) {
function returnValue(methodName, res = {}) {
// 通用 returnValue 解析
if (res.error || res.errorMessage) {
res.errMsg = `${methodName}:fail ${res.errorMessage || res.error}`;
......@@ -1107,8 +1107,18 @@ const connectSocket = {
// TODO 有没有返回值还需要测试下
};
const chooseImage = {
returnValue: {
apFilePaths: 'tempFilePaths',
returnValue(result) {
var _a, _b;
const hasTempFilePaths = hasOwn(result, 'tempFilePaths') && result.tempFilePaths;
if (hasOwn(result, 'apFilePaths') && !hasTempFilePaths) {
result.tempFilePaths = [];
(_a = result.apFilePaths) === null || _a === void 0 ? void 0 : _a.forEach((apFilePath) => { var _a; return (_a = result.tempFilePaths) === null || _a === void 0 ? void 0 : _a.push(apFilePath); });
}
if (!hasOwn(result, 'tempFiles') && hasTempFilePaths) {
result.tempFiles = [];
(_b = result.tempFilePaths) === null || _b === void 0 ? void 0 : _b.forEach((tempFilePath) => { var _a; return (_a = result.tempFiles) === null || _a === void 0 ? void 0 : _a.push({ path: tempFilePath }); });
}
return {};
},
};
const previewImage = {
......
import { isPlainObject, isArray } from '@vue/shared'
import { isPlainObject, isArray, hasOwn } from '@vue/shared'
import { addSafeAreaInsets } from '@dcloudio/uni-mp-core'
......@@ -36,7 +36,7 @@ function handleSystemInfo(
toRes.platform = platform
}
export function returnValue(methodName: string, res: Record<string, any>) {
export function returnValue(methodName: string, res: Record<string, any> = {}) {
// 通用 returnValue 解析
if (res.error || res.errorMessage) {
res.errMsg = `${methodName}:fail ${res.errorMessage || res.error}`
......@@ -224,8 +224,27 @@ export const connectSocket = {
// TODO 有没有返回值还需要测试下
}
export const chooseImage = {
returnValue: {
apFilePaths: 'tempFilePaths',
returnValue(
result: my.IChooseImageSuccessResult & {
tempFilePaths?: string[]
tempFiles?: Array<{ path: string }>
}
) {
const hasTempFilePaths =
hasOwn(result, 'tempFilePaths') && result.tempFilePaths
if (hasOwn(result, 'apFilePaths') && !hasTempFilePaths) {
result.tempFilePaths = []
result.apFilePaths?.forEach((apFilePath) =>
result.tempFilePaths?.push(apFilePath)
)
}
if (!hasOwn(result, 'tempFiles') && hasTempFilePaths) {
result.tempFiles = []
result.tempFilePaths?.forEach((tempFilePath) =>
result.tempFiles?.push({ path: tempFilePath })
)
}
return {}
},
}
export const previewImage = {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册