123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218 |
- function Index(){
- Common.call(this)
- }
- Index.prototype = new Common()
- Index.prototype.constructor = Index
- // 渲染默认的看点
- Index.prototype.renderCount = function(obj){
- var count = parseInt(obj.type)
- $('.count_item').removeClass('count_item_active').eq(count).addClass('count_item_active')
- }
- // 报名的接口处理
- Index.prototype.encroll = function(obj){
- var that = this
- $.ajax({
- type: 'get',
- url: '/api/campaign/checkIn',
- data: obj,
- success: function(data){
- console.log(obj)
- if(data.code == 0){
- // $('.clock_enter_success').show()
- // that.logClick({
- // module: 'read_change_index',
- // zone: 'baomingsuccess',
- // json: {
- // amount: obj.amount,
- // date: date
- // }
- // })
- }else{
- window.bookSotre.bookStoreClick('', '18', '', data.msg);
- }
-
- },
- error: function(){
- window.bookSotre.bookStoreClick('', '18', '', '请求失败');
- }
- })
-
- }
- // 所有的点击事件
- Index.prototype.triggerClick = function(){
- var that = this
- // 公用的点击事件
- that.handleClick()
- var data = {};
- // var clickKandian = $('.count_item_active div .kandian');
- // 点击切换看点
- $('body').on('click', '.count_item', function(){
- topCardShow($(this).index());
- if(!$(this).hasClass('count_item_active')){
- that.renderCount({
- type: $(this).index()
- })
- }
- })
- // 点击立即报名
- $('.now_btn_index').click(function(){
- var data = {};
- data.userKandian = $('.userKandian').val();
- data.cotegoryId = $('.userKandian').attr('good_cotegory');
- data.activeId = $(".count_item_active div .kandian").attr('data-id');
- data.matchDate = $(".count_item_active div .kandian").attr('data-date');
- data.matchId = $(".count_item_active div .kandian").attr('data-match');
- data.kandian = $(".count_item_active div .kandian").text();
- data.activeName = $(".userKandian").attr('active-name');
- data.readNumber = $('.userKandian').attr('read_number');
- if(data.userKandian < data.amount){
- // 余额不足
- $('.amount_null').show();
- return;
- }
- // toastSuccess(data);exit;
- console.log(data);
- $.ajax({
- type: 'post',
- url: '/api/campaign/checkIn',
- data: data,
- success: function(res){
- if(res.data.code == 200){
- toastSuccess(res.data.return);
- }else{
- alert(res.data.msg)
- }
- },
- error: function(err){
- alert("网络出错")
- }
- })
-
- })
- // 查看详细规则
- $('.enter_btn').click(function(){
- $('.charge_rule_pop').show()
- })
- $('.pop_close_index').click(function(){
- if($(this).parents('.clock_enter_success').length > 0){
- $(this).parents('.clock_enter_success').hide()
- window.location.reload()
- }
-
- })
- //挑战成功查看规则
- $('.clock_enter_success_rule_btn').click(function(){
- if($(this).parents('.clock_enter_success').length > 0){
- $(this).parents('.clock_enter_success').hide()
- }
- $('.charge_rule_pop').show();
- $('.pop_close').unbind();
- $('.pop_close').click(function(){
- $(this).parents('.common_pop').hide();
- window.location.reload()
- })
- })
- // 关闭余额不足
- $('.amount_null_close').click(function(){
- $('.amount_null').hide()
- })
- //报名成功跳转阅读
- $('body').on('click', '.clocl_enter_success_see_book', function(){
- var url = String($("#web_status").attr('channel-url'));
- window.location.href=url+"/index/user/recent?from=wechat";
- })
-
- }
- Index.prototype.init = function(){
- var level = $(".userKandian").attr('level');
- topCardShow(level);
- this.transitionFun()
- this.triggerClick()
- // this.renderPageCount()
- }
- var indexObj = new Index()
- function topCardShow( index ) {
- var kandian = [];
- kandian[0] = $('.kandian').eq(0).text();
- kandian[1] = $('.kandian').eq(1).text();
- kandian[2] = $('.kandian').eq(2).text();
- var userKandian = $('.userKandian').val();
- for (var i=0; i<3; i++){
- var cardId = "#top_card"+kandian[i];
- var participatorNum = "#participator_num"+kandian[i];
- if ( i != index ){
- $(cardId).hide();
- $(participatorNum).hide();
- $('.count_item').eq(i).removeClass('count_item_active');
- continue;
- }
- $(cardId).show();
- $(participatorNum).show();
- $('.count_item').eq(i).addClass('count_item_active');
- if ( kandian[i] - userKandian > 0 ){
- var money = $('.kandian').eq(i).attr('data-money');
- $('.now_btn_index').hide();
- $('.now_btn_chongzhi').text("仅需充值"+money+"元,即可参与活动");
- $('.now_btn_chongzhi').show();
- }else{
- $('.now_btn_index').show();
- $('.now_btn_chongzhi').hide();
- }
- }
- }
- function taskCallback(type){
- if(type == 1){
- indexObj.logClick({
- module: 'read_change_index',
- zone: 'chongzhisuccess',
- json: {
- date: date
- }
- })
- window.location.reload()
- }
- }
- function toastSuccess( res ){
- // console.log(res);
- $('.enter_title').text(res.kandian);
- $('.enter_tip').text("成功加入"+res.kandian+"书币挑战");
- $('.enter_which span').text(res.matchDate);
- $('.enter_tip_text').text("记得每日阅读"+res.readNumber+"章后,准时打卡哦~");
- $('.clock_enter_success').show();
- // window.location.reload()
- }
- // cpslog([703, {
- // map: {
- // cztype: 'wechat',
- // package: 1222,
- // result: 1,
- // book_id: 0,
- // chapter_id: 0,
- // money: 20,
- // res: {}
- // }
- // }, 'campagin_index']);
- indexObj.init()
|