feat: 调整优化登录的逻辑
This commit is contained in:
@@ -11,18 +11,41 @@
|
||||
<text class="title">我的</text>
|
||||
</view>
|
||||
|
||||
<MineSetting />
|
||||
<MineSetting v-if="isDrawerVisible" />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import MineSetting from "./MineSetting.vue";
|
||||
import { defineEmits } from "vue";
|
||||
import { defineEmits, ref, onMounted, onUnmounted } from "vue";
|
||||
const emits = defineEmits(["closeDrawer"]);
|
||||
|
||||
const isDrawerVisible = ref(false);
|
||||
|
||||
const closeDrawer = () => {
|
||||
isDrawerVisible.value = false;
|
||||
emits("closeDrawer");
|
||||
};
|
||||
|
||||
// 监听抽屉显示事件
|
||||
const handleDrawerShow = () => {
|
||||
isDrawerVisible.value = true;
|
||||
};
|
||||
|
||||
// 监听抽屉隐藏事件
|
||||
const handleDrawerHide = () => {
|
||||
isDrawerVisible.value = false;
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
uni.$on("drawerShow", handleDrawerShow);
|
||||
uni.$on("drawerHide", handleDrawerHide);
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
uni.$off("drawerShow", handleDrawerShow);
|
||||
uni.$off("drawerHide", handleDrawerHide);
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
@@ -36,9 +36,9 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted } from "vue";
|
||||
import { ref } from "vue";
|
||||
import { onShow } from "@dcloudio/uni-app";
|
||||
import { getLoginUserPhone } from "@/request/api/LoginApi";
|
||||
import { checkToken } from "@/hooks/useGoLogin";
|
||||
|
||||
// 假数据
|
||||
const userInfo = ref({
|
||||
@@ -60,11 +60,9 @@ const menuList = ref([
|
||||
{ label: "订阅消息", type: "action", action: "subscribeMessage" },
|
||||
]);
|
||||
|
||||
// 生命周期钩子
|
||||
onMounted(() => {
|
||||
checkToken().then(() => {
|
||||
getLoginUserPhoneInfo();
|
||||
});
|
||||
// 页面生命周期钩子 - 页面显示时调用
|
||||
onShow(() => {
|
||||
getLoginUserPhoneInfo();
|
||||
});
|
||||
|
||||
const getLoginUserPhoneInfo = async () => {
|
||||
|
||||
Reference in New Issue
Block a user