This commit is contained in:
2026-08-07 11:11:38 +08:00
parent 289e582ba1
commit 5f60504c75
4 changed files with 64 additions and 14 deletions

View File

@@ -36,8 +36,6 @@
<text style="font-size:21rpx;color:#666;">专属推荐码</text>
</view>
<view style="display:flex;align-items:center;gap:4rpx;">
<text style="font-size:22rpx;">👥</text>
<text style="font-size:21rpx;color:#666;">邀请好友</text>
</view>
</view>
<!-- 去登录按钮 -->

View File

@@ -10,4 +10,6 @@ export const lang = {
// Modal dialog
tip: 'Tip',
paramError: 'Parameter error',
// Back to home
backHome: 'Back to Home',
}

View File

@@ -9,4 +9,6 @@ export const lang = {
// 弹窗
tip: '提示',
paramError: '参数错误',
// 返回主页
backHome: '返回主页',
}

View File

@@ -1,12 +1,16 @@
<template>
<view :style="themeColor">
<!-- 返回主页按钮:左上角固定,始终可见 -->
<view class="home-btn" @click="goHome">
<text class="home-btn-text">{{ $lang('form.formdata.backHome') }}</text>
</view>
<block v-if="detail">
<view class="page">
<view class="system-form-wrap">
<!-- 复用 diy-form:banner / tip / 表单字段 / 提交按钮 全部由其内部渲染,样式(bannerPaddingX/tipColor/submitBgColor 等)由 form_config 控制。
:onSubmit 接管提交逻辑(带 uniacid + showModal);跨 H5 / MP 一致,不依赖 $listeners。
注意:create 重度依赖本组件 this(id/uniacid/memberInfo/$api 等),必须在 created 阶段 bind this,
否则 diy-form 通过 this.onSubmit(formData) 调用时 this 会漂移到子组件实例 -->
:onSubmit 接管提交逻辑(带 uniacid + showModal);跨 H5 / MP 一致,不依赖 $listeners。
注意:create 重度依赖本组件 this(id/uniacid/memberInfo/$api 等),必须在 created 阶段 bind this,
否则 diy-form 通过 this.onSubmit(formData) 调用时 this 会漂移到子组件实例 -->
<diy-form ref="form" :value="diyValue" dataMode="raw" :onSubmit="handleSubmit" />
</view>
</view>
@@ -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;