Commit d41c8a6a authored by xinzhedeai's avatar xinzhedeai

better:消费者页面校验优化

parent 93354a86
...@@ -201,7 +201,7 @@ ...@@ -201,7 +201,7 @@
<span></span> <span></span>
</h5> </h5>
<div> <div>
<textarea class="textareaEle" v-model="formData.content" name="" id="" cols="10" rows="3" style="resize: none;"></textarea> <textarea maxlength="100" class="textareaEle" v-model="formData.content" placeholder="请输入安全建议(最多100字)" name="" id="" cols="10" rows="3" style="resize: none;"></textarea>
</div> </div>
</div> </div>
...@@ -222,7 +222,7 @@ ...@@ -222,7 +222,7 @@
</div> </div>
</div> --> </div> -->
<!-- 新增检查单 隐患图片上传 2025年7月31日13:07:28新增逻辑修改 --> <!-- 新增检查单 隐患图片上传 2025年7月31日13:07:28新增逻辑修改 -->
<div class="form-label form-label-div title_require title_requirediv" style="width: 4rem;">上传作业证件(最多4张)</div> <div class="form-label form-label-div title_require title_requirediv" style="width: 4rem;">请上传图片(最多4张)</div>
<div class="img-wrapper"> <div class="img-wrapper">
<div style="position: relative;" v-for="(imgItem, index) in formData.photos"> <div style="position: relative;" v-for="(imgItem, index) in formData.photos">
<img :src="previewUrl + imgItem" style="width: 1.6rem; height: 1.6rem;" <img :src="previewUrl + imgItem" style="width: 1.6rem; height: 1.6rem;"
...@@ -243,14 +243,14 @@ ...@@ -243,14 +243,14 @@
<div class="form-item"> <div class="form-item">
<span class="form-label">联系人</span> <span class="form-label">联系人</span>
<div class="form-input-wrap"> <div class="form-input-wrap">
<input type="text" v-model="formData.contactName" class="form-input" placeholder="请输入姓名"> <input type="text" maxlength="4" v-model="formData.contactName" class="form-input" placeholder="请输入姓名">
</div> </div>
</div> </div>
<div class="form-item"> <div class="form-item">
<span class="form-label">联系方式</span> <span class="form-label">联系方式</span>
<div class="form-input-wrap"> <div class="form-input-wrap">
<input type="text" v-model="formData.contactDetails" class="form-input" <input type="number" maxlength="11" v-model="formData.contactDetails" class="form-input"
placeholder="请输入手机号"> placeholder="请输入手机号">
</div> </div>
</div> </div>
......
...@@ -17,14 +17,11 @@ window.addEventListener("load", function () { ...@@ -17,14 +17,11 @@ window.addEventListener("load", function () {
previewUrl: BASE_URL, previewUrl: BASE_URL,
// 新增以下数据 // 新增以下数据
formData: { formData: {
submitDate: gemhoUtil.getTargetDateYMD(),
createDate: gemhoUtil.getTargetDateYMD(),
date: gemhoUtil.getTargetDateYMD(), date: gemhoUtil.getTargetDateYMD(),
phone: '', content: '',
area: '', contactName: '',
businessHours: '', contactDetails: '',
type: '', // 新增类型字段 photos: [],
photos: []
}, },
merId: '', merId: '',
merInformation: { // 新增商户信息对象 merInformation: { // 新增商户信息对象
...@@ -174,6 +171,29 @@ window.addEventListener("load", function () { ...@@ -174,6 +171,29 @@ window.addEventListener("load", function () {
}) })
return; return;
} }
if (!this.formData.photos.length) {
vant.Dialog.alert({
message: '图片不可为空',
})
return;
}
if (this.formData.contactDetails && !/^1[3-9]\d{9}$/.test(this.formData.contactDetails)) {
vant.Dialog.alert({
message: '联系方式格式不正确',
})
return;
}
if (this.formData.contactName && this.formData.contactName.length <2) {
vant.Dialog.alert({
message: '联系人名称字符长度不可小于2位',
})
return;
}
vant.Toast.loading({ vant.Toast.loading({
message: '正在处理...', message: '正在处理...',
forbidClick: true, forbidClick: true,
...@@ -187,23 +207,27 @@ window.addEventListener("load", function () { ...@@ -187,23 +207,27 @@ window.addEventListener("load", function () {
http3.post('/gq/consumer', reqParam).then((res) => { http3.post('/gq/consumer', reqParam).then((res) => {
console.log('添加结果', res) console.log('添加结果', res)
vant.Toast({ if(res.code === 200){
message: '操作成功', vant.Toast({
}) message: '提交成功,感谢您的参与!',
// this.formData = { })
// submitDate: gemhoUtil.getTargetDateYMD(),
// createDate: gemhoUtil.getTargetDateYMD(), this.formData.content = ''
// phone: '', this.formData.photos = []
// area: '', this.formData.contactName = ''
// businessHours: '', this.formData.contactDetails = ''
// type: '', // 新增类型字段 // history.back()
// content: '', // setTimeout(() => {
// photos: [], // location.reload()
// contactName: '', // }, 300);
// contactDetails: '', }else{
// }, vant.Toast({
location.reload() message: '提交失败',
// gemhoUtil.navigatePage(`${this.pageName}.html${window.location.search}`, '操作完成,跳转中...') })
}
}) })
}, },
//获取商户信息 //获取商户信息
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment