Browse Source

授权登录修改

master
DX 2 weeks ago
parent
commit
b3f0d90b16
  1. 45
      sub/common/waiting.vue

45
sub/common/waiting.vue

@ -8,18 +8,23 @@
:fade="true"
duration="200"
></u--image>
<button class="login" @click="login">授权登录</button>
<button
class="login"
@click="login"
>
授权登录
</button>
</view>
</template>
<script>
import { getAccessToken, getOpenId } from '@/utils/auth'
import { qrLogin } from '@/api/login'
import { getAccessToken, getOpenId } from '@/utils/auth'
import { qrLogin } from '@/api/login'
export default {
export default {
data() {
return {
scene: ''
scene: '',
}
},
methods: {
@ -28,42 +33,54 @@ export default {
uni
.showModal({
content: '链接失效,请重新扫码',
showCancel: false
showCancel: false,
})
.then(() => {
uni.exitMiniProgram({
success: res => {
console.log(res)
}
},
})
})
} else {
uni.showLoading({
title: '登陆中。。。'
title: '登陆中。。。',
})
uni.login({
success: res => {
console.log('微信code', res.code)
qrLogin({
code: this.scene,
openid: getOpenId()
openid: res.code,
}).then(res => {
setTimeout(() => {
uni.hideLoading()
uni.switchTab({
url: '/pages/index'
url: '/pages/index',
})
}, 3000)
})
},
fail: err => {
uni.showToast({
title: err,
duration: 2000,
icon: 'none',
})
},
})
}
}
},
},
onLoad(query) {
// scene 使 decodeURIComponent scene
this.scene = decodeURIComponent(query.scene)
},
}
}
</script>
<style lang="scss" scoped>
.waiting {
.waiting {
height: 100vh;
display: flex;
flex-flow: column nowrap;
@ -93,5 +110,5 @@ export default {
font-weight: 500;
line-height: normal;
}
}
}
</style>

Loading…
Cancel
Save