优化登录,修改bug

This commit is contained in:
zhouyanli
2026-07-29 17:47:10 +08:00
parent 9be76c6386
commit a6243cf466
24 changed files with 533 additions and 1012 deletions

View File

@@ -27,7 +27,11 @@
"Bash(sed -i '232s/^\t\t /\\\\t\\\\t/' pages/index/index.vue)",
"Bash(sed -i '233s/^\t\t /\\\\t\\\\t\\\\t/' pages/index/index.vue)",
"Bash(awk 'NR==235 { print substr\\($0, 2\\); next } 1' \"D:/wuye-jumin-front/property-uniapp-project/pages.json\")",
"Bash(mv /tmp/pages_temp.json \"D:/wuye-jumin-front/property-uniapp-project/pages.json\")"
"Bash(mv /tmp/pages_temp.json \"D:/wuye-jumin-front/property-uniapp-project/pages.json\")",
"Bash(sed -i '32,36s/.*//' App.vue)",
"Bash(sed -i '32d;33d;34d;35d;36d' App.vue)",
"Bash(perl -i -pe 's/\\\\\\\\t\\\\t\\\\t\\\\t\\\\t\"disableScroll\": true/\\\\t\\\\t\\\\t\\\\t\\\\t\\\\t\"disableScroll\": true/' pages.json)",
"Bash(perl -i -pe 's/^t\\\\t\\\\t\\\\t\\\\t\"disableScroll\"/\\\\t\\\\t\\\\t\\\\t\\\\t\\\\t\"disableScroll\"/' pages.json)"
]
}
}

View File

@@ -17,20 +17,18 @@
getPushCID()
// #endif
// 首页已是入口页:已登录用户不做跳转,直接留首页
// 仅对未登录用户按需跳转到引导页或登录页
const token = uni.getStorageSync('token')
// 路由分发(同步):所有人先进首页,点击功能再提示登录
const token = uni.getStorageSync('token') || ''
const hasShowGuide = uni.getStorageSync('hasShowGuide')
// 首次使用:标记引导已看过(不再强制引导页),直接进首页
if (!token && !hasShowGuide) {
// 首次使用:跳转引导页
console.log('首次启动,跳转引导页')
uni.reLaunch({ url: '/pages/navigation/navigation' })
} else if (!token && hasShowGuide) {
// 已看过引导但未登录:跳转登录页
console.log('已看过引导页,跳转登录页')
uni.reLaunch({ url: '/pageSubPack/loginSub/pwd-login' })
console.log('首次启动,标记引导已看过,进入首页')
uni.setStorageSync('hasShowGuide', true)
}
// 有 token已在首页不做跳转
// 所有人统一进首页
console.log('进入首页hasToken=' + !!token + '')
})
onShow((options) => {
console.log('App Show', options)

View File

@@ -57,6 +57,12 @@ export const deleteMyHouse = (data) => {
export const setMyHouseDefault = (data) => {
return post(`/api/resident/my/house/default`, data)
}
// 添加房屋与业主关系-下拉数据
export const getHouseDataList = (data) => {
return get(`/api/resident/my/house/dataList`, data)
}
// 获取当前用户登录信息
export const getUserProfile = (data) => {
return get(`/api/resident/user/profile`, data)

View File

@@ -13,15 +13,20 @@ export default function request(url, data = {}, method = "GET") {
// mask: true
// });
const token = uni.getStorageSync("token") || "";
const header = {
"clientid": "resident",
'content-type': 'application/json'
};
if (token) {
header["Authorization"] = "Bearer " + token;
}
uni.request({
url: baseUrl + url,
data: data,
method: method,
header: {
"Authorization": "Bearer " + (uni.getStorageSync("token") || ''),
"clientid": "resident",
'content-type': 'application/json'
},
header,
success: (res) => {
// uni.hideLoading();
@@ -33,13 +38,12 @@ export default function request(url, data = {}, method = "GET") {
const resData = res.data || {};
// token 过期
// token 过期:仅在有 token 且过期时跳转登录页(无 token 用户正常浏览首页,由点击拦截处理)
if (resData.code === 401) {
uni.showToast({ title: '登录过期,请重新登录', icon: 'none' });
if (token) {
uni.clearStorageSync('token');
setTimeout(() => {
uni.reLaunch({ url: '/pageSubPack/loginSub/pwd-login' });
}, 1500);
uni.reLaunch({ url: '/pageSubPack/loginSub/login?mode=pwd' });
}
reject({ msg: '登录过期', code: 401 });
return;
}
@@ -69,14 +73,19 @@ export const putMethod = (url, data) => request(url, data, 'PUT');
// 上传
export const upload = (filePath, url) => {
return new Promise((resolve, reject) => {
const t = uni.getStorageSync("token") || "";
const uploadHeader = {
"clientid": "resident"
};
if (t) {
uploadHeader["Authorization"] = "Bearer " + t;
}
uni.uploadFile({
url: baseUrl + url,
filePath: filePath,
name: 'file',
header: {
"Authorization": "Bearer " + (uni.getStorageSync("token") || ''),
"clientid": "resident"
},
header: uploadHeader,
success: (res) => {
try {
const data = JSON.parse(res.data);

View File

@@ -1,5 +1,6 @@
// 服务器地址(与 request.js 保持一致)
const baseUrl = 'https://wuyeapi.ckdzkj.com';
// const baseUrl = 'https://wuyeapi.ckdzkj.com';
const baseUrl = "http://192.168.1.222:8080"
/**
* 图片上传 Hook

View File

@@ -2,10 +2,10 @@
<view class="reset-pwd-page">
<view class="status_bar"></view>
<!-- 顶部导航栏 -->
<view class="nav-bar">
<!-- <view class="nav-bar">
<uni-icons type="left" size="28" color="#333" @click="goBack"></uni-icons>
<view class="nav-title">修改密码</view>
</view>
</view> -->
<!-- 密码提示 -->
<view class="pwd-tips">密码为 6-16 需同时包含字母和数字</view>
@@ -13,14 +13,14 @@
<!-- 新密码输入框 -->
<view class="input-item">
<uni-easyinput class="input-content" type="password" v-model="newPassword"
placeholder="请输入密码" :inputBorder="false" :placeholderStyle="placeholderStyle">
placeholder="请输入密码" :inputBorder="false" maxlength="16" :placeholderStyle="placeholderStyle">
</uni-easyinput>
</view>
<!-- 确认密码输入框 -->
<view class="input-item">
<uni-easyinput class="input-content" type="password" v-model="confirmPassword"
placeholder="请再次输入密码" :inputBorder="false" :placeholderStyle="placeholderStyle">
placeholder="请再次输入密码" :inputBorder="false" maxlength="16" :placeholderStyle="placeholderStyle">
</uni-easyinput>
</view>
@@ -95,7 +95,7 @@ const handleConfirm = () => {
//uni.setStorageSync('token', res.token); // 假设后端返回token字段
uni.showToast({ title: '修改成功', icon: 'success' });
setTimeout(() =>{
uni.navigateTo({ url: '/pageSubPack/loginSub/pwd-login' });
uni.navigateTo({ url: '/pageSubPack/loginSub/login?mode=pwd' });
},1500)
}else{
@@ -116,7 +116,9 @@ const handleConfirm = () => {
/* 页面容器 */
.reset-pwd-page {
padding: 20rpx 40rpx 40rpx;
min-height: 100vh;
height: 100vh;
overflow: hidden;
box-sizing: border-box;
background: repeating-linear-gradient(180deg, #E2F0FF, #F6FAFF );
}
.status_bar{

View File

@@ -1,16 +1,16 @@
<template>
<view class="forget-page">
<view class="status_bar"></view>
<view class="nav-bar">
<!-- <view class="nav-bar">
<uni-icons type="left" size="28" color="#333" @click="goBack"></uni-icons>
<view class="nav-title">忘记密码</view>
</view>
</view> -->
<!-- 手机号输入框 -->
<view class="input-item">
<view class="input-icon">
<image src="http://47.104.199.163:9090/images/login/phone.png" mode="" style="height: 100%;width: 100%;"></image>
</view>
<uni-easyinput class="input-content" type="number" v-model="phoneNumber" trim="all"
<uni-easyinput class="input-content" type="number" v-model="phoneNumber" @input="phoneNumber = phoneNumber.replace(/\D/g, '')" trim="all"
placeholder="请输入手机号" :inputBorder="false" maxlength="11" :placeholderStyle="placeholderStyle">
</uni-easyinput>
</view>
@@ -20,7 +20,7 @@
<image src="http://47.104.199.163:9090/images/login/code.png" mode="" style="height: 100%;width: 100%;"></image>
<!-- <uni-icons type="locked" size="24" color="#999"></uni-icons> -->
</view>
<uni-easyinput class="input-content verify-input" type="number" v-model="verifyCode" trim="all"
<uni-easyinput class="input-content verify-input" type="number" v-model="verifyCode" @input="verifyCode = verifyCode.replace(/\D/g, '')" trim="all"
placeholder="请输入验证码" :inputBorder="false" maxlength="6" :placeholderStyle="placeholderStyle">
</uni-easyinput>
<button
@@ -131,7 +131,9 @@ const goBack = () => {
<style scoped>
.forget-page{
padding: 20rpx 40rpx 40rpx;
min-height: 100vh;
height: 100vh;
overflow: hidden;
box-sizing: border-box;
background: repeating-linear-gradient(180deg, #E2F0FF, #F6FAFF );
}
.status_bar{

View File

@@ -1,19 +1,21 @@
<template>
<view class="login-page">
<view class="status_bar"></view>
<!-- 登录标题 -->
<view class="login-title">手机验证码登录</view>
<!-- 登录标题 -->
<view class="login-title">{{ loginMode === 'sms' ? '手机验证码登录' : '账号密码登录' }}</view>
<!-- ====== 验证码登录模式 ====== -->
<template v-if="loginMode === 'sms'">
<!-- 手机号输入框 -->
<view class="input-item">
<view class="input-icon">
<!-- <uni-icons type="phone" size="24" color="#999"></uni-icons> -->
<image src="https://wuyeadmin.bugtc.com/images/login/phone.png" mode="" style="height: 100%;width: 100%;"></image>
</view>
<uni-easyinput class="input-content" type="number" v-model="phoneNumber"
@input="phoneNumber = phoneNumber.replace(/\D/g, '')"
placeholder="请输入手机号" :inputBorder="false" maxlength="11" :placeholderStyle="placeholderStyle">
</uni-easyinput>
</view>
<!-- 验证码输入框 + 获取验证码按钮 -->
@@ -22,51 +24,59 @@
<image src="https://wuyeadmin.bugtc.com/images/login/code.png" mode="" style="height: 100%;width: 100%;"></image>
</view>
<uni-easyinput class="input-content verify-input" type="number" v-model="verifyCode"
@input="verifyCode = verifyCode.replace(/\D/g, '')"
placeholder="请输入验证码" :inputBorder="false" maxlength="6" :placeholderStyle="placeholderStyle">
</uni-easyinput>
<button
class="get-verify-btn"
:disabled="!canGetVerify || countDown > 0"
@click="getVerifyCode"
>
<button class="get-verify-btn" :disabled="!canGetVerify || countDown > 0" @click="getVerifyCode">
{{ countDown > 0 ? `${countDown}s后重新获取` : '获取验证码' }}
</button>
</view>
</template>
<!-- 协议勾选 -->
<!-- ====== 账号密码登录模式 ====== -->
<template v-if="loginMode === 'pwd'">
<!-- 账号输入框 -->
<view class="input-item">
<view class="input-icon">
<image src="https://wuyeadmin.bugtc.com/images/login/phone.png" mode="" style="height: 100%;width: 100%;"></image>
</view>
<uni-easyinput class="input-content" type="text" v-model="account"
placeholder="请输入帐号" :inputBorder="false" maxlength="16" :placeholderStyle="placeholderStyle">
</uni-easyinput>
</view>
<!-- 密码输入框 -->
<view class="input-item">
<view class="input-icon">
<image src="https://wuyeadmin.bugtc.com/images/login/password.png" mode="" style="height: 100%;width: 100%;"></image>
</view>
<uni-easyinput class="input-content" type="password" v-model="password"
placeholder="请输入密码" :inputBorder="false" maxlength="16" :placeholderStyle="placeholderStyle">
</uni-easyinput>
</view>
</template>
<!-- 协议勾选 + 忘记密码 -->
<view class="agreement-wrap">
<view class="agreement-item">
<view @click="toggleAgreement">
<uni-icons
type="checkbox-filled"
size="24"
color="#007aff"
v-if="agreeAgreement"
></uni-icons>
<uni-icons
type="checkbox"
size="24"
color="#999"
v-else
></uni-icons>
<view @click="toggleAgreement" class="checkbox-icon">
<uni-icons type="checkbox-filled" size="24" color="#007aff" v-if="agreeAgreement"></uni-icons>
<uni-icons type="checkbox" size="24" color="#999" v-else></uni-icons>
</view>
<text class="agreement-text">我已阅读并同意
<text class="agreePrivacy" @click.stop="goToUserAgreement">用户协议</text>
<text class="agreePrivacy" @click.stop="goToPrivacy">隐私政策</text>
</text>
</view>
<text class="forget-pwd" v-if="loginMode === 'pwd'" @click="goForgetPwd">忘记密码</text>
</view>
<!-- 登录按钮 -->
<button
class="login-btn"
@click="handleLogin"
>
登录
</button>
<button class="login-btn" @click="handleLogin">登录</button>
<!-- 底部链接 -->
<view class="bottom-link">
<navigator class="link-item" url="/pageSubPack/loginSub/pwd-login">账号密码登录</navigator>
<text class="link-item" @click="switchMode">{{ loginMode === 'sms' ? '账号密码登录' : '验证码登录' }}</text>
<navigator class="link-item" url="/pageSubPack/loginSub/register-new-user">注册新用户</navigator>
</view>
@@ -77,51 +87,50 @@
<script setup>
import { ref, computed, onUnmounted } from 'vue';
import {getLoginBySms,getSendCode} from '../api/api.js'
import { onLoad } from '@dcloudio/uni-app'
import { getLoginBySms, getLoginPassword, getSendCode } from '../api/api.js'
import PrivacyPopup from '@/components/privacy-popup/privacy-popup.vue'
// ========== 模式切换 ==========
// 'sms' = 手机验证码登录, 'pwd' = 账号密码登录
const loginMode = ref('pwd')
// ========== 响应式数据 ==========
// 手机号
const phoneNumber = ref('');
// 验证码
const verifyCode = ref('');
const phoneNumber = ref('') // 短信登录:手机号
const verifyCode = ref('') // 短信登录:验证码
const account = ref('') // 密码登录:账号
const password = ref('') // 密码登录:密码
const agreeAgreement = ref(false)
const placeholderStyle = ref('font-size:24rpx')
// 是否同意协议
const agreeAgreement = ref(false); // 默认不勾选
// 倒计时(秒)
const countDown = ref(0);
// 定时器
let timer = null;
// 验证码倒计时
const countDown = ref(0)
let timer = null
// 隐私弹窗
const showPrivacyPopup = ref(false)
const pendingAction = ref('')
// ========== onLoad: 读取 mode 参数 ==========
onLoad((options) => {
if (options && options.mode === 'sms') {
loginMode.value = 'sms'
} else if (options && options.mode === 'pwd') {
loginMode.value = 'pwd'
}
})
// ========== 计算属性 ==========
// 是否可获取验证码(手机号格式正确)
// 短信模式:是否可获取验证码
const canGetVerify = computed(() => {
// 手机号正则11位数字以1开头
const phoneReg = /^1[3-9]\d{9}$/;
return phoneReg.test(phoneNumber.value);
});
if (loginMode.value !== 'sms') return false
const phoneReg = /^1[3-9]\d{9}$/
return phoneReg.test(phoneNumber.value)
})
// 是否可以登录(手机号+验证码+协议都满足)
const canLogin = computed(() => {
const phoneReg = /^1[3-9]\d{9}$/;
const verifyReg = /^\d{6}$/;
return phoneReg.test(phoneNumber.value) && verifyReg.test(verifyCode.value) && agreeAgreement.value;
});
// ========== 共享方法 ==========
const toggleAgreement = () => { agreeAgreement.value = !agreeAgreement.value }
// ========== 方法 ==========
// 检查表单状态
const checkForm = () => {
// 无需额外逻辑,计算属性已实时监听
};
// 切换协议勾选状态
const toggleAgreement = () => {
agreeAgreement.value = !agreeAgreement.value;
};
// 打开用户协议
const goToUserAgreement = () => {
// #ifdef APP-PLUS
plus.runtime.openURL('https://wuye.ckdzkj.com/parivw/ownler_xieyi.html')
@@ -131,7 +140,6 @@ const goToUserAgreement = () => {
// #endif
}
// 打开隐私政策
const goToPrivacy = () => {
// #ifdef APP-PLUS
plus.runtime.openURL('https://wuye.ckdzkj.com/parivw/owner.html')
@@ -140,13 +148,12 @@ const goToPrivacy = () => {
window.open('https://wuye.ckdzkj.com/parivw/owner.html')
// #endif
}
// 打开隐私弹窗
const openPrivacyPopup = (action) => {
pendingAction.value = action || ''
showPrivacyPopup.value = true
}
// 同意隐私协议
const agreePrivacy = () => {
showPrivacyPopup.value = false
agreeAgreement.value = true
@@ -156,151 +163,136 @@ const agreePrivacy = () => {
pendingAction.value = ''
}
// 不同意隐私协议
const disagreePrivacy = () => {
showPrivacyPopup.value = false
pendingAction.value = ''
}
// 获取验证码
// 切换登录模式
const switchMode = () => {
if (loginMode.value === 'sms') {
loginMode.value = 'pwd'
} else {
loginMode.value = 'sms'
}
// 重置相关字段
agreeAgreement.value = false
if (timer) { clearInterval(timer); timer = null }
countDown.value = 0
}
// 忘记密码跳转
const goForgetPwd = () => {
uni.navigateTo({ url: '/pageSubPack/loginSub/forget-pwd' })
}
// ========== 验证码登录:获取验证码 ==========
const getVerifyCode = () => {
if (!canGetVerify.value) return;
let params = {
phone:phoneNumber.value,
scene:'login'
}
uni.showLoading({ title: '发送中...', mask: true });
getSendCode(params).then(res =>{
if(res.code === 200){
uni.hideLoading();
uni.showToast({
title: '验证码已发送',
icon: 'success'
});
// 开始60秒倒计时
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 handleLogin = () => {
if (!phoneNumber.value) {
uni.showToast({ title: '请输入手机号', icon: 'none' });
return;
}
if (!/^1[3-9]\d{9}$/.test(phoneNumber.value)) {
uni.showToast({ title: '请输入正确的手机号', icon: 'none' });
return;
}
if (!verifyCode.value) {
uni.showToast({ title: '请输入验证码', icon: 'none' });
return;
}
if (!/^\d{6}$/.test(verifyCode.value)) {
uni.showToast({ title: '验证码为 6 位数字', icon: 'none' });
return;
}
if (!agreeAgreement.value) {
openPrivacyPopup('login')
return;
}
doLogin()
};
const doLogin = () => {
uni.showLoading({ title: '登录中...', mask: true });
const push_cid = uni.getStorageSync('push_cid')
let params = {
phone:phoneNumber.value,
smsCode:verifyCode.value,
scene:'login',
cid:push_cid
}
getLoginBySms(params).then(res =>{
if(res.code === 200){
uni.hideLoading();
if(res.data){
uni.setStorageSync('token', res.data.token);
// 存用户ID
if(res.data.userId) {
uni.setStorageSync('userId', res.data.userId);
}
// 存当前绑定的小区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' });
},1500)
}else{
uni.showToast({ title: '登录失败', icon: 'none' });
}
}else{
uni.showToast({ title:'登录失败', icon: 'none' });
}
}).catch(err => {
uni.hideLoading();
uni.showToast({
title: err.msg || '网络异常,请重试',
icon: 'none'
});
})
// 登录成功后上报推送 CID
// #ifdef APP-PLUS
const cid = uni.getStorageSync('push_cid')
if (cid) {
reportPushCID(cid)
}
// #endif
// setTimeout(() =>{
// uni.switchTab({ url: '/pages/index/index' });
// },1500)
if (!canGetVerify.value) return
uni.showLoading({ title: '发送中...', mask: true })
getSendCode({ phone: phoneNumber.value, scene: 'login' }).then(res => {
uni.hideLoading()
};
if (res.code === 200) {
uni.showToast({ title: '验证码已发送', icon: 'success' })
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 handleLogin = () => {
if (loginMode.value === 'sms') {
handleSmsLogin()
} else {
handlePwdLogin()
}
}
// ========== 验证码登录 ==========
const handleSmsLogin = () => {
if (!phoneNumber.value) { uni.showToast({ title: '请输入手机号', icon: 'none' }); return }
if (!/^1[3-9]\d{9}$/.test(phoneNumber.value)) { uni.showToast({ title: '请输入正确的手机号', icon: 'none' }); return }
if (!verifyCode.value) { uni.showToast({ title: '请输入验证码', icon: 'none' }); return }
if (!/^\d{6}$/.test(verifyCode.value)) { uni.showToast({ title: '验证码为 6 位数字', icon: 'none' }); return }
if (!agreeAgreement.value) { openPrivacyPopup('login'); return }
doLogin()
}
// ========== 密码登录 ==========
const handlePwdLogin = () => {
if (!account.value) { uni.showToast({ title: '请输入账号', icon: 'none' }); return }
if (account.value.length < 4 || account.value.length > 20) { uni.showToast({ title: '账号长度需为 4-20 位', icon: 'none' }); return }
if (!password.value) { uni.showToast({ title: '请输入密码', icon: 'none' }); return }
if (password.value.length < 6) { uni.showToast({ title: '密码至少输入 6 位', icon: 'none' }); return }
if (password.value.length > 16) { uni.showToast({ title: '密码不能超过 16 位', icon: 'none' }); return }
if (!agreeAgreement.value) { openPrivacyPopup('login'); return }
doLogin()
}
// ========== 执行登录 ==========
const doLogin = () => {
uni.showLoading({ title: '登录中...', mask: true })
const push_cid = uni.getStorageSync('push_cid')
if (loginMode.value === 'sms') {
// 验证码登录
getLoginBySms({ phone: phoneNumber.value, smsCode: verifyCode.value, scene: 'login', cid: push_cid })
.then(onLoginSuccess).catch(onLoginError)
} else {
// 密码登录
getLoginPassword({ username: account.value, password: password.value, cid: push_cid })
.then(onLoginSuccess).catch(onLoginError)
}
}
const onLoginSuccess = (res) => {
if (res.code === 200 && res.data) {
uni.setStorageSync('token', res.data.token)
if (res.data.userId) { uni.setStorageSync('userId', res.data.userId) }
const currentVillageId = res.data.currentVillageId || 0
uni.setStorageSync('currentVillageId', currentVillageId)
uni.hideLoading()
uni.showToast({ title: '登录成功', icon: 'success' })
setTimeout(() => { uni.switchTab({ url: '/pages/index/index' }) }, 1500)
} else {
uni.hideLoading()
uni.showToast({ title: res.msg || '登录失败', icon: 'none' })
}
}
const onLoginError = (err) => {
uni.hideLoading()
uni.showToast({ title: err.msg || '网络异常,请重试', icon: 'none' })
}
// ========== 生命周期 ==========
// 页面卸载时清除定时器
onUnmounted(() => {
if (timer) {
clearInterval(timer);
}
});
if (timer) { clearInterval(timer) }
})
</script>
<style scoped>
/* 页面容器 */
.login-page {
padding: 80rpx 40rpx 40rpx;
/* background-color: #f8f9fa; */
min-height: 100vh;
height: 100vh;
overflow: hidden;
box-sizing: border-box;
background: repeating-linear-gradient(to bottom, #E2F0FF, #F6FAFF );
}
.status_bar {
height: 160px;
width: 100%;
@@ -338,7 +330,6 @@ onUnmounted(() => {
width: 50rpx;
height: 50rpx;
margin-right: 20rpx;
color: #999;
}
/* 输入框内容 */
@@ -349,7 +340,7 @@ onUnmounted(() => {
height: 100%;
}
/* 深度覆盖 uni-easyinput 内部默认样式,解决高度偏移 */
/* 深度覆盖 uni-easyinput 内部默认样式 */
.input-content :deep(.uni-easyinput__content) {
height: 100% !important;
min-height: unset !important;
@@ -386,36 +377,56 @@ onUnmounted(() => {
margin: 0;
}
/* 获取验证码按钮禁用状态 */
.get-verify-btn:disabled {
background-color: #ccc;
color: #fff;
border-radius: 50px;
}
.get-verify-btn::after {
border-radius: 50px;
}
/* 协议勾选项 */
.agreement-item {
/* 协议和忘记密码行 */
.agreement-wrap {
display: flex;
align-items: center;
align-items: flex-start;
justify-content: space-between;
margin: 70rpx 0 28rpx 0;
padding-left: 10rpx;
padding: 0 10rpx;
}
.agreement-item {
display: flex;
align-items: flex-start;
flex: 1;
min-width: 0;
}
.checkbox-icon {
flex-shrink: 0;
margin-top: 2rpx;
}
/* 协议文本 */
.agreement-text {
font-size: 24rpx;
color: #666;
margin-left: 10rpx;
line-height: 1.5;
}
.agreePrivacy {
color: #2F77FD;
}
/* .agreePrivacy.active{
color: #2F77FD;
} */
.forget-pwd {
font-size: 24rpx;
color: #666;
flex-shrink: 0;
margin-left: 16rpx;
line-height: 1.5;
}
/* 登录按钮 */
.login-btn {
width: 100%;
@@ -428,13 +439,11 @@ onUnmounted(() => {
margin-bottom: 60rpx;
}
/* 登录按钮禁用状态 */
.login-btn:disabled {
background-color: #99c8ff;
color: #fff;
/* border-radius: 50px; */
}
/* 禁用按钮边框 */
button:after {
border-radius: 8px;
}
@@ -446,7 +455,6 @@ button:after{
padding: 0 20rpx;
}
/* 链接项 */
.link-item {
font-size: 28rpx;
color: #007aff;

View File

@@ -1,356 +0,0 @@
<template>
<view class="login-page">
<view class="status_bar"></view>
<!-- 标题 -->
<view class="login-title">账号密码登录</view>
<!-- 手机号输入框 -->
<view class="input-item">
<view class="input-icon">
<!-- <uni-icons type="phone" size="24" color="#999"></uni-icons> -->
<image src="https://wuyeadmin.bugtc.com/images/login/phone.png" mode="" style="height: 100%;width: 100%;"></image>
</view>
<uni-easyinput class="input-content" type="text" v-model="phoneNumber"
placeholder="请输入帐号" :inputBorder="false" :placeholderStyle="placeholderStyle">
</uni-easyinput>
</view>
<!-- 密码输入框 -->
<view class="input-item">
<view class="input-icon">
<!-- <uni-icons type="locked" size="24" color="#999"></uni-icons> -->
<image src="https://wuyeadmin.bugtc.com/images/login/password.png" mode="" style="height: 100%;width: 100%;"></image>
</view>
<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">
<view @click="toggleAgreement" class="checkbox-icon">
<uni-icons
type="checkbox-filled"
size="24"
color="#007aff"
v-if="agreeAgreement"
></uni-icons>
<uni-icons
type="checkbox"
size="24"
color="#999"
v-else
></uni-icons>
</view>
<text class="agreement-text" >我已阅读并同意
<text class="agreePrivacy" @click.stop="goToUserAgreement">用户协议</text>
<text class="agreePrivacy" @click.stop="goToPrivacy">隐私政策</text>
</text>
</view>
<navigator class="forget-pwd" url="/pageSubPack/loginSub/forget-pwd">忘记密码</navigator>
</view>
<!-- 登录按钮 -->
<button
class="login-btn"
@click="handleLogin"
>
登录
</button>
<!-- 底部链接 -->
<view class="bottom-link">
<navigator class="link-item" url="/pageSubPack/loginSub/login">验证码登录</navigator>
<navigator class="link-item" url="/pageSubPack/loginSub/register-new-user">注册新用户</navigator>
</view>
</view>
<!-- 隐私协议弹窗 -->
<privacy-popup v-model:show="showPrivacyPopup" @agree="agreePrivacy" @disagree="disagreePrivacy" @close="showPrivacyPopup = false" />
</template>
<script setup>
import { ref, computed } from 'vue';
import {onLoad} from "@dcloudio/uni-app"
import {getLoginPassword} from '../api/api.js'
import PrivacyPopup from '@/components/privacy-popup/privacy-popup.vue'
// 响应式数据
const phoneNumber = ref('');
const password = ref('');
const agreeAgreement = ref(false); // 默认勾选
const placeholderStyle = ref('font-size:24rpx')
// 计算属性:是否可登录(帐号+密码+协议都满足)
const canLogin = computed(() => {
const phoneReg = /^[a-zA-Z0-9_-]{4,16}$/; // 4-16位
const pwdReg = /^.{6,16}$/; // 密码6-16位
return phoneReg.test(phoneNumber.value) && pwdReg.test(password.value) && agreeAgreement.value;
});
// 切换协议勾选
const toggleAgreement = () => {
agreeAgreement.value = !agreeAgreement.value;
};
const showPrivacyPopup = ref(false)
const pendingAction = ref('') // 记录待执行操作,如 'smsLogin'
// 打开用户协议
const goToUserAgreement = () => {
// #ifdef APP-PLUS
plus.runtime.openURL('https://wuye.ckdzkj.com/parivw/ownler_xieyi.html')
// #endif
// #ifdef H5
window.open('https://wuye.ckdzkj.com/parivw/ownler_xieyi.html')
// #endif
}
// 打开隐私政策
const goToPrivacy = () => {
// #ifdef APP-PLUS
plus.runtime.openURL('https://wuye.ckdzkj.com/parivw/owner.html')
// #endif
// #ifdef H5
window.open('https://wuye.ckdzkj.com/parivw/owner.html')
// #endif
}
// 打开隐私弹窗(可传入待执行操作标识)
const openPrivacyPopup = (action) => {
pendingAction.value = action || ''
showPrivacyPopup.value = true
}
// 同意隐私协议
const agreePrivacy = () => {
showPrivacyPopup.value = false
agreeAgreement.value = true
// 执行之前拦截的操作
if (pendingAction.value === 'smsLogin') {
uni.navigateTo({ url: '/pageSubPack/loginSub/login' })
} else if (pendingAction.value === 'login') {
doLogin()
}
pendingAction.value = ''
}
// 不同意隐私协议
const disagreePrivacy = () => {
showPrivacyPopup.value = false
pendingAction.value = ''
}
// 检查表单
const checkForm = () => {};
onLoad(() =>{
});
// 登录逻辑
const handleLogin = () => {
if (!phoneNumber.value) {
uni.showToast({ title: '请输入账号', icon: 'none' });
return;
}
if (phoneNumber.value.length < 4 || phoneNumber.value.length > 16) {
uni.showToast({ title: '账号长度需为 4-16 位', icon: 'none' });
return;
}
if (!password.value) {
uni.showToast({ title: '请输入密码', icon: 'none' });
return;
}
if (password.value.length < 6) {
uni.showToast({ title: '密码至少输入 6 位', icon: 'none' });
return;
}
if (password.value.length > 16) {
uni.showToast({ title: '密码不能超过 16 位', icon: 'none' });
return;
}
if(!agreeAgreement.value){
openPrivacyPopup('login')
return;
}
doLogin()
};
const doLogin = () => {
uni.showLoading({ title: '登录中...', mask: true });
const push_cid = uni.getStorageSync('push_cid')
let params = {
username:phoneNumber.value,
password:password.value,
cid:push_cid
}
getLoginPassword(params).then(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.setStorageSync('userId',res.data.userId)
}
uni.hideLoading();
uni.showToast({ title: '登录成功', icon: 'success' });
setTimeout(() =>{
uni.switchTab({
url: '/pages/index/index'
},2000);
})
}else{
uni.showToast({ title: res.msg, icon: 'none' });
}
}).catch(err => {
// console.log('密码登录异常',err)
uni.hideLoading();
uni.showToast({
title: err.msg || '网络异常',
icon: 'none'
});
})
};
</script>
<style scoped>
.login-page {
padding: 80rpx 40rpx 40rpx;
/* background-color: #f8f9fa; */
min-height: 100vh;
background: repeating-linear-gradient(180deg, #E2F0FF, #F6FAFF );
}
.status_bar {
height: 160px;
width: 100%;
}
.login-title {
font-size: 52rpx;
font-weight: 600;
color: #333;
text-align: center;
margin-bottom: 142rpx;
}
.input-item {
display: flex;
align-items: center;
background-color: #fff;
border-radius: 40rpx;
padding: 0 30rpx;
height: 88rpx;
margin-bottom: 30rpx;
box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
}
.input-icon {
margin-right: 20rpx;
width: 50rpx;
height: 50rpx;
}
.input-content {
flex: 1;
font-size: 28rpx;
color: #333;
height: 100%;
}
/* 深度覆盖 uni-easyinput 内部默认样式,解决高度偏移 */
.input-content :deep(.uni-easyinput__content) {
height: 100% !important;
min-height: unset !important;
padding: 0 !important;
background-color: transparent !important;
}
.input-content :deep(.uni-easyinput__content-input) {
height: 100% !important;
min-height: unset !important;
padding: 0 !important;
line-height: 88rpx;
}
.agreement-wrap {
display: flex;
align-items: flex-start;
justify-content: space-between;
margin: 70rpx 0 28rpx 0;
padding: 0 10rpx;
}
.agreement-item {
display: flex;
align-items: flex-start;
flex: 1;
min-width: 0;
}
.checkbox-icon {
flex-shrink: 0;
margin-top: 2rpx;
}
.agreement-text {
font-size: 24rpx;
color: #666;
margin-left: 10rpx;
line-height: 1.5;
}
.agreePrivacy{
color: #2F77FD;
}
.forget-pwd {
font-size: 24rpx;
color: #666;
text-decoration: none;
flex-shrink: 0;
margin-left: 16rpx;
line-height: 1.5;
}
.login-btn {
width: 100%;
height: 88rpx;
line-height: 88rpx;
background-color: #007aff;
color: #fff;
border-radius: 8rpx;
font-size: 28rpx;
margin-bottom: 60rpx;
}
.login-btn:disabled {
background-color: #99c8ff;
color: #fff;
/* border-radius: 50px; */
}
/* 禁用按钮边框 */
button:after{
border-radius: 8px;
}
.bottom-link {
display: flex;
justify-content: space-between;
padding: 0 20rpx;
}
.link-item {
font-size: 28rpx;
color: #007aff;
text-decoration: none;
}
</style>

View File

@@ -2,10 +2,10 @@
<view class="register-page">
<view class="status_bar"></view>
<!-- 顶部导航 -->
<view class="nav-bar">
<!-- <view class="nav-bar">
<uni-icons type="left" size="28" color="#333" @click="goBack"></uni-icons>
<view class="nav-title">注册</view>
</view>
</view> -->
<!-- 注册标题 -->
<view class="register-title">注册用户</view>
@@ -16,9 +16,9 @@
<image src="https://wuyeadmin.bugtc.com/images/login/phone.png" mode=""
style="height: 100%;width: 100%;"></image>
</view>
<uni-easyinput class="input-content" type="number" v-model="phoneNumber" placeholder="请输入手机号"
:inputBorder="false" maxlength="11" :placeholderStyle="placeholderStyle">
</uni-easyinput>
<uni-easyinput class="input-content" type="number" v-model="phoneNumber" @input="phoneNumber = phoneNumber.replace(/\D/g, '')" placeholder="请输入手机号"
:inputBorder="false" maxlength="11" :placeholderStyle="placeholderStyle" />
</view>
<!-- 验证码输入 + 获取验证码按钮 -->
@@ -28,9 +28,9 @@
</image>
<!-- <uni-icons type="locked" size="24" color="#999"></uni-icons> -->
</view>
<uni-easyinput class="input-content verify-input" type="number" v-model="verifyCode" placeholder="请输入验证码"
:inputBorder="false" maxlength="6" :placeholderStyle="placeholderStyle">
</uni-easyinput>
<uni-easyinput class="input-content verify-input" type="number" v-model="verifyCode" @input="verifyCode = verifyCode.replace(/\D/g, '')" placeholder="请输入验证码"
:inputBorder="false" maxlength="6" :placeholderStyle="placeholderStyle" />
<button class="get-verify-btn" :disabled="!canGetVerify || countDown > 0" @click="getVerifyCode">
{{ countDown > 0 ? `${countDown}s后重新获取` : '获取验证码' }}
@@ -45,8 +45,8 @@
<!-- <uni-icons type="person" size="24" color="#999"></uni-icons> -->
</view>
<uni-easyinput class="input-content" type="text" v-model="account" placeholder="请输入账号4-20位" :inputBorder="false"
:placeholderStyle="placeholderStyle">
</uni-easyinput>
maxlength="20" :placeholderStyle="placeholderStyle" />
</view>
@@ -58,8 +58,8 @@
<!-- <uni-icons type="locked" size="24" color="#999"></uni-icons> -->
</view>
<uni-easyinput class="input-content" type="password" v-model="password" placeholder="请输入密码6-16位"
:inputBorder="false" :placeholderStyle="placeholderStyle">
</uni-easyinput>
:inputBorder="false" maxlength="16" :placeholderStyle="placeholderStyle" />
</view>
<!-- 协议勾选 -->
@@ -302,7 +302,7 @@
});
setTimeout(() => {
uni.redirectTo({
url: '/pageSubPack/loginSub/pwd-login'
url: '/pageSubPack/loginSub/login?mode=pwd'
});
}, 1500);
@@ -335,7 +335,9 @@
.register-page {
padding: 20rpx 40rpx 40rpx;
/* background-color: #f8f9fa; */
min-height: 100vh;
height: 100vh;
overflow: hidden;
box-sizing: border-box;
background: repeating-linear-gradient(180deg, #E2F0FF, #F6FAFF);
}

View File

@@ -10,13 +10,13 @@
<view class="form-item">
<view class="item-label">车牌号</view>
<input class="item-input" v-model="formData.carNum" placeholder="请输入"
placeholder-class="input-placeholder" />
placeholder-class="input-placeholder" maxlength="8" />
</view>
<view class="form-item">
<text class="item-label">车辆品牌</text>
<input class="item-input" v-model="formData.carBrand" placeholder="请输入"
placeholder-class="input-placeholder" />
placeholder-class="input-placeholder" maxlength="32"/>
</view>
<!-- <view class="form-item" @click="selectItem('车辆品牌')">
<text class="item-label">车辆品牌</text>
@@ -28,13 +28,13 @@
<view class="form-item">
<view class="item-label">车辆型号</view>
<input class="item-input" v-model="formData.carModel" placeholder="请输入"
placeholder-class="input-placeholder" />
placeholder-class="input-placeholder" maxlength="32"/>
</view>
<view class="form-item">
<view class="item-label">车辆颜色</view>
<input class="item-input" v-model="formData.carColor" placeholder="请输入"
placeholder-class="input-placeholder" />
placeholder-class="input-placeholder" maxlength="5"/>
</view>
<view class="form-item upload-item">
@@ -140,7 +140,6 @@
title: err.msg || '网络异常',
icon: 'none'
})
console.error('列表接口报错:', err)
} finally {
}

View File

@@ -90,7 +90,7 @@
<scroll-view scroll-y class="form-box">
<view class="form-item">
<text class="label">住户名称</text>
<input class="input" v-model="form.name" placeholder="请输入真实姓名" placeholder-class="ph" />
<input class="input" v-model="form.name" placeholder="请输入真实姓名" placeholder-class="ph" maxlength="20"/>
</view>
<view class="form-item">
@@ -117,7 +117,7 @@
<view class="form-item">
<text class="label">证件号码</text>
<input class="input" v-model="form.cardNo" placeholder="请输入证件号码" placeholder-class="ph" />
<input class="input" v-model="form.cardNo" placeholder="请输入证件号码" placeholder-class="ph" maxlength="18"/>
</view>
<view class="form-item arrow-item" @click="openRelation">
@@ -129,7 +129,7 @@
<view class="form-item phone-item">
<text class="label">手机号码</text>
<input class="input" v-model="form.phone" placeholder="请输入手机号" placeholder-class="ph"
type="tel" />
type="tel" maxlength="11"/>
<!-- <button class="code-btn" :disabled="cd>0" @click="sendCode">
{{ cd > 0 ? cd+'s' : '获取验证码' }}
</button> -->
@@ -141,7 +141,7 @@
<view class="form-item">
<text class="label">验证码</text>
<input class="input" v-model="form.code" placeholder="请输入6位验证码" placeholder-class="ph"
type="number" />
type="number" maxlength="6"/>
</view>
<!-- 身份证上传 -->
@@ -255,6 +255,7 @@
getHouseAuthSendSmsCode,
getMyHouseDetail,
upDateMyHouse,
getHouseDataList,
} from '/pageSubPack/api/apiSub.js'
import {
useImageUpload
@@ -315,35 +316,7 @@
const relations = ref([{
id: 0,
name: '本人'
},
{
id: 1,
name: '配偶'
},
{
id: 2,
name: '父母'
},
{
id: 3,
name: '子女'
},
{
id: 4,
name: '亲属'
},
{
id: 5,
name: '租户'
},
{
id: 6,
name: '其他'
}
])
const relations = ref([])
const upDataListNum = ref(0)
// const idCardFront = ref('')
@@ -495,8 +468,8 @@
idCardBackUpload.setPreviewUrl(data.data.cardImageBack?.url || data.data.cardImageBack || '')
} else {
uni.showToast({
title: `${res.msg}`,
icon: 'error'
title: res.msg,
icon: 'none'
});
}
} catch (err) {
@@ -514,6 +487,7 @@
clearInterval(timer)
})
onLoad((option) => {
loadRelations()
console.log(uni.getStorageSync('updateHouseId'));
if (option.id) {
if (uni.getStorageSync('operationType') == 'update') {
@@ -560,6 +534,21 @@
showRelation.value = false
upDataListNum.value++
}
// 获取与业主关系下拉数据
const loadRelations = async () => {
try {
const res = await getHouseDataList({dictType:"com_resident_relationship",dictName:'与业主关系'})
if (res.code === 200) {
relations.value = (res.rows || []).map(item => ({
id: item.dictValue,
name: item.dictLabel
}))
}
} catch (err) {
console.error('加载与业主关系失败:', err)
}
}
const selectClick = (item) => {
formData.status = item;
uni.setStorageSync('houseStatus', item)

View File

@@ -76,7 +76,7 @@ const onDeleteAccount = () => {
uni.showToast({ title: '注销成功', icon: 'success' })
setTimeout(() => {
uni.redirectTo({
url: '/pageSubPack/loginSub/pwd-login'
url: '/pageSubPack/loginSub/login?mode=pwd'
})
}, 1500)
} else {

View File

@@ -195,7 +195,7 @@
title: err.msg || '网络异常',
icon: 'none'
})
console.error('列表接口报错:', err)
// console.error('列表接口报错:', err)
} finally {
}

View File

@@ -298,6 +298,8 @@
border-radius: 20rpx;
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
transition: all 0.2s ease;
overflow: hidden;
min-width: 0;
}
/* 选中状态 */
@@ -315,6 +317,9 @@
font-size: 32rpx;
color: #333;
font-weight: 500;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
/* 成功提示弹窗 */

View File

@@ -62,7 +62,7 @@
}else {
uni.showToast({
title: `${res.msg}`,
icon: 'error'
icon: 'none'
});
}
})
@@ -86,7 +86,7 @@
}else {
uni.showToast({
title: `${res.msg}`,
icon: 'error'
icon: 'none'
});
}
})
@@ -105,10 +105,7 @@
content: '确认选择此' + checkType.value + '吗?',
success: (res) => {
if (res.confirm) {
uni.showLoading({
title: '选择中...',
mask: true
})
setTimeout(() => {
uni.showToast({
title: '选择成功',
@@ -129,7 +126,6 @@
}
}, 1000)
setTimeout(() => {
uni.hideLoading()
goFreash()
}, 2500)
}
@@ -190,12 +186,7 @@
box-sizing: border-box;
}
.parkingLot-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 30rpx;
}
.empty-state {
display: flex;
@@ -212,6 +203,15 @@
margin-top: 20rpx;
margin-bottom: 10rpx;
}
.parkingLot-grid {
/* display: flex;
flex-wrap: wrap;
gap: 30rpx; */
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 30rpx
}
.parkingLot-item {
height: 100rpx;
@@ -223,6 +223,9 @@
border-radius: 20rpx;
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
transition: all 0.2s ease;
/* padding: 0 24rpx; */
overflow: hidden;
min-width: 0;
}
.parkingLot-item.active {
@@ -238,5 +241,8 @@
font-size: 32rpx;
color: #333;
font-weight: 500;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
</style>

View File

@@ -310,7 +310,7 @@
setTimeout(() => {
uni.hideLoading();
uni.reLaunch({
url: '/pageSubPack/loginSub/pwd-login'
url: '/pageSubPack/loginSub/login?mode=pwd'
});
}, 1500);
} else {
@@ -320,7 +320,7 @@
uni.removeStorageSync('currentVillageId');
uni.hideLoading();
uni.reLaunch({
url: '/pageSubPack/loginSub/pwd-login'
url: '/pageSubPack/loginSub/login?mode=pwd'
});
}
@@ -332,7 +332,7 @@
uni.removeStorageSync('currentVillageId');
uni.hideLoading();
uni.reLaunch({
url: '/pageSubPack/loginSub/pwd-login'
url: '/pageSubPack/loginSub/login?mode=pwd'
});
})

View File

@@ -42,12 +42,6 @@
<text class="label">预约时间</text>
<text class="value time-value">{{ showTimeText || '请选择预约时间' }}</text>
</view>
<!-- <view class="form-item">
<text class="label">预约时间</text>
<view class="value" @click="">
<uni-datetime-picker type="datetime" v-model="form.datetime" @change="changeTime" />
</view>
</view> -->
<!-- 问题照片 -->
<view class="form-item-wenti">

View File

@@ -1,8 +1,5 @@
<template>
<view class="contentStyle" style="">
<view class="status-bar"></view>
<uni-nav-bar title="生活缴费" left-icon="left" @clickLeft="goBack" backgroundColor="transparent" :border="false">
</uni-nav-bar>
<view class="contentStyle">
<view class="topbox">
<image class="titleImg" src="https://wuyeadmin.bugtc.com/images/propertyImgs/payTitle.png"></image>
<image class="payImg" src="https://wuyeadmin.bugtc.com/images/propertyImgs/payImg.png"></image>
@@ -91,29 +88,14 @@
</template>
<script setup>
import {
ref,
onMounted,
computed
} from 'vue'
import {
onShow,
onReady,
onReachBottom,
onLoad,
onUnload,
onPullDownRefresh
} from '@dcloudio/uni-app'
import { ref } from 'vue'
import { onShow, onLoad } from '@dcloudio/uni-app'
import {
getTopUpSelectByResident,
postInsertOpenId,
postSubscribeAuth,
getTopUpDetails,
} from '/pageSubPack/api/apiSub.js'
// 响应式数据
const statusBarHeight = ref(20)
const detailslist = ref([])
const pageNum = ref(1)
const pageSize = ref(3)
@@ -179,29 +161,6 @@
const postOpenId = async () => {
// App 端直接从本地存储获取 openid
try {
const openid = uni.getStorageSync('openid')
if (!openid) {
uni.showToast({
title: '请先登录',
icon: 'none'
})
return
}
await postInsertOpenId({
openid: openid,
residentUserId: uni.getStorageSync('userId')
})
} catch (err) {
uni.showToast({
title: err.msg || '网络异常',
icon: 'none'
})
// console.error('列表接口报错:', err)
}
}
onShow(() => {
// Zy --------------
@@ -211,13 +170,8 @@
// 不再自动请求订阅消息,改为用户点击触发
})
// 生命周期
onReady(() => {})
onLoad(() => {
// postOpenId()
uni.hideTabBar({
animation: false // 关闭动画,更稳定
});
uni.hideTabBar({ animation: false });
getPayList()
})
@@ -278,21 +232,6 @@
uni.setStorageSync('addPaymentType', type.name)
}
const goBack = () => {
console.log('返回',uni.getStorageSync('sourcePage'))
if (uni.getStorageSync('sourcePage') == 'serviceIndex') {
uni.switchTab({
url: '/pages/serviceIndex/serviceIndex'
})
} else if (uni.getStorageSync('sourcePage') == 'index') {
uni.switchTab({
url: '/pages/index/index'
})
}
uni.removeStorageSync('sourcePage')
}
// 获取缴费列表
const getBillDetails = (isLoadMore = false) => {
if (isLoadMore) {
@@ -348,8 +287,9 @@
.contentStyle {
display: flex;
flex-direction: column;
height: 100vh;
min-height: 100vh;
background: linear-gradient(180deg, #dfedfd, #F6FAFF);
overflow-x: hidden;
}
.page {
@@ -557,11 +497,6 @@
font-weight: 600;
}
.status-bar {
width: 100vw;
height: 46px;
}
.details-scroll {
max-height: 500rpx;
margin-bottom: 40rpx;

View File

@@ -3,7 +3,7 @@
"path": "pages/index/index",
"style": {
"navigationBarTitleText": "首页",
"navigationStyle": "custom",
// "navigationStyle": "custom",
"navigationBarBackgroundColor": "#F8F8F8"
}
},
@@ -19,15 +19,15 @@
{
"path": "pages/serviceIndex/serviceIndex",
"style": {
"navigationBarTitleText": "服务",
"navigationStyle": "custom"
"navigationBarTitleText": "服务"
// "navigationStyle": "custom"
}
},
{
"path": "pages/myIndex/myIndex",
"style": {
"navigationBarTitleText": "我的",
"navigationStyle": "custom"
"navigationBarTitleText": "我的"
// "navigationStyle": "custom"
}
}
@@ -38,35 +38,32 @@
"path": "register-new-user",
"style": {
"navigationBarTitleText": "注册新用户",
"navigationStyle": "custom"
}
},
{
"path": "pwd-login",
"style": {
"navigationBarTitleText": "账号密码登录",
"navigationStyle": "custom"
// "navigationStyle": "custom",
"disableScroll": true
}
},
{
"path": "login",
"style": {
"navigationBarTitleText": "验证码登录",
"navigationStyle": "custom"
"navigationStyle": "custom",
"disableScroll": true
}
},
{
"path": "forget-pwd",
"style": {
"navigationBarTitleText": "忘记密码",
"navigationStyle": "custom"
// "navigationStyle": "custom",
"disableScroll": true
}
},
{
"path": "change-pwd",
"style": {
"navigationBarTitleText": "修改密码",
"navigationStyle": "custom"
// "navigationStyle": "custom",
"disableScroll": true
}
},
{
@@ -398,8 +395,14 @@
{
"path": "paymentIndex",
"style": {
"navigationBarTitleText": "",
"navigationStyle": "custom"
"navigationBarTitleText": "生活缴费",
"navigationBarBackgroundColor": "#dfedfd",
"navigationBarTextStyle": "black",
"app-plus": {
"titleNView": {
"autoBackButton": true
}
}
}
}, {
"path": "addHydropower",

View File

@@ -1,25 +1,22 @@
<template>
<view class="content-class">
<!-- 首次加载遮罩 -->
<view class="loading-mask" v-if="!pageReady">
<view class="loading-bg"></view>
</view>
<!-- 固定头部 -->
<view class="header-fixed">
<view class="header-fixed" v-if="pageReady">
<view class="nar-top"></view>
<view class="header-content">
<!-- 状态栏占位 -->
<view class="status_bar" :style="{ height: statusBarHeight + 'px' }"></view>
<!-- 导航栏 -->
<view class="nav-bar">
<text class="nav-title">首页</text>
</view>
<!-- 小区选择 -->
<view class="header-container" @click="navigateToPage">
<!-- 左侧小区选择区域 -->
<view class="location-area">
<!-- 定位图标 -->
<view class="location-icon">
<image src="https://wuyeadmin.bugtc.com/images/home/adress.png"
style="height: 100%;width: 100%;"></image>
</view>
<!-- 小区名称和下拉箭头 -->
<view class="community-selector">
<text class="community-name">{{ currentCommunity }}</text>
<u-icon name="arrow-down-fill" size="16" :color="isDropdownOpen ? '#2979ff' : '#222222'"
@@ -31,7 +28,7 @@
</view>
<!-- 滚动内容区 -->
<scroll-view class="main-scroll" scroll-y>
<scroll-view class="main-scroll" v-if="pageReady" scroll-y>
<!-- banner -->
<view class="bannarClass">
<up-swiper :key="bannerSwiperKey" :list="bannerList" indicator indicatorMode="dot" radius="10">
@@ -107,7 +104,6 @@
<view style="color: #fff;font-size: 28rpx;">邻里便民服务 即将上线</view>
</view>
</up-col>
</up-row>
</view>
</view>
@@ -121,7 +117,6 @@
<text class="look-more-title" @click="moreClick">查看更多</text>
</view>
</view>
<!-- 活动列表内容去掉内层 scroll-view由外层统一滚动 -->
<view class="activity-list">
<view class="eventListCard" v-for="(activity, index) in activityList" :key="activity.id"
@click="goToActivityDetail(activity)">
@@ -155,7 +150,6 @@
</up-col>
</up-row>
</view>
</view>
</view>
<!-- 空状态 -->
@@ -163,15 +157,12 @@
<uni-icons type="info" size="30" color="#ccc"></uni-icons>
<text class="empty-text">暂无数据</text>
</view>
</uni-card>
<!-- 底部占位 -->
<view class="scroll-bottom-space"></view>
</scroll-view>
</view>
</template>
<script setup>
@@ -196,85 +187,77 @@
// 列表数据状态
const isDropdownOpen = ref(false)
const scrollTop = ref(0)
const activityList = ref([]) // 活动列表数据
const activityList = ref([])
const currentCommunity = ref('请绑定房屋')
const currentVillageId = ref('')
const statusBarHeight = ref(0)
const bannerList = ref([])
const bannerRawData = ref([]) // 保留原始数据含link
const bannerRawData = ref([])
const bannerSwiperKey = ref(0)
const noticeText = ref('暂无公告')
const noticeKey = ref(0)
const noticeId = ref('')
const lastUserId = ref('') // 用于检测是否切换账号
const lastUserId = ref('')
const pageReady = ref(false)
// =======工具方法=======
const requireLogin = () => {
const token = uni.getStorageSync('token')
if (!token) {
uni.showToast({ title: '请先登录', icon: 'none' })
setTimeout(() => {
uni.navigateTo({ url: '/pageSubPack/loginSub/login?mode=pwd' })
}, 1000)
return false
}
return true
}
// =======方法=======
// 格式化时间
const formatDate = (date) => {
if (!date) return ''
return moment(date).format('YYYY-MM-DD HH:mm')
}
// 公告跳转
const getNoticeMore = () => {
if (!requireLogin()) return
uni.setStorageSync('sourcePage', "index")
uni.navigateTo({
url: "/pageSubPack/notice-list/noticeList"
})
uni.navigateTo({ url: "/pageSubPack/notice-list/noticeList" })
}
// 获取bannar列表
const getbannarData = async () => {
try {
const res = await getBannarList({
villageId: uni.getStorageSync('currentVillageId')
})
const res = await getBannarList({ villageId: uni.getStorageSync('currentVillageId') })
if (res.code === 200) {
bannerRawData.value = res.data || []
const newList = (res.data || []).map(item => item.url)
// 只有 banner 数据真正变化时才更新,避免 swiper 反复重建
if (JSON.stringify(newList) !== JSON.stringify(bannerList.value)) {
bannerList.value = newList
await nextTick()
bannerSwiperKey.value++
}
} else {
uni.showToast({
title: '获取失败',
icon: 'none'
})
}
} catch (err) {
const msg = err?.msg || (typeof err === 'string' ? err : '获取失败')
uni.showToast({
title: msg,
icon: 'none'
})
// 静默失败
}
}
// banner点击跳转
const bannerClick = (index) => {
if (!requireLogin()) return
const item = bannerRawData.value[index]
if (item && item.link) {
uni.navigateTo({
url: item.link
})
uni.navigateTo({ url: item.link })
}
}
// 接收选择小区返回的参数
const slelctHomeData = (data) => {
// console.log('收到B页面返回的数据', data)
if (data.name) {
currentCommunity.value = data.name
}
if (data.villageId) {
currentVillageId.value = data.villageId
}
if (data.name) currentCommunity.value = data.name
if (data.villageId) currentVillageId.value = data.villageId
getCurrentCommunityData()
getNoticeData()
noticeKey.value++
getNewActivityList()
}
// 获取当前认证小区的方法
const getCurrentCommunityData = () => {
getCurrentVillage().then(res => {
if (res.code === 200 && res.data && res.data.villageId) {
@@ -286,15 +269,10 @@
currentVillageId.value = ''
}
}).catch(err => {
uni.showToast({
title: err.msg || '网络异常',
icon: 'error'
});
uni.showToast({ title: err.msg || '网络异常', icon: 'error' })
})
}
// 获取首页最新小区公告
const getNoticeData = async () => {
try {
const res = await getNoticeLatest()
@@ -306,54 +284,38 @@
noticeText.value = '暂无公告'
noticeId.value = ''
}
} else {
uni.showToast({
title: res.msg || '获取通知失败',
icon: 'none',
duration: 2000
})
}
} catch (err) {
uni.showToast({
title: err.msg || '网络异常',
icon: 'none',
duration: 1000
})
noticeText.value = '暂无公告'
noticeId.value = ''
}
}
// 刷新所有数据(提取公共方法)
const refreshAllData = async () => {
const token = uni.getStorageSync('token') || '';
const needReload = uni.getStorageSync('needReloadUserInfo');
// 只有从绑定房屋返回首页时才重新加载用户信息获取最新小区ID
const token = uni.getStorageSync('token') || ''
const needReload = uni.getStorageSync('needReloadUserInfo')
if (token && needReload) {
try {
const res = await getReloadUserInfo();
const res = await getReloadUserInfo()
if (res.code === 200 && res.data) {
if (res.data.userId) {
uni.setStorageSync('userId', res.data.userId);
}
const reloadedVillageId = res.data.currentVillageId || 0;
uni.setStorageSync('currentVillageId', reloadedVillageId);
if (res.data.userId) uni.setStorageSync('userId', res.data.userId)
const reloadedVillageId = res.data.currentVillageId || 0
uni.setStorageSync('currentVillageId', reloadedVillageId)
}
} catch (err) {
console.error('重新加载用户信息失败', err);
console.error('重新加载用户信息失败', err)
} finally {
uni.removeStorageSync('needReloadUserInfo');
uni.removeStorageSync('needReloadUserInfo')
}
}
getCurrentCommunityData();
getCurrentCommunityData()
getNoticeData()
noticeKey.value++
getNewActivityList()
getbannarData()
pageReady.value = true
}
// 切换账号时重置页面数据
const resetPageData = () => {
currentCommunity.value = '请先绑定房屋'
currentVillageId.value = ''
@@ -366,131 +328,84 @@
onShow(() => {
const currentUserId = uni.getStorageSync('userId') || ''
// 检测到切换账号:重置数据并重新加载
if (lastUserId.value && lastUserId.value !== currentUserId) {
resetPageData()
refreshAllData()
} else {
// 首次显示 或 非切换账号的普通返回,直接刷新数据(不清空已有数据)
refreshAllData()
}
lastUserId.value = currentUserId
})
onLoad(() => {
const info = uni.getSystemInfoSync()
statusBarHeight.value = info.statusBarHeight || 0
// 绑定全局事件监听
uni.$on('confirm', slelctHomeData)
// 记录当前用户ID用于 onShow 中检测是否切换账号
lastUserId.value = uni.getStorageSync('userId') || ''
// 数据刷新统一放到 onShow避免 onLoad + onShow 首次重复请求
})
// 页面销毁时移除监听(防止内存泄漏)
onUnload(() => {
uni.$off('confirm', slelctHomeData)
})
// 方法逻辑
const openDoorClick = () => {
if (!requireLogin()) return
uni.setStorageSync('sourcePage', "index")
uni.navigateTo({
url: "/pageSubPack/notice-list/oneClickOpen"
})
uni.navigateTo({ url: "/pageSubPack/notice-list/oneClickOpen" })
}
// 生活缴费
const payMentClick = () => {
if (!requireLogin()) return
uni.setStorageSync('sourcePage', "index")
uni.navigateTo({
url: "/pageSubPack/payment-list/paymentIndex"
})
uni.navigateTo({ url: "/pageSubPack/payment-list/paymentIndex" })
}
// 点击小区选择
const navigateToPage = () => {
// const token = uni.getStorageSync('token') || '';
const cachedVillageId = uni.getStorageSync('currentVillageId');
// 未登录 或 未绑定小区 → 去我的页面认证
const cachedVillageId = uni.getStorageSync('currentVillageId')
if (!cachedVillageId || cachedVillageId === '0' || cachedVillageId === 0) {
currentCommunity.value = '请先绑定房屋';
uni.setStorageSync('currentCommunity', '请先绑定房屋');
uni.showToast({
title: '请先绑定小区',
icon: 'none',
duration: 1500
});
setTimeout(() => {
uni.switchTab({
url: '/pages/myIndex/myIndex',
});
}, 1500);
currentCommunity.value = '请先绑定房屋'
uni.setStorageSync('currentCommunity', '请先绑定房屋')
uni.showToast({ title: '请先绑定小区', icon: 'none', duration: 1500 })
setTimeout(() => { uni.switchTab({ url: '/pages/myIndex/myIndex' }) }, 1500)
} else {
// 已登录且已绑定小区 → 去选择小区
uni.navigateTo({
url: `/pageSubPack/notice-list/selectHome?villageId=${cachedVillageId}`
});
uni.navigateTo({ url: `/pageSubPack/notice-list/selectHome?villageId=${cachedVillageId}` })
}
};
// 获取首页最新活动
}
const getNewActivityList = async () => {
try {
let params = {
villageId: uni.getStorageSync('currentVillageId')
}
const res = await getActivitylatest(params)
const res = await getActivitylatest({ villageId: uni.getStorageSync('currentVillageId') })
if (res.code === 200) {
if (res.data) {
activityList.value = res.data || []
} else {
activityList.value = []
}
} else {
activityList.value = []
uni.showToast({
title: res.msg,
icon: 'error',
duration: 1000
})
}
} catch (err) {
uni.showToast({
title: err.msg || '网络异常',
icon: 'error',
duration: 1000
})
activityList.value = []
}
}
const onlineRepairClick = () => {
if (!requireLogin()) return
uni.setStorageSync('sourcePage', "index")
uni.navigateTo({
url: '/pageSubPack/online-repair/onlineRepair'
})
uni.navigateTo({ url: '/pageSubPack/online-repair/onlineRepair' })
}
// 访客邀请
const visitorClick = () => {
if (!requireLogin()) return
uni.setStorageSync('sourcePage', "index")
uni.navigateTo({
url: "/pageSubPack/visitor/visitor-list"
})
uni.navigateTo({ url: "/pageSubPack/visitor/visitor-list" })
}
// 跳转到活动详情页
const goToActivityDetail = (activity) => {
if (!requireLogin()) return
uni.navigateTo({
url: `/pageSubPack/activity-list/activityListDetails?id=${activity.id}&title=${activity.title}&applied=${activity.applied || ''}&statusText=${activity.statusText || ''}`
})
}
// 活动列表的查看更多
const moreClick = () => {
if (!requireLogin()) return
uni.setStorageSync('sourcePage', "index")
uni.navigateTo({
url: "/pageSubPack/activity-list/activityList"
})
uni.navigateTo({ url: "/pageSubPack/activity-list/activityList" })
}
</script>
@@ -505,6 +420,22 @@
display: flex;
flex-direction: column;
/* 加载遮罩 */
.loading-mask {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 999;
}
.loading-bg {
width: 100%;
height: 100%;
background: repeating-linear-gradient(to right, #EDF4FA, #C0E4FB);
}
/* 固定头部 */
.header-fixed {
position: relative;
@@ -539,34 +470,12 @@
height: 40rpx;
}
.status_bar {
width: 100%;
flex-shrink: 0;
position: relative;
z-index: 1;
}
/* 导航栏 */
.nav-bar {
height: 44px;
line-height: 44px;
text-align: center;
position: relative;
z-index: 1;
}
.nav-title {
font-size: 32rpx;
font-weight: 500;
}
.header-container {
display: flex;
align-items: center;
justify-content: space-between;
padding: 4rpx 30rpx;
padding: 20rpx 30rpx;
box-sizing: border-box;
// border-bottom: 1rpx solid #f0f0f0;
position: relative;
z-index: 10;
}
@@ -607,7 +516,6 @@
.bannarClass {
position: relative;
padding: 20rpx 40rpx;
// margin-bottom: 20rpx;
height: 300rpx;
::v-deep .u-swiper {
@@ -634,7 +542,6 @@
margin-bottom: 20rpx;
}
// 修改通知栏样式
::v-deep .uni-noticebar__content-wrapper--scrollable {
margin-right: 20px;
}
@@ -643,10 +550,6 @@
padding: 4px 12px;
}
.notice-bar::after {
color: #3E8EFF;
}
.bg-card-open {
padding: 20rpx;
background-color: #fff;
@@ -664,8 +567,6 @@
width: 88rpx;
height: 88rpx;
border-radius: 10rpx;
// opacity: 0.4;
}
.iconClass-img {
@@ -682,31 +583,24 @@
}
.adCardClass {
// width: 100%;
height: 200rpx;
margin: 0 30rpx 20rpx;
background-color: #3E8EFF;
// margin-top: 30rpx;
border-radius: 28rpx;
.titleLeft {
text-align: left;
line-height: 2;
// margin-top: 32rpx;
// margin-left: 30rpx;
}
.iconRightClass {
width: 120rpx;
height: 120rpx;
border-radius: 50%;
// margin-top: 20rpx;
margin: 36rpx;
}
}
.activity-card {}
.uni-card {
margin: 0 18px 20rpx !important;
}
@@ -722,20 +616,16 @@
font-size: 32rpx;
font-weight: 600;
color: #222;
}
.eventListCard {
// min-height:200rpx ;
position: relative;
margin: 30rpx 0rpx;
// overflow: hidden;
.activity-img {
width: 170rpx;
height: 230rpx;
position: relative;
// background-color: #333333;
}
.status-tag {

View File

@@ -1,8 +1,8 @@
<template>
<view class="contentStyle" style="">
<view class="status-bar"></view>
<!-- <view class="status-bar"></view>
<uni-nav-bar title="我的" backgroundColor="transparent" :border="false">
</uni-nav-bar>
</uni-nav-bar> -->
<scroll-view class="page" scroll-y>
<view class="topBox">
<view class="name">

View File

@@ -71,17 +71,19 @@
</template>
<script setup>
import { ref } from 'vue';
import { ref, onMounted } from 'vue';
// 守卫:已登录或已看过引导页的用户不展示引导页,直接跳转
const hasShowGuide = uni.getStorageSync('hasShowGuide')
const tokenSave = uni.getStorageSync('token')
// 是否需要重定向(老用户跳过引导页)
const needRedirect = hasShowGuide || tokenSave
if (hasShowGuide || tokenSave) {
if (needRedirect) {
if (tokenSave) {
uni.reLaunch({ url: '/pages/index/index' })
} else if (hasShowGuide) {
uni.reLaunch({ url: '/pageSubPack/loginSub/pwd-login' })
uni.reLaunch({ url: '/pageSubPack/loginSub/login?mode=pwd' })
}
}
@@ -91,8 +93,17 @@ const currentStep = ref(0);
const mode = ref("default")
// 防重复跳转锁
const isNavigating = ref(false)
// 控制是否展示引导内容(已登录用户不展示,避免闪烁)
const showContent = ref(!hasShowGuide && !tokenSave)
// 控制是否展示引导内容(初始为 false避免重定向用户看到闪烁)
const showContent = ref(false)
// 页面挂载后延迟显示,让过渡更平滑
onMounted(() => {
// 需要重定向的用户不展示引导内容
if (needRedirect) return
setTimeout(() => {
showContent.value = true
}, 100)
})
// ========== 方法 ==========
// 滑动swiper切换步骤
@@ -119,7 +130,7 @@ const handleBtnClick = () => {
})
} else {
uni.redirectTo({
url: "/pageSubPack/loginSub/pwd-login"
url: "/pageSubPack/loginSub/login?mode=pwd"
})
}
}
@@ -136,6 +147,19 @@ const handleBtnClick = () => {
flex-direction: column;
align-items: center;
box-sizing: border-box;
animation: guideFadeIn 0.5s ease-out;
}
/* 引导页淡入动画 */
@keyframes guideFadeIn {
from {
opacity: 0;
transform: translateY(20rpx);
}
to {
opacity: 1;
transform: translateY(0);
}
}
/* 状态栏 - 自适应设备状态栏高度 */

View File

@@ -1,8 +1,8 @@
<template>
<view class="contentStyle" style="">
<view class="status-bar"></view>
<!-- <view class="status-bar"></view>
<uni-nav-bar title="服务" backgroundColor="transparent" :border="false">
</uni-nav-bar>
</uni-nav-bar> -->
<!-- 表单区域 -->
<scroll-view class="page" scroll-y>
<view class="container">