修改bug
This commit is contained in:
@@ -130,9 +130,12 @@
|
||||
<text class="label">手机号码</text>
|
||||
<input class="input" v-model="form.phone" placeholder="请输入手机号" placeholder-class="ph"
|
||||
type="tel" />
|
||||
<button class="code-btn" :disabled="cd>0" @click="sendCode">
|
||||
<!-- <button class="code-btn" :disabled="cd>0" @click="sendCode">
|
||||
{{ cd > 0 ? cd+'s' : '获取验证码' }}
|
||||
</button>
|
||||
</button> -->
|
||||
<button class="get-verify-btn" :disabled=" countDown > 0 || !canGetVerify" @click="getVerifyCode">
|
||||
{{ countDown > 0 ? `${countDown}s后重新获取` : '获取验证码' }}
|
||||
</button>
|
||||
</view>
|
||||
|
||||
<view class="form-item">
|
||||
@@ -237,7 +240,9 @@
|
||||
import {
|
||||
ref,
|
||||
onMounted,
|
||||
reactive
|
||||
reactive,
|
||||
onUnmounted,
|
||||
computed
|
||||
} from 'vue'
|
||||
import {
|
||||
onReachBottom,
|
||||
@@ -350,8 +355,8 @@
|
||||
const type = ref('')
|
||||
const currentStep = ref(0)
|
||||
const showPopup = ref(false)
|
||||
const cd = ref(0)
|
||||
const timer = ref(null)
|
||||
const countDown = ref(0)
|
||||
let timer = null
|
||||
const showCardType = ref(false)
|
||||
const showRelation = ref(false)
|
||||
|
||||
@@ -363,6 +368,54 @@
|
||||
const idCardBackUpload = useImageUpload({
|
||||
uploadUrl: '/api/resident/file/uploadImage'
|
||||
})
|
||||
|
||||
// ========== 计算属性 ==========
|
||||
// 是否可以获取验证码(手机号格式正确)
|
||||
const canGetVerify = computed(() => {
|
||||
// 手机号正则:11位数字,以1开头
|
||||
const phoneReg = /^1[3-9]\d{9}$/;
|
||||
return phoneReg.test(form.phone);
|
||||
});
|
||||
// 获取验证码
|
||||
const getVerifyCode = () => {
|
||||
if (!canGetVerify.value) return;
|
||||
let params = {
|
||||
phone:form.phone,
|
||||
scene:'house_bind'
|
||||
}
|
||||
uni.showLoading({ title: '发送中...', mask: true });
|
||||
getHouseAuthSendSmsCode(params).then(res =>{
|
||||
if(res.code === 200){
|
||||
uni.hideLoading();
|
||||
uni.showToast({
|
||||
title: '验证码已发送',
|
||||
icon: 'success'
|
||||
});
|
||||
// 开始60秒倒计时
|
||||
if (timer) clearInterval(timer);
|
||||
countDown.value = 60;
|
||||
timer = setInterval(() => {
|
||||
countDown.value--;
|
||||
if (countDown.value <= 0) {
|
||||
clearInterval(timer);
|
||||
timer = null;
|
||||
}
|
||||
}, 1000);
|
||||
}else{
|
||||
uni.showToast({
|
||||
title: '验证码发送失败',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
}).catch(err => {
|
||||
uni.hideLoading();
|
||||
uni.showToast({
|
||||
title: err.msg||'网络异常',
|
||||
icon: 'none'
|
||||
});
|
||||
})
|
||||
|
||||
};
|
||||
// ==================== 获取列表数据 ====================
|
||||
const getDetail = async () => {
|
||||
|
||||
@@ -372,7 +425,7 @@
|
||||
})
|
||||
|
||||
const data = res
|
||||
console.log(data);
|
||||
// console.log('列表返回数据',data);
|
||||
if (data.code === 200) {
|
||||
uni.setStorageSync('communityName', data.data.villageName)
|
||||
uni.setStorageSync('buildingName', data.data.buildingName)
|
||||
@@ -381,7 +434,7 @@
|
||||
uni.setStorageSync('houseNumberName', data.data.houseNo)
|
||||
uni.setStorageSync('communityId', data.data.villageId)
|
||||
uni.setStorageSync('buildingId', data.data.buildingId)
|
||||
uni.setStorageSync('unitId', data.data.unitNo)
|
||||
uni.setStorageSync('unitId', data.data.unitNoId)
|
||||
uni.setStorageSync('floorId', data.data.floorNo)
|
||||
uni.setStorageSync('houseNumberId', data.data.houseId)
|
||||
uni.setStorageSync('houseStatus', data.data.houseStatus)
|
||||
@@ -491,12 +544,6 @@
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const openCardType = () => {
|
||||
showCardType.value = true
|
||||
}
|
||||
@@ -519,42 +566,6 @@
|
||||
showPopup.value = false;
|
||||
upDataListNum.value++
|
||||
}
|
||||
const sendCode = () => {
|
||||
if (!/^1[3-9]\d{9}$/.test(form.phone)) {
|
||||
return uni.showToast({
|
||||
title: '手机号格式错误',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
cd.value = 60
|
||||
timer.value = setInterval(() => {
|
||||
cd.value--
|
||||
if (cd.value <= 0) clearInterval(timer)
|
||||
}, 1000)
|
||||
|
||||
let params = {
|
||||
phone: form.phone,
|
||||
scene: "house_bind"
|
||||
}
|
||||
getHouseAuthSendSmsCode(params).then(res => {
|
||||
if (res.code === 200) {
|
||||
uni.showToast({
|
||||
title: '发送成功',
|
||||
icon: 'success'
|
||||
});
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'error'
|
||||
});
|
||||
}
|
||||
}).catch(err => {
|
||||
uni.showToast({
|
||||
title: err.msg || '发送失败',
|
||||
icon: 'none'
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
// 下一步
|
||||
const goNext = () => {
|
||||
@@ -745,7 +756,7 @@
|
||||
|
||||
const updateMethod = async (params) => {
|
||||
await upDateMyHouse(params).then(res => {
|
||||
console.log('33333', res)
|
||||
// console.log('33333', res)
|
||||
if (res.code === 200) {
|
||||
uni.hideLoading();
|
||||
uni.showToast({
|
||||
@@ -771,9 +782,6 @@
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// 选择项点击事件(可替换为picker/弹窗选择)
|
||||
const selectItem = (type) => {
|
||||
console.log(type);
|
||||
@@ -859,6 +867,13 @@
|
||||
formData.isDefault = e.detail.value
|
||||
uni.setStorageSync('houseIsDefault', e.detail.value)
|
||||
}
|
||||
// ========== 生命周期 ==========
|
||||
// 页面卸载时清除定时器
|
||||
onUnmounted(() => {
|
||||
if (timer) {
|
||||
clearInterval(timer);
|
||||
}
|
||||
});
|
||||
|
||||
const goBack = () => {
|
||||
uni.removeStorageSync('communityId');
|
||||
@@ -1018,6 +1033,32 @@
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
}
|
||||
/* 获取验证码按钮 */
|
||||
.get-verify-btn {
|
||||
position: absolute;
|
||||
right: 10rpx;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
width: 200rpx;
|
||||
height: 70rpx;
|
||||
line-height: 70rpx;
|
||||
background-color: #007aff;
|
||||
color: #fff;
|
||||
border-radius: 35rpx;
|
||||
font-size: 28rpx;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/* 获取验证码按钮禁用状态 */
|
||||
.get-verify-btn:disabled {
|
||||
background-color: #ccc;
|
||||
color: #fff;
|
||||
border-radius: 50px;
|
||||
}
|
||||
.get-verify-btn::after{
|
||||
border-radius: 50px;
|
||||
}
|
||||
|
||||
/* .item-arrow {
|
||||
font-size: 40rpx;
|
||||
|
||||
@@ -148,13 +148,13 @@
|
||||
uni.setStorageSync('houseIsDefault', e.detail.value)
|
||||
uni.showToast({
|
||||
title: '设置默认房屋成功',
|
||||
icon: 'success'
|
||||
icon: 'none'
|
||||
});
|
||||
} else {
|
||||
// uni.hideLoading();
|
||||
uni.showToast({
|
||||
title: `${res.msg}`,
|
||||
icon: 'error'
|
||||
title: res.msg,
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user