Browse Source

优化登录逻辑,改进用户登录流程,调整二维码扫码逻辑并集成状态管理

master
parent
commit
932affebad
  1. 47
      sub/common/waiting.vue

47
sub/common/waiting.vue

@ -8,23 +8,18 @@
: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: {
@ -33,30 +28,36 @@
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)
success: async res => {
const data = {
type: 34,
code: res.code,
state: 'default',
userType: 3
}
await this.$store.dispatch('Login', data)
qrLogin({
code: this.scene,
openid: res.code,
openid: getAccessToken()
}).then(res => {
setTimeout(() => {
uni.hideLoading()
uni.switchTab({
url: '/pages/index',
url: '/pages/index'
})
}, 3000)
})
@ -65,22 +66,22 @@
uni.showToast({
title: err,
duration: 2000,
icon: 'none',
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;
@ -110,5 +111,5 @@
font-weight: 500;
line-height: normal;
}
}
}
</style>

Loading…
Cancel
Save