Commit d41c8a6a authored by xinzhedeai's avatar xinzhedeai

better:消费者页面校验优化

parent 93354a86
......@@ -201,7 +201,7 @@
<span></span>
</h5>
<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>
......@@ -222,7 +222,7 @@
</div>
</div> -->
<!-- 新增检查单 隐患图片上传 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 style="position: relative;" v-for="(imgItem, index) in formData.photos">
<img :src="previewUrl + imgItem" style="width: 1.6rem; height: 1.6rem;"
......@@ -243,14 +243,14 @@
<div class="form-item">
<span class="form-label">联系人</span>
<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 class="form-item">
<span class="form-label">联系方式</span>
<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="请输入手机号">
</div>
</div>
......
......@@ -17,14 +17,11 @@ window.addEventListener("load", function () {
previewUrl: BASE_URL,
// 新增以下数据
formData: {
submitDate: gemhoUtil.getTargetDateYMD(),
createDate: gemhoUtil.getTargetDateYMD(),
date: gemhoUtil.getTargetDateYMD(),
phone: '',
area: '',
businessHours: '',
type: '', // 新增类型字段
photos: []
content: '',
contactName: '',
contactDetails: '',
photos: [],
},
merId: '',
merInformation: { // 新增商户信息对象
......@@ -174,6 +171,29 @@ window.addEventListener("load", function () {
})
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({
message: '正在处理...',
forbidClick: true,
......@@ -187,23 +207,27 @@ window.addEventListener("load", function () {
http3.post('/gq/consumer', reqParam).then((res) => {
console.log('添加结果', res)
vant.Toast({
message: '操作成功',
})
// this.formData = {
// submitDate: gemhoUtil.getTargetDateYMD(),
// createDate: gemhoUtil.getTargetDateYMD(),
// phone: '',
// area: '',
// businessHours: '',
// type: '', // 新增类型字段
// content: '',
// photos: [],
// contactName: '',
// contactDetails: '',
// },
location.reload()
// gemhoUtil.navigatePage(`${this.pageName}.html${window.location.search}`, '操作完成,跳转中...')
if(res.code === 200){
vant.Toast({
message: '提交成功,感谢您的参与!',
})
this.formData.content = ''
this.formData.photos = []
this.formData.contactName = ''
this.formData.contactDetails = ''
// history.back()
// setTimeout(() => {
// location.reload()
// }, 300);
}else{
vant.Toast({
message: '提交失败',
})
}
})
},
//获取商户信息
......
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