修改bug
This commit is contained in:
@@ -221,8 +221,8 @@ const handleLogin = () => {
|
||||
if (res.data) {
|
||||
uni.setStorageSync('token', res.data.token)
|
||||
// 存用户ID
|
||||
if (res.data.userId) {
|
||||
uni.setStorageSync('userId', res.data.userId)
|
||||
if (res.data.user.userId) {
|
||||
uni.setStorageSync('userId', res.data.user.userId)
|
||||
}
|
||||
// 清掉上次账号的小区缓存,防止新账号显示旧小区
|
||||
uni.removeStorageSync('currentVillage')
|
||||
|
||||
@@ -118,6 +118,7 @@
|
||||
switchVillage({ villageId: selectedItem.value.id }).then((res) =>{
|
||||
if(res.code === 200){
|
||||
uni.showToast({ title: '切换成功', icon: 'success', duration: 1500 })
|
||||
uni.hideLoading()
|
||||
uni.$emit('confirm', selectedItem.value)
|
||||
setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
|
||||
@@ -46,8 +46,16 @@
|
||||
:current="current"
|
||||
mode="default"
|
||||
>
|
||||
<swiper class="swiper-box" :current="current" @change="onSwiperChange" autoplay>
|
||||
<swiper-item v-for="(item, index) in bannerList" :key="index">
|
||||
<swiper
|
||||
class="swiper-box"
|
||||
:current="current"
|
||||
@change="onSwiperChange"
|
||||
autoplay
|
||||
circular
|
||||
:interval="5000"
|
||||
:duration="500"
|
||||
>
|
||||
<swiper-item v-for="(item, index) in bannerList" :key="item.id || item.url || index">
|
||||
<view class="swiper-item">
|
||||
<image :src="item.url" style="width: 100%; height: 100%"></image>
|
||||
</view>
|
||||
@@ -166,7 +174,7 @@ import {
|
||||
|
||||
// 列表数据状态
|
||||
const current = ref(0)
|
||||
const currentCommunity = ref('请选择小区')
|
||||
const currentCommunity = ref('请先绑定房屋')
|
||||
const bannerList = ref([])
|
||||
const noticeText = ref('暂无公告')
|
||||
const allCount = ref(0) // 全部巡检
|
||||
@@ -239,7 +247,7 @@ const goToReport = () => {
|
||||
// 获取当前小区
|
||||
const currentVillageData = () => {
|
||||
// 先重置,避免新账号无小区时仍显示旧账号的小区
|
||||
currentCommunity.value = '请选择小区'
|
||||
currentCommunity.value = '请先绑定房屋'
|
||||
getCurrentVillage()
|
||||
.then(res => {
|
||||
const data = res.data
|
||||
@@ -290,7 +298,12 @@ function getbannarData() {
|
||||
getBannarList()
|
||||
.then(res => {
|
||||
if (res.code === 200 && res.data) {
|
||||
bannerList.value = res.data
|
||||
// 只有数据真正变化时才更新,避免 swiper 重新渲染导致闪动
|
||||
const newData = res.data
|
||||
const oldData = bannerList.value
|
||||
if (JSON.stringify(newData) !== JSON.stringify(oldData)) {
|
||||
bannerList.value = newData
|
||||
}
|
||||
} else {
|
||||
bannerList.value = []
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user