对接切换小区接口
This commit is contained in:
@@ -438,7 +438,7 @@
|
|||||||
.container {
|
.container {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
background-color: #f9f9f9;
|
background-color: #fff;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
@@ -453,7 +453,7 @@
|
|||||||
.top-bar {
|
.top-bar {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
background: #f9f9f9;
|
background: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 滚动区域 */
|
/* 滚动区域 */
|
||||||
@@ -551,6 +551,7 @@
|
|||||||
margin-bottom: 30rpx;
|
margin-bottom: 30rpx;
|
||||||
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.05);
|
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.05);
|
||||||
position: relative;
|
position: relative;
|
||||||
|
border: 1px solid #e1e1e1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 活动状态标签 */
|
/* 活动状态标签 */
|
||||||
|
|||||||
@@ -23,6 +23,26 @@ export const getResetPassword = (data) =>{
|
|||||||
}
|
}
|
||||||
// =========首页=======
|
// =========首页=======
|
||||||
// 首页最新公告
|
// 首页最新公告
|
||||||
export const getNoticeList = () =>{
|
export const getNoticeLatest = () =>{
|
||||||
return get('/api/resident/notice/latest')
|
return get('/api/resident/notice/latest')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 查询已认证的小区
|
||||||
|
export const getVillageList = (data) =>{
|
||||||
|
return get('/api/resident/village/myList', data)
|
||||||
|
}
|
||||||
|
// 获取当前小区
|
||||||
|
export const getCurrentVillage = () =>{
|
||||||
|
return get('/api/resident/village/current')
|
||||||
|
}
|
||||||
|
// 切换小区
|
||||||
|
export const getVillageSwitch = (data)=>{
|
||||||
|
return post('/api/resident/village/switch',data)
|
||||||
|
}
|
||||||
|
// ====公告列表======
|
||||||
|
// 获取公告列表
|
||||||
|
export const getNoticeList = (data) =>{
|
||||||
|
return get('/api/resident/notice/list',data)
|
||||||
|
}
|
||||||
|
// 获取公告详情
|
||||||
|
// export const getNoticeDetails =
|
||||||
@@ -43,7 +43,7 @@ export default function request(url, data = {}, method = "GET") {
|
|||||||
uni.showToast({ title: '登录过期,请重新登录', icon: 'none', duration: 2000 });
|
uni.showToast({ title: '登录过期,请重新登录', icon: 'none', duration: 2000 });
|
||||||
uni.clearStorageSync('token');
|
uni.clearStorageSync('token');
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
uni.reLaunch({ url: '/pages/login/login' });
|
uni.reLaunch({ url: '/pageSubPack/loginSub/pwd-login' });
|
||||||
}, 1500);
|
}, 1500);
|
||||||
reject('token 过期');
|
reject('token 过期');
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -134,7 +134,6 @@ const getVerifyCode = () => {
|
|||||||
}
|
}
|
||||||
uni.showLoading({ title: '发送中...', mask: true });
|
uni.showLoading({ title: '发送中...', mask: true });
|
||||||
getSendCode(params).then(res =>{
|
getSendCode(params).then(res =>{
|
||||||
console.log('44444',res)
|
|
||||||
if(res.code === 200){
|
if(res.code === 200){
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
@@ -176,12 +175,23 @@ const handleLogin = () => {
|
|||||||
}
|
}
|
||||||
getLoginBySms(params).then(res =>{
|
getLoginBySms(params).then(res =>{
|
||||||
if(res.code === 200){
|
if(res.code === 200){
|
||||||
//uni.setStorageSync('token', res.token); // 假设后端返回token字段
|
if(res.data){
|
||||||
|
uni.setStorageSync('token', res.data.token);
|
||||||
|
// 存用户ID
|
||||||
|
if(res.data.userId) {
|
||||||
|
uni.setStorageSync('userId', res.data.userId);
|
||||||
|
}
|
||||||
|
// 存当前绑定的小区ID,0 表示未绑定
|
||||||
|
const currentVillageId = res.data.currentVillageId || 0;
|
||||||
|
uni.setStorageSync('currentVillageId', currentVillageId);
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
uni.showToast({ title: '登录成功', icon: 'success' });
|
uni.showToast({ title: '登录成功', icon: 'success' });
|
||||||
setTimeout(() =>{
|
setTimeout(() =>{
|
||||||
uni.switchTab({ url: '/pages/index/index' });
|
uni.switchTab({ url: '/pages/index/index' });
|
||||||
},1500)
|
},1500)
|
||||||
|
}else{
|
||||||
|
uni.showToast({ title: '登录失败', icon: 'error' });
|
||||||
|
}
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
uni.showToast({ title:'登录失败', icon: 'error' });
|
uni.showToast({ title:'登录失败', icon: 'error' });
|
||||||
|
|||||||
@@ -50,7 +50,7 @@
|
|||||||
<!-- 登录按钮 -->
|
<!-- 登录按钮 -->
|
||||||
<button
|
<button
|
||||||
class="login-btn"
|
class="login-btn"
|
||||||
|
:disabled="!canLogin"
|
||||||
@click="handleLogin"
|
@click="handleLogin"
|
||||||
>
|
>
|
||||||
登录
|
登录
|
||||||
@@ -100,6 +100,7 @@ const handleLogin = () => {
|
|||||||
// uni.showToast({ title: '请输入账号和密码', icon: 'none' });
|
// uni.showToast({ title: '请输入账号和密码', icon: 'none' });
|
||||||
// return
|
// return
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if (!phoneNumber.value) {
|
if (!phoneNumber.value) {
|
||||||
uni.showToast({ title: '请输入账号', icon: 'none' });
|
uni.showToast({ title: '请输入账号', icon: 'none' });
|
||||||
return;
|
return;
|
||||||
@@ -112,41 +113,48 @@ const handleLogin = () => {
|
|||||||
uni.showToast({ title: '请勾选协议', icon: 'none' });
|
uni.showToast({ title: '请勾选协议', icon: 'none' });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// uni.showLoading({ title: '登录中...', mask: true });
|
uni.showLoading({ title: '登录中...', mask: true });
|
||||||
// let params = {
|
let params = {
|
||||||
// username:phoneNumber.value,
|
username:phoneNumber.value,
|
||||||
// password:password.value
|
password:password.value
|
||||||
// }
|
}
|
||||||
// getLoginPassword(params).then(res =>{
|
getLoginPassword(params).then(res =>{
|
||||||
// // console.log('33333',res)
|
console.log('33333',res)
|
||||||
// if(res.code === 200){
|
if(res.code === 200){
|
||||||
// uni.setStorageSync('token', res.token);
|
uni.setStorageSync('token', res.data.token);
|
||||||
// uni.hideLoading();
|
// 存用户ID
|
||||||
// uni.showToast({ title: '登录成功', icon: 'success' });
|
if(res.data) {
|
||||||
|
// 存当前绑定的小区ID,0 表示未绑定
|
||||||
|
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(() => {
|
// setTimeout(() => {
|
||||||
// uni.switchTab({ url: '/pages/index/index' });
|
// uni.switchTab({ url: '/pages/index/index' });
|
||||||
// }, 1500);
|
// }, 1500);
|
||||||
// }else{
|
// uni.hideLoading()
|
||||||
// uni.showToast({ title: `${res.msg},请先注册账号`, icon: 'error' });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// }).catch(err => {
|
|
||||||
// // console.error('登录接口异常:', err);
|
|
||||||
// uni.showToast({
|
|
||||||
// title: '网络异常',
|
|
||||||
// icon: 'error'
|
|
||||||
// });
|
|
||||||
// })
|
|
||||||
|
|
||||||
// 测试
|
|
||||||
uni.showLoading({
|
|
||||||
title: '登录中...',
|
|
||||||
mask:true
|
|
||||||
});
|
|
||||||
setTimeout(() => {
|
|
||||||
uni.switchTab({ url: '/pages/index/index' });
|
|
||||||
}, 1500);
|
|
||||||
uni.hideLoading()
|
|
||||||
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
scroll-y
|
scroll-y
|
||||||
:refresher-enabled="true"
|
:refresher-enabled="true"
|
||||||
:refresher-triggered="refreshing"
|
:refresher-triggered="refreshing"
|
||||||
|
@refresherrefresh="onRefresh"
|
||||||
|
@scrolltolower="loadMore"
|
||||||
:style="{ height: `calc(100vh - ${statusBarHeight + navBarHeight}px)` }"
|
:style="{ height: `calc(100vh - ${statusBarHeight + navBarHeight}px)` }"
|
||||||
>
|
>
|
||||||
<view class="status_bar"></view>
|
<view class="status_bar"></view>
|
||||||
@@ -21,16 +23,16 @@
|
|||||||
<!-- 通知列表项 -->
|
<!-- 通知列表项 -->
|
||||||
<view
|
<view
|
||||||
v-for="(notice, index) in noticeList"
|
v-for="(notice, index) in noticeList"
|
||||||
:key="notice.id"
|
:key="notice.noticeId"
|
||||||
class="notice-item"
|
class="notice-item"
|
||||||
@click="goToDetail(notice)"
|
@click="goToDetail(notice)"
|
||||||
>
|
>
|
||||||
<!-- 通知标题 -->
|
<!-- 通知标题 -->
|
||||||
<view class="notice-header">
|
<view class="notice-header">
|
||||||
<view class="notice-title">
|
<view class="notice-title">
|
||||||
{{notice.title}}
|
{{notice.noticeTitle}}
|
||||||
</view>
|
</view>
|
||||||
<view class="unread-dot" v-if="notice.hasRead"></view>
|
<view class="unread-dot" v-if="notice.readStatus"></view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 红点 -->
|
<!-- 红点 -->
|
||||||
@@ -47,7 +49,7 @@
|
|||||||
|
|
||||||
<!-- 通知摘要 -->
|
<!-- 通知摘要 -->
|
||||||
<view class="notice-summary">
|
<view class="notice-summary">
|
||||||
{{ notice.summary }}
|
{{ notice.noticeContent }}
|
||||||
</view>
|
</view>
|
||||||
<!-- 详情 -->
|
<!-- 详情 -->
|
||||||
<view class="notice-actions" @click.stop="goToDetail(notice)">
|
<view class="notice-actions" @click.stop="goToDetail(notice)">
|
||||||
@@ -77,7 +79,7 @@
|
|||||||
|
|
||||||
<!-- 空状态 -->
|
<!-- 空状态 -->
|
||||||
<view v-if="noticeList.length === 0 && !loading" class="empty-state">
|
<view v-if="noticeList.length === 0 && !loading" class="empty-state">
|
||||||
<image src="/static/empty-notice.png" mode="aspectFit" class="empty-image"></image>
|
<!-- <image src="/static/empty-notice.png" mode="aspectFit" class="empty-image"></image> -->
|
||||||
<text class="empty-text">暂无通知</text>
|
<text class="empty-text">暂无通知</text>
|
||||||
<button class="btn-refresh" @click="loadNotices">刷新试试</button>
|
<button class="btn-refresh" @click="loadNotices">刷新试试</button>
|
||||||
</view>
|
</view>
|
||||||
@@ -87,39 +89,77 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
|
import { onLoad } from '@dcloudio/uni-app'
|
||||||
|
import { getNoticeList } from '../api/api.js'
|
||||||
|
|
||||||
|
const noticeList = ref([])
|
||||||
const noticeList = ref([
|
|
||||||
{
|
|
||||||
id:'1',
|
|
||||||
title:'我那我是咖啡牛奶附件说的都是vv的v给v梵蒂冈v辅导报告发布',
|
|
||||||
author:'张三',
|
|
||||||
publishTime:'2026.3.5',
|
|
||||||
summary:'为保障社区居民生命财产安全,维护社区和谐稳定,根据上级部门要求,结合我社区实际情况,现就进一步加强社区安全管理工作通知如下',
|
|
||||||
hasRead:true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id:'2',
|
|
||||||
title:'今天停水了',
|
|
||||||
author:'张三',
|
|
||||||
publishTime:'2026.3.5',
|
|
||||||
summary:'为保障社区居民生命财产安全,维护社区和谐稳定,根据上级部门要求,结合我社区实际情况,现就进一步加强社区安全管理工作通知如下',
|
|
||||||
hasRead:true
|
|
||||||
|
|
||||||
}
|
|
||||||
])
|
|
||||||
const refreshing = ref(false)
|
const refreshing = ref(false)
|
||||||
const loadingMore = ref(false)
|
const loadingMore = ref(false)
|
||||||
const noMoreData = ref(false)
|
const noMoreData = ref(false)
|
||||||
|
const loading = ref(false)
|
||||||
|
const pageNum = ref(1)
|
||||||
const pageSize = 10
|
const pageSize = 10
|
||||||
const statusBarHeight = ref(0)
|
const statusBarHeight = ref(0)
|
||||||
const navBarHeight = 44
|
const navBarHeight = 44
|
||||||
|
|
||||||
// --方法----
|
// --方法----
|
||||||
const goToDetail = () =>{
|
const goToDetail = (notice) =>{
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url:'/pageSubPack/notice-list/noticeListDetails'
|
url:'/pageSubPack/notice-list/noticeListDetails?id=' + (notice.id || '')
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取列表接口
|
||||||
|
const loadNotices = async (isRefresh = false) => {
|
||||||
|
if (loading.value) return
|
||||||
|
loading.value = true
|
||||||
|
|
||||||
|
if (isRefresh) {
|
||||||
|
pageNum.value = 1
|
||||||
|
noMoreData.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const res = await getNoticeList({
|
||||||
|
pageNum: pageNum.value,
|
||||||
|
pageSize: pageSize
|
||||||
|
})
|
||||||
|
if (res.code === 200) {
|
||||||
|
const list = res.data.rows
|
||||||
|
if (isRefresh) {
|
||||||
|
noticeList.value = list
|
||||||
|
} else {
|
||||||
|
noticeList.value = [...noticeList.value, ...list]
|
||||||
|
}
|
||||||
|
if (list.length < pageSize) {
|
||||||
|
noMoreData.value = true
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
uni.showToast({ title: res.msg || '加载失败', icon: 'none' })
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
uni.showToast({ title: '网络异常', icon: 'none' })
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
refreshing.value = false
|
||||||
|
loadingMore.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 下拉刷新
|
||||||
|
const onRefresh = () => {
|
||||||
|
refreshing.value = true
|
||||||
|
loadNotices(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 上拉加载更多
|
||||||
|
const loadMore = () => {
|
||||||
|
if (noMoreData.value || loadingMore.value || loading.value) return
|
||||||
|
loadingMore.value = true
|
||||||
|
pageNum.value++
|
||||||
|
loadNotices()
|
||||||
|
}
|
||||||
|
|
||||||
// 返回
|
// 返回
|
||||||
const narBack = () =>{
|
const narBack = () =>{
|
||||||
if(uni.getStorageSync('sourcePage') === "index"){
|
if(uni.getStorageSync('sourcePage') === "index"){
|
||||||
@@ -134,6 +174,12 @@
|
|||||||
uni.removeStorageSync('sourcePage')
|
uni.removeStorageSync('sourcePage')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onLoad(() => {
|
||||||
|
const sysInfo = uni.getSystemInfoSync()
|
||||||
|
statusBarHeight.value = sysInfo.statusBarHeight || 0
|
||||||
|
loadNotices(true)
|
||||||
|
})
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
|||||||
@@ -75,9 +75,17 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, onMounted } from 'vue'
|
import { ref, onMounted } from 'vue'
|
||||||
// import { onLoad, onShow } from '@dcloudio/uni-app'
|
import { onLoad, onShow } from '@dcloudio/uni-app'
|
||||||
|
|
||||||
const isLoading = ref(false)
|
const isLoading = ref(false)
|
||||||
|
|
||||||
|
// =====方法====
|
||||||
|
onLoad((options) =>{
|
||||||
|
console.log('options',options.id)
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 下载文件
|
// 下载文件
|
||||||
const downloadFile = (fileName) => {
|
const downloadFile = (fileName) => {
|
||||||
uni.showModal({
|
uni.showModal({
|
||||||
|
|||||||
@@ -30,16 +30,14 @@
|
|||||||
v-for="item in displayedCommunities"
|
v-for="item in displayedCommunities"
|
||||||
:key="item.villageId"
|
:key="item.villageId"
|
||||||
class="community-item"
|
class="community-item"
|
||||||
|
:class="{ 'active-item': selectedItem && selectedItem.villageId === item.villageId }"
|
||||||
:id="'item-' + item.villageId"
|
:id="'item-' + item.villageId"
|
||||||
@tap="selectCommunity(item)"
|
@tap="selectCommunity(item)"
|
||||||
>
|
>
|
||||||
<view class="community-item-left">
|
<view class="community-item-left">
|
||||||
<image src="http://47.104.199.163:9090/images/home/community.png" style="width: 60rpx;height: 60rpx;"></image>
|
<image src="http://47.104.199.163:9090/images/home/community.png" style="width: 60rpx;height: 60rpx;"></image>
|
||||||
<!-- <uni-icons class="house-icon" type="home" size="24" color="#666"></uni-icons> -->
|
|
||||||
<view class="community-info">
|
<view class="community-info">
|
||||||
<text class="community-name">{{ item.villageName }}</text>
|
<text class="community-name">{{ item.villageName }}</text>
|
||||||
<!-- <text class="community-address">{{ item.address }}</text> -->
|
|
||||||
<!-- <text class="community-id">ID: {{ item.id }}</text> -->
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view v-if="selectedItem && selectedItem.villageId === item.villageId" class="selected-icon">
|
<view v-if="selectedItem && selectedItem.villageId === item.villageId" class="selected-icon">
|
||||||
@@ -57,7 +55,6 @@
|
|||||||
<uni-icons type="spinner-cycle" size="20" color="#007AFF" class="loading-icon"></uni-icons>
|
<uni-icons type="spinner-cycle" size="20" color="#007AFF" class="loading-icon"></uni-icons>
|
||||||
<text>正在加载...</text>
|
<text>正在加载...</text>
|
||||||
</view>
|
</view>
|
||||||
<!-- <text class="page-info">第 {{ currentPage }} 页 / 共 {{ totalPages }} 页</text> -->
|
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 没有更多数据 -->
|
<!-- 没有更多数据 -->
|
||||||
@@ -66,13 +63,13 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 空状态 -->
|
<!-- 空状态 -->
|
||||||
<view v-if="displayedCommunities.length === 0 && !isSearching" class="empty-state">
|
<view v-if="displayedCommunities.length === 0 && !isSearching && !isLoading" class="empty-state">
|
||||||
<uni-icons type="info" size="60" color="#ccc"></uni-icons>
|
<uni-icons type="info" size="60" color="#ccc"></uni-icons>
|
||||||
<text class="empty-text">暂无小区数据</text>
|
<text class="empty-text">暂无小区数据</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 搜索无结果 -->
|
<!-- 搜索无结果 -->
|
||||||
<view v-if="displayedCommunities.length === 0 && isSearching" class="empty-state">
|
<view v-if="displayedCommunities.length === 0 && isSearching && !isLoading" class="empty-state">
|
||||||
<uni-icons type="search" size="60" color="#ccc"></uni-icons>
|
<uni-icons type="search" size="60" color="#ccc"></uni-icons>
|
||||||
<text class="empty-text">未找到相关小区</text>
|
<text class="empty-text">未找到相关小区</text>
|
||||||
<text class="empty-tip">请尝试其他关键词</text>
|
<text class="empty-tip">请尝试其他关键词</text>
|
||||||
@@ -89,9 +86,6 @@
|
|||||||
>
|
>
|
||||||
确认选择
|
确认选择
|
||||||
</button>
|
</button>
|
||||||
<view v-if="selectedItem" class="selected-info">
|
|
||||||
已选: {{ selectedItem.name }}
|
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
@@ -99,17 +93,18 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed, onMounted, watch } from 'vue'
|
import { ref, computed, onMounted, watch } from 'vue'
|
||||||
import { onLoad } from '@dcloudio/uni-app'
|
import { onLoad } from '@dcloudio/uni-app'
|
||||||
// import {getVillageList} from "/pages/api/api.js"
|
import { getVillageList, getVillageSwitch } from "../api/api.js"
|
||||||
|
|
||||||
// 响应式数据
|
// 响应式数据
|
||||||
const searchText = ref('')
|
const searchText = ref('')
|
||||||
const selectedItem = ref(null)
|
const selectedItem = ref(null)
|
||||||
const scrollIntoViewId = ref('')
|
const scrollIntoViewId = ref('')
|
||||||
|
const currentVillageIdFromHome = ref('') // 首页传入的当前选中小区ID
|
||||||
|
|
||||||
// 分页相关
|
// 分页相关
|
||||||
const currentPage = ref(1)
|
const currentPage = ref(1)
|
||||||
const pageSize = 5
|
const pageSize = 5
|
||||||
const totalCommunities = ref([])
|
const totalCount = ref(0)
|
||||||
const displayedCommunities = ref([])
|
const displayedCommunities = ref([])
|
||||||
const hasMoreData = ref(true)
|
const hasMoreData = ref(true)
|
||||||
const isLoading = ref(false)
|
const isLoading = ref(false)
|
||||||
@@ -118,100 +113,84 @@ const isLoading = ref(false)
|
|||||||
const isSearching = ref(false)
|
const isSearching = ref(false)
|
||||||
let searchTimeout = null
|
let searchTimeout = null
|
||||||
|
|
||||||
// 所有小区数据
|
|
||||||
const allCommunities = ref([
|
|
||||||
// { id: 1, name: '北境碧桂园小区', address: '北境市光明区碧桂路1号' },
|
|
||||||
// { id: 2, name: '南湖花园小区', address: '南湖市滨湖区湖滨路28号' },
|
|
||||||
// { id: 3, name: '东城国际社区', address: '东城市新城区人民路156号' },
|
|
||||||
// { id: 4, name: '西湖雅苑', address: '西湖市风景区梅灵路88号' },
|
|
||||||
// { id: 5, name: '北境锦绣家园', address: '北境市朝阳区朝阳路56号' },
|
|
||||||
// { id: 6, name: '阳光100小区', address: '阳光市高新区创业路100号' },
|
|
||||||
// { id: 7, name: '绿城玫瑰园', address: '绿城市西湖区学院路188号' },
|
|
||||||
// { id: 8, name: '金地自在城', address: '金城市江干区金沙大道200号' },
|
|
||||||
// { id: 9, name: '万科城市花园', address: '万城市余杭区文一西路299号' },
|
|
||||||
// { id: 10, name: '保利中央公园', address: '保利市拱墅区莫干山路500号' },
|
|
||||||
// { id: 11, name: '龙湖天街小区', address: '龙湖市滨江区江南大道100号' },
|
|
||||||
])
|
|
||||||
|
|
||||||
// 计算属性
|
|
||||||
const totalPages = computed(() => {
|
|
||||||
return Math.ceil(totalCommunities.value.length / pageSize)
|
|
||||||
})
|
|
||||||
|
|
||||||
// =====方法======
|
// =====方法======
|
||||||
// 查询小区列表
|
// 查询已认证小区列表
|
||||||
const getCommunityList = () =>{
|
const getCommunityList = async (pageNum = 1, keyword = '') => {
|
||||||
let params = {
|
isLoading.value = true
|
||||||
keyword:searchText.value
|
|
||||||
}
|
|
||||||
getVillageList(params).then(res =>{
|
|
||||||
console.log('1111',res)
|
|
||||||
if(res.code === 200){
|
|
||||||
allCommunities.value = res.data
|
|
||||||
uni.showToast({
|
|
||||||
title:"查询成功",
|
|
||||||
icon:'success'
|
|
||||||
})
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
const params = {
|
||||||
|
pageNum,
|
||||||
|
pageSize,
|
||||||
|
keyword: keyword.trim()
|
||||||
|
}
|
||||||
|
|
||||||
|
const res = await getVillageList(params)
|
||||||
|
|
||||||
|
if (res.code === 200) {
|
||||||
|
const listData = res.data?.rows || res.data?.list || res.data || []
|
||||||
|
const total = res.data?.total || listData.length
|
||||||
|
|
||||||
|
if (pageNum === 1) {
|
||||||
|
displayedCommunities.value = listData
|
||||||
} else {
|
} else {
|
||||||
allCommunities.value = []
|
displayedCommunities.value = [...displayedCommunities.value, ...listData]
|
||||||
|
}
|
||||||
|
|
||||||
|
totalCount.value = total
|
||||||
|
hasMoreData.value = displayedCommunities.value.length < totalCount.value
|
||||||
|
|
||||||
|
// 默认选中:优先匹配传入的 villageId,否则选第一条(仅第一页时)
|
||||||
|
if (pageNum === 1 && displayedCommunities.value.length > 0) {
|
||||||
|
const targetId = currentVillageIdFromHome.value || uni.getStorageSync('currentVillageId') || ''
|
||||||
|
if (targetId) {
|
||||||
|
const matched = displayedCommunities.value.find(
|
||||||
|
item => String(item.villageId) === String(targetId)
|
||||||
|
)
|
||||||
|
selectedItem.value = matched || displayedCommunities.value[0]
|
||||||
|
} else {
|
||||||
|
selectedItem.value = displayedCommunities.value[0]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
displayedCommunities.value = []
|
||||||
|
hasMoreData.value = false
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title:"查询失败",
|
title: res.msg || "查询失败",
|
||||||
icon: 'error'
|
icon: 'error'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error('获取小区列表失败:', err)
|
||||||
|
displayedCommunities.value = []
|
||||||
|
hasMoreData.value = false
|
||||||
|
uni.showToast({
|
||||||
|
title: "网络异常",
|
||||||
|
icon: 'error'
|
||||||
})
|
})
|
||||||
}
|
} finally {
|
||||||
|
|
||||||
onLoad(() =>{
|
|
||||||
// getCommunityList()
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 加载分页数据
|
|
||||||
const loadPageData = (pageNum) => {
|
|
||||||
isLoading.value = true
|
|
||||||
|
|
||||||
// 模拟网络请求延迟
|
|
||||||
setTimeout(() => {
|
|
||||||
const startIndex = (pageNum - 1) * pageSize
|
|
||||||
const endIndex = startIndex + pageSize
|
|
||||||
const pageData = totalCommunities.value.slice(startIndex, endIndex)
|
|
||||||
|
|
||||||
if (pageNum === 1) {
|
|
||||||
displayedCommunities.value = pageData
|
|
||||||
} else {
|
|
||||||
displayedCommunities.value = [...displayedCommunities.value, ...pageData]
|
|
||||||
}
|
|
||||||
|
|
||||||
currentPage.value = pageNum
|
|
||||||
hasMoreData.value = displayedCommunities.value.length < totalCommunities.value.length
|
|
||||||
isLoading.value = false
|
isLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 滚动到新加载的内容
|
// 页面加载时初始化
|
||||||
if (pageNum > 1 && pageData.length > 0) {
|
onLoad((options) => {
|
||||||
setTimeout(() => {
|
currentVillageIdFromHome.value = options?.villageId || ''
|
||||||
scrollIntoViewId.value = 'item-' + pageData[0].id
|
getCommunityList(1)
|
||||||
}, 100)
|
})
|
||||||
}
|
|
||||||
}, 500)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 加载更多数据
|
// 加载更多数据
|
||||||
const loadMoreData = () => {
|
const loadMoreData = () => {
|
||||||
if (isLoading.value || !hasMoreData.value) return
|
if (isLoading.value || !hasMoreData.value) return
|
||||||
loadPageData(currentPage.value + 1)
|
getCommunityList(currentPage.value + 1, searchText.value)
|
||||||
|
currentPage.value += 1
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理搜索输入
|
// 处理搜索输入(防抖)
|
||||||
const handleSearchInput = () => {
|
const handleSearchInput = () => {
|
||||||
// 防抖处理
|
|
||||||
if (searchTimeout) {
|
if (searchTimeout) {
|
||||||
clearTimeout(searchTimeout)
|
clearTimeout(searchTimeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
searchTimeout = setTimeout(() => {
|
searchTimeout = setTimeout(() => {
|
||||||
handleSearch()
|
handleSearch()
|
||||||
}, 300)
|
}, 300)
|
||||||
@@ -219,30 +198,18 @@ const handleSearchInput = () => {
|
|||||||
|
|
||||||
// 处理搜索
|
// 处理搜索
|
||||||
const handleSearch = () => {
|
const handleSearch = () => {
|
||||||
const keyword = searchText.value.trim().toLowerCase()
|
const keyword = searchText.value.trim()
|
||||||
|
isSearching.value = !!keyword
|
||||||
if (!keyword) {
|
currentPage.value = 1
|
||||||
isSearching.value = false
|
getCommunityList(1, keyword)
|
||||||
totalCommunities.value = [...allCommunities.value]
|
|
||||||
loadPageData(1)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
isSearching.value = true
|
|
||||||
totalCommunities.value = allCommunities.value.filter(community =>
|
|
||||||
community.name.toLowerCase().includes(keyword) ||
|
|
||||||
community.address.toLowerCase().includes(keyword)
|
|
||||||
)
|
|
||||||
|
|
||||||
loadPageData(1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 清空搜索
|
// 清空搜索
|
||||||
const clearSearch = () => {
|
const clearSearch = () => {
|
||||||
searchText.value = ''
|
searchText.value = ''
|
||||||
isSearching.value = false
|
isSearching.value = false
|
||||||
totalCommunities.value = [...allCommunities.value]
|
currentPage.value = 1
|
||||||
loadPageData(1)
|
getCommunityList(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 选择小区
|
// 选择小区
|
||||||
@@ -251,7 +218,7 @@ const selectCommunity = (item) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 确认选择
|
// 确认选择
|
||||||
const handleConfirm = () => {
|
const handleConfirm = async () => {
|
||||||
if (!selectedItem.value) {
|
if (!selectedItem.value) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '请先选择小区',
|
title: '请先选择小区',
|
||||||
@@ -260,29 +227,51 @@ const handleConfirm = () => {
|
|||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
uni.showLoading({
|
||||||
|
title: '切换小区中...',
|
||||||
|
mask: true
|
||||||
|
})
|
||||||
|
const params = {
|
||||||
|
villageId: selectedItem.value.villageId,
|
||||||
|
}
|
||||||
|
const res = await getVillageSwitch(params)
|
||||||
|
uni.hideLoading()
|
||||||
|
|
||||||
uni.showModal({
|
if (res.code === 200) {
|
||||||
title: '确认选择',
|
if (res.data.villageId) {
|
||||||
content: `您已选择: ${selectedItem.value.name}\n地址: ${selectedItem.value.address}`,
|
selectedItem.value.villageId = res.data.villageId
|
||||||
success: (res) => {
|
}
|
||||||
if (res.confirm) {
|
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '选择成功',
|
title: '选择成功',
|
||||||
icon: 'success',
|
icon: 'success',
|
||||||
duration: 1500
|
duration: 1500
|
||||||
})
|
})
|
||||||
|
// 更新缓存并通知首页
|
||||||
// 这里可以触发回调或页面跳转
|
uni.setStorageSync('currentVillageId', selectedItem.value.villageId)
|
||||||
// uni.navigateBack() 或 emit('confirm', selectedItem.value)
|
uni.$emit('confirm', {
|
||||||
uni.$emit('confirm', selectedItem.value)
|
name: selectedItem.value.villageName,
|
||||||
// 模拟2秒后返回上一页
|
villageId: selectedItem.value.villageId
|
||||||
|
})
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
uni.navigateBack()
|
uni.navigateBack()
|
||||||
}, 1500)
|
}, 1000)
|
||||||
}
|
} else {
|
||||||
}
|
uni.showToast({
|
||||||
|
title: res.msg || '切换小区失败',
|
||||||
|
icon: 'error',
|
||||||
|
duration: 2000
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
} catch (err) {
|
||||||
|
uni.hideLoading()
|
||||||
|
uni.showToast({
|
||||||
|
title: '网络异常,请重试',
|
||||||
|
icon: 'error',
|
||||||
|
duration: 2000
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 监听搜索文本变化
|
// 监听搜索文本变化
|
||||||
watch(searchText, (newVal) => {
|
watch(searchText, (newVal) => {
|
||||||
@@ -293,19 +282,13 @@ watch(searchText, (newVal) => {
|
|||||||
|
|
||||||
// 初始化
|
// 初始化
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
// 初始化数据
|
if (displayedCommunities.value.length === 0 && !isLoading.value) {
|
||||||
totalCommunities.value = [...allCommunities.value]
|
getCommunityList(1)
|
||||||
loadPageData(1)
|
|
||||||
|
|
||||||
// 默认选中第一项
|
|
||||||
if (displayedCommunities.value.length > 0) {
|
|
||||||
selectedItem.value = displayedCommunities.value[0]
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
/* 页面容器 */
|
|
||||||
.container {
|
.container {
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
background-color: #f5f5f5;
|
background-color: #f5f5f5;
|
||||||
@@ -314,7 +297,6 @@ onMounted(() => {
|
|||||||
padding: 40rpx;
|
padding: 40rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 搜索区域 */
|
|
||||||
.search-container {
|
.search-container {
|
||||||
padding: 20rpx 30rpx;
|
padding: 20rpx 30rpx;
|
||||||
background-color: #ffffff;
|
background-color: #ffffff;
|
||||||
@@ -372,13 +354,10 @@ onMounted(() => {
|
|||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 小区列表 */
|
|
||||||
.community-list {
|
.community-list {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
/* padding: 0 30rpx; */
|
|
||||||
margin-top: 20rpx;
|
margin-top: 20rpx;
|
||||||
margin-bottom: 180rpx;
|
margin-bottom: 180rpx;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.community-item {
|
.community-item {
|
||||||
@@ -393,9 +372,9 @@ onMounted(() => {
|
|||||||
transition: all 0.2s;
|
transition: all 0.2s;
|
||||||
}
|
}
|
||||||
|
|
||||||
.community-item:active {
|
.community-item:active,
|
||||||
background-color: #f9f9f9;
|
.community-item.active-item {
|
||||||
transform: translateY(2rpx);
|
background-color: #e6f2ff;
|
||||||
}
|
}
|
||||||
|
|
||||||
.community-item-left {
|
.community-item-left {
|
||||||
@@ -404,39 +383,23 @@ onMounted(() => {
|
|||||||
flex: 1;
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.house-icon {
|
|
||||||
margin-right: 20rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.community-info {
|
.community-info {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
margin-left: 20rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.community-name {
|
.community-name {
|
||||||
font-size: 32rpx;
|
font-size: 32rpx;
|
||||||
color: #333;
|
color: #333;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
margin-bottom: 8rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.community-address {
|
|
||||||
font-size: 24rpx;
|
|
||||||
color: #999;
|
|
||||||
margin-bottom: 5rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.community-id {
|
|
||||||
font-size: 22rpx;
|
|
||||||
color: #ccc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.selected-icon {
|
.selected-icon {
|
||||||
margin-left: 20rpx;
|
margin-left: 20rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 加载更多容器 */
|
|
||||||
.load-more-container {
|
.load-more-container {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@@ -483,12 +446,6 @@ onMounted(() => {
|
|||||||
to { transform: rotate(360deg); }
|
to { transform: rotate(360deg); }
|
||||||
}
|
}
|
||||||
|
|
||||||
.page-info {
|
|
||||||
font-size: 24rpx;
|
|
||||||
color: #999;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 没有更多数据 */
|
|
||||||
.no-more-data {
|
.no-more-data {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
padding: 40rpx 0;
|
padding: 40rpx 0;
|
||||||
@@ -496,7 +453,6 @@ onMounted(() => {
|
|||||||
font-size: 28rpx;
|
font-size: 28rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 空状态 */
|
|
||||||
.empty-state {
|
.empty-state {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@@ -517,7 +473,6 @@ onMounted(() => {
|
|||||||
color: #ccc;
|
color: #ccc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 确认区域 */
|
|
||||||
.confirm-area {
|
.confirm-area {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
@@ -544,17 +499,6 @@ onMounted(() => {
|
|||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
.selected-info {
|
|
||||||
text-align: center;
|
|
||||||
font-size: 24rpx;
|
|
||||||
color: #666;
|
|
||||||
margin-top: 20rpx;
|
|
||||||
padding: 10rpx;
|
|
||||||
background-color: #f8f8f8;
|
|
||||||
border-radius: 8rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 适配不同屏幕 */
|
|
||||||
@media (min-width: 768px) {
|
@media (min-width: 768px) {
|
||||||
.container {
|
.container {
|
||||||
max-width: 500px;
|
max-width: 500px;
|
||||||
|
|||||||
@@ -157,9 +157,8 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import {onLoad,onUnload} from '@dcloudio/uni-app'
|
import {onLoad,onUnload,onShow} from '@dcloudio/uni-app'
|
||||||
import {getNoticeList} from "/pageSubPack/api/api.js"
|
import {getNoticeLatest,getCurrentVillage} from "/pageSubPack/api/api.js"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 列表数据状态
|
// 列表数据状态
|
||||||
@@ -187,14 +186,17 @@ const activityList = ref([
|
|||||||
|
|
||||||
// },
|
// },
|
||||||
])
|
])
|
||||||
const currentCommunity = ref('碧桂园小区')
|
const currentCommunity = ref('请认证小区')
|
||||||
|
const currentVillageId = ref('')
|
||||||
const bannerList = ref([
|
const bannerList = ref([
|
||||||
'http://47.104.199.163:9090/images/home/banner.png',
|
'http://47.104.199.163:9090/images/home/banner.png',
|
||||||
|
|
||||||
])
|
])
|
||||||
const noticeText = ref('公告公告本小区今天安装了摄像头')
|
const noticeText = ref('暂无公告')
|
||||||
|
const noticeId = ref('')
|
||||||
|
|
||||||
// =======方法=======
|
// =======方法=======
|
||||||
|
// 公告跳转
|
||||||
const getNoticeMore = () =>{
|
const getNoticeMore = () =>{
|
||||||
uni.setStorageSync('sourcePage',"index")
|
uni.setStorageSync('sourcePage',"index")
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
@@ -203,31 +205,82 @@ const getNoticeMore = () =>{
|
|||||||
}
|
}
|
||||||
// 接收选择小区返回的参数
|
// 接收选择小区返回的参数
|
||||||
const slelctHomeData = (data) =>{
|
const slelctHomeData = (data) =>{
|
||||||
// console.log('收到B页面返回的数据:', data)
|
console.log('收到B页面返回的数据:', data)
|
||||||
|
if(data.name){
|
||||||
currentCommunity.value = data.name
|
currentCommunity.value = data.name
|
||||||
}
|
}
|
||||||
|
if(data.villageId){
|
||||||
|
currentVillageId.value = data.villageId
|
||||||
|
}
|
||||||
|
getCurrentCommunityData()
|
||||||
|
}
|
||||||
|
// 获取当前认证小区的方法
|
||||||
|
const getCurrentCommunityData = () => {
|
||||||
|
getCurrentVillage().then(res =>{
|
||||||
|
if(res.code === 200 && res.data && res.data.villageId){
|
||||||
|
currentCommunity.value = res.data.villageName || '未命名小区'
|
||||||
|
currentVillageId.value = res.data.villageId
|
||||||
|
uni.setStorageSync('currentVillageId',res.data.villageId)
|
||||||
|
}else{
|
||||||
|
currentCommunity.value = '请认证小区'
|
||||||
|
currentVillageId.value = ''
|
||||||
|
}
|
||||||
|
}).catch(err =>{
|
||||||
|
uni.showToast({
|
||||||
|
title: '网络异常',
|
||||||
|
icon: 'error'
|
||||||
|
});
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// 获取小区公告
|
// 获取小区公告
|
||||||
// const getNoticeData = () =>{
|
const getNoticeData = async() =>{
|
||||||
// getNoticeList().then(res =>{
|
try{
|
||||||
// if(res.code === 200){
|
const res = await getNoticeLatest()
|
||||||
// noticeText.value = res.data.noticeTitle
|
if (res.code === 200) {
|
||||||
|
if(res.data){
|
||||||
|
noticeText.value = res.data.noticeTitle || ''
|
||||||
|
noticeId.value = res.data.noticeId || ''
|
||||||
|
}else{
|
||||||
|
noticeText.value = ''
|
||||||
|
noticeId.value = ''
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
uni.showToast({
|
||||||
|
title: res.msg || '获取通知失败',
|
||||||
|
icon: 'none',
|
||||||
|
duration: 2000
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
// console.error('获取通知数据异常:', err)
|
||||||
|
uni.showToast({
|
||||||
|
title: err.msg,
|
||||||
|
icon: 'error',
|
||||||
|
duration: 1000
|
||||||
|
})
|
||||||
|
noticeText.value = ''
|
||||||
|
noticeId.value = ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onShow(() =>{
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
// }else{
|
|
||||||
// noticeText.value = ''
|
|
||||||
// }
|
|
||||||
// }).catch(err =>{
|
|
||||||
// uni.showToast({
|
|
||||||
// title: '网络异常',
|
|
||||||
// icon: 'error'
|
|
||||||
// });
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
onLoad(() => {
|
onLoad(() => {
|
||||||
// 绑定全局事件监听
|
// 绑定全局事件监听
|
||||||
uni.$on('confirm', slelctHomeData)
|
uni.$on('confirm', slelctHomeData)
|
||||||
// getNoticeData()
|
|
||||||
|
|
||||||
|
// 页面加载时,先判断是否有token,有则获取认证小区
|
||||||
|
const token = uni.getStorageSync('token') || '';
|
||||||
|
const currentVillageId = uni.getStorageSync('currentVillageId');
|
||||||
|
if (token && currentVillageId && currentVillageId !== '0' && currentVillageId !== 0) {
|
||||||
|
getCurrentCommunityData(); // 加载时获取认证小区
|
||||||
|
}
|
||||||
|
getNoticeData()
|
||||||
})
|
})
|
||||||
|
|
||||||
// 页面销毁时移除监听(防止内存泄漏)
|
// 页面销毁时移除监听(防止内存泄漏)
|
||||||
@@ -250,33 +303,32 @@ const payMentClick =() =>{
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
// 点击小区选择
|
// 点击小区选择
|
||||||
// const navigateToPage = () => {
|
|
||||||
// // 获取登录状态 / token
|
|
||||||
// const token = uni.getStorageSync('token') || '';
|
|
||||||
// // 获取是否已经认证
|
|
||||||
// const userInfo = uni.getStorageSync('userInfo') || {};
|
|
||||||
// // 未登录 / 未认证 → 去我的页面(去认证)
|
|
||||||
// // 已登录 / 已认证 → 去选择小区
|
|
||||||
// if (!token || !userInfo.isAuth) {
|
|
||||||
// uni.showToast({
|
|
||||||
// title: '请先完成实名认证',
|
|
||||||
// icon: 'none'
|
|
||||||
// });
|
|
||||||
// // 跳转到我的页面
|
|
||||||
// uni.switchTab({
|
|
||||||
// url: '/pages/myIndex/myIndex'
|
|
||||||
// });
|
|
||||||
// } else {
|
|
||||||
// uni.navigateTo({
|
|
||||||
// url: '/pageSubPack/notice-list/selectHome'
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
const navigateToPage = () => {
|
const navigateToPage = () => {
|
||||||
|
const token = uni.getStorageSync('token') || '';
|
||||||
|
const cachedVillageId = uni.getStorageSync('currentVillageId');
|
||||||
|
// 未登录 或 未绑定小区 → 去我的页面认证
|
||||||
|
if (!token || !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);
|
||||||
|
} else {
|
||||||
|
// 已登录且已绑定小区 → 去选择小区
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: '/pageSubPack/notice-list/selectHome'
|
url: `/pageSubPack/notice-list/selectHome?villageId=${cachedVillageId}`
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
const onlineRepairClick = () =>{
|
const onlineRepairClick = () =>{
|
||||||
uni.setStorageSync('sourcePage',"index")
|
uni.setStorageSync('sourcePage',"index")
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
|
|||||||
Reference in New Issue
Block a user