Commit 507de7bb authored by 李超鹏's avatar 李超鹏

修改登录错误提示

parent 0d9b1840
<template>
<view class="quick">
<view class="quick-color">
<view class="quick-color-cancel" :style="{ 'padding-top': platform == '3' ? 0 : statusBarHeight + 'px' }"><u-icon name="close" @click="toIndex"></u-icon></view>
<view class="quick-color-cancel" :style="{ 'padding-top': platform == '3' ? 0 : statusBarHeight + 'px' }">
<u-icon name="close" @click="toIndex"></u-icon></view>
</view>
<view class="quick-background">
<image :src="logoImage" mode="" class="quick-background-logo"></image>
......@@ -20,7 +21,7 @@
</view>
</template>
<script>
import { baseUrl } from '@/utils/config.js';
import { baseUrl } from '@/utils/config.js';
import log from '@/utils/log.js';
import { showToast } from '@/utils/common.js';
import { mapGetters } from 'vuex';
......@@ -28,9 +29,9 @@ export default {
components: {},
data() {
return {
logoImage:baseUrl+'login-logo@3x.png',
logoImage: baseUrl + 'login-logo@3x.png',
needAuth: true,
canIUseGetUserProfile: false,
agree: false,
params: {},
......@@ -41,7 +42,7 @@ export default {
computed: {
...mapGetters(['platform', 'isIOS', 'systemInfo'])
},
onLoad: function(options) {
onLoad: function (options) {
switch (this.platform) {
case '1': // 微信
if (uni.canIUse('getUserProfile')) {
......@@ -57,13 +58,13 @@ export default {
this.statusBarHeight = statusBarHeight;
if (options && options.path) {
this.returnUrl = decodeURIComponent(decodeURIComponent(options.path))
}
this.returnUrl = decodeURIComponent(decodeURIComponent(options.path))
}
},
methods: {
toIndex(){
toIndex() {
uni.navigateBack({
delta:1
delta: 1
})
},
// setLoginStatus() {
......@@ -130,8 +131,22 @@ export default {
that.loginSignup();
},
fail: function(res) {
console.log('授权失败', res); // App.track('wxlogin_getUserInfo_fail', {})
fail: function (res) {
console.log('授权失败', res);
uni.getNetworkType({
success(res) {
const networkType = res.networkType;
if (networkType === 'none') {
uni.showToast({ title: '网络请求错误,请检查网络连接', icon: 'none' });
} else {
uni.showToast({
title: '授权失败,请重新授权',
icon: 'none'
});
}
}
});
// App.track('wxlogin_getUserInfo_fail', {})
// uni.switchTab({
// url: '/pages/index/index'
// });
......@@ -182,7 +197,7 @@ export default {
});
},
loginSignup: function() {
loginSignup: function () {
var that = this;
login
.wxLogin()
......@@ -227,48 +242,61 @@ export default {
},
newLoginup() {
uni.getUserProfile({
desc: '用于授权登录',
success: res => {
console.log('授权成功', res);
const userInfo = {
nickname: res.userInfo.nickName,
avatar: res.userInfo.avatarUrl
};
getApp().globalData.wxUserInfo = userInfo;
console.log('授权成功', JSON.stringify(userInfo));
uni.showLoading({
title: '授权中..',
mask: true
desc: '用于授权登录',
success: res => {
console.log('授权成功', res);
const userInfo = {
nickname: res.userInfo.nickName,
avatar: res.userInfo.avatarUrl
};
getApp().globalData.wxUserInfo = userInfo;
console.log('授权成功', JSON.stringify(userInfo));
uni.showLoading({
title: '授权中..',
mask: true
});
console.log('--------------', res);
this.$store
.dispatch('Auto_login', userInfo)
.then(res => {
console.log('登录成功', res);
setTimeout(() => {
if (this.returnUrl) { // 需要跳转到特定页面
var isSwitchTab = this.returnUrl.indexOf('pages/index/') != -1
this.$u.route({
url: this.returnUrl,
type: isSwitchTab ? 'switchTab' : 'redirectTo',
})
} else {
uni.switchTab({
url: '/pages/index/index'
});
}
}, 1000);
})
.catch(err => {
showToast('登录失败');
console.log('登录失败', err);
});
console.log('--------------', res);
this.$store
.dispatch('Auto_login',userInfo)
.then(res => {
console.log('登录成功', res);
setTimeout(() => {
if (this.returnUrl) { // 需要跳转到特定页面
var isSwitchTab = this.returnUrl.indexOf('pages/index/') != -1
this.$u.route({
url: this.returnUrl,
type: isSwitchTab ? 'switchTab' : 'redirectTo',
})
}else {
uni.switchTab({
url: '/pages/index/index'
});
}
}, 1000);
})
.catch(err => {
showToast('登录失败');
console.log('登录失败', err);
});
},
fail: function(res) {
console.log('授权失败', res);
return;
}
});
},
fail: function (res) {
console.log('授权失败', res);
uni.getNetworkType({
success(res) {
const networkType = res.networkType;
if (networkType === 'none') {// TODO 精确判断的话,还是通过ping实际接口来判断
uni.showToast({ title: '无网络连接', icon: 'none' });
} else {
uni.showToast({
title: '授权失败,请重新授权',
icon: 'none'
});
}
}
});
return;
}
});
},
signup(e) {
log.setFilterMsg('getPhoneNumber');
......@@ -279,7 +307,7 @@ export default {
title: '提示',
showCancel: false,
content: '未授权不能完成自动注册',
success: function(res) {}
success: function (res) { }
});
} else {
console.log('用户同意', e.detail);
......@@ -296,19 +324,19 @@ export default {
this.$store
.dispatch('Get_UserInfo')
.then(() => {
this.showToast('登录成功',true);
this.showToast('登录成功', true);
setTimeout(() => {
if (this.returnUrl) { // 需要跳转到特定页面
var isSwitchTab = this.returnUrl.indexOf('pages/index/') != -1
this.$u.route({
url: this.returnUrl,
type: isSwitchTab ? 'switchTab' : 'redirectTo',
})
}else {
uni.switchTab({
url: '/pages/index/index'
});
}
if (this.returnUrl) { // 需要跳转到特定页面
var isSwitchTab = this.returnUrl.indexOf('pages/index/') != -1
this.$u.route({
url: this.returnUrl,
type: isSwitchTab ? 'switchTab' : 'redirectTo',
})
} else {
uni.switchTab({
url: '/pages/index/index'
});
}
}, 1000);
})
.catch(() => {
......@@ -434,15 +462,15 @@ export default {
});
} else {
if (this.returnUrl) { // 需要跳转到特定页面
var isSwitchTab = this.returnUrl.indexOf('pages/index/') != -1
this.$u.route({
url: this.returnUrl,
type: isSwitchTab ? 'switchTab' : 'redirectTo',
})
}else {
uni.switchTab({
url: '/pages/index/index'
});
var isSwitchTab = this.returnUrl.indexOf('pages/index/') != -1
this.$u.route({
url: this.returnUrl,
type: isSwitchTab ? 'switchTab' : 'redirectTo',
})
} else {
uni.switchTab({
url: '/pages/index/index'
});
}
}
},
......@@ -454,7 +482,7 @@ export default {
handleClick(e) {
var type = e.currentTarget.dataset.type;
uni.navigateTo({
animationType:'pop-in',
animationType: 'pop-in',
url: '/pages/login/agreement?type=' + type
});
}
......@@ -468,11 +496,13 @@ export default {
background: #ffffff;
position: relative;
color: #333333;
&-color {
width: 100%;
height: 30%;
background: linear-gradient(180deg, #F4FFFC 0%, #ffffff 100%);
overflow: hidden;
&-cancel {
width: 60upx;
height: 60upx;
......@@ -482,6 +512,7 @@ export default {
font-size: 32upx;
}
}
&-background {
position: absolute;
overflow: hidden;
......@@ -492,16 +523,19 @@ export default {
justify-content: center;
align-items: center;
flex-direction: column;
&-logo {
width: 216upx;
height: 216upx;
}
&-slogn {
width: 362upx;
height: 38upx;
margin-top: 10upx;
}
}
&-mark {
// overflow: hidden;
width: 100%;
......@@ -510,13 +544,16 @@ export default {
top: 50%;
transform: translate(-50%, -50%);
}
&-center {
position: relative;
width: 100%;
.submit-button-box {
width: 100%;
padding: 0 80upx;
margin-bottom: 54upx;
.submit-button {
position: relative;
width: 100%;
......@@ -533,9 +570,11 @@ export default {
display: flex;
align-items: center;
justify-content: center;
&:active {
background: #41c845;
}
.submit-button-icon {
width: 38upx;
height: 32upx;
......@@ -543,6 +582,7 @@ export default {
}
}
}
.auth-tip {
margin-top: 80rpx;
margin-bottom: 40rpx;
......@@ -551,11 +591,13 @@ export default {
color: #8d8d8d;
line-height: 1;
}
&-buttons {
display: flex;
align-items: center;
justify-content: space-between;
}
.login-refuse {
width: 292rpx;
height: 104rpx;
......@@ -567,6 +609,7 @@ export default {
font-weight: bold;
background: #ffffff;
}
.login-accept {
color: #ffffff;
background: $default-color;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment