登录逻辑修改

parent 56979060
...@@ -16,10 +16,13 @@ declare module 'vue' { ...@@ -16,10 +16,13 @@ declare module 'vue' {
VanForm: typeof import('vant/es')['Form'] VanForm: typeof import('vant/es')['Form']
VanIcon: typeof import('vant/es')['Icon'] VanIcon: typeof import('vant/es')['Icon']
VanList: typeof import('vant/es')['List'] VanList: typeof import('vant/es')['List']
VanNoticeBar: typeof import('vant/es')['NoticeBar']
VanPopup: typeof import('vant/es')['Popup'] VanPopup: typeof import('vant/es')['Popup']
VanPullRefresh: typeof import('vant/es')['PullRefresh'] VanPullRefresh: typeof import('vant/es')['PullRefresh']
VanSearch: typeof import('vant/es')['Search'] VanSearch: typeof import('vant/es')['Search']
VanSticky: typeof import('vant/es')['Sticky'] VanSticky: typeof import('vant/es')['Sticky']
VanSwipe: typeof import('vant/es')['Swipe']
VanSwipeItem: typeof import('vant/es')['SwipeItem']
VanTab: typeof import('vant/es')['Tab'] VanTab: typeof import('vant/es')['Tab']
VanTabs: typeof import('vant/es')['Tabs'] VanTabs: typeof import('vant/es')['Tabs']
VanTextEllipsis: typeof import('vant/es')['TextEllipsis'] VanTextEllipsis: typeof import('vant/es')['TextEllipsis']
......
...@@ -6,13 +6,13 @@ import { loginBySgy } from '@/api/account' ...@@ -6,13 +6,13 @@ import { loginBySgy } from '@/api/account'
const userStore = useUserStore() const userStore = useUserStore()
onLaunch(async () => { onLaunch(async () => {
// #ifdef H5-SGY // #ifdef H5-SGY
if (import.meta.env.VITE_APP_ENV === 'production') { // if (import.meta.env.VITE_APP_ENV === 'production') {
userStore.logout() // userStore.logout()
fastLoginBySgy() // fastLoginBySgy()
return // return
} else { // } else {
if (userStore.logout) await signIn2(); // if (userStore.logout) await signIn2();
} // }
// #endif // #endif
}); });
......
...@@ -75,6 +75,7 @@ ...@@ -75,6 +75,7 @@
import { showToast, showLoadingToast, closeToast } from 'vant' import { showToast, showLoadingToast, closeToast } from 'vant'
import { loginByPassword, loginBySgy } from '@/api/account' import { loginByPassword, loginBySgy } from '@/api/account'
import useUserStore from '@/store/user' import useUserStore from '@/store/user'
import testJson from '@/utils/test.json';
const router = useRouter() const router = useRouter()
const userStore = useUserStore() const userStore = useUserStore()
...@@ -85,6 +86,19 @@ const formData = ref({ ...@@ -85,6 +86,19 @@ const formData = ref({
account: '', account: '',
password: '' password: ''
}) })
onLoad(async() => {
if (import.meta.env.VITE_APP_ENV === 'development') {
if (userStore.logout) await signIn2();
return
}
if(xma.xh.isMediaConvergenceXinhuaApp()) {
userStore.logout()
fastLoginBySgy()
}
})
const login = async () => { const login = async () => {
if (!formData.value.account) { if (!formData.value.account) {
showToast('请输入用户名') showToast('请输入用户名')
...@@ -133,10 +147,26 @@ const fastLoginBySgy = () => { ...@@ -133,10 +147,26 @@ const fastLoginBySgy = () => {
icon: 'success' icon: 'success'
}) })
// router.pushTab({ name: 'home' }) // router.pushTab({ name: 'home' })
router.back() // router.back()
router.push({ name: 'home' })
} }
}); });
} }
// 登录
const signIn2 = async () => {
showLoadingToast({
title: '加载中...',
mask: true,
});
sgyLoginParams.value.encryptDataMap = testJson
const res = await loginBySgy(sgyLoginParams.value)
console.log(res)
userStore.login(res)
closeToast()
// router.pushTab({ name: 'home' })
router.push({ name: 'mine' })
};
</script> </script>
<style scoped> <style scoped>
......
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