//components var components = { header: { data: function () { return {}; }, mounted: function () { }, methods: { }, template: '\
\
\ \
\
\
\ \
\
\ \
\
\
\  \ 中文\ |\ en\
\
\ \
\
\ ' }, footer: { data: function () { return { link: "http://www.huangshan.gov.cn/" }; }, mounted: function () { }, methods: { openwin: function () { if (this.link) { var u = navigator.useragent, app = navigator.appversion; if (!!u.match(/\(i[^;]+;( u;)? cpu.+mac os x/)) { location.href = this.link; } else { var winref = window.open("", "_blank");//打开一个新的页面 var _this = this; settimeout(function () { winref.location = _this.link }, 800); } } } }, template: '\ \ ' } }; //格式化时间 //dateformat("yyyy/mm/dd") 结果 2017/07/19 //dateformat("yyyy/mm/dd hh:mm:ss") 结果 2017/07/19 10:09:11 //dateformat("yyyy/mm/dd ee hh:mm:ss") 结果 2017/07/19 周三 10:09:11 function dateformat(dateobj, fmt) { var date; if (typeof (dateobj) == "string") { date = this.strtodate(dateobj) } else if (typeof (dateobj) == "object") { date = dateobj } else { return "" } var o = { "m+": date.getmonth() + 1, //月份 "d+": date.getdate(), //日 "h+": date.gethours() % 12 == 0 ? 12 : date.gethours() % 12, //小时 "h+": date.gethours(), //小时 "m+": date.getminutes(), //分 "s+": date.getseconds(), //秒 "q+": math.floor((date.getmonth() + 3) / 3), //季度 "s": date.getmilliseconds() //毫秒 }; var week = { "0": "日", "1": "一", "2": "二", "3": "三", "4": "四", "5": "五", "6": "六" }; if (!fmt) { fmt = "yyyy-mm-dd hh:mm:ss"; } if (/(y+)/.test(fmt)) { fmt = fmt.replace(regexp.$1, (date.getfullyear().tostring() + "").substr(4 - regexp.$1.length)); } if (/(e+)/.test(fmt)) { fmt = fmt.replace(regexp.$1, ((regexp.$1.length > 1) ? (regexp.$1.length > 2 ? "星期" : "周") : "") + week[date.getday().tostring() + ""]); } for (var k in o) { if (new regexp("(" + k + ")").test(fmt)) { fmt = fmt.replace(regexp.$1, (regexp.$1.length == 1) ? (o[k].tostring()) : (("00" + o[k].tostring()).substr(("" + o[k].tostring()).length))); } } return fmt; } function strtodate(dateobj) { if (typeof (dateobj) == "object") { return dateobj; } dateobj = dateobj.replace(/t/g, ' ').replace(/\.[\d]{3}z/, '').replace(/(-)/g, '/') if (dateobj.indexof(".") > 0) dateobj = dateobj.slice(0, dateobj.indexof(".")) return new date(dateobj) } //格式化星期 function formatweek(week) { switch (week) { case 0: return "周日"; break; case 1: return "周一"; break; case 2: return "周二"; break; case 3: return "周三"; break; case 4: return "周四"; break; case 5: return "周五"; break; case 6: return "周六"; break; } } function formatweek2(week) { switch (week) { case 0: return "星期日"; break; case 1: return "星期一"; break; case 2: return "星期二"; break; case 3: return "星期三"; break; case 4: return "星期四"; break; case 5: return "星期五"; break; case 6: return "星期六"; break; } } $(function () { $("header dl dd ul li>a").on("mouseover", function () { $(this).parent().addclass("active").siblings().removeclass("active"); $(".search-box").removeclass("active"); }); $("header dl dd ul li .sub").on("mouseleave", function (event) { if (event.clienty > $("header").outerheight()) { $(this).removeclass("active"); $("header dl dd ul li").removeclass("active"); } }); $("header").on("mouseleave", function () { $("header dl dd ul li").removeclass("active"); }); $(window).on("scroll", function () { var scrolltop = document.documentelement.scrolltop || window.pageyoffset || document.body.scrolltop; if (scrolltop > 0) { $("header,.header-mobile").addclass("active"); } else { $("header,.header-mobile").removeclass("active"); } }); $(".header-mobile .nav ul li i").on("click", function () { $(this).parent().toggleclass("active"); }); //打开菜单 $(".header-mobile .left").on("click", function () { if ($(this).parents(".header-mobile").hasclass("open")) { $(".header-mobile").removeclass("open"); } else { $(".header-mobile").addclass("open"); } }); //搜索 $(".lang a.search").on("click", function () { $(this).parent().siblings(".search-box").addclass("active"); $(".search-box .input .box input").val('').focus(); }); $(".search-box .input .close").on("click", function () { $(".search-box").removeclass("active"); }); $(".search-box .input .box input").on("keyup", function (e) { if (e.keycode == '13') { if ($(this).val().trim()) { location.href = "/html/search_result.html?k=" + encodeuricomponent($(this).val().trim()); } } }); //footer $('.footer-main-item .item-title').on('click', function () { if (!ispc()) { if ($(this).hasclass('active')) { $(this).removeclass('active').siblings('.item-list').hide(); } else { $(this).addclass('active').siblings('.item-list').show(); } } }); //wx_code $(".footer-main-media .media-list .wechat").on("click", function () { var html = '
'; $("body").append(html); }); //totop if ($("meta[name=totop]").attr("content") == "true") { $("
").appendto('body'); $("#totop").css({ width: '50px', height: '50px', bottom: '150px', right: '25px', position: 'fixed', cursor: 'pointer', zindex: '999999' }); if ($(this).scrolltop() == 0) { $("#totop").hide(); } $(window).scroll(function (event) { if ($(this).scrolltop() == 0) { $("#totop").hide(); } if ($(this).scrolltop() != 0) { $("#totop").show(); } }); $("#totop").click(function (event) { $("html,body").animate({ scrolltop: "0px" }, 666); }); } }); function ispc() { if ((navigator.useragent.match(/(phone|pad|pod|iphone|ipod|ios|ipad|android|mobile|blackberry|iemobile|mqqbrowser|juc|fennec|wosbrowser|browserng|webos|symbian|windows phone)/i))) { return false; } else { return true; } } function getstock() { $.ajax({ url: "http://yunhq.sse.com.cn:32041/v1/sh1/snap/600054?callback=showstock&select=name%2clast%2cchg_rate%2cchange%2camount%2cvolume%2copen%2cprev_close%2cask%2cbid%2chigh%2clow%2ctradephase&_=1548998699817", type: "get", datatype: "jsonp", success: function (data) { } }); $.ajax({ url: "http://yunhq.sse.com.cn:32041/v1/sh1/snap/900942?callback=showstock&select=name%2clast%2cchg_rate%2cchange%2camount%2cvolume%2copen%2cprev_close%2cask%2cbid%2chigh%2clow%2ctradephase&_=1548998699817", type: "get", datatype: "jsonp", success: function (data) { } }); //var data = [ // { "code": "600054", "date": 20190201, "time": 141742, "snap": ["黄山旅游", 9.21, 2.33, 0.21, 27384041, 3001473, 9.05, 9.00, [9.21, 29200, 9.22, 22900, 9.23, 38400, 9.24, 21600, 9.25, 18600], [9.20, 6600, 9.19, 19200, 9.18, 31000, 9.17, 33387, 9.16, 11500], 9.21, 9.02, "t111"] }, // { "code": "900942", "date": 20190201, "time": 141757, "snap": ["黄山b股", 1.202, 0.75, 0.009, 190425, 158701, 1.188, 1.193, [1.203, 36000, 1.204, 29500, 1.205, 28700, 1.206, 62200, 1.207, 29000], [1.202, 900, 1.201, 1100, 1.20, 6600, 1.199, 7700, 1.198, 10400], 1.207, 1.182, "t111"] } //]; } function showstock(data) { if (data.code == "600054") { //设置首页股票 if ($(".shares-main").length > 0) { $(".shares-main .shares-item:eq(0)").find(".num span:eq(0)").html(data.snap[1]); $(".shares-main .shares-item:eq(0)").find(".num span:eq(1)").html((data.snap[3] >= 0 ? "+" : "") + data.snap[3] + "(" + (data.snap[3] >= 0 ? "+" : "") + "" + (data.snap[2]) + "%)"); if (data.snap[3] < 0) { $(".shares-main .shares-item:eq(0)").find(".num span:eq(1)").addclass("fall"); } else { $(".shares-main .shares-item:eq(0)").find(".num span:eq(1)").addclass("rise"); } $(".shares-main .shares-item:eq(0)").find(".time").html(formatestockdate(data.date) + " " + formatestockdate(data.time) + " (北京时间)"); } //子页面股票 if ($(".investors-stock").length > 0) { $(".investors-stock .investors-stock-content>div:eq(0)").find(".investors-stock-content-price").html(data.snap[1] + "" + (data.snap[3] < 0 ? "↓" : "↑") + " " + (data.snap[3] >= 0 ? "+" : "") + (data.snap[3]) + "(" + (data.snap[3] >= 0 ? "+" : "") + (data.snap[2]) + "%)").addclass((data.snap[3] < 0 ? "down" : "")); $(".investors-stock .investors-stock-content>div:eq(0)").find(".investors-stock-content-time").html(formatestockdate(data.date) + " " + formatestockdate(data.time) + " (北京时间)"); } } else { //设置首页股票 if ($(".shares-main").length > 0) { $(".shares-main .shares-item:eq(1)").find(".num span:eq(0)").html(data.snap[1]); $(".shares-main .shares-item:eq(1)").find(".num span:eq(1)").html((data.snap[3] >= 0 ? "+" : "") + data.snap[3] + "(" + (data.snap[3] >= 0 ? "+" : "") + "" + (data.snap[2]) + "%)"); if (data.snap[3] < 0) { $(".shares-main .shares-item:eq(1)").find(".num span:eq(1)").addclass("fall"); } else { $(".shares-main .shares-item:eq(1)").find(".num span:eq(1)").addclass("rise"); } $(".shares-main .shares-item:eq(1)").find(".time").html(formatestockdate(data.date) + " " + formatestockdate(data.time) + " (北京时间)"); } //子页面股票 if ($(".investors-stock").length > 0) { $(".investors-stock .investors-stock-content>div:eq(1)").find(".investors-stock-content-price").html(data.snap[1] + "" + (data.snap[3] < 0 ? "↓" : "↑") + " " + (data.snap[3] >= 0 ? "+" : "") + (data.snap[3]) + "(" + (data.snap[3] >= 0 ? "+" : "") + (data.snap[2]) + "%)").addclass((data.snap[3] < 0 ? "down" : "")); $(".investors-stock .investors-stock-content>div:eq(1)").find(".investors-stock-content-time").html(formatestockdate(data.date) + " " + formatestockdate(data.time) + " (北京时间)"); } } } function formatestockdate(str) { str = str.tostring(); if (str.length == 8) { return str.substring(0, 4) + " / " + str.substring(4, 6) + " / " + str.substring(6, 8); } else if (str.length == 6) { return str.substring(0, 2) + ":" + str.substring(2, 4) + ":" + str.substring(4, 6); } else if (str.length == 5) { return "0" + str.substring(0, 1) + ":" + str.substring(1, 3) + ":" + str.substring(3, 5); } } getstock(); function playvideo(title, video_url) { var ww = $(window).width(); var aw = (ww > 1280 ? 1280 : ww) * 0.9; layer.open({ title: title, type: 1, skin: 'layui-layer-rim', area: [aw + 'px', (aw * 9 / 16) + 'px'], content: '' }); } function initgallerymodal(gallerymodel, type, index) { var html = ""; html += "
"; html += "
"; html += "
"; html += " "; html += " "; html += "
"; html += "
"; if (type == 0) { for (var i = 0; i < gallerymodel.img.length; i++) { html += "
"; } } else { for (var i = 0; i < gallerymodel.video.length; i++) { html += "
"; } } html += "
"; html += "
"; html += "
"; html += "
"; html += "
"; html += "
"; if (type == 0) { for (var i = 0; i < gallerymodel.img.length; i++) { html += " "; } } else { for (var i = 0; i < gallerymodel.video.length; i++) { html += " "; } } html += "
"; html += "
"; html += " "; html += " "; html += "
"; html += "
"; if (type == 0) { for (var i = 0; i < gallerymodel.img.length; i++) { html += "
"; } } else { for (var i = 0; i < gallerymodel.video.length; i++) { html += "
"; } } html += "
"; html += "
"; html += "
"; html += "
"; html += "
"; html += "
"; html += " "; html += " 图片" + (gallerymodel.img.length) + ""; html += "
"; html += "
"; html += " "; html += " 视频" + (gallerymodel.video.length) + ""; html += "
"; html += "
"; html += "
"; html += "
"; $("body").append(html); var gallerythumbs = new swiper('.gallery-thumbs', { spacebetween: 10, slidesperview: 7, freemode: true, centeredslides: false, watchslidesvisibility: true, watchslidesprogress: true, pagination: { el: '.swiper-pagination', type: 'progressbar' }, breakpoints: { 1440: { slidesperview: 5 }, 1366: { slidesperview: 4 }, 1024: { slidesperview: 3 }, 640: { slidesperview: 2 }, 320: { slidesperview: 1 } } }); var gallerytop = new swiper('.gallery-top', { spacebetween: 10, initialslide: index || 0, navigation: { nextel: '.layui-layer-viewgroup .viewgroup-main .next-btn,.viewgroup-select-list .next-btn', prevel: '.layui-layer-viewgroup .viewgroup-main .last-btn,.viewgroup-select-list .last-btn' }, thumbs: { swiper: gallerythumbs }, on: { slidechange: function () { $(".viewgroup-select-bar span").removeclass("bg-skyblue"); $(".viewgroup-select-bar span:lt(" + (this.activeindex + 1) + ")").addclass("bg-skyblue"); var activeindex = this.activeindex; $(".swiper-slide video").each(function (i) { if (i == activeindex) { $(this)[0].play(); } else { $(this)[0].pause(); } }); } } }); if (type == 1) { $(".swiper-slide-active video")[0].play(); } $(".layui-layer-viewgroup .viewgroup-footer .viewgroup-nav .viewgroup-nav-item").on("click", function () { var _swiper_slide = ""; var __item = ""; var _span = ""; if ($(this).index() == 0) {//图片 for (var i = 0; i < gallerymodel.img.length; i++) { _swiper_slide += "
"; __item += "
"; _span += " "; } } else {//视频 for (var i = 0; i < gallerymodel.video.length; i++) { _swiper_slide += "
"; __item += "
"; _span += " "; } } $(".gallery-top .swiper-wrapper").html(_swiper_slide); $(".gallery-thumbs .swiper-wrapper").html(__item); $(".viewgroup-select-bar").html(_span); gallerythumbs.update(); gallerytop.update(); $(this).addclass("bg-skyblue").siblings().removeclass("bg-skyblue"); if ($(this).index() == 1) { $(".swiper-slide-active video")[0].play(); } }); } /* * urlhelper */ var urlhelper = { getquerystring: function (name) { var reg = new regexp("(^|&)" + name + "=([^&]*)(&|$)"); var r = window.location.search.substr(1).match(reg); if (r != null) return unescape(decodeuricomponent(r[2])); return null; } }; /* * cookiehelper */ var cookiehelper = { //获取cookie get: function (name) { if (document.cookie.length > 0) { c_start = document.cookie.indexof(name + "=") if (c_start != -1) { c_start = c_start + name.length + 1 c_end = document.cookie.indexof(";", c_start) if (c_end == -1) c_end = document.cookie.length return unescape(decodeuricomponent(document.cookie.substring(c_start, c_end))) } } return ""; }, //获取所有cookie getall: function () { var cookies = document.cookie.split(/;\s/g); var cookieobj = {}; cookies.foreach(function (item) { var key = item.split('=')[0]; cookieobj[key] = item.split('=')[1]; }); return cookieobj; }, //设置cookie set: function (name, value, minutes) { var expdate = new date(); expdate.settime(expdate.gettime() + (minutes || 480) * 60 * 1000); document.cookie = name + "=" + encodeuricomponent(value) + ";expires=" + expdate.togmtstring() + ";path=/"; }, //删除cookie remove: function (name) { cookiehelper.set(name, "", -1); }, //删除所有cookie removeall: function () { var keys = object.keys(cookiehelper.getall()); keys.foreach(function (item) { cookiehelper.remove(item); }); } }; try { axios.defaults.baseurl = 'http://api.hstd.com'; } catch (e) { }