feat: 登录的逻辑调整
This commit is contained in:
@@ -38,20 +38,11 @@
|
||||
<!-- 同意隐私协议并获取手机号按钮 -->
|
||||
|
||||
<button
|
||||
v-if="!isAgree"
|
||||
class="login-btn"
|
||||
type="primary"
|
||||
@click="handleAgreeAndGetPhone"
|
||||
>
|
||||
手机号快捷登录
|
||||
</button>
|
||||
|
||||
<button
|
||||
v-if="isAgree && !appStore.tokenExpired"
|
||||
class="login-btn"
|
||||
type="primary"
|
||||
open-type="getPhoneNumber"
|
||||
:open-type="needWxLogin ? 'getPhoneNumber' : ''"
|
||||
@getphonenumber="getPhoneNumber"
|
||||
@click="handleAgreeAndGetPhone"
|
||||
>
|
||||
手机号快捷登录
|
||||
</button>
|
||||
@@ -67,19 +58,19 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { onShow } from "@dcloudio/uni-app";
|
||||
import { ref, computed } from "vue";
|
||||
import {
|
||||
getServiceAgreement,
|
||||
getPrivacyAgreement,
|
||||
} from "@/request/api/LoginApi";
|
||||
import { onLogin, goBack } from "@/hooks/useGoLogin";
|
||||
import { onLogin, goBack, loginAuth, refreshToken } from "@/hooks/useGoLogin";
|
||||
import CheckBox from "@/components/CheckBox/index.vue";
|
||||
import AgreePopup from "./components/AgreePopup/index.vue";
|
||||
import { zniconsMap } from "@/static/fonts/znicons.js";
|
||||
import { getCurrentConfig } from "@/constant/base";
|
||||
import { useAppStore } from "@/store";
|
||||
const appStore = useAppStore();
|
||||
|
||||
const needWxLogin = ref(false);
|
||||
const isAgree = ref(false);
|
||||
const visible = ref(false);
|
||||
const serviceAgreement = ref("");
|
||||
@@ -90,6 +81,11 @@ const logo = computed(() => getCurrentConfig().logo);
|
||||
|
||||
// 同意隐私协议并获取手机号
|
||||
const handleAgreeAndGetPhone = () => {
|
||||
// 如果需要微信登录,直接返回
|
||||
if (needWxLogin.value) {
|
||||
return
|
||||
}
|
||||
|
||||
if (!isAgree.value) {
|
||||
uni.showToast({
|
||||
title: "请先同意服务协议和隐私协议",
|
||||
@@ -97,6 +93,8 @@ const handleAgreeAndGetPhone = () => {
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
refreshToken().then(() => goBack());
|
||||
};
|
||||
|
||||
const getPhoneNumber = (e) => {
|
||||
@@ -141,6 +139,13 @@ const getPrivacyAgreementData = async () => {
|
||||
};
|
||||
|
||||
getPrivacyAgreementData();
|
||||
|
||||
// 页面显示时刷新token
|
||||
onShow(async () => {
|
||||
const res = await refreshToken();
|
||||
|
||||
needWxLogin.value = res;
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
Reference in New Issue
Block a user