From 5f60504c75e3a9bb9ea0ed674e0ccf5545eb8316 Mon Sep 17 00:00:00 2001
From: jinhhanhan <1683105490@qq.com>
Date: Fri, 7 Aug 2026 11:11:38 +0800
Subject: [PATCH] =?UTF-8?q?chore=EF=BC=9A?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
components-diy/diy-recommend-code.vue | 2 -
lang/en-us/form/formdata.js | 2 +
lang/zh-cn/form/formdata.js | 2 +
pages_tool/form/formdata.vue | 72 ++++++++++++++++++++++-----
4 files changed, 64 insertions(+), 14 deletions(-)
diff --git a/components-diy/diy-recommend-code.vue b/components-diy/diy-recommend-code.vue
index dff1ff7..8e0cf5f 100644
--- a/components-diy/diy-recommend-code.vue
+++ b/components-diy/diy-recommend-code.vue
@@ -36,8 +36,6 @@
专属推荐码
- 👥
- 邀请好友
diff --git a/lang/en-us/form/formdata.js b/lang/en-us/form/formdata.js
index b00de04..6999de6 100644
--- a/lang/en-us/form/formdata.js
+++ b/lang/en-us/form/formdata.js
@@ -10,4 +10,6 @@ export const lang = {
// Modal dialog
tip: 'Tip',
paramError: 'Parameter error',
+ // Back to home
+ backHome: 'Back to Home',
}
diff --git a/lang/zh-cn/form/formdata.js b/lang/zh-cn/form/formdata.js
index ec5a95f..b4682bc 100644
--- a/lang/zh-cn/form/formdata.js
+++ b/lang/zh-cn/form/formdata.js
@@ -9,4 +9,6 @@ export const lang = {
// 弹窗
tip: '提示',
paramError: '参数错误',
+ // 返回主页
+ backHome: '返回主页',
}
diff --git a/pages_tool/form/formdata.vue b/pages_tool/form/formdata.vue
index abd2f62..49291d2 100644
--- a/pages_tool/form/formdata.vue
+++ b/pages_tool/form/formdata.vue
@@ -1,12 +1,16 @@
+
+
+ {{ $lang('form.formdata.backHome') }}
+
+ :onSubmit 接管提交逻辑(带 uniacid + showModal);跨 H5 / MP 一致,不依赖 $listeners。
+ 注意:create 重度依赖本组件 this(id/uniacid/memberInfo/$api 等),必须在 created 阶段 bind this,
+ 否则 diy-form 通过 this.onSubmit(formData) 调用时 this 会漂移到子组件实例 -->
@@ -174,6 +178,18 @@ export default {
// #endif
uni.setNavigationBarTitle({ title: formName });
},
+ // 返回主页(用 reLaunch 避免返回后还能 navigateBack 回到已提交的表单页)
+ goHome() {
+ this.$util.redirectTo(this.$util.INDEX_PAGE_URL, {}, 'reLaunch');
+ },
+ // 清空表单数据:通过 diy-form 的 ref 拿到 ns-newform 实例,调用 setFormData 重置
+ resetForm() {
+ try {
+ if (this.$refs.form && this.$refs.form.$refs.nsNewform && this.$refs.form.$refs.nsNewform.setFormData) {
+ this.$refs.form.$refs.nsNewform.setFormData();
+ }
+ } catch(e) {}
+ },
// 由 diy-form 内置提交按钮触发:diy-form handleSubmit 已先做 verify(),
// 仅在通过时才通过 :onSubmit 函数 prop 调用本方法(跨 H5 / MP 一致,不走 $emit / $listeners)。
// 注意:本方法通过 created 中 this.handleSubmit = this.create.bind(this) 预绑定 this,
@@ -193,15 +209,18 @@ export default {
member_id: this.memberInfo ? this.memberInfo.id : 0
},
success: res => {
- if (res.code == 0) {
- this.complete = true
- uni.showModal({
- title: this.$lang('form.formdata.tip'),
- content: this.$lang('form.formdata.submitSuccess'),
- showCancel: false,
- success: () => { }
- })
- } else {
+ if (res.code == 0) {
+ this.complete = true
+ // 提交成功后清空表单
+ this.resetForm()
+ this.isRepeat = false
+ uni.showModal({
+ title: this.$lang('form.formdata.tip'),
+ content: this.$lang('form.formdata.submitSuccess'),
+ showCancel: false,
+ success: () => { }
+ })
+ } else {
this.isRepeat = false
this.$util.showToast({
title: res.message
@@ -235,6 +254,35 @@ page {
border-radius: 0;
}
+// 左上角返回主页按钮
+.home-btn {
+ position: fixed;
+ left: 30rpx;
+ // #ifdef MP-WEIXIN || MP-ALIPAY || MP-BAIDU || MP-TOUTIAO || MP-QQ || MP-LARK
+ // 小程序端需避开右上角胶囊按钮,下移到状态栏 + 胶囊高度之下
+ top: calc(var(--status-bar-height, 20px) + 10rpx);
+ // #endif
+ // #ifdef H5
+ top: 20rpx;
+ // #endif
+ z-index: 999;
+ padding: 12rpx 28rpx;
+ background-color: rgba(0, 0, 0, 0.5);
+ border-radius: 40rpx;
+ display: flex;
+ align-items: center;
+
+ .home-btn-text {
+ color: #ffffff;
+ font-size: 26rpx;
+ line-height: 1;
+ }
+
+ &:active {
+ opacity: 0.8;
+ }
+}
+
::v-deep .mescroll-totop {
/* #ifdef H5 */
right: 27rpx !important;