$('.mui-title').html('ECT专区'); var ect_top = '<div class="ect_top"><p class="ect_m">最新价</p><p class="ect_m">24H成交量</p><img src="'+ hyhImgUrl('Upload/app/icon/star.png') +'" /><p class="ect_m" id="last"></p><p class="ect_m" id="vol"></p></div>'; $('header').before(ect_top); var time_ = '距活动结束还有<span id="_d"></span>天'; $('.mui-scroll-wrapper').removeClass('scroll_out1').addClass('scroll_out3'); //var info = '<img src="http://img.heyuanhui.cn/Upload/app/icon/info.png" class="tanhao" />'; //$('header').append(info); var nav = '<div class="nav clearfix"></div>'; $('.ect_top').before(nav); var html_con = '<div class="ten clearfix"></div><div class="title_img"></div><div class="time_"></div><div class="con_"></div>' $('.con').html(html_con); $('.time_').html(time_); var nav_data = []; var secTypeId = 1; var timestamp1 = Date.parse(new Date()); if(timestamp1 >= 1538755200000) { $('.mui-scroll-wrapper').removeClass('scroll_out3').addClass('scroll_out4'); } else { } function getimg(num) { var img_ = '<img src="'+ hyhImgUrl('static/app/img/ect101-' + num + '.png') +'"/>' $('.title_img').html(img_); } function getTwoClass(secTypeId) { mui.ajax(kxUrl('addon/hyhlimitactive-Hyhlimitactive-activits'), { data: { topTypeId: secTypeId }, dataType: 'json', //服务器返回json格式数据 type: 'post', //HTTP请求类型 timeout: 10000, //超时时间设置为10秒 success: function(data) { //服务器返回响应,根据响应结果,分析是否登录成功; var data = toJson(data, 1); if(data.status == 1) { data = data.data; var html_ = ''; $.each(data, function() { html_ += '<div class="ten_t" data-secTypeId="' + this.secTypeId + '">' + this.secTypeName + '</div>' }); $('.ten').html(html_); } else { console.log(data); } }, error: function(xhr, type, errorThrown) { //异常处理; // mui.alert(errorThrown); } }); } var issx = 0; var doller = 0; var secTypeId = ''; function getData(secTypeId, goodsCatId) { // mui('').pullRefresh().scroll(0, 0, 0); backTop(); var data_set = { secTypeId: secTypeId, topTypeId: 1, goodsCatId: goodsCatId ? goodsCatId : '' }; mui.ajax(kxUrl('addon/hyhlimitactive-Hyhlimitactive-frontList'), { data: data_set, dataType: 'json', //服务器返回json格式数据 type: 'post', //HTTP请求类型 timeout: 10000, //超时时间设置为10秒 success: function(data) { //服务器返回响应,根据响应结果,分析是否登录成功; var data = toJson(data, 1); if(data.status == 1) { data = data.data; var html_ = ''; var htmlcon = ''; doller = data.doller; // if(data.secTypeId == 5 || data.secTypeId == 4) { // htmlcon = '<div class="ect_activity"><img src="http://img.heyuanhui.cn/static/app/img/e' + secTypeId + '.png" class="ect_hd" /></div>' // } else { // htmlcon = '<div class="ect_activity_"><img src="http://img.heyuanhui.cn/static/app/img/countdown.png" class="ect_djs" /> <span id="_h">00</span><span id="_m">00</span><span id="_s">00</span></div>' // html_ = '<div class="day"><p>此活动仅限14-15号两天</p></div>'; // } $.each(data.list, function(num) { htmlcon += '<div class="ect_com" data-id="' + this.goodsId + '" ><div class="com_img1" ><img src="' + hyhImgUrl(this.goodsImg) + '" /></div><p class="p1"><img src="'+ hyhImgUrl('static/app/img/ectb.png') +'" class="com_img2" />' + this.goodsName + '</p><p class="p3"><l></l>CNY <o>' + this.shopPrice + '</o></p>' + html_ + '</div>'; }); $('.con_').html(htmlcon); setTimeout(function() { $('.com_img1').height($('.com_img1').width()); }, 200) countTime(); } else { console.log(data); } }, error: function(xhr, type, errorThrown) { //异常处理; // mui.alert(type); } }); } function countTime() { //获取当前时间 var date = new Date(); var now = date.getTime(); //设置截止时间 var endDate = new Date("2018/10/6 00:00:00"); var end = endDate.getTime(); //时间差 var leftTime = end - now; //定义变量 d,h,m,s保存倒计时的时间 var d, h, m, s; if(leftTime >= 0) { d = Math.floor(leftTime / 1000 / 60 / 60 / 24); // h = Math.floor(leftTime / 1000 / 60 / 60); // m = Math.floor(leftTime / 1000 / 60 % 60); // s = Math.floor(leftTime / 1000 % 60); //将倒计时赋值到div中 if(d < 10) { d = "0" + d; } if(h < 10) { h = "0" + h; } if(m < 10) { m = "0" + m; } if(s < 10) { s = "0" + s; } $("#_d").html(d); // $("#_h").html(h); // $("#_m").html(m); // $("#_s").html(s); } //递归每秒调用countTime方法,显示动态时间效果 setTimeout(countTime, 1000); } mui.plusReady(function() { window.addEventListener('refresh', function(e) { //执行刷新 location.reload(); }); // countTime(); // getData(secTypeId); mui.ajax(kxUrl('addon/hyhlimitactive-Hyhlimitactive-activityList'), { data: { topTypeId: 1 }, dataType: 'json', //服务器返回json格式数据 type: 'post', //HTTP请求类型 timeout: 10000, //超时时间设置为10秒 success: function(data) { //服务器返回响应,根据响应结果,分析是否登录成功; // var data = toJson(data, 1); if(data.status == 1) { // console.log(1) var data = data.data; var html_ = ''; $.each(data, function(num) { html_ += '<div class="nav_block" data-num="' + num + '" data-secTypeId="' + this.secTypeId + '">' + this.secTypeName + '</div>'; }); $('.nav').html(html_); $('.nav_block').eq(0).addClass('on'); secTypeId = $('.nav_block').eq(0).attr('data-secTypeId'); getTwoClass(secTypeId); getData(secTypeId); getimg(1); } }, error: function(xhr, type, errorThrown) { //异常处理; // mui.alert(type); } }); setInterval(function() { mui.ajax('https://api.tokencan.net/exchange-open-api/open/api/get_ticker?symbol=ectusdt&random=' + Math.random(), { dataType: 'json', //服务器返回json格式数据 type: 'get', //HTTP请求类型 timeout: 10000, //超时时间设置为10秒 success: function(data) { //服务器返回响应,根据响应结果,分析是否登录成功; // var data = toJson(data, 1); $('#last').html(Math.floor((+data.data.last) * doller * 100) / 100); $('#vol').html(data.data.vol); $('.p3').each(function(num) { $(this).children('l').html('ECT ' + (Math.floor(+$(this).children('o').html() / (+data.data.last) / (+doller) * 100)) / 100 + '≈'); }) }, error: function(xhr, type, errorThrown) { //异常处理; // mui.alert(type); } }); }, 2000) mui("body").on('tap', '.nav_block', function(e) { secTypeId = this.attributes["data-secTypeId"].nodeValue; var num = +$(this).attr('data-num'); $(this).addClass('on').siblings().removeClass('on'); getTwoClass(secTypeId); getData(secTypeId); getimg(num + 1); }) mui("body").on('tap', '.ten_t', function() { var goodsCatId = this.attributes["data-secTypeId"].nodeValue; $(this).addClass('on').siblings().removeClass('on'); getData(secTypeId, goodsCatId) }) mui(".con").on('tap', '.ect_com', function() { // var tj = plus.webview.create('search.html'); // tj.show(); // mui.alert(e.target.attributes["data-id"].nodeValue); var data_id = this.attributes["data-id"].nodeValue; var isEct = 1; // console.log(this.attributes["data-id"].nodeValue); mui.openWindow({ url: 'details.html', id: 'details.html' + data_id, styles: { top: '0px', //新页面顶部位置 bottom: '0px', //新页面底部位置 width: '100%', //新页面宽度,默认为100% height: '100%' //新页面高度,默认为100% }, extras: { data_id: data_id, isEct: isEct // ..... //自定义扩展参数,可以用来处理页面间传值 }, createNew: false, //是否重复创建同样id的webview,默认为false:不重复创建,直接显示 show: { // autoShow: true, //页面loaded事件发生后自动显示,默认为true // aniShow: animationType, //页面显示动画,默认为”slide-in-right“; // duration: animationTime, //页面动画持续时间,Android平台默认100毫秒,iOS平台默认200毫秒; // event: 'titleUpdate', //页面显示时机,默认为titleUpdate事件时显示 // extras: {} //窗口动画是否使用图片加速 }, waiting: { autoShow: true, //自动显示等待框,默认为true title: '正在加载...', //等待对话框上显示的提示内容 options: { // width: waiting - dialog - widht, //等待框背景区域宽度,默认根据内容自动计算合适宽度 // height: waiting - dialog - height, //等待框背景区域高度,默认根据内容自动计算合适高度 // ...... } } }) }) document.querySelector('.mui-scroll-wrapper').addEventListener('scroll', function(e) { if(scroll.y == scroll.maxScrollY) { // if(isjiazai == 1) { // page++; // } } else if(scroll.y > 100 && issx == 0) { issx = 1; setTimeout(function() { location.reload() }, 1000) } }) $('header').on('tap', '.tanhao', function() { mui.openWindow({ url: 'activity8.html', id: 'activity8.html', styles: { top: '0px', //新页面顶部位置 bottom: '0px', //新页面底部位置 width: '100%', //新页面宽度,默认为100% height: '100%' //新页面高度,默认为100% }, extras: { // data_keyword: searchName // ..... //自定义扩展参数,可以用来处理页面间传值 }, createNew: false, //是否重复创建同样id的webview,默认为false:不重复创建,直接显示 show: { // autoShow: true, //页面loaded事件发生后自动显示,默认为true // aniShow: animationType, //页面显示动画,默认为”slide-in-right“; // duration: animationTime, //页面动画持续时间,Android平台默认100毫秒,iOS平台默认200毫秒; // event: 'titleUpdate', //页面显示时机,默认为titleUpdate事件时显示 // extras: {} //窗口动画是否使用图片加速 }, waiting: { autoShow: true, //自动显示等待框,默认为true title: '正在加载...', //等待对话框上显示的提示内容 options: { // width: waiting - dialog - widht, //等待框背景区域宽度,默认根据内容自动计算合适宽度 // height: waiting - dialog - height, //等待框背景区域高度,默认根据内容自动计算合适高度 // ...... } } }) }); })