123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- //$('body').on('click','.my-shelf-right', function(){
- $('.my-shelf-right').click(function () {
- $('.my-shelf-right').hide()
- if($(this).hasClass('my-shelf-setting')){
- $('.my-shelf-cancle').show()
- $('.book-item:not(.book-item-more)').addClass('book-item-unselected')
- }else if($(this).hasClass('my-shelf-cancle')){
- $('.my-shelf-setting').show()
- $('.my-shelf-left strong').show();
- $('.my-shelf-left em').hide()
- $('.book-item').removeClass('book-item-unselected book-item-selected')
- }else if($(this).hasClass('my-shelf-delete')){
- $('.my-shelf-setting').show();
- var books_arr = [];
- $(".book-item-selected").each(function () {
- books_arr.push($(this).data('book_id'));
- });
- bookids_str = JSON.stringify(books_arr);
- $.ajax({
- type: 'post',
- url: '/api/bookshelf/delbooks',
- timeout: 10000,
- cache: false,
- data: {
- bookIds:bookids_str
- },
- success: function (data) {
- if(data.err==0){
- //consoleMain('删除成功');
- window.location.reload();
- }
- },
- error: function (XMLHttpRequest, textStatus, errorThrown) {
- consoleMain('删除失败,请稍后重试');
- }
- });
- // 删除选中的书籍
- $('.book-item-selected').remove()
- $('.book-item').removeClass('book-item-unselected')
- }
- })
- $('body').on('click','.book-item', function(e){
- if($(this).hasClass('book-item-unselected')){
- $(this).removeClass('book-item-unselected').addClass('book-item-selected')
- }else if($(this).hasClass('book-item-selected')){
- $(this).removeClass('book-item-selected').addClass('book-item-unselected')
- }else{
- return
- }
- $('.my-shelf-left strong').hide();
- $('.my-shelf-left em').html('已选择'+$('.book-item-selected').length+'本书').css('display', 'inline-block');
- if ($('.book-item-selected').length > 0) {
- $('.my-shelf-right').hide()
- $('.my-shelf-delete').show()
- } else {
- $('.my-shelf-right').hide()
- $('.my-shelf-cancle').show()
- }
- //不要删 阻止点击a标签跳转
- e.stopPropagation();
- return false;
- })
- //编辑最近阅读
- $('.r_bookshelf_edit_open').click(function(){
- $('.r_my_bookshelf_box').addClass('r_bookshelf_list_edit');
- });
- //取消编辑最近阅读
- $('.r_bookshelf_edit_close').click(function(){
- $('.r_my_bookshelf_box').removeClass('r_bookshelf_list_edit');
- });
- //选中要删除的book
- $('.r_my_bookshelf_box').on('click','.r_bookshelf_list_edit .r_my_bookshelf a',function(e){
- var $this=$(this),booknum=0;
- $this.toggleClass('r_bookshelf_remove_select');
- booknum=$('.r_bookshelf_remove_select').length;
- $('.r_bookshelf_num em span').text(booknum);
- if(booknum<=0){
- $('.r_my_bookshelf_box').removeClass('r_bookshelf_list_edit_remove');
- }else{
- $('.r_my_bookshelf_box').addClass('r_bookshelf_list_edit_remove');
- }
- //不要删 阻止点击a标签跳转
- e.stopPropagation();
- return false;
- });
- //删除操作
- $('.r_bookshelf_edit_remove').on('click',function(){
- $('.r_my_bookshelf_box').removeClass('r_bookshelf_list_edit_remove');
- $('.r_my_bookshelf_box').removeClass('r_bookshelf_list_edit');
- var books_arr = [];
- $(".r_bookshelf_remove_select").each(function () {
- books_arr.push($(this).attr('book_id'));
- });
- bookids_str = JSON.stringify(books_arr);
- console.log(bookids_str);
- $.ajax({
- type: 'post',
- url: '/api/bookshelf/delbooks',
- timeout: 10000,
- cache: false,
- data: {
- bookIds:bookids_str
- },
- success: function (data) {
- if(data.err==0){
- consoleMain('删除成功');
- window.location.reload();
- }
- },
- error: function (XMLHttpRequest, textStatus, errorThrown) {
- consoleMain('删除失败,请稍后重试');
- }
- });
- })
|