/**
* 寮曞叆layer寮圭獥
* @type {Boolean}
*/
var ey_layer_1609663499 = false;
if (window.jQuery && !window.layer) {
ey_layer_1609663499 = true;
}
if (ey_layer_1609663499) {
document.write(unescape("%3Cscript src='"+fe912b5dac71082e12c1827a3107f9b.root_dir+"/public/plugins/layer-v3.1.0/layer.js' type='text/javascript'%3E%3C/script%3E"));
}
// 鍔犲叆璐墿杞
function shop_add_cart() {
var JsonData = fe912b5dac71082e12c1827a3107f9b;
var QuantityObj = document.getElementById(JsonData.quantity);
var SelectValueIds = document.getElementById(JsonData.SelectValueIds);
var aid = JsonData.aid;
var num = QuantityObj.value;
var url = JsonData.shop_add_cart_url;
var ajaxdata = 'aid='+aid+'&num='+num+'&spec_value_id='+SelectValueIds.value;
// 搴撳瓨鏁伴噺
var StockCountObj = document.getElementById('ey_stock_1565602291').value;
if (parseInt(StockCountObj) == 0) {
if (!window.layer) {
alert('鍟嗗搧宸插敭缃勶紒');
} else {
layer.alert('鍟嗗搧宸插敭缃勶紒', {icon: 5, title: false, closeBtn: false});
}
return false;
} else if (parseInt(StockCountObj) < parseInt(num)) {
if (!window.layer) {
alert('鍟嗗搧搴撳瓨涓嶈冻锛?);
} else {
layer.alert('鍟嗗搧搴撳瓨涓嶈冻锛?, {icon: 5, title: false, closeBtn: false});
}
return false;
}
//鍒涘缓寮傛瀵硅薄
var ajaxObj = new XMLHttpRequest();
ajaxObj.open("post", url, true);
ajaxObj.setRequestHeader("X-Requested-With","XMLHttpRequest");
ajaxObj.setRequestHeader("Content-type","application/x-www-form-urlencoded");
//鍙戦€佽姹
ajaxObj.send(ajaxdata);
ajaxObj.onreadystatechange = function () {
// 杩欐涓哄垽鏂湇鍔″櫒鏄惁姝g‘鍝嶅簲
if (ajaxObj.readyState == 4 && ajaxObj.status == 200) {
var json = ajaxObj.responseText;
var res = JSON.parse(json);
if ('1' == res.code) {
// 鏄惁瑕佸幓璐墿杞
shop_cart_list(JsonData.shop_cart_list_url);
}else{
if (-1 == res.data.code) {
if (!window.layer) {
confirm(res.msg);
} else {
layer.alert(res.msg, {icon: 5, title: false, closeBtn: false});
}
}else{
// 鍘荤櫥闄
is_login(JsonData.login_url);
}
}
}
};
}
/**
* 鑾峰彇url鍙傛暟鍊肩殑鏂规硶
* @param {[type]} name [description]
* @return {[type]} [description]
*/
function getUrlParam_1607507428(name)
{
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if (r!=null) return unescape(r[2]); return null;
}
// 琛ㄥ崟鎻愪氦
function submitForm_1607507428(formname)
{
$("form[name="+formname+"]").submit();
}
// 閫夋嫨鏀粯鏂瑰紡
function paySelect_1607507428(formname)
{
var JsonData = fe912b5dac71082e12c1827a3107f9b;
var QuantityObj = document.getElementById(JsonData.quantity);
var SelectValueIds = document.getElementById(JsonData.SelectValueIds);
var aid = JsonData.aid;
var spec_value_id = SelectValueIds.value;
var mini_id = getUrlParam_1607507428('mini_id');
if ($('select[name=mini_id]') && 0 < $('select[name=mini_id]').val()) {
mini_id = $('select[name=mini_id]').val();
}
if (mini_id > 0) {
mini_id = parseInt(mini_id);
} else {
mini_id = 0;
}
// 搴撳瓨鏁伴噺
var StockCountObj = document.getElementById('ey_stock_1565602291').value;
if (parseInt(StockCountObj) == 0) {
layer.alert('鍟嗗搧宸插敭缃勶紒', {icon: 5, title: false, closeBtn: false});
return false;
} else if (parseInt(StockCountObj) < parseInt(QuantityObj.value)) {
layer.alert('鍟嗗搧搴撳瓨涓嶈冻锛?, {icon: 5, title: false, closeBtn: false});
return false;
}
var formhtml = '';
formhtml += '
';
$('body').append(formhtml);
var content = '';
content += '';
content += '';
layer.open({
type: 1,
title: '閫夋嫨鏀粯鏂瑰紡',
shadeClose: false,
maxmin: false, //寮€鍚渶澶у寲鏈€灏忓寲鎸夐挳
skin: 'WeChatScanCode_1607507428',
area: ['320px', '150px'],
content: content
});
}
// 寰俊鎵爜鏀粯
function WeChatScanCode_1607507428(aid, mini_id, spec_value_id, pay_code)
{
var formData = new FormData();
formData.append('aid_1607507428', aid);
formData.append('mini_id_1607507428', mini_id);
formData.append('spec_value_id_1607507428', spec_value_id);
formData.append('pay_code_1607507428', pay_code);
weipay_1607507428(formData);
}
// 寰俊鎵爜鏀粯锛岀敤浜嶱C绔
function weipay_1607507428(formData)
{
formData.append('_ajax', 1);
layer_loading('姝e湪澶勭悊');
$.ajax({
url: fe912b5dac71082e12c1827a3107f9b.buyFormUrl,
type: 'POST',
data: formData,
dataType: "json", //澹版槑鎴愬姛浣跨敤json鏁版嵁绫诲瀷鍥炶皟
//濡傛灉浼犻€掔殑鏄疐ormData鏁版嵁绫诲瀷锛岄偅涔堜笅鏉ョ殑涓変釜鍙傛暟鏄繀椤荤殑锛屽惁鍒欎細鎶ラ敊
cache: false, //榛樿鏄痶rue锛屼絾鏄竴鑸笉鍋氱紦瀛
processData: false, //鐢ㄤ簬瀵筪ata鍙傛暟杩涜搴忓垪鍖栧鐞嗭紝杩欓噷蹇呴』false锛涘鏋滄槸true锛屽氨浼氬皢FormData杞崲涓篠tring绫诲瀷
contentType: false, //涓€浜涙枃浠朵笂浼爃ttp鍗忚鐨勫叧绯伙紝鑷鐧惧害锛屽鏋滀笂浼犵殑鏈夋枃浠讹紝閭d箞鍙兘璁剧疆涓篺alse
success: function(res){
layer.closeAll();
if (res.code == 1) {
AlertPayImg_1607507428(res.data);
} else {
layer.alert(res.msg, {icon:5, title: false, closeBtn: false});
}
},
error: function(e){
layer.closeAll();
layer.alert(e.responseText, {icon:5, title: false, closeBtn: false});
}
});
}
var PayPolling_1607507428;
// 瑁呰浇鏄剧ず鎵爜鏀粯鐨勪簩缁寸爜
function AlertPayImg_1607507428(data) {
var html = "
姝e湪鏀粯涓?..璇峰嬁鍒锋柊";
layer.alert(html, {
title: '寰俊鎵爜鏀粯',
btn: [],
success: function() {
PayPolling_1607507428 = window.setInterval(function(){ OrderPayPolling_1607507428(data); }, 2000);
},
cancel: function() {
window.clearInterval(PayPolling_1607507428);
}
});
}
// 璁㈠崟杞
function OrderPayPolling_1607507428(data) {
var pay_id = data.pay_id;
var pay_mark = data.pay_mark;
var unified_id = data.unified_id;
var unified_number = data.unified_number;
var transaction_type = data.transaction_type;
if (!pay_id || !pay_mark || !unified_id || !unified_number || !transaction_type) {
layer.msg('璁㈠崟寮傚父锛屽埛鏂伴噸璇?, {time: 1500}, function(){
window.location.reload();
});
}
$.ajax({
url: fe912b5dac71082e12c1827a3107f9b.OrderPayPolling,
data: {
pay_id: pay_id,
pay_mark: pay_mark,
unified_id: unified_id,
unified_number: unified_number,
transaction_type: transaction_type
},
type:'post',
dataType:'json',
success:function(res){
if (1 == res.code) {
if (res.data) {
layer_loading('姝e湪澶勭悊');
window.clearInterval(PayPolling_1607507428);
if (2 == transaction_type) {
if (!res.data.mobile && !res.data.email) {
layer.closeAll();
layer.msg(res.msg, {time: 1500}, function() {
window.location.href = res.url;
});
}
if (res.data.mobile) SendMobile(res.data.mobile);
if (res.data.email) SendEmail(res.data.email);
}
layer.closeAll();
layer.msg(res.msg, {time: 1500}, function() {
window.location.href = res.url;
});
}
} else {
layer.alert(res.msg, {icon:5, title: false, closeBtn: false});
}
},
error: function(e){
layer.closeAll();
layer.alert(e.responseText, {icon:5, title: false, closeBtn: false});
}
});
}
// 鍙戦€佺煭淇
function SendMobile(result) {
if (result) {
$.ajax({
url: result.url,
data: result.data,
type:'post',
dataType:'json'
});
}
}
// 鍙戦€侀偖浠
function SendEmail(result) {
if (result) {
$.ajax({
url: result.url,
data: result.data,
type:'post',
dataType:'json'
});
}
}
// 绔嬪嵆璐拱
function BuyNow(aid){
var JsonData = fe912b5dac71082e12c1827a3107f9b;
var QuantityObj = document.getElementById(JsonData.quantity);
var SelectValueIds = document.getElementById(JsonData.SelectValueIds);
var url = JsonData.shop_buy_now_url;
var aid = JsonData.aid;
var num = QuantityObj.value;
var spec_value_id = SelectValueIds.value;
var ajaxdata = 'aid='+aid+'&num='+num+'&spec_value_id='+spec_value_id;
try {
if (document.getElementsByName("mini_id")[0]) {
var mini_id = getUrlParam_1607507428('mini_id');
if (0 < document.getElementsByName("mini_id")[0].value) {
mini_id = document.getElementsByName("mini_id")[0].value;
}
if (mini_id > 0) {
ajaxdata += '&mini_id='+parseInt(mini_id);
}
}
}catch(err){}
// 搴撳瓨鏁伴噺
var StockCountObj = document.getElementById('ey_stock_1565602291').value;
if (parseInt(StockCountObj) == 0) {
if (!window.layer) {
alert('鍟嗗搧宸插敭缃勶紒');
} else {
layer.alert('鍟嗗搧宸插敭缃勶紒', {icon: 5, title: false, closeBtn: false});
}
return false;
} else if (parseInt(StockCountObj) < parseInt(num)) {
if (!window.layer) {
alert('鍟嗗搧搴撳瓨涓嶈冻锛?);
} else {
layer.alert('鍟嗗搧搴撳瓨涓嶈冻锛?, {icon: 5, title: false, closeBtn: false});
}
return false;
}
//鍒涘缓寮傛瀵硅薄
var ajaxObj = new XMLHttpRequest();
ajaxObj.open("post", url, true);
ajaxObj.setRequestHeader("X-Requested-With","XMLHttpRequest");
ajaxObj.setRequestHeader("Content-type","application/x-www-form-urlencoded");
//鍙戦€佽姹
ajaxObj.send(ajaxdata);
ajaxObj.onreadystatechange = function () {
// 杩欐涓哄垽鏂湇鍔″櫒鏄惁姝g‘鍝嶅簲
if (ajaxObj.readyState == 4 && ajaxObj.status == 200) {
var json = ajaxObj.responseText;
var res = JSON.parse(json);
if ('1' == res.code) {
// 鍘昏喘涔
window.location.href = res.url;
}else{
if (-1 == res.data.code) {
if (!window.layer) {
confirm(res.msg);
} else {
layer.alert(res.msg, {icon: 5, title: false, closeBtn: false});
}
}else{
// 鍘荤櫥闄
is_login(JsonData.login_url);
}
}
}
};
}
// 鏁伴噺鍔犲噺澶勭悊
function CartUnifiedAlgorithm(symbol){
// 鏁伴噺
var QuantityObj = document.getElementById(fe912b5dac71082e12c1827a3107f9b.quantity);
// 搴撳瓨鏁伴噺
var StockCountObj = document.getElementById('ey_stock_1565602291');
// 榛樿鏁伴噺
var quantity = '';
if ('change' == symbol) {
// 鐩存帴淇敼鏁伴噺
if ('1' > QuantityObj.value || '' == QuantityObj.value) {
quantity = 1;
// if (!window.layer) {
// alert('鍟嗗搧鏁伴噺鏈€灏戜负1');
// } else {
// layer.alert('鍟嗗搧鏁伴噺鏈€灏戜负1', {icon: 5, title: false, closeBtn: false});
// }
}else{
if (Number(QuantityObj.value) > Number(StockCountObj.value)) {
quantity = Number(StockCountObj.value);
}else{
quantity = Number(QuantityObj.value);
}
}
}else if ('+' == symbol) {
// 鍔犳暟閲
quantity = Number(QuantityObj.value) + 1;
}else if ('-' == symbol && QuantityObj.value > '1') {
// 鍑忔暟閲
quantity = Number(QuantityObj.value) - 1;
}else{
quantity = 1;
// 濡傛灉鏁伴噺灏忎簬1鍒欒嚜鍔ㄥ~鍏?
// if (!window.layer) {
// alert('鍟嗗搧鏁伴噺鏈€灏戜负1');
// } else {
// layer.alert('鍟嗗搧鏁伴噺鏈€灏戜负1', {icon: 5, title: false, closeBtn: false});
// }
}
// 鏁伴噺鏄惁澶т簬搴撳瓨閲
if (StockCountObj.value < quantity) {
if (!window.layer) {
alert('杩欎欢浜у搧搴撳瓨浠呬负锛?+StockCountObj.value);
} else {
layer.alert('杩欎欢浜у搧搴撳瓨浠呬负锛?+StockCountObj.value, {icon: 5, title: false, closeBtn: false});
}
return false;
}
// 鍔犺浇鏁伴噺
QuantityObj.value = quantity;
}
// 鍘昏喘杞﹀幓
function shop_cart_list(url) {
window.location.href = url;
/*
if (!window.layer) {
var mymessage = confirm('鍔犲叆璐墿杞︽垚鍔燂紝鍓嶅線璐墿杞︼紒');
if (mymessage == true) window.location.href = url;
} else {
var confirms = layer.confirm('宸插姞鍏ヨ喘鐗╄溅鎴愬姛锛?, {
title: false,
btn: ['鍓嶅線璐墿杞?]
}, function (index) {
layer.close(confirms);
window.location.href = url;
});
}
*/
}
// 鍘荤櫥闄
function is_login(url){
if (document.getElementById('ey_login_id_1609665117')) {
$('#ey_login_id_1609665117').trigger('click');
} else {
if (!window.layer) {
var mymessage = confirm('鎮ㄨ繕娌℃湭鐧诲綍锛岃鐧诲綍鍚庤喘涔帮紒');
if(mymessage == true){
window.location.href = url;
}
} else {
layer.alert('鎮ㄨ繕娌℃湭鐧诲綍锛岃鐧诲綍鍚庤喘涔帮紒', {icon: 5, title: false}, function(){
window.location.href = url;
});
}
}
}
function sortNumber(a, b) {
return a - b
}
function SpecSelect(spec_mark_id, spec_value_id, discount_price) {
var JsonData = fe912b5dac71082e12c1827a3107f9b;
var currentstyle = JsonData.currentstyle;
// 娓呴櫎鍚屼竴绫讳笅鐨勬墍鏈夐€変腑鍙傛暟class
var ClassArray = document.getElementsByClassName("spec_mark_"+spec_mark_id);
for (var i = 0; i < ClassArray.length; i++) {
ClassArray[i].classList.remove(currentstyle);
}
// 褰撳墠鐐瑰嚮鐨勬坊鍔犱笂class
document.getElementsByClassName('spec_value_'+spec_value_id)[0].classList.add(currentstyle);
/*瑙勬牸鍊糏D澶勭悊*/
// 鑾峰彇鎵€鏈夐€変腑鐨勮鏍煎€糏D
var SelectValueIds = '';
var danger = document.getElementsByClassName(currentstyle);
for (var i = 0; i < danger.length; i++) {
if (danger[i].dataset.spec_value_id) {
SelectValueIds += danger[i].dataset.spec_value_id;
SelectValueIds += '_';
}
}
// 鍘婚櫎鏈€鍚庝竴涓瓧绗
SelectValueIds = SelectValueIds.substring(0, SelectValueIds.length-1);
// 瀛楃涓茶浆鏁扮粍
SelectValueIds = SelectValueIds.split('_');
// 浠庡皬鍒板ぇ鎺掑簭
SelectValueIds = SelectValueIds.sort(sortNumber);
// 鏁扮粍杞瓧绗︿覆
SelectValueIds = SelectValueIds.join('_');
/* END */
// 瑙f瀽json鏁版嵁
var SpecData = JSON.parse(JsonData.SpecData);
// 鏇存柊浠锋牸鍙婂簱瀛
for(var i = 0; i < SpecData.length; i++){
if (SelectValueIds == SpecData[i]['spec_value_id']) {
document.getElementById('SelectValueIds').value = SelectValueIds;
if (discount_price) {
if (document.getElementById('old_price')) {
var old_price = Number(SpecData[i]['spec_price']);
document.getElementById('old_price').innerText = parseFloat(old_price.toFixed(2));
}
if (document.getElementById('users_price')) {
var users_price = Number(SpecData[i]['spec_price']) * discount_price;
document.getElementById('users_price').innerText = parseFloat(users_price.toFixed(2));
}
}else{
if (document.getElementById('users_price')) {
var users_price = Number(SpecData[i]['spec_price']);
document.getElementById('users_price').innerText = parseFloat(users_price.toFixed(2));
}
}
if (document.getElementById('stock_count')) {
document.getElementById('stock_count').innerText = SpecData[i]['spec_stock'];
}
if (document.getElementById('ey_stock_1565602291')) {
document.getElementById('ey_stock_1565602291').value = SpecData[i]['spec_stock'];
}
// 鏇存柊浠锋牸鍜屽簱瀛樺悗锛岃喘涔版暟閲忛噸缃负 1
document.getElementById(fe912b5dac71082e12c1827a3107f9b.quantity).value = 1;
}
}
}