chore:在线留言提交后,再次打开在线留言,输入框会清空上次内容

This commit is contained in:
2026-01-07 14:29:53 +08:00
parent 4a44eb66c9
commit 012b1339aa
3 changed files with 40 additions and 101 deletions

View File

@@ -98,8 +98,7 @@ export default {
markers: [],
Form: {
realname: "",
mobile: "",
remark: ""
mobile: ""
},
ismessage: 0,
video_url: ""
@@ -264,7 +263,6 @@ export default {
success: (res) => {
this.$refs.informationPopup.close();
this.$util.showToast({ title: res.message });
this.resetForm();
},
fail: (err) => {
console.log(err);
@@ -282,14 +280,6 @@ export default {
closeinformationPopup() {
this.ismessage = 0;
this.$refs.informationPopup.close();
this.resetForm();
},
resetForm() {
this.Form = {
realname: "",
mobile: "",
remark: ""
};
},
Tel(phone) {
uni.makePhoneCall({

View File

@@ -113,20 +113,20 @@
<view class="fui-cell ">
<view class="fui-cell-label ">{{ $lang('name') }}</view>
<view class="fui-cell-info">
<input v-model="Form.realname" class="fui-input" :placeholder="$lang('pleaseEnterName')" value=""></input>
<input v-model="Form.realname" class="fui-input" :placeholder="$lang('pleaseEnterName')":key="formKey" value=""></input>
</view>
</view>
<view class="fui-cell ">
<view class="fui-cell-label">{{ $lang('contactInfo') }}</view>
<view class="fui-cell-info">
<input v-model="Form.mobile" class="fui-input" maxlength="11" :placeholder="$lang('pleaseEnterMobile')" type="number"></input>
<input v-model="Form.mobile" class="fui-input" maxlength="11" :placeholder="$lang('pleaseEnterMobile')" type="number":key="formKey"></input>
</view>
</view>
<view class="fui-cell ">
<view class="fui-cell-label" style="position: absolute;top:10px">{{ $lang('messageContent') }}</view>
<view class="fui-cell-info" style="margin-left: 160rpx;border: solid 2rpx #eee;">
<!-- <input v-model="Form.mailbox" class="fui-input" placeholder="请输入您的邮箱" type="text" ></input> -->
<textarea class="textarea" v-model="Form.remark" :placeholder="$lang('pleaseEnterMessage')" style="font-size: 28rpx;padding: 10rpx;"></textarea>
<textarea class="textarea" v-model="Form.remark" :placeholder="$lang('pleaseEnterMessage')" style="font-size: 28rpx;padding: 10rpx;":key="formKey"></textarea>
</view>
</view>
</view>
@@ -158,6 +158,7 @@ export default {
remark: ''
},
formKey: Date.now(),
markers: [
{
id: 1,
@@ -222,16 +223,28 @@ export default {
// window.open('https://xcx10.5g-quickapp.com/test.php')
},
save() {
if (!this.Form.realname.trim()) {
uni.showToast({ title: '请填写姓名', icon: 'none' });
return;
}
if (!this.Form.mobile || !/^1[3-9]\d{9}$/.test(this.Form.mobile)) {
uni.showToast({ title: '手机号格式不正确', icon: 'none' });
return;
}
if (!this.Form.remark.trim()) {
uni.showToast({ title: '请填写留言内容', icon: 'none' });
return;
}
this.$api.sendRequest({
url: '/api/member/message',
data: this.Form,
success: res => {
this.$refs.informationPopup.close();
this.$util.showToast({
title: res.message
});
},
fail: res => {
uni.showToast({ title: res.message || '提交成功', icon: 'success' });
this.Form = { realname: '', mobile: '', remark: '' };
this.formKey = Date.now();
}
});
},
@@ -241,7 +254,16 @@ export default {
},
//留言打开
tapMessage() {
this.ismessage = 1
// 清空表单数据
this.Form = {
realname: '',
mobile: '',
remark: ''
};
// 关键:更新 key强制重建输入框
this.formKey = Date.now();
this.ismessage = 1;
this.$refs.informationPopup.open();
},
//留言关闭

View File

@@ -1,5 +1,4 @@
<template>
<<<<<<< HEAD
<view :style="themeColor">
<mescroll-uni ref="mescroll" @getData="getData" class="member-point" :size="8" @listenRefresh="listenRefresh"
v-if="storeToken">
@@ -75,78 +74,6 @@ export default {
}
}
}
=======
<view :style="themeColor">
<mescroll-uni ref="mescroll" @getData="getData" class="member-point" :size="8" @listenRefresh="listenRefresh">
<block class="goods_list" slot="list">
<block v-if="collectionList.length > 0">
<view class="goods_li margin-top" v-for="(item, index) in collectionList" :key="index"
@click.stop="toDetail(item)">
<view class="pic">
<image :src="$util.img(item.goods_image.split(',')[0], { size: 'mid' })" mode="aspectFill"
@error="goodsImageError(index)"></image>
</view>
<view class="goods_info">
<view class="goods_name font-size-base">{{ item.sku_name }}</view>
<view class="goods_opection">
<view class="left lineheight-clear ">
<text class="symbol price-style small"></text>
<text class="price price-style large">{{
parseFloat(item.discount_price).toFixed(2).split('.')[0] }}</text>
<text class="symbol price-style small">.{{
parseFloat(item.discount_price).toFixed(2).split('.')[1] }}</text>
</view>
<view class="right">
<view class="cars" @click.stop="deleteItem(item.goods_id)">
<view class="icon iconfont icon-icon7"></view>
</view>
</view>
</view>
</view>
</view>
</block>
<!-- 第一个列表为空时 -->
<view class="collection-empty" v-else>
<ns-empty v-if="collectionList.length == 0 && isShowEmpty" text="暂无关注的商品"
:isIndex="Boolean(storeToken)" :emptyBtn="{ text: $lang('toGoodsCategoryPage'), url: '/pages_goods/category' }"></ns-empty>
<button type="primary" size="mini" class="button mini" v-if="!storeToken"
@click="toLogin">{{ $lang('toLogin') }}</button>
</view>
<ns-goods-recommend ref="goodsRecommend"></ns-goods-recommend>
</block>
</mescroll-uni>
<ns-login ref="login"></ns-login>
<loading-cover ref="loadingCover"></loading-cover>
</view>
</template>
<script>
import common from './public/js/common.js';
import collection from './public/js/collection.js';
export default {
mixins: [common, collection],
data() {
return {};
},
onShow() {
if (this.storeToken) {
if (this.$refs.mescroll) this.$refs.mescroll.refresh();
} else {
this.$nextTick(() => {
this.$refs.loadingCover.hide();
});
}
},
watch: {
storeToken: function (nVal, oVal) {
if (nVal) {
this.$refs.mescroll.refresh();
}
}
}
>>>>>>> remotes/origin/dev/1.0
};
</script>