123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- function Common(){
- }
- Common.prototype.sendAjax = function (obj) {
- var that = this
- $.ajax({
- "type": "post",
- "dataType":"json",
- "contentType": "application/json",
- "url": obj.url,
- "data": obj.data,
- "success": function(res){
- // 请求的回调函数
- obj.fun && obj.fun(res)
- },
- error:function(){
- var toastjson = {msg:'网络出错,请稍后再试'};
- window.bookSotre.toast(JSON.stringify(toastjson));
- }
- })
- }
- Common.prototype.getQueryString = function (name){
- if(name){
- var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
- var r = window.location.search.substr(1).match(reg);
- if(r!=null){
- return unescape(r[2]);
- }
- return '';
- }else{
- return window.location.search
- }
- }
- Common.prototype.logClick = function(obj){
- // 客户端打点
- try{
- window.bookSotre.logClick(obj.module, obj.zone, '', '', JSON.stringify(obj.json || {}));
- }catch(err){
- console.log(obj)
- }
- }
- // 动画效果
- Common.prototype.transitionFun = function(){
- if($('.top_item').length < 3){
- $('.top_list').hide()
- return
- }
- var tempY = 0
- let heightTem = $('.top_item').height()
- var timers = setInterval(function(){
- tempY -= 1
- // if(tempY < -10 && tempY >= -30){
- // $('.top_item').eq(1).addClass('transition_item')
- // }else if(tempY < -50 && tempY > -100 ){
-
- // $('.top_item').eq(2).addClass('transition_item')
- // }
- // else if(tempY <= -100){
- // $('.top_list').find('.top_item').removeClass('transition_item')
- // tempY += $('.top_list').find('.top_item').eq(1).position().top
- // $('.top_item').eq(3).addClass('transition_item')
- // $('.top_list').find('.top_item').eq(0).appendTo($('.top_list'))
- // }
- if(tempY <= -heightTem){
- tempY += $('.top_list').find('.top_item').eq(1).position().top
- $('.top_list').find('.top_item').eq(0).appendTo($('.top_list'))
- }
- $('.top_list').css({
- 'transform': 'translateY('+tempY+'px)'
- })
-
- },30)
- }
- // 公用点击事件
- Common.prototype.handleClick = function(){
- var that = this
- // 关闭活弹层
- $('body').on('click', '.common_pop .pop_close', function(){
- $(this).parents('.common_pop').hide()
- })
- // 打开活动规则
- $('.top_change_rule').click(function(){
- $('.charge_rule_pop').show()
- })
- // 去我的挑战页面
- $('.top_my_change').click(function(){
- var urlJson = {
- url: '/index/recharge/myRecharge',
- title: '我的挑战'
- }
- try{
- that.goUrl({
- url: '/index/recharge/myRecharge'+window.location.search
- })
- // window.bookSotre.bookStoreClick('', '4', '', JSON.stringify(urlJson));
- }catch(err){
- that.goUrl({
- url: '/index/recharge/myRecharge'+window.location.search
- })
- }
-
- })
- }
- // 客户端js
- Common.prototype.goUrl = function(obj){
- var url = window.location.origin + obj.url + window.location.search
- var json = {
- url: url,
- paramAppend: true
- }
- try{
- window.location.href = url
- // window.bookSotre.bookStoreClick('','4','',JSON.stringify(json))
- }catch(err){
- window.location.href = url
- // window.location.replace(url)
- }
- }
|