hookehuyr

feat: 添加对iframe项目标识的支持并处理表单提交消息

1 <!-- 1 <!--
2 * @Date: 2022-07-18 10:22:22 2 * @Date: 2022-07-18 10:22:22
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2025-07-03 17:44:43 4 + * @LastEditTime: 2025-09-25 14:31:46
5 * @FilePath: /data-table/src/views/index.vue 5 * @FilePath: /data-table/src/views/index.vue
6 * @Description: 首页 6 * @Description: 首页
7 --> 7 -->
...@@ -281,6 +281,8 @@ const data_id = $route.query.data_id ? $route.query.data_id : null; ...@@ -281,6 +281,8 @@ const data_id = $route.query.data_id ? $route.query.data_id : null;
281 const x_field_1 = $route.query.x_field_1 ? $route.query.x_field_1 : null; 281 const x_field_1 = $route.query.x_field_1 ? $route.query.x_field_1 : null;
282 // 周期ID标识 282 // 周期ID标识
283 const x_cycle = $route.query.x_cycle ? $route.query.x_cycle : null; 283 const x_cycle = $route.query.x_cycle ? $route.query.x_cycle : null;
284 +// iframe项目标识 - 现在是美乐爱觉使用
285 +const x_project = $route.query.x_project ? $route.query.x_project : null;
284 // iframe传值openid 286 // iframe传值openid
285 const iframe_openid = getUrlParams(location.href) ? getUrlParams(location.href).openid : ''; 287 const iframe_openid = getUrlParams(location.href) ? getUrlParams(location.href).openid : '';
286 // 强制后台检查标识 288 // 强制后台检查标识
...@@ -1076,6 +1078,30 @@ const successHandle = () => { // 表单成功提交后续操作 ...@@ -1076,6 +1078,30 @@ const successHandle = () => { // 表单成功提交后续操作
1076 getChildVal(); 1078 getChildVal();
1077 return false; 1079 return false;
1078 } 1080 }
1081 +
1082 + // iframe 项目标识 - 现在是美乐爱觉使用
1083 + if (x_project === 'behalo') {
1084 + // 向父页面发送消息
1085 + const messageData = {
1086 + id: successInfo.value?.id,
1087 + type: 'formSubmit',
1088 + timestamp: Date.now(),
1089 + };
1090 +
1091 + try {
1092 + // 发送消息到父页面
1093 + if (window.parent && window.parent !== window) {
1094 + window.parent.postMessage(messageData, '*');
1095 + console.log('已向父页面发送消息:', messageData);
1096 + }
1097 + } catch (error) {
1098 + console.error('发送消息到父页面失败:', error);
1099 + }
1100 +
1101 + // 提交成功,直接返回
1102 + return false;
1103 + }
1104 +
1079 // 如果类型为跳转网页 1105 // 如果类型为跳转网页
1080 if (successInfo.value.commit_action === 'url') { 1106 if (successInfo.value.commit_action === 'url') {
1081 window.location.href = successInfo.value.commit_url; 1107 window.location.href = successInfo.value.commit_url;
......