|
@@ -12,15 +12,15 @@ if(localStorage.getItem('userInfo')){
|
|
|
GLOBAL_USER_IDENTITY = globalUserData.userIdentity;
|
|
|
GLOBAL_SHOP_ID = globalUserData.shopId;
|
|
|
} else {
|
|
|
- if(!getCookie("weChatAutoLogin")){
|
|
|
+ if(!getBaseCookie("weChatAutoLogin")){
|
|
|
var userAgent = navigator.userAgent.toLowerCase();
|
|
|
if (userAgent.match(/MicroMessenger/i)) {
|
|
|
// 微信浏览器自动授权登录
|
|
|
var urlForWeChat = 'https://www.caimei365.com/we_chat/redirect_uri.html';
|
|
|
$.get(spiServer+'/user/authorizationLink?redirectUri='+urlForWeChat, function(r){
|
|
|
if(r.code===0 && r.data){
|
|
|
- setCookie("loginBeforePath", window.location.href);
|
|
|
- setCookie("weChatAutoLogin", 1);
|
|
|
+ setBaseCookie("loginBeforePath", window.location.href);
|
|
|
+ setBaseCookie("weChatAutoLogin", 1);
|
|
|
window.location.href = r.data;
|
|
|
}
|
|
|
});
|
|
@@ -116,6 +116,7 @@ var globalHead = new Vue({
|
|
|
// 退出登录
|
|
|
userLogOut: function(){
|
|
|
localStorage.removeItem('userInfo');
|
|
|
+ delBaseCookie("loginBeforePath");
|
|
|
this.loginStatus = false;
|
|
|
window.location.href = "/index.html";
|
|
|
},
|
|
@@ -196,7 +197,7 @@ $(function(){
|
|
|
text: btnTxt,
|
|
|
btnClass: 'btn-confirm-login',
|
|
|
action: function(){
|
|
|
- setCookie("loginBeforePath", window.location.href);
|
|
|
+ setBaseCookie("loginBeforePath", window.location.href);
|
|
|
window.location.href = '/login.html';
|
|
|
}
|
|
|
},
|
|
@@ -210,12 +211,13 @@ $(function(){
|
|
|
// 去登录弹窗
|
|
|
$('body').on("click", '.toLogin',function () {
|
|
|
//loginAert('<span>你还未登录</span><span>请登录后再进行购买</span>', '去登录');
|
|
|
- setCookie("loginBeforePath", window.location.href);
|
|
|
+ setBaseCookie("loginBeforePath", window.location.href);
|
|
|
window.location.href = '/login.html';
|
|
|
});
|
|
|
// 退出登录
|
|
|
$('body').on("click", '.toLogOut',function () {
|
|
|
localStorage.removeItem('userInfo');
|
|
|
+ delBaseCookie("loginBeforePath");
|
|
|
globalHead.loginStatus = false;
|
|
|
window.location.href = "/index.html";
|
|
|
});
|
|
@@ -324,7 +326,7 @@ $(function(){
|
|
|
|
|
|
});
|
|
|
// 公共方法
|
|
|
-function setCookie(cname,cvalue,exdays){
|
|
|
+function setBaseCookie(cname,cvalue,exdays){
|
|
|
if (exdays) {
|
|
|
var d = new Date();
|
|
|
d.setTime(d.getTime()+(exdays*24*60*60*1000));
|
|
@@ -334,7 +336,7 @@ function setCookie(cname,cvalue,exdays){
|
|
|
document.cookie = cname+"="+cvalue+"; path=/";
|
|
|
}
|
|
|
}
|
|
|
-function getCookie(cname){
|
|
|
+function getBaseCookie(cname){
|
|
|
if (document.cookie) {
|
|
|
var name = cname + "=";
|
|
|
var ca = document.cookie.split(';');
|
|
@@ -347,6 +349,14 @@ function getCookie(cname){
|
|
|
}
|
|
|
return "";
|
|
|
}
|
|
|
+function delBaseCookie(cname){
|
|
|
+ var exp = new Date();
|
|
|
+ exp.setTime(exp.getTime() - 1);
|
|
|
+ var cval=getBaseCookie(cname);
|
|
|
+ if(cval!=null) {
|
|
|
+ document.cookie= cname + "="+cval+";expires="+exp.toGMTString();
|
|
|
+ }
|
|
|
+}
|
|
|
function getDateStr(dd, addCount) {
|
|
|
dd.setDate(dd.getDate() + addCount);//获取addCount天后的日期
|
|
|
var y = dd.getFullYear();
|
|
@@ -494,6 +504,7 @@ function tokenAjax(type, url, params, callback, errorBack){
|
|
|
success : function (res) {
|
|
|
if(res.code === -99){
|
|
|
localStorage.removeItem('userInfo');
|
|
|
+ delBaseCookie("loginBeforePath");
|
|
|
window.location.href ='/login.html';
|
|
|
}else{
|
|
|
callback(res);
|
|
@@ -561,14 +572,15 @@ function setProductPrice(productList, productIds, userId, callback){
|
|
|
}
|
|
|
// 登录后返回登录前页面
|
|
|
function toBeforePath(){
|
|
|
- var loginBeforePath = getCookie("loginBeforePath");
|
|
|
+ var loginBeforePath = getBaseCookie("loginBeforePath");
|
|
|
if (loginBeforePath && loginBeforePath!=='undefined') {
|
|
|
+ delBaseCookie("loginBeforePath");
|
|
|
window.location.href = loginBeforePath;
|
|
|
}
|
|
|
window.location.href = '/index.html';
|
|
|
}
|
|
|
function toLogin() {//去登录
|
|
|
- setCookie("loginBeforePath", window.location.href);
|
|
|
+ setBaseCookie("loginBeforePath", window.location.href);
|
|
|
window.location.href = '/login.html';
|
|
|
}
|
|
|
function upgrade () { //升级会员
|
|
@@ -576,6 +588,7 @@ function upgrade () { //升级会员
|
|
|
}
|
|
|
function toLogOut() {//登出
|
|
|
localStorage.removeItem('userInfo');
|
|
|
+ delBaseCookie("loginBeforePath");
|
|
|
this.loginStatus = false;
|
|
|
window.location.href = "/index.html";
|
|
|
}
|