mirror of
https://gitee.com/java110/WechatOwnerService.git
synced 2026-02-24 05:46:04 +08:00
优化登录页面完成
This commit is contained in:
parent
97fe40e6d8
commit
b19fee72e3
@ -338,7 +338,6 @@ const navigateTo = function(_param) {
|
||||
//校验是否登录,如果没有登录跳转至温馨提示页面
|
||||
factory.login.checkSession().then(function() {
|
||||
//有回话 跳转至相应页面
|
||||
|
||||
uni.navigateTo(_param);
|
||||
}, function(error) { //回话过期
|
||||
// #ifdef H5
|
||||
|
||||
@ -161,18 +161,23 @@ class LoginFactory {
|
||||
/**
|
||||
* h5刷新 token
|
||||
*/
|
||||
wechatRefreshToken(errorUrl) {
|
||||
wechatRefreshToken(errorUrl, _login) {
|
||||
let _errorUrl = errorUrl;
|
||||
if(errorUrl == null || errorUrl == undefined || errorUrl == null){
|
||||
if (errorUrl == null || errorUrl == undefined || errorUrl == '') {
|
||||
_errorUrl = '/#/pages/showlogin/showlogin';
|
||||
}
|
||||
|
||||
if(_login == null || _login == undefined || _login == ''){
|
||||
_login = 0; // 不是登录页面鉴权
|
||||
}
|
||||
uni.request({
|
||||
url: constant.url.wechatRefrashToken,
|
||||
method: 'get',
|
||||
header: this.getHeaders(),
|
||||
data: {
|
||||
redirectUrl: window.location.href, // 当前页地址
|
||||
errorUrl: _errorUrl
|
||||
errorUrl: _errorUrl,
|
||||
loginFlag: _login
|
||||
},
|
||||
success: function(res) {
|
||||
let _param = res.data;
|
||||
@ -276,7 +281,7 @@ class LoginFactory {
|
||||
return wx.getStorageSync(constant.mapping.LOGIN_FLAG);
|
||||
}
|
||||
|
||||
_doLoginOwnerByKey(_key){
|
||||
_doLoginOwnerByKey(_key) {
|
||||
uni.request({
|
||||
url: constant.url.loginOwnerByKey,
|
||||
method: 'post',
|
||||
@ -288,12 +293,12 @@ class LoginFactory {
|
||||
let _param = res.data;
|
||||
if (_param.code != 0) {
|
||||
uni.navigateTo({
|
||||
url:'/pages/showlogin/showlogin'
|
||||
url: '/pages/showlogin/showlogin'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
let _ownerInfo = _data.owner;
|
||||
let _ownerInfo = _param.owner;
|
||||
wx.setStorageSync(constant.mapping.OWNER_INFO, _ownerInfo);
|
||||
wx.setStorageSync(constant.mapping.USER_INFO, JSON.stringify(_ownerInfo));
|
||||
let _currentCommunityInfo = {
|
||||
@ -314,14 +319,14 @@ class LoginFactory {
|
||||
sessionKey: _ownerInfo.userId,
|
||||
expireTime: afterOneHourDate.getTime()
|
||||
});
|
||||
wx.setStorageSync(constant.mapping.TOKEN, _data.token);
|
||||
wx.setStorageSync(constant.mapping.TOKEN, _param.token);
|
||||
//保存临时 钥匙
|
||||
wx.setStorageSync(constant.mapping.OWNER_KEY, _data.key);
|
||||
wx.setStorageSync(constant.mapping.OWNER_KEY, _param.key);
|
||||
},
|
||||
fail: function(error) {
|
||||
// 调用服务端登录接口失败
|
||||
uni.navigateTo({
|
||||
url:'/pages/showlogin/showlogin'
|
||||
url: '/pages/showlogin/showlogin'
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@ -30,6 +30,8 @@
|
||||
const context = require("../../context/Java110Context.js");
|
||||
const constant = context.constant;
|
||||
const factory = context.factory;
|
||||
|
||||
const login = 1;//1标识登录页面 请下发code 不要下发key
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
@ -46,10 +48,12 @@
|
||||
let _key = option.key;
|
||||
if(_key){
|
||||
context.onLoad(option);
|
||||
// 判断当前是否已经登录 ,如果登录了跳转至首页
|
||||
|
||||
}else{
|
||||
if (this.code == '' || this.code == undefined) {
|
||||
//跳转鉴权
|
||||
factory.login.wechatRefreshToken(window.location.href);
|
||||
factory.login.wechatRefreshToken(window.location.href,login);
|
||||
}
|
||||
}
|
||||
// #endif
|
||||
|
||||
2
unpackage/dist/build/h5/index.html
vendored
2
unpackage/dist/build/h5/index.html
vendored
@ -2,4 +2,4 @@
|
||||
document.documentElement.style.fontSize = document.documentElement.clientWidth / 20 + 'px'
|
||||
})
|
||||
var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') || CSS.supports('top: constant(a)'))
|
||||
document.write('<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' + (coverSupport ? ', viewport-fit=cover' : '') + '" />')</script><link rel=stylesheet href=./static/index.cdf7f91b.css></head><body><noscript><strong>Please enable JavaScript to continue.</strong></noscript><div id=app></div><script src=./static/js/chunk-vendors.ad64f782.js></script><script src=./static/js/index.69de2277.js></script></body></html>
|
||||
document.write('<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' + (coverSupport ? ', viewport-fit=cover' : '') + '" />')</script><link rel=stylesheet href=./static/index.cdf7f91b.css></head><body><noscript><strong>Please enable JavaScript to continue.</strong></noscript><div id=app></div><script src=./static/js/chunk-vendors.ad64f782.js></script><script src=./static/js/index.ccd93bdc.js></script></body></html>
|
||||
File diff suppressed because one or more lines are too long
1
unpackage/dist/build/h5/static/js/pages-login-login.7120295a.js
vendored
Normal file
1
unpackage/dist/build/h5/static/js/pages-login-login.7120295a.js
vendored
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user