修复bug
This commit is contained in:
@@ -99,6 +99,7 @@
|
||||
<script setup>
|
||||
import { ref, computed, onUnmounted } from 'vue'
|
||||
import { getLoginBySms, getSendCode } from '../../api/api.js'
|
||||
import { clearAccountStorage } from '../../api/request.js'
|
||||
import PrivacyPopup from '@/components/privacy-popup/privacy-popup.vue'
|
||||
import { usePermStore } from '@/stores/usePermStore'
|
||||
|
||||
@@ -249,6 +250,8 @@ const handleLogin = () => {
|
||||
cid: push_cid
|
||||
}
|
||||
permStore.clearPerm()
|
||||
// 清除上个账号的所有缓存,防止新账号显示旧数据
|
||||
clearAccountStorage()
|
||||
getLoginBySms(params)
|
||||
.then(res => {
|
||||
if (res.code === 200) {
|
||||
@@ -259,8 +262,6 @@ const handleLogin = () => {
|
||||
if (res.data.user.userId) {
|
||||
uni.setStorageSync('userId', res.data.user.userId)
|
||||
}
|
||||
// 清掉上次账号的小区缓存,防止新账号显示旧小区
|
||||
uni.removeStorageSync('currentVillage')
|
||||
// 存当前绑定的小区ID,0 表示未绑定
|
||||
const currentVillageId = res.data.currentVillageId || 0
|
||||
uni.setStorageSync('currentVillageId', currentVillageId)
|
||||
|
||||
@@ -98,6 +98,7 @@
|
||||
import { ref, computed } from 'vue'
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import { getLoginPassword } from '../../api/api.js'
|
||||
import { clearAccountStorage } from '../../api/request.js'
|
||||
import PrivacyPopup from '@/components/privacy-popup/privacy-popup.vue'
|
||||
import { usePermStore } from '@/stores/usePermStore'
|
||||
|
||||
@@ -204,13 +205,13 @@ const handleLogin = () => {
|
||||
cid: push_cid
|
||||
}
|
||||
permStore.clearPerm()
|
||||
// 清除上个账号的所有缓存,防止新账号显示旧数据
|
||||
clearAccountStorage()
|
||||
getLoginPassword(params)
|
||||
.then(res => {
|
||||
// console.log('33333',res)
|
||||
if (res.code === 200) {
|
||||
uni.setStorageSync('token', res.data.token)
|
||||
// 清掉上次账号的小区缓存,防止新账号显示旧小区
|
||||
uni.removeStorageSync('currentVillage')
|
||||
// 存用户ID
|
||||
// if(res.data) {
|
||||
// // 存当前绑定的小区ID,0 表示未绑定
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { ref } from 'vue'
|
||||
import {onLoad} from '@dcloudio/uni-app'
|
||||
import { getVillageList,switchVillage} from '../../api/api.js'
|
||||
|
||||
@@ -64,15 +64,26 @@
|
||||
const res = await getVillageList({ villageName })
|
||||
if (res.code === 200) {
|
||||
displayedCommunities.value = res.data
|
||||
// 自动选中传入的小区
|
||||
if (defaultVillageId.value) {
|
||||
const found = displayedCommunities.value.find(
|
||||
item => String(item.id) === String(defaultVillageId.value)
|
||||
)
|
||||
if (found) {
|
||||
selectedItem.value = found
|
||||
}
|
||||
|
||||
// 如果当前选中项不在新的列表中(搜索过滤掉了),则清空选中状态
|
||||
if (selectedItem.value) {
|
||||
const stillExists = displayedCommunities.value.find(
|
||||
item => String(item.id) === String(selectedItem.value.id)
|
||||
)
|
||||
if (!stillExists) {
|
||||
selectedItem.value = null
|
||||
}
|
||||
}
|
||||
|
||||
// 自动选中传入的默认小区(仅在默认小区存在于列表时)
|
||||
if (defaultVillageId.value) {
|
||||
const found = displayedCommunities.value.find(
|
||||
item => String(item.id) === String(defaultVillageId.value)
|
||||
)
|
||||
if (found) {
|
||||
selectedItem.value = found
|
||||
}
|
||||
}
|
||||
} else {
|
||||
uni.showToast({ title: res.msg || '获取数据失败', icon: 'none' })
|
||||
}
|
||||
@@ -82,11 +93,13 @@
|
||||
isLoading.value = false
|
||||
}
|
||||
}
|
||||
// 接收传入的参数
|
||||
// 接收传入的参数,并初始加载小区列表
|
||||
onLoad((options) => {
|
||||
if (options?.villageId) {
|
||||
defaultVillageId.value = options.villageId
|
||||
}
|
||||
// 在 onLoad 中调用初始加载,确保 defaultVillageId 已设置
|
||||
fetchVillageList()
|
||||
})
|
||||
|
||||
// 处理搜索输入(防抖)
|
||||
@@ -147,11 +160,6 @@
|
||||
// })
|
||||
}
|
||||
|
||||
|
||||
// 初始化
|
||||
onMounted(() => {
|
||||
fetchVillageList()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
import { ref } from 'vue'
|
||||
import { onShow } from '@dcloudio/uni-app'
|
||||
import { logout, getSettingInfo } from '../../api/api.js'
|
||||
import { clearAccountStorage } from '../../api/request.js'
|
||||
import { usePermStore } from '@/stores/usePermStore'
|
||||
|
||||
const permStore = usePermStore()
|
||||
@@ -121,9 +122,10 @@ const confirmLogout = () => {
|
||||
.then(res => {
|
||||
if (res.code === 200) {
|
||||
permStore.clearPerm()
|
||||
uni.clearStorageSync()
|
||||
clearAccountStorage()
|
||||
uni.showToast({ title: '退出登录成功', icon: 'success' })
|
||||
uni.redirectTo({ url: '/pageSubPack/loginSub/pwd-login' })
|
||||
// 使用 reLaunch 销毁所有页面(包括 tab 页),确保新账号登录后页面重新初始化
|
||||
uni.reLaunch({ url: '/pageSubPack/loginSub/pwd-login' })
|
||||
} else {
|
||||
uni.showToast({ title: res.msg || '退出失败', icon: 'none' })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user