Authored by yyq

fix

This diff could not be displayed because it is too large.
... ... @@ -25,6 +25,7 @@ var parseUrl = function (url) {
}
};
var webCacheUser;
var env = '';
var _appGetUid = function () {
... ... @@ -121,19 +122,26 @@ module.exports = {
return url;
},
//uid
getUser: function () {
getUser: function (force) {
return new Promise(function (resolve) {
var obj = {
sessionType: cookies.cookie('app_client_type') || getQueryObj().app_client_type || '',
appVersion: cookies.cookie('app_version') || getQueryObj().app_version || ''
};
if (env === 'h5' || env === 'pc') {
if (!force && webCacheUser) {
return resolve(webCacheUser);
};
jsonp({url: '//m.yohobuy.com/passport/login/user', jsonp: 'callback'}).then(function (r) {
obj.uid = 0;
if (r.code === 200) {
obj.uid = Number(r.data)
}
obj.sessionKey = cookies.cookie('app_session_key') || getQueryObj().session_key || '';
if (r.code === 200 || r.code === 403) {
obj.uid = Number(r.data) || 0;
webCacheUser = obj;
}
resolve(obj);
});
} else if (env === 'app') {
... ...
... ... @@ -23,7 +23,7 @@ function login(obj) {
_this.auth = function (nodeList, user) {
if (!user.uid) {
nodeList.forEach(function (value) {
[].forEach.call(nodeList, function(value) {
value.onclick = function (event) {
event.preventDefault();
_this.goLogin();
... ...
... ... @@ -98,8 +98,8 @@ var _initCoupon = function (nodeList, user) {
cookies.setCookie('yoho-conpon-token', '');
}
}
console.log(nodeList);
nodeList.forEach(function (value) {
[].forEach.call(nodeList, function (value) {
value.onclick = function (event) {
event.preventDefault();
var el = event.currentTarget;
... ... @@ -130,7 +130,7 @@ var _initRedEnvelope = function (nodeList, user) {
cookies.setCookie('yoho-redenvelope-token', '');
}
}
nodeList.forEach(function (value) {
[].forEach.call(nodeList, function (value) {
value.onclick = function (event) {
event.preventDefault();
var el = event.currentTarget;
... ...
var tipTmpl = '<div class="tip {{tipClassName}}"><div class="title">{{title}}</div><div class="content">{{content}}</div><a class="button {{buttonClass}}">{{button}}</a></div>'
var toastTmpl = '<div style="{{style}}" class="feature-toast-content">{{content}}</div>';
var frameRate = 75; // 动画帧率
var showTip = function (data) {
var tipNode = null;
data = data || {
... ... @@ -91,6 +92,9 @@ var toast = function (content, options) {
}, (obj.duration && obj.duration > 0) ? obj.duration : 2000);
};
function fadeIn(el,time){
var mt = 1000 / frameRate,
opacityStep = mt / time;
if(el.style.opacity === ""){
el.style.opacity = 0;
}
... ... @@ -98,17 +102,22 @@ function fadeIn(el,time){
el.style.display = 'block';
}
var t = setInterval(function(){
if(el.style.opacity < 1){
el.style.opacity = parseFloat(el.style.opacity)+0.01;
el.timer && clearInterval(el.timer);
el.timer = setInterval(function(){
if(el.style.opacity < 1 - opacityStep){
el.style.opacity = parseFloat(el.style.opacity) + opacityStep;
}
else{
clearInterval(t);
clearInterval(el.timer);
el.style.opacity = 1;
}
},time/100);
}, mt);
}
function fadeOut(el,time){
var mt = 1000 / frameRate,
opacityStep = mt / time;
if(el.style.opacity === ""){
el.style.opacity = 1;
}
... ... @@ -116,15 +125,17 @@ function fadeOut(el,time){
el.style.display = 'block';
}
var t = setInterval(function(){
if(el.style.opacity > 0){
el.style.opacity = parseFloat(el.style.opacity)-0.01;
el.timer && clearInterval(el.timer);
el.timer = setInterval(function(){
if(el.style.opacity > opacityStep){
el.style.opacity = parseFloat(el.style.opacity) - mt / time;
}
else{
clearInterval(t);
clearInterval(el.timer);
el.style.opacity = 0;
el.style.display = 'none'
}
},time/100);
}, mt);
}
module.exports = {
... ...
... ... @@ -6,8 +6,14 @@ function jsonp(params) {
params = params || {};
params.data = params.data || {};
//创建script标签并加入到页面中
var callbackName = params.jsonp;
if (window[callbackName]) {
callbackName += Math.floor(Math.random() * 1000);
params.jsonp = callbackName;
}
// 设置传递给后台的回调参数名
params.data['callback'] = callbackName;
var data = formatParams(params.data);
... ...