qlg.tsgz.moe/static/app/js/activity7.js
2019-09-06 23:53:10 +08:00

281 lines
9.1 KiB
JavaScript
Executable File
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

$('.mui-title').html('ECT专区');
var ect_top = '<div class="ect_top"><p class="ect_m">最新价</p><p class="ect_m">24H成交量</p><img src="http://img.heyuanhui.cn/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 = 0;
var timestamp1 = Date.parse(new Date());
if(timestamp1 >= 1537027200000) {
secTypeId = 4;
nav_data = [{
"secTypeId": 4,
"name": "海鲜大咖"
}, {
"secTypeId": 5,
"name": "为您推荐"
}];
} else {
secTypeId = 1;
nav_data = [{
"secTypeId": 1,
"name": "9.15元专区"
}, {
"secTypeId": 2,
"name": "满199减100"
}, {
"secTypeId": 3,
"name": "买二赠一专区"
}, {
"secTypeId": 4,
"name": "海鲜大咖"
}, {
"secTypeId": 5,
"name": "为您推荐"
}];
}
var issx = 0;
var doller = 0;
function getData(secTypeId) {
// mui('').pullRefresh().scroll(0, 0, 0);
backTop();
var data_set = {
secTypeId: secTypeId,
topTypeId: 1
};
mui.ajax(llUrl('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 = ''
html_ = '<div class="day"><p>此活动仅限14-15号两天</p></div>';
}
$.each(data.list, function() {
htmlcon += '<div class="ect_com" data-id="' + this.goodsId + '"><div class="com_img1" ><img src="' + hyhImgUrl(this.goodsImg) + '" /></div><p class="p1"><img src="http://img.heyuanhui.cn/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) {
//异常处理;
// alert(type);      
}
}); 
}
function countTime() {
//获取当前时间
var date = new Date();
var now = date.getTime();
//设置截止时间
var endDate = new Date("2018/10/01 00:00:00");
var end = endDate.getTime();
//时间差
var leftTime = end - now;
//定义变量 d,h,m,s保存倒计时的时间
var 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;
}
document.getElementById("_d").innerHTML = d;
// document.getElementById("_h").innerHTML = h;
// document.getElementById("_m").innerHTML = m;
// document.getElementById("_s").innerHTML = s;
}
//递归每秒调用countTime方法显示动态时间效果
setTimeout(countTime, 1000);
}
mui.plusReady(function() {
window.addEventListener('refresh', function(e) { //执行刷新
location.reload();
});
getData(secTypeId);
var html = '';
$.each(nav_data, function() {
if(timestamp1 >= 1537027200000) {
html += '<div class="nav_block" style="width:50%;" data-secTypeId="' + this.secTypeId + '">' + this.name + '</div>';
} else {
html += '<div class="nav_block" data-secTypeId="' + this.secTypeId + '">' + this.name + '</div>';
}
});
$('.nav').html(html);
$('.nav_block').eq(0).addClass('on');
setInterval(function() {
mui.ajax('https://api.tokencan.com/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) {
//异常处理;
// alert(type);      
}
});
}, 2000)
mui("body").on('tap', '.nav_block', function() {
secTypeId = this.attributes["data-secTypeId"].nodeValue;
$(this).addClass('on').siblings().removeClass('on');
getData(secTypeId)
})
mui(".con").on('tap', '.ect_com', function() {
// var tj = plus.webview.create('search.html');
// tj.show();
// 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, //等待框背景区域高度,默认根据内容自动计算合适高度
// ......
}
}
})
});
})