hldy_xcx/pages/login/callback.vue

165 lines
3.5 KiB
Vue

<template>
<view class="login-container">
<!-- 性能最好 -->
<image :class="playfirst? `login-imge`:`login-imge-an`"
src="https://www.focusnu.com/media/directive/login/firstdonghua.png" mode="widthFix" lazy-load="true" />
<view class="loading">
努力加载中
<!-- <view v-for="(item,index) in [0,0,0]" :key="index" class="dian" :style="num==index?{marginTop:`-10rpx`}:{}" >
.
</view> -->
</view>
</view>
</template>
<script setup>
import {
onLoad
} from '@dcloudio/uni-app';
import {
reactive,
ref,
onMounted,
onUnmounted
} from 'vue';
import {
getOpenid,
getMessage
} from '@/api/loginApi.js'
const playfirst = ref(false);
const superLogin = () => {
uni.login({
provider: 'weixin',
success(res) {
getOpenid(res.code).then(res => {
let openid = res.data.openid
uni.setStorageSync("openid", openid)
getMessage(openid).then(res => {
uni.setStorageSync('tel', res.result.tel);
uni.setStorageSync('token', res.result.token);
uni.setStorageSync('serverUrl', res.result.serverUrl);
uni.setStorageSync('platId', res.result.platId);
uni.setStorageSync('izJg', res.result.izJg);
uni.setStorageSync('izJs', res.result.izJs);
uni.setStorageSync('izYg', res.result.izYg);
uni.setStorageSync('allinfo', res.result);
// console.log("allinfo",res.result.id)
// return
if (!res.result.tel) {
uni.reLaunch({
url: `/pages/login/xuanchuan`
});
} else {
if (uni.getStorageSync('special')) {
uni.reLaunch({
url: `/pages/login/specialloginafther`
});
} else {
switch (res.result.advisoryType) {
case `1`:
uni.reLaunch({
url: `/pages/oldmanindex/index`
});
break;
case `2`:
uni.reLaunch({
url: `/pages/yuangongindex/index`
});
break;
case `3`:
uni.reLaunch({
url: `/pages/index/index`
});
break;
default:
uni.reLaunch({
url: `/pages/login/threeselectone`
});
}
}
}
})
})
},
fail(err) {
console.error('获取 code 失败:', err);
}
});
}
onLoad((options) => {
if (options.type) {
uni.setStorageSync('special', true);
} else {
uni.setStorageSync('special', false);
}
superLogin();
// playing.value = true
});
let timer = null
// let fourtimer = null
// const num = ref(0)
onMounted(() => {
timer = setInterval(() => {
playfirst.value = !playfirst.value
}, 700) // 每0.5秒取反
// fourtimer = setInterval(() => {
// num.value = (num.value + 1) % 3 // 到2后又回到0
// }, 350) // 每1秒执行一次
})
onUnmounted(() => {
clearInterval(timer)
// clearInterval(fourtimer)
})
</script>
<style scoped lang="scss">
.login-imge {
width: 150rpx;
height: 150rpx;
position: absolute;
top: 45%;
left: 50%;
transform: translate(-45%, -50%);
transition: all 0.7s ease;
}
.login-imge-an {
// margin-top: 10rpx;
// margin-left: -10rpx;
width: 150rpx;
height: 150rpx;
position: absolute;
top: 46%;
left: 49%;
transform: translate(-46%, -49%);
transition: all 0.7s ease;
}
.login-container {
display: flex;
flex-direction: column;
min-height: 100vh;
width: 100%;
background-color: rgb(239, 241, 252);
position: relative;
justify-content: center;
align-items: center;
}
.loading {
margin-top: 100rpx;
display: flex;
}
// .dian{
// margin: 0 10rpx;
// }
</style>