| xqd
@@ -1,6 +1,18 @@
|
|
|
<template>
|
|
|
<app-layout>
|
|
|
-
|
|
|
+ <u-modal v-model="modal.show"
|
|
|
+ title="提示"
|
|
|
+ content="需要获取您的用户信息"
|
|
|
+ cancel-color="#CCCCCC"
|
|
|
+ confirm-color="#046E64"
|
|
|
+ :async-close="true"
|
|
|
+ :show-cancel-button="true"
|
|
|
+ @cancel="handleRedirect"
|
|
|
+ >
|
|
|
+ <view slot="confirm-button">
|
|
|
+ <button @click="handleLogin" class="btn main-center cross-center">确定</button>
|
|
|
+ </view>
|
|
|
+ </u-modal>
|
|
|
</app-layout>
|
|
|
</template>
|
|
|
|
| xqd
@@ -12,7 +24,11 @@
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
- redirect: ''
|
|
|
+ redirect: '',
|
|
|
+ code: '',
|
|
|
+ modal: {
|
|
|
+ show: false
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
| xqd
@@ -22,6 +38,7 @@
|
|
|
uni.login({
|
|
|
provider: 'weixin',
|
|
|
success: res => {
|
|
|
+ _this.code = res.code;
|
|
|
uni.getUserInfo({
|
|
|
provider: 'weixin',
|
|
|
success: data => {
|
| xqd
@@ -32,28 +49,61 @@
|
|
|
signature:data.signature
|
|
|
}
|
|
|
_this.$u.api.login(params).then(loginRes => {
|
|
|
+ uni.hideLoading();
|
|
|
_this.$u.vuex(_this.$const.USER_TOKEN,loginRes.token)
|
|
|
_this.$u.vuex(_this.$const.USER_DATA,loginRes.user)
|
|
|
- uni.hideLoading()
|
|
|
- uni.reLaunch({
|
|
|
- url: _this.redirect
|
|
|
- });
|
|
|
+ if(loginRes.user.nickname === '微信用户'){
|
|
|
+ _this.modal.show = true;
|
|
|
+ }else{
|
|
|
+ _this.handleRedirect();
|
|
|
+ }
|
|
|
})
|
|
|
+ },
|
|
|
+ fail: error => {
|
|
|
+ _this.$u.toast('获取用户信息失败')
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
+ handleLogin(){
|
|
|
+ let _this = this;
|
|
|
+ uni.getUserProfile({
|
|
|
+ desc: '获取用户信息',
|
|
|
+ success: data => {
|
|
|
+ console.log('-->data',data)
|
|
|
+ let params = {
|
|
|
+ encryptedData: data.encryptedData,
|
|
|
+ iv: data.iv,
|
|
|
+ }
|
|
|
+ _this.$u.api.userUpdate(params).then(res => {
|
|
|
+ _this.$u.vuex(_this.$const.USER_DATA, res)
|
|
|
+ _this.handleRedirect();
|
|
|
+ })
|
|
|
+ },
|
|
|
+ fail: err => {
|
|
|
+ console.log('-->data',err)
|
|
|
+ _this.$u.toast('获取用户信息失败')
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ handleRedirect(){
|
|
|
+ console.log('-->data',this.redirect)
|
|
|
+ uni.reLaunch({
|
|
|
+ url: this.redirect
|
|
|
+ });
|
|
|
+ }
|
|
|
},
|
|
|
onLoad(options) {
|
|
|
- let redirect = options.redirect;
|
|
|
- delete options.redirect;
|
|
|
- let arr = [];
|
|
|
- for (const key in options) {
|
|
|
- arr.push(`${key}=${options[key]}`)
|
|
|
- }
|
|
|
- this.redirect = `/${redirect}?${arr.join("&")}`
|
|
|
- if(!this.redirect){
|
|
|
+ if(options.redirect){
|
|
|
+ let redirect = options.redirect;
|
|
|
+ delete options.redirect;
|
|
|
+ let arr = [];
|
|
|
+ for (const key in options) {
|
|
|
+ arr.push(`${key}=${options[key]}`)
|
|
|
+ }
|
|
|
+ this.redirect = `/${redirect}?${arr.join("&")}`
|
|
|
+ }else{
|
|
|
this.redirect = '/pages/index/index'
|
|
|
}
|
|
|
if(!this.vuex_user_token){
|
| xqd
@@ -64,5 +114,14 @@
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
-
|
|
|
+ .btn{
|
|
|
+ background: #fff;
|
|
|
+ color: $main-color;
|
|
|
+ border-radius: 0;
|
|
|
+ font-size: 28rpx;
|
|
|
+ height: 100rpx;
|
|
|
+ &:after{
|
|
|
+ content: unset;
|
|
|
+ }
|
|
|
+ }
|
|
|
</style>
|