feat(card): add leads and share pages with platform-specific handling

- Implemented leads.vue for managing lead statuses and displaying lead information.
- Added share.vue for sharing card links with platform-specific web-view handling for WeChat Mini Programs, HarmonyOS, and H5.
- Introduced tests for cross-platform compatibility, ensuring proper handling of conditional compilation and API usage across WeChat, H5, and HarmonyOS.
- Ensured that sharing functionality correctly encodes and decodes URLs for different platforms.
This commit is contained in:
2026-10-12 14:32:20 +08:00
parent a957679957
commit 9e6dc8665f
8 changed files with 1822 additions and 4 deletions

View File

@@ -272,6 +272,59 @@ export default {
}
});
},
/**
* JSON body 请求通道
*
* 为什么需要: sendRequest 走表单编码, 嵌套数组(如 fields.mobiles)的序列化
* 格式在各端不一致(uni 序列化器的平台差异, 小程序/H5 产出不同),
* 后端 input('fields/a') 依赖 PHP 方括号语法, 踩坑风险高。
* 本方法统一 JSON.stringify + application/json —— TP6 Request
* 原生解析 JSON body(getInputData), 且字符串 body 各端原样发送, 零歧义。
* token/uniacid/app_type 与 sendRequest 一样自动补齐。
*/
sendJson(params) {
if (!Config.baseUrl) {
uni.showToast({
title: getLang().lang('http.baseUrlNotConfigured'),
'icon': 'none',
'duration': 10000
});
return;
}
const url = (Config.baseUrl + params.url).replace(/(?<!:)\/+/g, '/');
const data = {
app_type: appType,
app_type_name: appTypeName,
token: store.state.token || '',
uniacid: uni.getStorageSync('uniacid') || Config.uniacid
};
if (params.data != undefined) Object.assign(data, params.data);
const store_info = store.state.globalStoreInfo;
if (store_info) data.store_id = store_info.store_id;
console.log('[HTTP][REQUEST] sendJson', url);
uni.request({
url: url,
method: params.method || 'POST',
header: Object.assign({ 'content-type': 'application/json' }, params.header || {}),
data: JSON.stringify(data),
dataType: params.dataType || 'json',
responseType: params.responseType || 'text',
success: (res) => {
console.log('[HTTP][RESPONSE] sendJson', url, 'statusCode=', res.statusCode);
let r = res.data;
if (typeof r === 'string') {
try { r = JSON.parse(r); } catch (e) { /* 保持原样 */ }
}
typeof params.success == 'function' && params.success(r);
},
fail: (res) => {
console.error('[HTTP][FAIL] sendJson', url, JSON.stringify(res));
typeof params.fail == 'function' && params.fail(res);
}
});
},
upload(params) {
console.log('[HTTP][REQUEST] upload', Config.baseUrl + params.url, 'name=', params.name || 'file');
uni.uploadFile({

View File

@@ -200,6 +200,10 @@ export const PAGE_KEY_MAP = {
// === 电子名片 ===
PAGE_CONTACT_CARD: '/pages/contact/contact',
// === 名片云(card 插件) ===
PAGE_CARD_LIST: '/pages_tool/card/list',
PAGE_CARD_LEADS: '/pages_tool/card/leads',
// === VR ===
PAGE_VR_INDEX: '/pages_tool/vr/index',