/* 未能缩小。正在返回未缩小的内容。 (460,44-52): run-time error JS1193: Expected ',' or ')': function (460,57-58): run-time error JS1004: Expected ';': { (473,28-36): run-time error JS1004: Expected ';': checkBuy (495,6-7): run-time error JS1195: Expected expression: ) (497,53-54): run-time error JS1004: Expected ';': { (503,30-38): run-time error JS1004: Expected ';': checkBuy (508,6-7): run-time error JS1195: Expected expression: ) (510,62-63): run-time error JS1004: Expected ';': { (535,1-2): run-time error JS1002: Syntax error: } (539,48-49): run-time error JS1004: Expected ';': { (511,9,531,11): run-time error JS1018: 'return' statement outside of function: return new Promise(function (resolve, reject) { $.ajax({ url: '/medicine/getMedicineIsBuy', type: "post", dateType: "json", data: { medicineid: medicineid, store_medicineid: store_medicineid, storeid: storeid }, success: function (d) { if (d.code < 0) { openInfo(d.result || "该商品暂不能购买"); resolve(false) } else { resolve(true) } }, error: function () { reject(false) }, complete: function () { } }) }) */ jQuery(function () { timer(); var _par = ''; var _desc = ''; $("#moreGuide").click(function () { if ($("#guideInfo").css("display") == "none" || $("#guideInfo").css("display") == "") { $(this).removeClass("bb"); $(this).html("收起完整说明书 ↑"); } else { $(this).html("展开完整说明书 ↓"); $(this).addClass("bb"); } $("#guideInfo").toggle(); }) //购买弹层 $(".js-buy-show").click(function () { _par = $(this).attr("par"); _desc = $(this).attr("desc"); var period = $("#js-value-period-show").val().toLocaleLowerCase(); if (period == "2") { $("#near_period_add").show(); return } var rx_max_qty = $(this).data("rx_max_qty"); if (rx_max_qty != null && rx_max_qty != undefined && parseInt(rx_max_qty)>0) { $("#quantity").val(rx_max_qty); } buyOrAddToCart(_par, _desc) }) // 效期弹框 点击是 $('#showMedicitionSelect').click(function (e) { $("#near_period_add").hide(); e.stopPropagation() buyOrAddToCart() }) function buyOrAddToCart(paramsPar, paramsDesc) { var par = paramsPar || _par; var desc = paramsDesc || _desc; if (par == "1") { $("#addCart_before").attr("par", par).removeClass("yellow").addClass("red").text("立即购买"); $("#addCart").attr("par", par).removeClass("yellow").addClass("red").text("立即购买"); } else if (par == "2") { //$("#addCart").attr("par", "1").removeClass("yellow").addClass("red").text("领券购买"); } else { $("#addCart_before").removeAttr("par").addClass("yellow").removeClass("red").text("加入购物车"); $("#addCart").removeAttr("par").addClass("yellow").removeClass("red").text("加入购物车"); } $(".coupon_tips").hide(); if (desc != "" && desc != undefined) { $(".coupon_tips").show(); $(".coupon_tips span").html(desc); } check_buy(); openDialogBtn("#div_buy"); } $(".js-open-inquiry").click(function () { var period = $("#js-value-period-show").val().toLocaleLowerCase(); if (period == "2") { $("#near_period_add").show(); return } check_buy(); openDialogBtn("#div_buy"); }); $(".js-inquiry").click(function () { var obj = $(".js-buy-medicine-id.active"); var smid = obj.attr("smid"); var qty = $("#quantity").val(); var maxqty = $("#quantity").data("maxqty"); var start_buyqty = $("#quantity").data("start_buyqty"); if (qty && maxqty && maxqty > 0 && maxqty < qty) { yb.error("超过限购数量,请重新选择"); return; } if (quantity && start_buyqty && start_buyqty > 0 && start_buyqty > quantity) { yb.error("购买数量需满" + start_buyqty + "件起售"); return; } var top_referrer = window.location.pathname; window.location.href = "/wenzhen/inquiry?top_referrer=" + top_referrer + "&smids=" + smid + "&qtys=" + qty ; }); $('.js-buy-medicine-id').click(function () { $('.js-buy-medicine-id').removeClass('active'); $('.tc-div .cart-suit-item').hide(); $(this).addClass('active'); var key = $(this).attr('data-key'); if (key != undefined && key != "" && key != null) { $('.tc-div .cart-suit-item[data-key=' + key + ']').show(); } $(".js-xz-name").text($(this).attr("name")); var price = parseFloat($(this).attr("price")).toFixed(2); var qty = parseInt($("#quantity").val()); $(".js-price").text((price * qty).toFixed(2)); if (qty>1) { $(".js-price-desc").text("¥"+price+"/件").show(); } else { $(".js-price-desc").text("").hide(); } var amount = $(this).attr("amount") || 0; if (amount > 0) { $(".checked_size").html(amount); $(".checked_size").show(); } else { $(".checked_size").hide(); } }) var defaultcount = 1; $("#buyplus").click(function () { var obj = $("#quantity"); var quantity = obj.val(); var reserve = $("#reserve").text(); var limitNum = $("#limitNum").text(); if (!isNaN(quantity) && quantity != "") { if (parseInt(quantity) + 1 > parseInt(reserve)) { quantity = reserve; openInfo("商品库存仅剩" + reserve + "件"); } else if (!isNaN(limitNum) && parseInt(limitNum) > 0 && parseInt(quantity) + 1 > parseInt(limitNum)) { quantity = limitNum; openInfo("该商品限购" + limitNum + "件"); } else { quantity = parseInt($(obj).val()) + 1; } } else { quantity = defaultcount; openInfo("请输入正确的购买数量"); } $("#quantity").val(quantity); check_buy(); }) $("#buyminus").click(function () { var obj = $("#quantity"); var quantity = obj.val(); var reserve = $("#reserve").text(); var limitNum = $("#limitNum").text(); if (!isNaN(quantity) && quantity != "") { if (parseInt(quantity) - 1 > parseInt(reserve)) { quantity = reserve; openInfo("商品库存仅剩" + reserve + "件"); } else if (!isNaN(limitNum) && parseInt(limitNum) > 0 && parseInt(quantity) - 1 > parseInt(limitNum)) { quantity = limitNum; openInfo("该商品限购" + limitNum + "件"); } else { if (parseInt(quantity) - 1 <= 0) { quantity = defaultcount; } else { quantity = parseInt($(obj).val()) - 1; } } } else { quantity = defaultcount; openInfo("请输入正确的购买数量"); } $("#quantity").val(quantity); check_buy(); }) $("#quantity").keyup(function () { var obj = $(this); var quantity = obj.val(); var reserve = $("#reserve").text(); var limitNum = $("#limitNum").text(); if (!isNaN(quantity) && quantity != "") { if (parseInt(quantity) > parseInt(reserve)) { quantity = reserve; openInfo("商品库存仅剩" + reserve + "件"); } else if (!isNaN(limitNum) && parseInt(limitNum) > 0 && parseInt(quantity) > parseInt(limitNum)) { quantity = limitNum; openInfo("该商品限购" + limitNum + "件"); } } else { quantity = defaultcount; openInfo("请输入正确的购买数量"); } $("#quantity").val(quantity); check_buy(); }) function check_buy() { var prescription_qty = parseInt($('#prescription_qty').val());//已有处方最大购买数量 var quantity = parseInt($("#quantity").val()); var is_inquiry_open_rx = $('#is_inquiry_open_rx').val();//该商品是否在线问诊灰度商品 $('.js-buy-btn-show').css('display', 'block'); $('.js-inquiry').css('display', 'none'); if (is_inquiry_open_rx == 1 && (prescription_qty == null || prescription_qty == undefined || prescription_qty == 0 || prescription_qty < quantity)) { $('.js-buy-btn-show').css('display', 'none'); $('.js-inquiry').css('display', 'block'); } if (is_inquiry_open_rx == 1 && prescription_qty != null && prescription_qty != undefined && prescription_qty >= quantity) { $('#isneed_rx').val(1); } $(".js-buy-medicine-id.active").click(); }; function timer() { var diff = $("#end_sec").val(); a = window.setInterval(function () { hour = 0, minute = 0, second = 0; //时间默认值 if (diff > 0) { hour = Math.floor(diff / (60 * 60)); minute = Math.floor(diff / 60) - (hour * 60); second = Math.floor(diff) - (hour * 60 * 60) - (minute * 60); } if (hour <= 9) hour = '0' + hour; if (minute <= 9) minute = '0' + minute; if (second <= 9) second = '0' + second; $("#perid_time").html(hour + ":" + minute + ":" + second); diff--; }, 1000); if (diff < 0) { window.clearInterval(a); } } $("label.icons.qbtn").click(function () { var id = $(this).attr("para"); var timeParam = Math.round(new Date().getTime() / 1000); $.ajax({ url: "/common/acceptcoupon", type: "post", data: { id: id, s: timeParam }, success: function (data) { if (data.code == -999) { location.href = "/login.html?Referer=" + encodeURIComponent(location.href); return false; } if (data.code > 0) { msg.success("领取成功"); } else { openInfo("领取失败"); } } }) }); $(".linqucoupons").click(function () { var id = $(this).attr("para"); var timeParam = Math.round(new Date().getTime() / 1000); $.ajax({ url: "/common/acceptcoupon", type: "post", data: { id: id, s: timeParam }, success: function (data) { if (data.code == -999) { location.href = "/login.html?Referer=" + encodeURIComponent(location.href); return false; } if (data.code > 0) { msg.success("领取成功"); } else { openInfo(data.msg); } } }) }); $(document).on("click", ".js_lczlist .so_item", function () { var cur = $(this); var smid = parseInt(cur.data("smid")), smpid = parseInt(cur.data("smpid")), num = parseInt(cur.data("num")), price = parseFloat(cur.data("price")), saving = parseFloat(cur.data("saving")); smpid = smpid ? smpid : 0; smid = smid ? smid : 0; price = price ? price : 0; saving = saving ? saving : 0; num = num ? num : 0; cur.siblings().removeClass("on"); cur.addClass("on"); $(".js_total").html("¥" + price.toFixed(2)); $(".js_sheng").html("¥" + saving.toFixed(2)); $(".js_h_smpid").val(smpid); $(".js_h_smp_num").val(num); }); $(".tt").click(function () { var list = $(".tt"); var i = 0; for (i = 0; i < list.length; i++) { list[i].classList.remove('checked'); } $(this).toggleClass('checked'); }) // 导航绑定 var scrollNav $(window).on('scroll', function () { if (scrollNav) { clearTimeout(scrollNav) } scrollNav = setTimeout(function () { var $route1 = $('#route1') var $route2 = $('#route2') var $route3 = $('#route3') var scroll1 = $route1.offset() && $route1.offset().top || 0 var scroll2 = $route2.offset() && $route2.offset().top || 0 var scroll3 = $route3.offset() && $route3.offset().top || 0 var header1 = $('.imggege').height() var header2 = $('.topnavBar').height() var top = $(window).scrollTop() + header1 + header2 if (top < scroll2 - 1) { $('.goods__nav a').eq(0).addClass('_active').siblings().removeClass('_active') } else if (top >= scroll2 - 1 && top < scroll3 - 1) { $('.goods__nav a').eq(1).addClass('_active').siblings().removeClass('_active') } else { $('.goods__nav a').eq(2).addClass('_active').siblings().removeClass('_active') } }, 100); }) // 导航点击 $('.goods__nav').on('click', 'a', function () { var key = $(this).attr('data-key') var $route = $('#route' + key) var scroll = $route.offset().top var header1 = $('.imggege').height() var header2 = $('.topnavBar').height() var top = scroll - header1 - header2 if (key == 1) { top = 0 } $(this).addClass('_active').siblings().removeClass('_active') //$('html').animate({ scrollTop: top }) var body = $('body, html') body.animate({ scrollTop: top }) }) // tab切换 $('.goods__tabHeader').on('click', '.goods__tabRoute', function () { var route = $(this) if (route.hasClass('_active')) return false; route.addClass('_active').siblings().removeClass('_active') var key = +route.attr('data-key') $(".goods__tabContain").removeClass('_active') $('.goods__tabContain[data-key=' + key + ']').addClass('_active') }) $("#tcUl").newTab({ className: "cur", event: "click" }); $("#tcBtn").click(function () { OpenFixBt($("#ctBt")); }); $("#hdBtn").click(function () { OpenFixBt($("#hdBt")); }); $("#yhqBtn").click(function () { OpenFixBt($("#yhqBt")); }); if ($.cookie("newgift") == null || $.cookie("newgift") != "1") { $.post("/common/IsFreshByMobile", function (d) { if (d.code > 0 && d.result) { $('#newgift').show(); $.cookie("newgift", "1", { expires: 1, path: "/", domain: $("#domain").val() }); } }); } new Swiper('.goods__shopMain', { slidesPerView: 'auto' }) var _qual = new Swiper('.dialog__shopQualSwiper._qual', { navigation: { nextEl: '.dialog__shopQual-next', prevEl: '.dialog__shopQual-prev' }, init: false }) var _shop = new Swiper('.dialog__shopQualSwiper._shop', { navigation: { nextEl: '.dialog__shopQualP-next', prevEl: '.dialog__shopQualP-prev' }, init: false }) function dialogInit() { $('.dialog__shopQualSwiper._qual')[0] && _qual.init() $('.dialog__shopQualSwiper._shop')[0] && _shop.init() } function innerInit() { $('.dialog__shopQualInnerBox1')[0] && _inner1.init() $('.dialog__shopQualInnerBox2')[0] && _inner2.init() } $('.dialog__shopQualHeader').on('click', 'a', function () { var $that = $(this) if ($that.hasClass('_active')) return false; var key = +$that.attr('data-key'); $that.addClass('_active').siblings().removeClass('_active') $('.dialog__shopQualContain').removeClass('_active') $('.dialog__shopQualContain[data-key=' + key + ']').addClass('_active') dialogInit() }) $('.goods__shopQual').on('click', function () { $('#dialog__shopQual').show() dialogInit() }) $('.dialog__shopQualClose').on('click', function () { $('#dialog__shopQual').hide() }) $('#dialog__shopQual').on('click', '.mask', function () { $('#dialog__shopQual').hide() }) $('.dialog__shopQualSwiper').on('click', '.dialog__shopQualItem', function () { var key = +$(this).attr('data-key') var pas = $(this).parents('.dialog__shopQualContain') var tar = pas.find('.dialog__shopQualInner') var swiper = tar.find('.dialog__shopQualInnerBox') var name = swiper[0].classList tar.show() new Swiper('.' + Array.prototype.join.call(name, '.'), { initialSlide: key - 1, }) }) $('.dialog__shopQualBack').on('click', function () { $(this).parents('.dialog__shopQualInner').hide() }) $("#downloadApp").on('click', function () { if (isWXvisited()) { window.location.href = "https://m.yaofangwang.com/app/download.html"; } else { window.location.href = "https://at.umtrack.com/onelink/eSfK9n"; } }) $("#addCart_before").on("click", async function (e) { $('#div_buy').removeClass('active') var period = $("#js-value-period-show").val().toLocaleLowerCase(); //if (period == "2") { // $("#near_period_add").show(); //} else { e.stopPropagation(); //先加入购物车 var store_medicineid = $(".js-buy-medicine-id.active").attr("smid"); var packageid = $(".js-buy-medicine-id.active").attr("packageid"); var medicineid = $(this).data("medicineid"); var storeid = $(this).data("storeid"); var qty = $("#quantity").val(); var canBuy = await checkBuy(medicineid, store_medicineid, storeid); if (canBuy) { if (packageid > 0) { var url = AddCart_2(store_medicineid, qty, 1, packageid, "h5", ""); if (url != null && url != '') { location.href = url; if (window.event) { window.event.returnValue = false; } } } else { if ($('#isneed_rx').val() == "1") { AddCart3(store_medicineid, qty, '', '', 1); } else { if (_par == 1) {//立即购买 var top_referrer = window.location.pathname; window.location.href = "/settle/confirm?top_referrer=" + top_referrer + "&store_medicineid=" + store_medicineid + "&qty=" + qty; } else { // 加入购物车 $("#addCart").click(); } } } } //} }) $(".js_inquiry").on("click", async function (e) { e.stopPropagation(); //直接问诊 var store_medicineid = $(this).data("store_medicineid"); var medicineid = $(this).data("medicineid"); var storeid = $(this).data("storeid"); const canBuy = await checkBuy(medicineid, store_medicineid, storeid) if (canBuy) { var top_referrer = window.location.pathname; window.location.href = "/wenzhen/inquiry?top_referrer=" + top_referrer + "&smids=" + store_medicineid + "&qtys=1"; } }) function checkBuy(medicineid, store_medicineid, storeid) { return new Promise(function (resolve, reject) { $.ajax({ url: '/medicine/getMedicineIsBuy', type: "post", dateType: "json", data: { medicineid: medicineid, store_medicineid: store_medicineid, storeid: storeid }, success: function (d) { if (d.code < 0) { openInfo(d.result || "该商品暂不能购买"); resolve(false) } else { resolve(true) } }, error: function () { reject(false) }, complete: function () { } }) }) } }) function Favorite(mid, sid, millId, IsFavorit) { jQuery.post("/Common/AccountFavorite", { mid: mid, sid: sid }, function (data) { if (data.code < 0) { if (data.code == -999) { //openInfo("请以个人身份登录后再进行收藏"); redirctLogin(); } else { openInfo("收藏失败,请重试"); } return; } if (IsFavorit != 1) { openInfo("该商品已成功加入您的收藏夹"); $("#addFav").addClass("cur"); } else { openInfo("您已经成功取消收藏该商品"); $("#addFav").removeClass("cur"); } }) } function isMobile(strMobile) { var reg1 = /^1\d{10}$/; var my = false; if (reg1.test(strMobile)) my = true; if (!my) { return false; } return true; } var show_rx_inform = (function () { var isExist = false; return function () { var rx_html = '