登录

parent d250007c
<script setup lang="ts">
onLaunch(() => {
console.log('App Launch');
<script setup>
import useUserStore from '@/store/user'
import { showToast, showLoadingToast, closeToast } from 'vant'
import testJson from '@/utils/test.json';
import { loginBySgy } from '@/api/account'
const userStore = useUserStore()
onLaunch(async () => {
// #ifdef H5-SGY
if (import.meta.env.VITE_APP_ENV === 'production') {
userStore.logout()
fastLoginBySgy()
return
} else {
if (userStore.logout) await signIn2();
}
// #endif
});
onShow(() => {
console.log('App Show');
console.log('App Show');
});
onHide(() => {
console.log('App Hide');
console.log('App Hide');
});
const sgyLoginParams = ref({
appid: import.meta.env.VITE_APP_SGY_APPID,
type: "sgy",
encryptDataMap: {},
systemcode: import.meta.env.VITE_APP_SYSTEM_CODE
})
// 登录
const signIn2 = async () => {
showLoadingToast({
title: '加载中...',
mask: true,
});
sgyLoginParams.value.encryptDataMap = testJson
const res = await loginBySgy(sgyLoginParams.value)
console.log(res)
userStore.login(res)
closeToast()
};
const fastLoginBySgy = () => {
xma.xh.getUserProfile({
range: ['ACCOUNT', 'MOBILE'],
async success(info) {
showLoadingToast({
message: '登录中',
forbidClick: true,
duration: 0
})
sgyLoginParams.value.encryptDataMap = info.data
const res = await loginBySgy(sgyLoginParams.value)
userStore.login(res)
closeToast()
}
});
}
</script>
<style></style>
......@@ -6,14 +6,6 @@
}
},
"pages": [ // pages 数组中第一项表示应用启动页
{
"path": "pages/home/loading",
"name": "loading",
"style": {
"navigationBarTitleText": "",
"navigationStyle": "custom"
}
},
{
"path": "pages/home/indexNew",
"name": "home",
......
......@@ -114,7 +114,7 @@ const sgyLoginParams = ref({
})
const fastLoginBySgy = () => {
xma.xh.getUserProfile({
range: ['ACCOUNT', 'MOBILE', 'CITIZEN'],
range: ['ACCOUNT', 'MOBILE'],
async success(info) {
console.log(info)
showLoadingToast({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment