Authored by 郝肖肖

记住滚动条位置 潮流优选

... ... @@ -95,7 +95,7 @@ const getResources = (params, options) => {
}
break;
case 'title_image' :
case 'title_image' :
if (typeof data[res.template_name] === 'undefined') {
data[res.template_name] = [];
}
... ...
... ... @@ -10,7 +10,9 @@ var plusstar = {},
require('../common');
plusstar = {
scrollObj: {},
common: {
codeDefault: ''
},
init: function() {
var that = this,
$liDom,
... ... @@ -18,6 +20,13 @@ plusstar = {
$tabUlDom = $('.plusstar-page .tab-nav ul');
// 重置tab code位置
if (window.localStorage) {
$tabUlDom.find('li').each(function() {
localStorage.setItem($(this).data('code'), 0);
});
}
$tabUlDom.find('li').css({
width: 100 / $tabUlDom.find('li').length + '%'
});
... ... @@ -50,13 +59,10 @@ plusstar = {
tabNav: function(code) {
var that = this;
if (typeof this.scrollObj[code] === 'undefined') {
// 如果不是第一次点击,回顶部
$(document).scrollTop(0);
this.scrollObj[code] = true;
}
this.common.codeDefault = code;// 记住最后一次的tab code
loading.showLoadingMask();
$.ajax({
type: 'GET',
url: '/guang/plusstar/resources-template',
... ... @@ -86,6 +92,11 @@ plusstar = {
}
});
}, 40);
// 设置滚动条的位置
if (window.localStorage) {
$(document).scrollTop(localStorage.getItem(code) || 0);
}
},
error: function() {
tip.show('网络断开连接了~');
... ... @@ -125,4 +136,10 @@ $(function() {
}
plusstar.init();
if (window.localStorage) {
$(document).scroll(function() {
localStorage.setItem(plusstar.common.codeDefault, $(this).scrollTop());
});
}
});
... ...