1 changed files with 105 additions and 88 deletions
@ -1,97 +1,114 @@ |
|||||||
<template> |
<template> |
||||||
<view class="waiting"> |
<view class="waiting"> |
||||||
<u--image |
<u--image |
||||||
src="/static/favicon.png" |
src="/static/favicon.png" |
||||||
width="288rpx" |
width="288rpx" |
||||||
height="288rpx" |
height="288rpx" |
||||||
mode="aspectFit" |
mode="aspectFit" |
||||||
:fade="true" |
:fade="true" |
||||||
duration="200" |
duration="200" |
||||||
></u--image> |
></u--image> |
||||||
<button class="login" @click="login">授权登录</button> |
<button |
||||||
</view> |
class="login" |
||||||
|
@click="login" |
||||||
|
> |
||||||
|
授权登录 |
||||||
|
</button> |
||||||
|
</view> |
||||||
</template> |
</template> |
||||||
|
|
||||||
<script> |
<script> |
||||||
import { getAccessToken, getOpenId } from '@/utils/auth' |
import { getAccessToken, getOpenId } from '@/utils/auth' |
||||||
import { qrLogin } from '@/api/login' |
import { qrLogin } from '@/api/login' |
||||||
|
|
||||||
export default { |
export default { |
||||||
data() { |
data() { |
||||||
return { |
return { |
||||||
scene: '' |
scene: '', |
||||||
} |
} |
||||||
}, |
}, |
||||||
methods: { |
methods: { |
||||||
login() { |
login() { |
||||||
if (!this.scene) { |
if (!this.scene) { |
||||||
uni |
uni |
||||||
.showModal({ |
.showModal({ |
||||||
content: '链接失效,请重新扫码', |
content: '链接失效,请重新扫码', |
||||||
showCancel: false |
showCancel: false, |
||||||
}) |
}) |
||||||
.then(() => { |
.then(() => { |
||||||
uni.exitMiniProgram({ |
uni.exitMiniProgram({ |
||||||
success: res => { |
success: res => { |
||||||
console.log(res) |
console.log(res) |
||||||
} |
}, |
||||||
}) |
}) |
||||||
}) |
}) |
||||||
} else { |
} else { |
||||||
uni.showLoading({ |
uni.showLoading({ |
||||||
title: '登陆中。。。' |
title: '登陆中。。。', |
||||||
}) |
}) |
||||||
qrLogin({ |
uni.login({ |
||||||
code: this.scene, |
success: res => { |
||||||
openid: getOpenId() |
console.log('微信code', res.code) |
||||||
}).then(res => { |
qrLogin({ |
||||||
setTimeout(() => { |
code: this.scene, |
||||||
uni.hideLoading() |
openid: res.code, |
||||||
uni.switchTab({ |
}).then(res => { |
||||||
url: '/pages/index' |
setTimeout(() => { |
||||||
}) |
uni.hideLoading() |
||||||
}, 3000) |
uni.switchTab({ |
||||||
}) |
url: '/pages/index', |
||||||
} |
}) |
||||||
} |
}, 3000) |
||||||
}, |
}) |
||||||
onLoad(query) { |
}, |
||||||
// scene 需要使用 decodeURIComponent 才能获取到生成二维码时传入的 scene |
fail: err => { |
||||||
this.scene = decodeURIComponent(query.scene) |
uni.showToast({ |
||||||
} |
title: err, |
||||||
} |
duration: 2000, |
||||||
|
icon: 'none', |
||||||
|
}) |
||||||
|
}, |
||||||
|
}) |
||||||
|
} |
||||||
|
}, |
||||||
|
}, |
||||||
|
onLoad(query) { |
||||||
|
// scene 需要使用 decodeURIComponent 才能获取到生成二维码时传入的 scene |
||||||
|
this.scene = decodeURIComponent(query.scene) |
||||||
|
}, |
||||||
|
} |
||||||
</script> |
</script> |
||||||
|
|
||||||
<style lang="scss" scoped> |
<style lang="scss" scoped> |
||||||
.waiting { |
.waiting { |
||||||
height: 100vh; |
height: 100vh; |
||||||
display: flex; |
display: flex; |
||||||
flex-flow: column nowrap; |
flex-flow: column nowrap; |
||||||
justify-content: center; |
justify-content: center; |
||||||
align-items: center; |
align-items: center; |
||||||
background: #17c653; |
background: #17c653; |
||||||
gap: 40px; |
gap: 40px; |
||||||
.login { |
.login { |
||||||
display: flex; |
display: flex; |
||||||
padding: var(--Number-12px, 24rpx) var(--Number-40px, 80rpx); |
padding: var(--Number-12px, 24rpx) var(--Number-40px, 80rpx); |
||||||
justify-content: center; |
justify-content: center; |
||||||
align-items: center; |
align-items: center; |
||||||
border-radius: var(--Number-120px, 240rpx); |
border-radius: var(--Number-120px, 240rpx); |
||||||
background: var(--LightMode-Light-Light, #fff); |
background: var(--LightMode-Light-Light, #fff); |
||||||
box-shadow: 0px 6rpx 8rpx 0px rgba(0, 0, 0, 0.03); |
box-shadow: 0px 6rpx 8rpx 0px rgba(0, 0, 0, 0.03); |
||||||
color: var(--LightMode-Success-Success, #17c653); |
color: var(--LightMode-Success-Success, #17c653); |
||||||
font-family: 'PingFang SC'; |
font-family: 'PingFang SC'; |
||||||
font-size: 32rpx; |
font-size: 32rpx; |
||||||
font-style: normal; |
font-style: normal; |
||||||
font-weight: 500; |
font-weight: 500; |
||||||
line-height: normal; |
line-height: normal; |
||||||
} |
} |
||||||
.title { |
.title { |
||||||
font-family: 'PingFang SC'; |
font-family: 'PingFang SC'; |
||||||
font-size: 32rpx; |
font-size: 32rpx; |
||||||
font-style: normal; |
font-style: normal; |
||||||
font-weight: 500; |
font-weight: 500; |
||||||
line-height: normal; |
line-height: normal; |
||||||
} |
} |
||||||
} |
} |
||||||
</style> |
</style> |
||||||
|
Loading…
Reference in new issue