对接切换小区接口

This commit is contained in:
zhouyanli
2026-04-22 18:00:48 +08:00
parent c71102f256
commit 057758772e
9 changed files with 493 additions and 404 deletions

View File

@@ -24,21 +24,21 @@
<uni-easyinput class="input-content" type="password" v-model="password"
placeholder="请输入密码" :inputBorder="false" :placeholderStyle="placeholderStyle">
</uni-easyinput>
</view>
<!-- 协议勾选 + 忘记密码 -->
<view class="agreement-wrap">
<view class="agreement-item" @click="toggleAgreement">
<uni-icons
type="checkbox-filled"
size="24"
<uni-icons
type="checkbox-filled"
size="24"
color="#007aff"
v-if="agreeAgreement"
></uni-icons>
<uni-icons
type="checkbox"
size="24"
<uni-icons
type="checkbox"
size="24"
color="#999"
v-else
></uni-icons>
@@ -48,9 +48,9 @@
</view>
<!-- 登录按钮 -->
<button
<button
class="login-btn"
:disabled="!canLogin"
@click="handleLogin"
>
登录
@@ -100,6 +100,7 @@ const handleLogin = () => {
// uni.showToast({ title: '请输入账号和密码', icon: 'none' });
// return
// }
if (!phoneNumber.value) {
uni.showToast({ title: '请输入账号', icon: 'none' });
return;
@@ -112,42 +113,49 @@ const handleLogin = () => {
uni.showToast({ title: '请勾选协议', icon: 'none' });
return;
}
// uni.showLoading({ title: '登录中...', mask: true });
// let params = {
// username:phoneNumber.value,
// password:password.value
// }
// getLoginPassword(params).then(res =>{
// // console.log('33333',res)
// if(res.code === 200){
// uni.setStorageSync('token', res.token);
// uni.hideLoading();
// uni.showToast({ title: '登录成功', icon: 'success' });
// setTimeout(() => {
// uni.switchTab({ url: '/pages/index/index' });
// }, 1500);
// }else{
// uni.showToast({ title: `${res.msg},请先注册账号`, icon: 'error' });
// }
// }).catch(err => {
// // console.error('登录接口异常:', err);
// uni.showToast({
// title: '网络异常',
// icon: 'error'
// });
// })
uni.showLoading({ title: '登录中...', mask: true });
let params = {
username:phoneNumber.value,
password:password.value
}
getLoginPassword(params).then(res =>{
console.log('33333',res)
if(res.code === 200){
uni.setStorageSync('token', res.data.token);
// 存用户ID
if(res.data) {
// 存当前绑定的小区ID0 表示未绑定
const currentVillageId = res.data.currentVillageId || 0;
uni.setStorageSync('currentVillageId', currentVillageId);
}
uni.hideLoading();
uni.showToast({ title: '登录成功', icon: 'success' });
setTimeout(() =>{
uni.switchTab({
url: '/pages/index/index'
},1000);
})
}else{
uni.showToast({ title: res.msg, icon: 'error' });
}
}).catch(err => {
uni.showToast({
title: '网络异常',
icon: 'error'
});
})
// 测试
uni.showLoading({
title: '登录中...',
mask:true
});
setTimeout(() => {
uni.switchTab({ url: '/pages/index/index' });
}, 1500);
uni.hideLoading()
// uni.showLoading({
// title: '登录中...',
// mask:true
// });
// setTimeout(() => {
// uni.switchTab({ url: '/pages/index/index' });
// }, 1500);
// uni.hideLoading()
};
</script>
@@ -234,7 +242,7 @@ const handleLogin = () => {
background-color: #99c8ff;
color: #fff;
border-radius: 50px;
}
.bottom-link {