整理一下热门

This commit is contained in:
HelloWorld 2020-04-10 21:04:36 +08:00
parent 76821bc840
commit c4f61f6bbe
2 changed files with 9 additions and 59 deletions

View File

@ -4,7 +4,6 @@ app.controller('weixinArticleCtr', ['$scope', '$state', '$sce', '$filter', '$win
$window.location = "http://m.mybookmark.cn/#/tags";
return;
}
var key = curentDate(undefined, "yyyyMMdd");
$scope.hoverBookmark = null;
$scope.bookmarks = []; // 书签数据
@ -23,11 +22,9 @@ app.controller('weixinArticleCtr', ['$scope', '$state', '$sce', '$filter', '$win
$scope.toastrId = 0;
$scope.random = 0;
$scope.channels = JSON.parse(`[{"id":1,"name":"热门", "clicked": true},{"id":2,"name":"搞笑"},{"id":3,"name":"养生堂"},{"id":4,"name":"私房话"},{"id":5,"name":"八卦精"},{"id":6,"name":"科技咖"},{"id":7,"name":"财经迷"},{"id":8,"name":"汽车控"},{"id":9,"name":"生活家"},{"id":10,"name":"时尚圈"},{"id":11,"name":"育儿"},{"id":12,"name":"旅游"},{"id":13,"name":"职场"},{"id":14,"name":"美食"},{"id":15,"name":"历史"},{"id":16,"name":"教育"},{"id":17,"name":"星座"},{"id":18,"name":"体育"},{"id":19,"name":"军事"},{"id":20,"name":"游戏"},{"id":21,"name":"萌宠"}]`);
$scope.user = {};
var timeagoInstance = timeago();
get('user').then((user) => {
$scope.user = user;
pubSubService.publish('Common.menuActive', {
login: true,
index: dataService.LoginIndexHot
@ -93,16 +90,6 @@ app.controller('weixinArticleCtr', ['$scope', '$state', '$sce', '$filter', '$win
// 快捷键r随机推荐
$document.bind("keydown", function (event) {
$scope.$apply(function () {
// console.log(event.keyCode);
var menusScope = $('div[ng-controller="menuCtr"]').scope();
var login = (menusScope && menusScope.login) || false;
var blur = (menusScope && menusScope.blur) || false;
// r按键显示
if (event.keyCode == 82 && login && (!blur)) {
$scope.bookmarks = [];
$scope.randomHotBookmarks();
}
var key = event.key.toUpperCase();
if ($scope.hoverBookmark && dataService.keyShortcuts()) {
if (key == 'I') {
@ -114,20 +101,6 @@ app.controller('weixinArticleCtr', ['$scope', '$state', '$sce', '$filter', '$win
})
});
$scope.randomHotBookmarks = async function () {
var menusScope = $('div[ng-controller="menuCtr"]').scope();
var login = (menusScope && menusScope.login) || false;
if (login) {
$scope.random = true;
var beginDay = new Date(2016, 7, 15); // 注意日期是从0 ~ 11
var now = new Date();
var dayGap = parseInt(Math.abs(now - beginDay) / (1000 * 60 * 60 * 24)) + 1;
$scope.curDay = -(parseInt(Math.random() * 1000000) % dayGap);
} else {
$scope.toastrId = toastr.info('您只有先登录,才能使用查看随机热门标签', "提示");
}
}
$scope.setHoverBookmark = async function (bookmark) {
$scope.hoverBookmark = bookmark;
}
@ -155,20 +128,14 @@ app.controller('weixinArticleCtr', ['$scope', '$state', '$sce', '$filter', '$win
$scope.channelId = channelId;
$scope.currentPage = page;
$scope.totalPages = 0;
var start = (page - 1) * perPageItems;
var api = `https://api.jisuapi.com/weixinarticle/get?channelid=${channelId}&start=${start}&num=${perPageItems}&appkey=e95887468ab87d69`;
$.ajax({
url: api,
url: `https://api.jisuapi.com/weixinarticle/get?channelid=${channelId}&start=${(page - 1) * perPageItems}&num=${perPageItems}&appkey=e95887468ab87d69`,
type: 'get',
dataType: "jsonp",
jsonp: "callback",
success: function (body) {
dealBody(body);
if (channelId == 1 && page == 1) {
getHotBookmarksbyAPI();
} else {
$scope.randomHotBookmarks();
}
getHotBookmarksbyAPI(page - 1);
},
error: function (json) {
$scope.loadBusy = false;
@ -178,23 +145,22 @@ app.controller('weixinArticleCtr', ['$scope', '$state', '$sce', '$filter', '$win
});
}
function getHotBookmarksbyAPI() {
// $scope.loadBusy = true;
var requireData = {
async function getHotBookmarksbyAPI(page) {
let requireData = {
userId: null,
lastupdataTime: new Date().getTime(),
pageNo: 1,
pageSize: 1000,
sort: 'desc',
renderType: 0,
date: curentDate($scope.curDay, "yyyy年M月d日"),
date: dayjs(new Date().getTime() - page * 24 * 3600 * 1000).format("YYYY年M月D日"),
idfa: "d4995f8a0c9b2ad9182369016e376278",
os: "ios",
osv: "9.3.5"
}
var api = "https://api.shouqu.me/api_service/api/v1/daily/dailyMark";
$.ajax({
url: api,
url: "https://api.shouqu.me/api_service/api/v1/daily/dailyMark",
type: 'post',
data: requireData,
success: function (json) {
@ -229,7 +195,7 @@ app.controller('weixinArticleCtr', ['$scope', '$state', '$sce', '$filter', '$win
b.lastClick = $filter('date')(new Date(bookmark.createtime > bookmark.updatetime ? bookmark.createtime : bookmark.updatetime), "yyyy-MM-dd HH:mm:ss");
b.id = bookmark.articleId;
b.index = $scope.bookmarks.length - 1;
$scope.bookmarks.push(b);
$scope.bookmarks.unshift(b);
})
}
}, 10)
@ -241,22 +207,6 @@ app.controller('weixinArticleCtr', ['$scope', '$state', '$sce', '$filter', '$win
});
}
// TODO: 我要将编辑按钮固定在容器的右上角
function curentDate(i, format) {
if (i == undefined) {
i = 0;
}
if (format == undefined) {
format = 'yyyyMMddhhmmss'
}
var now = new Date();
now.setTime(now.getTime() + i * 24 * 60 * 60 * 1000);
clock = $filter('date')(now, format);
return clock;
}
function dealBody(body) {
console.log('success............', body);
$scope.loadBusy = false;

View File

@ -29,7 +29,7 @@
</div>
<button class="ui button" type="submit" ng-click="resetPassword()">重置密码</button>
</form>
<div class="ui four statistics" style="margin-top:30px;" ng-show="form[1]">
<div class="ui four statistics" style="margin-top: 60px; margin-left: -80px;" ng-show="form[1]">
<div class="statistic">
<div class="text value">
{{user.createdAt.substring(0, 4)}}<br />