You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
2.8 KiB
JavaScript

2 years ago
$(function() {
remInit(100, 375);
selectProductInit();
copyInit();
});
function remInit(screenSize, picSize) {
$(window)
.on("resize", function(e) {
var $body = $("body");
var browser_width = $body.width();
var browser_height = $body.height();
var htmlWidth = picSize;
var remResize;
if (browser_width > browser_height) {
remResize =
document.documentElement.clientHeight || document.body.clientHeight;
//$uiBox.addClass("horizontal");
} else {
remResize =
document.documentElement.clientWidth || document.body.clientWidth;
//$uiBox.removeClass("horizontal");
}
var size = ((remResize < 768 ? remResize : 768) / htmlWidth) * screenSize;
$("html").css("font-size", size + "px");
})
.trigger("resize");
}
function selectProductInit() {
var selectFlag = true;
var $selectProduct = $(".select-product");
if ($selectProduct.length > 0) {
if ($selectProduct.find("li").length <= 0) {
$selectProduct.addClass("no-item");
$selectProduct.find(".title-2 span").text("暂无产品");
} else {
$selectProduct.find("li").on("click", function() {
var $this = $(this);
if ($this.find(".select-btn a").hasClass("current")) {
$this.find(".select-btn a").removeClass("current");
} else {
$selectProduct.find(".select-btn a").removeClass("current");
$this.find(".select-btn a").addClass("current");
}
});
$selectProduct.find(".title-2 a").on("click", function() {
if (selectFlag) {
$selectProduct.find(".title-2 span").addClass("current");
$selectProduct.find("li").each(function() {
var $this = $(this);
if ($this.find(".select-btn a").hasClass("current")) {
$this.show();
} else {
$this.hide();
}
});
} else {
$selectProduct.find(".title-2 span").removeClass("current");
$selectProduct.find("li").show();
}
selectFlag = !selectFlag;
});
}
}
}
function copyInit() {
if ($(".vip-download").length > 0) {
$(".gift-list li").each(function() {
var $this = $(this);
var thisCopyBtn = $this.find(".gift-code a").attr("class");
var clipboard = new ClipboardJS("." + thisCopyBtn);
clipboard.on('success', function (e) {
alert("复制成功");
});
clipboard.on('error', function (e) {
var ua = navigator.userAgent;
var isIOS = !!ua.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
if (isIOS && ua.match(/os\s+(\d+)/i)[1] - 0 < 10) {
alert("您的系统版本过低,请手动复制下方地址");
}
});
});
}
}