refactor(form): remove unused back home button and related code
移除了表单页面中不再使用的返回主页按钮、对应的国际化文案和重置表单方法,清理冗余代码
This commit is contained in:
@@ -10,6 +10,4 @@ export const lang = {
|
|||||||
// Modal dialog
|
// Modal dialog
|
||||||
tip: 'Tip',
|
tip: 'Tip',
|
||||||
paramError: 'Parameter error',
|
paramError: 'Parameter error',
|
||||||
// Back to home
|
|
||||||
backHome: 'Back to Home',
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,4 @@ export const lang = {
|
|||||||
// 弹窗
|
// 弹窗
|
||||||
tip: '提示',
|
tip: '提示',
|
||||||
paramError: '参数错误',
|
paramError: '参数错误',
|
||||||
// 返回主页
|
|
||||||
backHome: '返回主页',
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,12 @@
|
|||||||
<template>
|
<template>
|
||||||
<view :style="themeColor">
|
<view :style="themeColor">
|
||||||
<!-- 返回主页按钮:左上角固定,始终可见 -->
|
|
||||||
<view class="home-btn" @click="goHome">
|
|
||||||
<text class="home-btn-text">{{ $lang('form.formdata.backHome') }}</text>
|
|
||||||
</view>
|
|
||||||
<block v-if="detail">
|
<block v-if="detail">
|
||||||
<view class="page">
|
<view class="page">
|
||||||
<view class="system-form-wrap">
|
<view class="system-form-wrap">
|
||||||
<!-- 复用 diy-form:banner / tip / 表单字段 / 提交按钮 全部由其内部渲染,样式(bannerPaddingX/tipColor/submitBgColor 等)由 form_config 控制。
|
<!-- 复用 diy-form:banner / tip / 表单字段 / 提交按钮 全部由其内部渲染,样式(bannerPaddingX/tipColor/submitBgColor 等)由 form_config 控制。
|
||||||
:onSubmit 接管提交逻辑(带 uniacid + showModal);跨 H5 / MP 一致,不依赖 $listeners。
|
:onSubmit 接管提交逻辑(带 uniacid + showModal);跨 H5 / MP 一致,不依赖 $listeners。
|
||||||
注意:create 重度依赖本组件 this(id/uniacid/memberInfo/$api 等),必须在 created 阶段 bind this,
|
注意:create 重度依赖本组件 this(id/uniacid/memberInfo/$api 等),必须在 created 阶段 bind this,
|
||||||
否则 diy-form 通过 this.onSubmit(formData) 调用时 this 会漂移到子组件实例 -->
|
否则 diy-form 通过 this.onSubmit(formData) 调用时 this 会漂移到子组件实例 -->
|
||||||
<diy-form ref="form" :value="diyValue" dataMode="raw" :onSubmit="handleSubmit" />
|
<diy-form ref="form" :value="diyValue" dataMode="raw" :onSubmit="handleSubmit" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -178,18 +174,6 @@ export default {
|
|||||||
// #endif
|
// #endif
|
||||||
uni.setNavigationBarTitle({ title: formName });
|
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(),
|
// 由 diy-form 内置提交按钮触发:diy-form handleSubmit 已先做 verify(),
|
||||||
// 仅在通过时才通过 :onSubmit 函数 prop 调用本方法(跨 H5 / MP 一致,不走 $emit / $listeners)。
|
// 仅在通过时才通过 :onSubmit 函数 prop 调用本方法(跨 H5 / MP 一致,不走 $emit / $listeners)。
|
||||||
// 注意:本方法通过 created 中 this.handleSubmit = this.create.bind(this) 预绑定 this,
|
// 注意:本方法通过 created 中 this.handleSubmit = this.create.bind(this) 预绑定 this,
|
||||||
@@ -209,18 +193,15 @@ export default {
|
|||||||
member_id: this.memberInfo ? this.memberInfo.id : 0
|
member_id: this.memberInfo ? this.memberInfo.id : 0
|
||||||
},
|
},
|
||||||
success: res => {
|
success: res => {
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
this.complete = true
|
this.complete = true
|
||||||
// 提交成功后清空表单
|
uni.showModal({
|
||||||
this.resetForm()
|
title: this.$lang('form.formdata.tip'),
|
||||||
this.isRepeat = false
|
content: this.$lang('form.formdata.submitSuccess'),
|
||||||
uni.showModal({
|
showCancel: false,
|
||||||
title: this.$lang('form.formdata.tip'),
|
success: () => { }
|
||||||
content: this.$lang('form.formdata.submitSuccess'),
|
})
|
||||||
showCancel: false,
|
} else {
|
||||||
success: () => { }
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
this.isRepeat = false
|
this.isRepeat = false
|
||||||
this.$util.showToast({
|
this.$util.showToast({
|
||||||
title: res.message
|
title: res.message
|
||||||
@@ -254,35 +235,6 @@ page {
|
|||||||
border-radius: 0;
|
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 {
|
::v-deep .mescroll-totop {
|
||||||
/* #ifdef H5 */
|
/* #ifdef H5 */
|
||||||
right: 27rpx !important;
|
right: 27rpx !important;
|
||||||
|
|||||||
Reference in New Issue
Block a user