1(function(window){ 2 'use strict'; 3 4 if (window.orderMakeAjax) 5 return; 6 7 window.orderMakeAjax = function(arParams){ 8 this.useFixDeliveryPrice = false; 9 10 this.input = false; 11 this.params = false; 12 this.visual = false; 13 this.totals = false; 14 this.path = false; 15 this.ajax = false; 16 17 this.needShowSuccessPopup = false; 18 19 this.obMain = false; 20 this.obForm = false; 21 22 this.obCity = false; 23 this.obDefaultCity = false; 24 25 this.obPersonalInfo = false; 26 this.obOrderParams = false; 27 28 this.obDelivery = false; 29 this.obDeliveryPrice = false; 30 this.obDeliveryList = false; 31 this.obDeliveryItems = false; 32 33 this.obDeliveryGroupsList = false; 34 this.obDeliveryGroupsItems = false; 35 36 this.obDeliveryShopBlock = false; 37 38 this.obDeliveryPVZBlock = false; 39 this.obDeliveryPVZAddress = false; 40 this.obDeliveryPVZAddress_shop = false; 41 this.obDeliveryPVZTarif = false; 42 this.obDeliveryPVZMapBtn = false; 43 44 this.obSdekPvzList = false; 45 this.obSdekPvzListItems = false; 46 47 this.obShopPvzList = false; 48 this.obShopPvzListItems = false; 49 50 this.obPayment = false; 51 this.obPaymentList = false; 52 this.obPaymentItems = false; 53 54 this.dpdPrice = false; 55 56 this.obTotal = false; 57 this.obSubmit = false; 58 59 this.obTotalDeliveryPrice = false; 60 this.obTotalOrderSum = false; 61 62 this.obLocation = false; 63 this.defLocation = false; 64 this.isLocationRequired = 'N'; 65 66 this.obConsent = false; 67 68 this.obCoupon = false; 69 70 this.requiredInput = []; 71 72 this.shopList = false; 73 74 75 this.basketItems = false; 76 77 this.obDisabledPopup = false; 78 79 // bonus 80 this.obBonusUse = false; 81 this.obBonusInput = false; 82 this.obBonusBtn = false; 83 // !bonus 84 85 this.anotherFields = false; 86 this.anotherToggle = false; 87 88 this.obBasketList = false; 89 this.stepQuantity = 1; 90 91 this.obAuth = false; 92 93 this.USER_EXCIST = false, 94 this.NOT_AUTH = false, 95 this.PHONE = false, 96 this.PHONE_OLD = false; 97 98 this.errorCode = 0; 99 100 if (typeof arParams === 'object'){ 101 this.input = arParams; 102 this.initData(); 103 } 104 105 if (this.errorCode === 0){ 106 BX.ready(BX.delegate(this.init, this)); 107 }else{ 108 console.log('error code: ' + this.errorCode); 109 } 110 111 this.input = {}; 112 }; 113 114 window.orderMakeAjax.prototype = { 115 initData: function(){ 116 this.USER_EXCIST = BX('USER_EXCIST'), 117 this.NOT_AUTH = BX('NOT_AUTH'), 118 this.PHONE = BX('PROP-PHONE'), 119 this.PHONE_OLD = BX('PHONE_OLD'); 120 121 if(!!this.input.USE_DELIVERY_FIX_PRICE){ 122 this.useFixDeliveryPrice = (this.input.USE_DELIVERY_FIX_PRICE == 'Y' ? true : false); 123 } 124 125 if(typeof this.input.PARAMS === 'object'){ 126 this.params = this.input.PARAMS; 127 }else{ 128 this.errorCode = -512; 129 } 130 131 if(typeof this.input.TOTAL === 'object'){ 132 this.totals = this.input.TOTAL; 133 }else{ 134 this.errorCode = -256; 135 } 136 137 if(typeof this.input.BASKET_ITEMS === 'object'){ 138 this.basketItems = this.input.BASKET_ITEMS; 139 } 140 141 if (typeof this.input.VISUAL === 'object'){ 142 this.visual = this.input.VISUAL; 143 144 if(BX(this.visual.MAIN_CONTAINER)){ 145 this.obMain = BX(this.visual.MAIN_CONTAINER); 146 147 this.anotherToggle = this.getEntity(this.obMain, 'another-user-toggle'); 148 if(!!this.anotherToggle){ 149 var parent = BX.findParent(this.anotherToggle, {attrs: {"data-entity": "order-props-group"}}, true); 150 if(!!parent){ 151 var children = [], 152 children_1 = BX.findChildren(parent, {tag: 'input'}, true), 153 children_2 = BX.findChildren(parent, {tag: 'textarea'}, true); 154 155 for(var i in children_1){ 156 if(typeof children_1[i] != 'object' || children_1[i].id == this.anotherToggle.id) continue; 157 158 children.push(children_1[i]); 159 } 160 161 for(var i in children_2 || children_2[i].id == this.anotherToggle.id){ 162 if(typeof children_2[i] != 'object') continue; 163 164 children.push(children_2[i]); 165 } 166 167 if(children.length > 0){ 168 this.anotherFields = children; 169 } 170 } 171 } 172 }else{ 173 this.errorCode = -1; 174 } 175 176 if(BX(this.visual.AUTH_POPUP)){ 177 this.obAuth = BX(this.visual.AUTH_POPUP); 178 } 179 180 if(BX(this.visual.FORM_CONTAINER)){ 181 this.obForm = BX(this.visual.FORM_CONTAINER); 182 }else{ 183 this.errorCode = -2; 184 } 185 186 this.obPersonalInfo = this.getEntity(this.obMain, 'order-personal-info'); 187 if(!this.obPersonalInfo){ 188 this.errorCode = -3; 189 } 190 this.obOrderParams = this.getEntity(this.obMain, 'order-params'); 191 if(!this.obOrderParams){ 192 this.errorCode = -4; 193 } 194 this.obDelivery = this.getEntity(this.obMain, 'order-delivery'); 195 if(!this.obDelivery){ 196 this.errorCode = -5; 197 } 198 this.obDeliveryList = this.getEntity(this.obMain, 'order-delivery-list'); 199 if(!this.obDeliveryList){ 200 this.errorCode = -6; 201 } 202 this.obDeliveryItems = this.getEntities(this.obMain, 'order-delivery-item'); 203 if(!this.obDeliveryItems){ 204 this.errorCode = -7; 205 } 206 this.obDeliveryGroupsList = this.getEntities(this.obMain, 'order-delivery-groups-list'); 207 if(!this.obDeliveryGroupsList){ 208 this.errorCode = -7.1; 209 } 210 this.obDeliveryGroupsItems = this.getEntities(this.obMain, 'order-delivery-group-item'); 211 if(!this.obDeliveryGroupsItems){ 212 this.errorCode = -7.2; 213 } 214 this.obPayment = this.getEntity(this.obMain, 'order-payment'); 215 if(!this.obPayment && ('HIDE_PAYMENT' in this.params && this.params.HIDE_PAYMENT != 'Y')){ 216 this.errorCode = -8; 217 } 218 this.obPaymentList = this.getEntity(this.obMain, 'order-payment-list'); 219 if(!this.obPaymentList && ('HIDE_PAYMENT' in this.params && this.params.HIDE_PAYMENT != 'Y')){ 220 this.errorCode = -9; 221 } 222 this.obPaymentItems = this.getEntities(this.obMain, 'order-payment-item'); 223 if(!this.obPaymentItems && ('HIDE_PAYMENT' in this.params && this.params.HIDE_PAYMENT != 'Y')){ 224 this.errorCode = -10; 225 } 226 this.obTotal = this.getEntity(this.obMain, 'order-total'); 227 if(!this.obTotal){ 228 this.errorCode = -11; 229 } 230 this.obSubmit = this.getEntity(this.obMain, 'order-submit'); 231 if(!this.obSubmit){ 232 this.errorCode = -12; 233 } 234 235 if (typeof this.input.PATH === 'object'){ 236 this.path = this.input.PATH; 237 }else{ 238 this.errorCode = -13; 239 } 240 if (typeof this.input.AJAX === 'object'){ 241 this.ajax = this.input.AJAX; 242 }else{ 243 this.errorCode = -14; 244 } 245 246 this.obDefaultCity = BX('DELIVERY_DEFAULT_CITY'); 247 if(!this.obDefaultCity){ 248 this.errorCode = -15; 249 } 250 this.obCity = BX('LOCATION_NAME_OLD'); 251 if(!this.obCity){ 252 this.errorCode = -16; 253 }else{ 254 BX.adjust(this.obCity, {attrs: {'data-type': 'LOCATION'}}); 255 } 256 257 this.obTotalDeliveryPrice = this.getEntities(this.obMain, 'order-delivery-price'); 258 if(!this.obTotalDeliveryPrice){ 259 this.errorCode = -17; 260 } 261 262 this.obTotalOrderSum = this.getEntity(this.obMain, 'order-sum'); 263 if(!this.obTotalOrderSum){ 264 this.errorCode = -18; 265 } 266 267 this.obDeliveryPVZBlock = this.getEntity(this.obMain, 'order-pvz-block'); 268 this.obDeliveryPVZBlock2 = this.getEntity(this.obMain, 'order-pvz-block'); 269 if(!!this.obDeliveryPVZBlock){ 270 this.obDeliveryPVZAddress = BX('PROP-PICKUP_POINT'); 271 this.obDeliveryPVZAddress_shop = BX('PROP-SHOP'); 272 this.obDeliveryPVZAddress_shopId = BX('PROP-SHOP-ID'); 273 this.obDeliveryPVZTarif = BX('PROP-IPOLSDEK_CNTDTARIF'); 274 this.obDeliveryPVZMapBtn = this.getEntity(this.obDeliveryPVZBlock, 'order-pvz-map-btn'); 275 this.obDeliveryPVZMapBtn2 = BX("PROP-PICKUP_POINT"); 276 this.obDeliveryPVZListBtn = this.getEntity(this.obDeliveryPVZBlock, 'order-pvz-list-btn'); 277 } 278 279 this.obSdekPvzList = this.getEntity(this.obMain, 'sdek-pvz-list'); 280 if(this.obSdekPvzList){ 281 this.obSdekPvzListItems = this.getEntities(this.obSdekPvzList, 'sdek-pvz-list-item'); 282 } 283 this.obShopPvzList = this.getEntity(this.obMain, 'shop-pvz-list'); 284 if(this.obShopPvzList){ 285 this.obShopPvzListItems = this.getEntities(this.obShopPvzList, 'shop-pvz-list-item'); 286 } 287 288 this.obDeliveryPrice = BX('DELIVERY_PRICE'); 289 if(!this.obDeliveryPrice){ 290 this.errorCode = -19; 291 } 292 293 this.obLocation = this.obMain.querySelector('[name="LOCATION"]'); 294 this.defLocation = this.obLocation.value; 295 296 if(BX('LOCATION_IS_REQUIRED')){ 297 this.isLocationRequired = BX('LOCATION_IS_REQUIRED').value; 298 } 299 300 this.obConsent = this.getEntity(this.obMain, 'order-consent'); 301 // if(!this.obConsent){ 302 // this.errorCode = -20; 303 // } 304 305 var listRequired = this.obMain.querySelectorAll('[data-requared="Y"]'); 306 this.requiredInput = Array.prototype.slice.call(listRequired); 307 if(this.isLocationRequired == 'Y' && !!this.obLocation){ 308 this.requiredInput.push(this.obLocation); 309 this.requiredInput.push(this.obCity); 310 } 311 if(!!this.obConsent){ 312 this.requiredInput.push(this.obConsent); 313 } 314 315 this.shopList = this.input.SHOP_LIST; 316 if(Object.keys(this.shopList).length > 0){ 317 318 } 319 320 this.obCoupon = this.getEntity(this.obMain, 'order-coupon'); 321 322 // bonus 323 this.obBonusUse = this.getEntity(this.obMain, 'use-bonus'); 324 if(this.obBonusUse && this.obBonusUse.value == 'Y'){ 325 this.obBonusInput = this.getEntity(this.obMain, 'bonus-input'); 326 this.obBonusBtnUse = this.getEntity(this.obMain, 'bonus-use'); 327 this.obBonusBtnDel = this.getEntity(this.obMain, 'bonus-del'); 328 } 329 // !bonus 330 331 this.obBasketList = this.getEntity(this.obMain, 'order-basket'); 332 if(!this.obBasketList){ 333 this.errorCode = -22; 334 } 335 } 336 }, 337 338 init: function(){ 339 var deleteBonus = BX('DELETE_BONUS'); 340 if(deleteBonus.value == 'Y'){ 341 this.updateOrder({}); 342 } 343 344 var obZip = BX('PROP-ZIP'); 345 if(obZip){ 346 BX.bind(obZip, 'change', BX.proxy(function(){ 347 this.updateOrder({}); 348 }, this)); 349 } 350
351 // пеÑеÑÑиÑаÑÑ ÐºÐ¾ÑÐ·Ð¸Ð½Ñ 352 if(!!this.basketItems) 353 for(var basketID in this.basketItems){ 354 if(this.basketItems[basketID].PRICE.BASE_SUM != this.basketItems[basketID].PRICE.SUM){ 355 $('#basket-item-sum-price-old-'+basketID).html(this.basketItems[basketID].PRICE_FORMAT.BASE_SUM); 356 }else{ 357 $('#basket-item-sum-price-old-'+basketID).html(''); 358 } 359 $('#basket-item-sum-price-'+basketID).html(this.basketItems[basketID].PRICE_FORMAT.SUM); 360 $('#basket-item-sum-price-difference-'+basketID).html(this.basketItems[basketID].PRICE_FORMAT.DISCOUNT); 361 } 362 // !пеÑеÑÑиÑаÑÑ ÐºÐ¾ÑÐ·Ð¸Ð½Ñ 363 364 if(!!this.obCoupon){ 365 var couponInput = this.getEntity(this.obCoupon, 'order-coupon-input'); 366 //appliedCoupons = this.getEntities(this.obCoupon, 'order-coupon-delete'); 367 368 if(!!couponInput){ 369 BX.bind(couponInput, 'change', BX.proxy(this.addCoupon, this)); 370 } 371 372// for(var i in appliedCoupons){ 373// BX.bind(appliedCoupons[i], 'click', BX.proxy(this.removeCoupon, this)); 374// } 375 376 var discoutnList = this.getEntity(this.obMain, 'discount-list'); 377 if(!!discoutnList){ 378 var appliedCoupons = this.getEntities(discoutnList, 'order-coupon-delete'); 379 for(var i in appliedCoupons){ 380 if(typeof appliedCoupons[i] != 'object') continue; 381 BX.bind(appliedCoupons[i], 'click', BX.proxy(this.removeCoupon, this)); 382 } 383 } 384 } 385 386 var deliveryItem, paymentItem; 387 388 for(var i in this.obDeliveryItems){ 389 deliveryItem = BX.findChild(this.obDeliveryItems[i], {tag: 'input'}, true); 390 if(!!deliveryItem) 391 BX.bind(deliveryItem, 'change', BX.proxy(function(){ 392 if(!!this.obDeliveryPVZAddress){ 393 this.obDeliveryPVZAddress.value = ''; 394 } 395 if(!!this.obDeliveryPVZAddress_shop){ 396 this.obDeliveryPVZAddress_shop.value = ''; 397 this.obDeliveryPVZAddress_shopId.value = ''; 398 } 399 400 this.updateOrder({}); 401 }, this)); 402 } 403 for(var i in this.obPaymentItems){ 404 paymentItem = BX.findChild(this.obPaymentItems[i], {tag: 'input'}, true); 405 if(!!paymentItem) 406 BX.bind(paymentItem, 'change', BX.proxy(function(){ 407 this.updateOrder({}); 408 }, this)); 409 } 410 411 var deliveryGroupItem; 412 for(var i in this.obDeliveryGroupsItems){ 413 deliveryGroupItem = BX.findChild(this.obDeliveryGroupsItems[i], {tag: 'input'}, true); 414 if(!!deliveryGroupItem) 415 BX.bind(deliveryGroupItem, 'change', BX.proxy(function(){ 416 if(!!this.obDeliveryPVZAddress){ 417 this.obDeliveryPVZAddress.value = ''; 418 } 419 if(!!this.obDeliveryPVZAddress_shop){ 420 this.obDeliveryPVZAddress_shop.value = ''; 421 this.obDeliveryPVZAddress_shopId.value = ''; 422 } 423 424 var target = BX.proxy_context; 425 426 this.updateOrder({'CHANGE_DELIVERY_GROUP': 'Y', 'DEF_DELIVERY_ID': target.getAttribute('data-def-child')}); 427 }, this)); 428 } 429 430 // CDEK || BOXBERRY || DPD || PICKPOINT 431 if(!!this.obDeliveryPVZBlock){ 432 if(!!this.obDeliveryPVZMapBtn){ 433 var pvz_name = this.obDeliveryPVZMapBtn.getAttribute('data-delivery'); 434 435 switch (pvz_name) { 436 case 'shop': 437 BX.bind(this.obDeliveryPVZMapBtn, 'click', BX.proxy(this.PVZPopupShops, this)); 438 break; 439 case 'sdek': 440 BX.bind(this.obDeliveryPVZMapBtn, 'click', BX.proxy(this.PVZPopupSdek, this)); 441 BX.bind(this.obDeliveryPVZMapBtn2, 'click', BX.proxy(this.PVZPopupSdek, this)); 442 break; 443 case 'boxberry': 444 BX.bind(this.obDeliveryPVZMapBtn, 'click', BX.proxy(this.PVZPopupBoxberry, this)); 445 break; 446 case 'dpd': 447 BX.bind(this.obDeliveryPVZMapBtn, 'click', BX.proxy(this.PVZPopupDpd, this)); 448 break; 449 case 'pickpoint': 450 BX.bind(this.obDeliveryPVZMapBtn, 'click', BX.proxy(this.PVZPopupPicpoint, this)); 451 break; 452 default: 453 break; 454 } 455 } 456 457 if(!!this.obDeliveryPVZListBtn){ 458 var pvz_name = this.obDeliveryPVZListBtn.getAttribute('data-delivery'); 459 460 switch (pvz_name) { 461 case 'shop': 462 BX.bind(this.obDeliveryPVZListBtn, 'click', BX.proxy(this.PVZListShops, this)); 463 break; 464 default: 465 break; 466 } 467 } 468 } 469 470 /* 471 var obCourier = BX('DELIVERY_COURIER'); 472 if(obCourier && obCourier.value == 'Y'){ 473 this.initCDEKCourier(); 474 } 475 */ 476 // !CDEK || BOXBERRY || DPD || PICKPOINT 477 478 if(!!this.obCity){ 479 BX.bind(this.obCity, 'blur', BX.proxy(function(){ 480 if(!!this.obDeliveryPVZAddress){ 481 this.obDeliveryPVZAddress.value = ''; 482 } 483 if(!!this.obDeliveryPVZAddress_shop){ 484 this.obDeliveryPVZAddress_shop.value = ''; 485 this.obDeliveryPVZAddress_shopId.value = ''; 486 } 487 }, this)); 488 } 489 490 this.updateRequired(); 491 492 var listPhone = $('#' + this.visual.MAIN_CONTAINER + ' [name^="PHONE"]'); 493 if(listPhone.length > 0){ 494 for(var i = 0; i < listPhone.length; i++){ 495 listPhone.eq(i).mask('+7 000 000 0000', {placeholder: listPhone.eq(i).attr('placeholder'), clearIfNotMatch: true}); 496 } 497 } 498 499 $('#PROP-BIRTHDAY').mask('00.00.0000', {placeholder: 'дд.мм.гггг', clearIfNotMatch: true}); 500 501 var PAYMENT_CARD = this.visual.PAYMENT_CARD; 502 503 $('input[type=radio][name=PAY_SYSTEM_ID]').change(function() { 504 if (this.value == PAYMENT_CARD) { // оплаÑа каÑÑой 505 $('button[data-entity="order-submit"]').text("ÐплаÑиÑÑ Ð·Ð°ÐºÐ°Ð·"); 506 }else{ 507 $('button[data-entity="order-submit"]').text("ÐÑоÑмиÑÑ Ð·Ð°ÐºÐ°Ð·"); 508 } 509 }); 510 511 512 513 514 BX.bind(this.obSubmit, 'click', BX.proxy(function(){ 515 if(this.tryRequired(this.requiredInput, 'all') == 0){ 516 var inputData = {}; 517 inputData['CREATE_ORDER'] = 'AJAX'; 518 519 // if(typeof window.recaptcha != 'undefined') 520 // inputData['recaptcha_token'] = window.recaptcha.getToken(); 521 522 523 $.ajax({
524 method: "POST", 525 url: "/local/ajax/isauth.php", 526 data: {}, 527 this_: this, 528 }).done(function(data) { 529 //if(data === "0") { 530 $("#authPhoneForm").val($("#PROP-PHONE").val()); 531 532 /*$("#processPhoneForm").show(); 533 $(".header-popup").show(); 534 $("#authPhoneForm").show(); 535 $("#authPhoneFormButton").show(); 536 $("#agreementNotes").show(); 537 538 $("#errorMessageForm").hide(); 539 $("#processSmsForm").hide(); 540 541 BX.setCookie('order2cart', 'y', {expires: 300}); 542 $.fancybox.open({ 543 src: '#modal-auth', 544 type: 'inline' 545 }); 546 }else if(data === "1"){*/ 547 this.this_.updateOrder(inputData); 548 //} 549 }); 550 551 }else{ 552 var fEmpty = this.obMain.querySelector('.empty-value'); 553 fEmpty.focus(); 554 fEmpty.scrollIntoView({block: "center", inline: "center", behavior: "smooth"}); 555 } 556 }, this)); 557 558 if(!!this.obBonusUse){ 559 BX.bind(this.obBonusUse, 'change', BX.proxy(function(){ 560 this.updateOrder({}); 561 }, this)); 562 563 BX.bind(this.obBonusInput, 'keyup', BX.proxy(function(){ 564 var target = BX.proxy_context, 565 curVal = parseFloat(target.value), 566 minVal = parseFloat(target.min), 567 maxVal = parseFloat(target.max); 568 569 if(curVal < minVal){ 570 target.value = minVal; 571 }else{ 572 if(curVal > maxVal){ 573 target.value = maxVal; 574 } 575 } 576 }, this)); 577 578 if(!!this.obBonusBtnUse){ 579 BX.bind(this.obBonusBtnUse, 'click', BX.proxy(function(){ 580 //this.doBonusCoupon(); 581 this.updateOrder({BONUS_APPLIED: 'Y'}); 582 }, this)); 583 } 584 585 if(!!this.obBonusBtnDel){ 586 BX.bind(this.obBonusBtnDel, 'click', BX.proxy(function(){ 587 //this.updateOrder({del_bonus_coupon: 'Y'}); 588 this.updateOrder({BONUS_APPLIED: 'N'}); 589 }, this)); 590 } 591 } 592 593 594 // SIZE 595 this.sizeList = this.getEntities(this.obBasketList, 'size-input'); 596 for(var i in this.sizeList){ 597 var prev = BX.findPreviousSibling(this.sizeList[i]), 598 next = BX.findNextSibling(this.sizeList[i]); 599 600 BX.bind(prev, 'click', BX.proxy(this.quantityDown, this)); 601 BX.bind(this.sizeList[i], 'change', BX.proxy(this.quantityChange, this)); 602 BX.bind(next, 'click', BX.proxy(this.quantityUp, this)); 603 } 604 605 this.removeBtns = this.getEntities(this.obBasketList, 'item-remove'); 606 for(var i in this.removeBtns){ 607 BX.bind(this.removeBtns[i], 'click', BX.proxy(this.removeItem, this)); 608 } 609 610 if(this.obSdekPvzListItems){ 611 BX.bind(this.obDeliveryPVZAddress, 'click', BX.proxy(function(){ 612 if(this.obSdekPvzList.style.display == 'none'){ 613 this.obSdekPvzList.style.display = ''; 614 }else{ 615 this.obSdekPvzList.style.display = 'none'; 616 } 617 }, this)); 618 619 for(var i in this.obSdekPvzListItems){ 620 if(typeof this.obSdekPvzListItems[i] != 'object') continue; 621 622 BX.bind(this.obSdekPvzListItems[i], 'click', BX.proxy(function(){ 623 var target = BX.proxy_context, 624 address = target.getAttribute('data-address'); 625 626 if(typeof address == 'undefined'){ 627 this.obDeliveryPVZAddress.value = ''; 628 BX.addClass(this.obDeliveryPVZAddress, 'empty-value'); 629 }else{ 630 this.obDeliveryPVZAddress.value = target.getAttribute('data-address'); 631 BX.removeClass(this.obDeliveryPVZAddress, 'empty-value'); 632 } 633 634 this.obSdekPvzList.style.display = 'none'; 635 636 }, this)); 637 } 638 } 639 640 if(this.obShopPvzListItems){ 641 BX.bind(this.obDeliveryPVZAddress_shop, 'click', BX.proxy(function(){ 642 if(this.obShopPvzList.style.display == 'none'){ 643 this.obShopPvzList.style.display = ''; 644 }else{ 645 this.obShopPvzList.style.display = 'none'; 646 } 647 }, this)); 648 649 for(var i in this.obShopPvzListItems){ 650 if(typeof this.obShopPvzListItems[i] != 'object') continue; 651 652 BX.bind(this.obShopPvzListItems[i], 'click', BX.proxy(function(){ 653 var target = BX.proxy_context, 654 address = target.getAttribute('data-address'); 655 656 if(typeof address == 'undefined'){ 657 this.obDeliveryPVZAddress_shop.value = ''; 658 this.obDeliveryPVZAddress_shopId.value = ''; 659 BX.addClass(this.obDeliveryPVZAddress_shop, 'empty-value'); 660 }else{ 661 this.obDeliveryPVZAddress_shop.value = target.getAttribute('data-address'); 662 this.obDeliveryPVZAddress_shopId.value = target.getAttribute('data-address-id'); 663 BX.removeClass(this.obDeliveryPVZAddress, 'empty-value'); 664 } 665 666 this.obShopPvzList.style.display = 'none'; 667 668 }, this)); 669 } 670 } 671 672 if(this.obAuth){ 673 var obAuthShow = this.getEntity(this.obMain, 'auth-show'), 674 obAuthClose = this.getEntity(this.obMain, 'auth-close'); 675 676 BX.bind(obAuthShow, 'click', BX.proxy(function(){ 677 BX.adjust(this.obAuth, {style: {display: ''}}); 678 }, this)); 679 680 BX.bind(obAuthClose, 'click', BX.proxy(function(){ 681 BX.adjust(this.obAuth, {style: {display: 'none'}}); 682 }, this)); 683 } 684 685 if(this.anotherToggle){ 686 this.changeRequired4Another(); 687 688 BX.bind(this.anotherToggle, 'change', BX.proxy(this.changeRequired4Another, this)); 689 } 690 691 if(this.NOT_AUTH && this.NOT_AUTH.value == 'Y'){ 692 if(this.PHONE && this.PHONE_OLD){ 693 BX.bind(this.PHONE, 'change', BX.proxy(function(){ 694 if(this.PHONE.value != this.PHONE_OLD.value){ 695 this.updateOrder({}); 696 } 697 }, this)); 698 } 699 } 700 }, 701 702 changeRequired4Another: function(){ 703 if(!this.anotherFields || this.anotherFields.length <= 0) return; 704 705 var parent = BX.findParent(this.anotherToggle, {attrs: {"data-entity": "order-props-group"}}, true); 706 707 for(var i = 0; i < this.anotherFields.length; i++){ 708 if(this.anotherToggle.checked){ 709 BX.addClass(parent, 'active_block'); 710 711 this.anotherFields[i].setAttribute('data-requared', 'Y'); 712 }else{ 713 BX.removeClass(parent, 'active_block'); 714 715 this.anotherFields[i].setAttribute('data-requared', 'N'); 716 BX.removeClass(this.anotherFields[i], 'empty-value'); 717 } 718 } 719 720 this.updateRequired(); 721 }, 722 723 updateRequired: function(){ 724 for(var i in this.requiredInput){ 725 BX.unbind(this.requiredInput[i], 'blur', BX.proxy(this.tryRequired, this)); 726 BX.unbind(this.requiredInput[i], 'change', BX.proxy(this.tryRequired, this)); 727 } 728 729 var listRequired = this.obMain.querySelectorAll('[data-requared="Y"]'); 730 731 this.requiredInput = Array.prototype.slice.call(listRequired); 732 if(this.isLocationRequired == 'Y' && !!this.obLocation){ 733 this.requiredInput.push(this.obLocation); 734 this.requiredInput.push(this.obCity); 735 } 736 if(!!this.obConsent){ 737 this.requiredInput.push(this.obConsent); 738 } 739 740 for(var i in this.requiredInput){ 741 BX.bind(this.requiredInput[i], 'blur', BX.proxy(this.tryRequired, this)); 742 BX.bind(this.requiredInput[i], 'change', BX.proxy(this.tryRequired, this)); 743 } 744 }, 745 746 getEntity: function(parent, entity, additionalFilter){ 747 if (!parent || !entity) 748 return null; 749 750 additionalFilter = additionalFilter || ''; 751 752 return parent.querySelector(additionalFilter + '[data-entity="' + entity + '"]'); 753 }, 754 755 getEntities: function(parent, entity, additionalFilter){ 756 if (!parent || !entity) 757 return {length: 0}; 758 759 additionalFilter = additionalFilter || ''; 760 761 return parent.querySelectorAll(additionalFilter + '[data-entity="' + entity + '"]'); 762 }, 763 764 // quantity change 765 quantityDown: function(){ 766 var target = BX.proxy_context, 767 sizeInput = BX.findNextSibling(target), 768 guid = sizeInput.getAttribute('data-id'), 769 curVal = parseFloat(sizeInput.value), 770 newVal = curVal - this.stepQuantity, 771 minVal = parseFloat(sizeInput.min); 772 773 if(newVal >= minVal){ 774 sizeInput.value = newVal; 775 this.quantityChangeAjax(guid, sizeInput.value); 776 } 777 }, 778 quantityChange: function(){ 779 var target = BX.proxy_context, 780 guid = target.getAttribute('data-id'), 781 curVal = target.value, 782 minVal = parseFloat(target.min); 783 // maxVal = parseFloat(target.max); 784 785 if(curVal == '' || parseFloat(curVal) < minVal){ 786 target.value = minVal; 787 this.quantityChangeAjax(guid, target.value); 788 } 789 else{ 790 target.value = parseFloat(curVal); 791 this.quantityChangeAjax(guid, target.value); 792 } 793 }, 794 quantityUp: function(){ 795 var target = BX.proxy_context, 796 sizeInput = BX.findPreviousSibling(target), 797 guid = sizeInput.getAttribute('data-id'), 798 curVal = parseFloat(sizeInput.value), 799 newVal = curVal + this.stepQuantity; 800 801 sizeInput.value = newVal; 802 this.quantityChangeAjax(guid, sizeInput.value); 803 }, 804 quantityChangeAjax: function(guid, quantity){ 805 if(guid.length > 0 && !!this.basketItems[guid]){ 806 var data = { 807 action: 'change_quantity', 808 quantity: quantity, 809 basket_id: guid 810 }; 811 this.updateOrder(data); 812 } 813 }, 814 // !quantity change 815 816 // remove basket item 817 removeItem: function(){ 818 var target = BX.proxy_context, 819 guid = target.getAttribute('data-id'); 820 821 if(guid.length > 0 && !!this.basketItems[guid]){ 822 var data = { 823 action: 'delete_item', 824 basket_id: guid 825 }; 826 this.updateOrder(data); 827 } 828 }, 829 830 doBonusCoupon: function(){ 831 var bonusSum = this.obBonusInput.value, 832 data = { 833 AJAX: 'Y', 834 ACTION: 'createCoupon', 835 ORDER_SUM: this.totals.DISCOUNT_PRICE, 836 BONUS_SUM: bonusSum 837 }; 838 839 BX.showWait(); 840 BX.ajax({ 841 method: 'post', 842 url: this.path.COMPONENT + '/include/ajax_bonus.php', 843 dataType: 'json', 844 data: data, 845 onsuccess: BX.proxy(this.doBonusCouponResult, this) 846 }); 847 }, 848 849 doBonusCouponResult: function(result){ 850 BX.closeWait(); 851 if(result['Coupon']){ 852 this.updateOrder({bonus_coupon: result['Coupon']}); 853 }else{ 854 console.log(result); 855 } 856 }, 857 858 addCoupon: function(){ 859 var target = BX.proxy_context, 860 coupon = $.trim(target.value); 861 862 if(coupon != ''){ 863 this.updateOrder({ 864 COUPON: coupon, 865 COUPON_ACTION: 'add' 866 }); 867 } 868 }, 869 870 removeCoupon: function(){ 871 var target = BX.proxy_context, 872 coupon = $.trim(target.getAttribute('data-coupon')); 873 874 if(coupon != ''){ 875 this.updateOrder({ 876 COUPON: coupon, 877 COUPON_ACTION: 'del' 878 }); 879 } 880 }, 881 882 tryRequired: function(arRequired, type){ 883 if(type == 'all'){ 884 var arRequiredLength = arRequired.length, 885 emptyLength = 0, 886 requiredItem; 887 888 for(var i in arRequired){ 889 emptyLength += this.tryRequired(arRequired[i], 'only'); 890 } 891 892 return emptyLength; 893 }else{ 894 var arRequired = (!!arRequired.target ? arRequired.target : arRequired), 895 requiredItemVal = $.trim(arRequired.value), 896 obItem = arRequired, 897 arRequiredLength = 0, 898 obName, 899 obRadio, 900 obRadioParent; 901 902 switch (arRequired.getAttribute('type')) { 903 case 'text': 904 if(arRequired.getAttribute('name') == 'LOCATION' || arRequired.getAttribute('data-type') == 'LOCATION'){ 905 obItem = BX.findParent(arRequired, {class: 'dropdown-block'});
906 } 907 break; 908 case 'textarea': 909 break; 910 case 'checkbox': 911 obItem = BX.findParent(arRequired, {tag: 'label'}); 912 requiredItemVal = (arRequired.checked ? 'Y' : ''); 913 break; 914 case 'radio': 915 obName = arRequired.name; 916 obRadio = this.obMain.querySelectorAll('[name="' + obName + '"]'); 917 for(var j in obRadio){ 918 if(obRadio[j].checked){ 919 requiredItemVal = 'Y'; 920 break; 921 }else{ 922 requiredItemVal = ''; 923 } 924 } 925 926 for(var j in obRadio){ 927 obRadioParent = BX.findNextSibling(obRadio[j], {tag: 'label'}); 928 929 if(requiredItemVal != ''){ 930 BX.removeClass(obRadioParent, 'empty-value'); 931 arRequiredLength = 0; 932 }else{ 933 BX.addClass(obRadioParent, 'empty-value'); 934 arRequiredLength = 1; 935 } 936 } 937 938 return arRequiredLength; 939 940 break; 941 default: 942 arRequiredLength = 0; 943 return arRequiredLength; 944 break; 945 } 946 947 if(requiredItemVal != '' && arRequired.getAttribute('name') == 'PHONE'){ 948 if(requiredItemVal.substring(3,4) === '8'){ 949 BX.addClass(obItem, 'empty-value'); 950 arRequiredLength = 1; 951 }else{ 952 BX.removeClass(obItem, 'empty-value'); 953 arRequiredLength = 0; 954 } 955 }else{ 956 if(requiredItemVal != ''){ 957 BX.removeClass(obItem, 'empty-value'); 958 arRequiredLength = 0; 959 }else{ 960 BX.addClass(obItem, 'empty-value'); 961 arRequiredLength = 1; 962 } 963 } 964 965 return arRequiredLength; 966 } 967 }, 968 969 /* ====================================================== DELIVERY ======================================================*/ 970 971 /* SHOP LIST (from iblock) */ 972 PVZPopupShops: function(){ 973 if (!window.obPopupWinShops) { 974 window.obPopupWinShops = BX.PopupWindowManager.create('SHOP_LIST', null, { 975 autoHide: true, 976 closeIcon: true, 977 closeByEsc: true, 978 offsetLeft: 0, 979 offsetTop: 0, 980 overlay: true, 981 titleBar: false, 982 contentColor: 'white', 983 className: 'popup-shop-list-container', 984 content: '<div id="shop_list_container"><div class="fb-body"><div id="dpd_forpvz" style="height:400px;width: 100%"></div></div></div>' 985 }); 986 } 987 988 this.initShops(); 989 }, 990 991 initShops: function(){ 992 var popupContent = ''; 993 994 if(typeof this.shopList == 'object'){ 995 popupContent += '<div class="popup-shop-list-block">'; 996 popupContent += '<div class="list-stores" id="store_container">'; 997 // content 998 popupContent += '</div>'; 999 popupContent += '<div class="shop-map">'; 1000 popupContent += '<div id="map">'; 1001 1002 // this.addShopsMap(this.shopList); 1003 1004 popupContent += '</div>'; 1005 popupContent += '</div>'; 1006 popupContent += '</div>'; 1007 }else{ 1008 popupContent += "ÐÑнкÑов вÑдаÑи в г."+ this.obCity.value + " не найдено"; 1009 } 1010 1011 var obPopup = BX('shop_list_container'); 1012 if(obPopup){ 1013 BX.adjust(obPopup, {html: popupContent}); 1014 1015 this.addShopsMap(this.shopList); 1016 1017 window.obPopupWinShops.show(); 1018 } 1019 }, 1020 1021 addShopsMap: function(shopList){ 1022 var menu = $('#store_container'), 1023 athis = this; 1024 1025 ymaps.ready(init); 1026 1027 var myMap, 1028 myPlacemark; 1029 function init(){ 1030 if ($('#map').find('*').length == 0) { 1031 for (var key in shopList) { 1032 var myMap = new ymaps.Map('map', { 1033 center:[shopList[key]['LAT'], shopList[key]['LON']], 1034 zoom: 9 1035 }, { 1036 searchControlProvider: 'yandex#search' 1037 }); 1038 break; 1039 } 1040 1041 var count1 = 0; 1042 for (var key in shopList) { 1043 count1++; 1044 1045 var balloon = ''; 1046 balloon += '<div class="date-store">'; 1047 // balloon += shopList[key]['TEMPLATES']['BALOON']; 1048 balloon += "<div class='order-pvz-select-default-address'>"; 1049 balloon += shopList[key]['CITY'] + ', ' + shopList[key]['ADDRESS'] + ', ' + shopList[key]['NAME']; 1050 balloon += "</div>"; 1051 1052 if(typeof shopList[key]['PHONE'] != 'undefined'){ 1053 balloon += "<div class='order-pvz-select-default-phone'>"; 1054 balloon += shopList[key]['PHONE']; 1055 balloon += "</div>"; 1056 } 1057 1058 if(typeof shopList[key]['SCHEDULE'] != 'undefined'){ 1059 balloon += "<div class='order-pvz-select-default-worktime'>"; 1060 balloon += shopList[key]['SCHEDULE']; 1061 balloon += "</div>"; 1062 } 1063 balloon += '</div>'; 1064 balloon += '<a href="javascript:void(0)" class="date-store-btn" data-id="'+key+'" onclick="selectPointFromBaloon('+key+')">'; 1065 balloon += 'вÑбÑаÑÑ'; 1066 balloon += '</a>'; 1067 1068 var pm = new ymaps.Placemark([shopList[key]['LAT'], shopList[key]['LON']], { 1069 balloonContent: balloon, 1070 iconContent: count1 1071 }, { 1072 preset: 'islands#icon', 1073 iconColor: '#A5D1B3' 1074 } 1075 ); 1076 1077 var baloonContainer = ''; 1078 baloonContainer += '<div class="store_block" >'; 1079 baloonContainer += '<div class="store" data-counter="' + count1 +'">'; 1080 baloonContainer += '<div class="date-store">'; 1081 //baloonContainer += shopList[key]['TEMPLATES']['LIST']; 1082 baloonContainer += "<div class='order-pvz-select-default-address'>"; 1083 baloonContainer += shopList[key]['CITY'] + ', ' + shopList[key]['ADDRESS'] + ', ' + shopList[key]['NAME']; 1084 baloonContainer += "</div>"; 1085 1086 if(typeof shopList[key]['PHONE'] != 'undefined'){ 1087 baloonContainer += "<div class='order-pvz-select-default-phone'>"; 1088 baloonContainer += shopList[key]['PHONE']; 1089 baloonContainer += "</div>"; 1090 } 1091 1092 if(typeof shopList[key]['SCHEDULE'] != 'undefined'){ 1093 baloonContainer += "<div class='order-pvz-select-default-worktime'>"; 1094 baloonContainer += shopList[key]['SCHEDULE']; 1095 baloonContainer += "</div>"; 1096 } 1097 baloonContainer += '</div>'; 1098 baloonContainer += '<a href="javascript:void(0)" class="date-store-btn" data-id="'+key+'">'; 1099 baloonContainer += 'вÑбÑаÑÑ'; 1100 baloonContainer += '</a>'; 1101 baloonContainer += '</div>'; 1102 baloonContainer += '</div>'; 1103 1104 var tmp = count1 - 1; 1105 myMap.geoObjects.add(pm, tmp); 1106 1107 $('#store_container').append(baloonContainer); 1108 $('#store_container') 1109 .find('div[data-counter="' + count1 + '"] .date-store') 1110 .on('click', function () { 1111 var index = $(this).parent().attr('data-counter') - 1; 1112 var geoPoint = myMap.geoObjects.get(index); 1113 if (!geoPoint.balloon.isOpen()) { 1114 myMap 1115 .setCenter( 1116 geoPoint.geometry.getCoordinates(), 15, {checkZoomRange: true} 1117 ) 1118 .then(function(){ 1119 geoPoint.balloon.open(); 1120 });
1121 } else { 1122 geoPoint.balloon.close(); 1123 } 1124 return false; 1125 }); 1126 } 1127 1128 $('#store_container .date-store-btn').on('click', function(){ 1129 var id = $(this).data('id'), 1130 shopId = athis.obMain.querySelector('[data-shop="id"]'), 1131 shopName = athis.obMain.querySelector('[data-shop="name"]'), 1132 shopHtml = athis.obMain.querySelector('[data-shop="html"]'), 1133 shopHtmlList = athis.obMain.querySelector('[data-shop="list-html"]'), 1134 html = ""; 1135 1136 shopId.value = id; 1137 // shopName.value = shopList[id]['TEMPLATES']['TO_ORDER']; 1138 var address = shopList[id]['CITY'] + ', ' + shopList[id]['ADDRESS'] + ', ' + shopList[id]['NAME']; 1139 shopName.value = address.replace(/"/g,'"'); 1140 1141 if(!!shopHtml && !!shopHtmlList){ 1142 1143 html += "<div class='order-pvz-select-default-address'>"; 1144 html += shopList[id]['CITY'] + ', ' + shopList[id]['ADDRESS'] + ', ' + shopList[id]['NAME']; 1145 html += "</div>"; 1146 1147 if(typeof shopList[id]['PHONE'] != 'undefined'){ 1148 html += "<div class='order-pvz-select-default-phone'>"; 1149 html += shopList[id]['PHONE']; 1150 html += "</div>"; 1151 } 1152 1153 if(typeof shopList[id]['SCHEDULE'] != 'undefined'){ 1154 html += "<div class='order-pvz-select-default-worktime'>"; 1155 html += shopList[id]['SCHEDULE']; 1156 html += "</div>"; 1157 } 1158 1159 // BX.adjust(shopHtml, {html: shopList[id]['TEMPLATES']['SELECT']}); 1160 BX.adjust(shopHtml, {html: html}); 1161 BX.adjust(shopHtmlList, {html: ''}); 1162 } 1163 1164 window.obPopupWinShops.close(); 1165 }); 1166 } 1167 else{ 1168 myMap.destroy();// ÐеÑÑÑÑкÑÐ¾Ñ ÐºÐ°ÑÑÑ 1169 myMap = null; 1170 $('#map').html = ""; 1171 } 1172 1173 //athis.initPopup(); 1174 } 1175 }, 1176 1177 PVZListShops: function(){ 1178 var athis = this, 1179 shopListHtml = $('[data-shop="list-html"]'); 1180 1181 shopListHtml.html(''); 1182 1183 for (var key in this.shopList) { 1184 var balloon = ''; 1185 balloon += '<div class="date-store" data-shop-list-id="'+key+'">'; 1186 // balloon += shopList[key]['TEMPLATES']['BALOON']; 1187 balloon += "<div class='order-pvz-select-default-address'>"; 1188 balloon += this.shopList[key]['CITY'] + ', ' + this.shopList[key]['ADDRESS'] + ', ' + this.shopList[key]['NAME']; 1189 balloon += "</div>"; 1190 1191 if(typeof this.shopList[key]['PHONE'] != 'undefined'){ 1192 balloon += "<div class='order-pvz-select-default-phone'>"; 1193 balloon += this.shopList[key]['PHONE']; 1194 balloon += "</div>"; 1195 } 1196 1197 if(typeof this.shopList[key]['SCHEDULE'] != 'undefined'){ 1198 balloon += "<div class='order-pvz-select-default-worktime'>"; 1199 balloon += this.shopList[key]['SCHEDULE']; 1200 balloon += "</div>"; 1201 } 1202 balloon += '</div>'; 1203 1204 shopListHtml.append(balloon); 1205 1206 $('[data-shop-list-id="'+key+'"]').on('click', function(){ 1207 var id = $(this).data('shop-list-id'), 1208 shopId = athis.obMain.querySelector('[data-shop="id"]'), 1209 shopName = athis.obMain.querySelector('[data-shop="name"]'), 1210 shopHtml = athis.obMain.querySelector('[data-shop="html"]'), 1211 shopHtmlList = athis.obMain.querySelector('[data-shop="list-html"]'), 1212 html = ""; 1213 1214 shopId.value = id; 1215 shopName.value = athis.shopList[id]['TEMPLATES']['TO_ORDER']; 1216 1217 html += "<div class='order-pvz-select-default-address'>"; 1218 html += athis.shopList[id]['CITY'] + ', ' + athis.shopList[id]['ADDRESS'] + ', ' + athis.shopList[id]['NAME']; 1219 html += "</div>"; 1220 if(typeof athis.shopList[id]['PHONE'] != 'undefined'){ 1221 html += "<div class='order-pvz-select-default-phone'>"; 1222 html += athis.shopList[id]['PHONE']; 1223 html += "</div>"; 1224 } 1225 if(typeof athis.shopList[id]['SCHEDULE'] != 'undefined'){ 1226 html += "<div class='order-pvz-select-default-worktime'>"; 1227 html += athis.shopList[id]['SCHEDULE']; 1228 html += "</div>"; 1229 } 1230 1231 // BX.adjust(shopHtml, {html: shopList[id]['TEMPLATES']['SELECT']}); 1232 BX.adjust(shopHtml, {html: html}); 1233 BX.adjust(shopHtmlList, {html: ''}); 1234 }); 1235 } 1236 1237 }, 1238 /* !SHOP LIST (from iblock) */ 1239 1240 /* CDEK */ 1241 PVZPopupSdek: function(){ 1242 if (!window.obPopupWinCdek) { 1243 window.obPopupWinCdek = BX.PopupWindowManager.create('CDEK', null, { 1244 autoHide: true, 1245 closeIcon: true, 1246 closeByEsc: true, 1247 offsetLeft: 0, 1248 offsetTop: 0, 1249 overlay: true, 1250 titleBar: false, 1251 contentColor: 'white', 1252 className: 'popup-sdek-container', 1253 content: '<div id="cdek_container"><div class="fb-body"><div id="cdek_forpvz" style="height:400px;width: 100%"></div></div></div>' 1254 }); 1255 } 1256 1257 this.initCDEK(); 1258 window.obPopupWinCdek.show(); 1259 }, 1260 1261 initCDEK: function(){ 1262 if(!!this.obDeliveryPVZBlock){ 1263 var defaultCity = this.obDefaultCity.value, 1264 city = (this.obCity.value != '' ? this.obCity.value : 'ÐоÑква'), 1265 athis = this; 1266 1267 window.servmTimeout = false; 1268 var widjetPVD = new ISDEKWidjet({ 1269 defaultCity: city, 1270 cityFrom: defaultCity, 1271 country: 'РоÑÑиÑ', 1272 link: 'cdek_forpvz', 1273 hidedelt: true, 1274 hidedress: true, 1275 hidecash: true,
1276 choose: true, 1277 path: this.path.COMPONENT + '/scripts/SDEK/scripts/', 1278 onChoose : function(result){ 1279 clearTimeout(window.servmTimeout); 1280 1281 //athis.obDeliveryPVZTarif.value = result.price; 1282 1283 // athis.obDeliveryPVZAddress.value = '[' + result.id + '], ' + result.cityName + ', ' + result.PVZ.Address; 1284 athis.obDeliveryPVZAddress.value = result.cityName + ', ' + result.PVZ.Address + ' #S' + result.id; 1285 BX.removeClass(athis.obDeliveryPVZAddress, 'empty-value'); 1286 1287 if(!athis.useFixDeliveryPrice){ 1288 var deliveryPrice = (!!result.price ? result.price*1 : 0), 1289 deliveryPriceFormated = (deliveryPrice > 0 ? BX.Currency.currencyFormat(deliveryPrice, athis.totals.CURRENCY, true) : 'беÑплаÑно'), 1290 orderSumm = athis.totals.DISCOUNT_PRICE*1 + deliveryPrice*1, 1291 orderSummFormated = BX.Currency.currencyFormat(orderSumm, athis.totals.CURRENCY, true); 1292 1293 athis.obDeliveryPrice.value = deliveryPrice; 1294 for(var i in athis.obTotalDeliveryPrice){ 1295 BX.adjust(athis.obTotalDeliveryPrice[i], {html: deliveryPriceFormated}); 1296 } 1297 BX.adjust(athis.obTotalOrderSum, {html: orderSummFormated}); 1298 1299 if(!!athis.obDeliveryPVZTarif){ 1300 athis.obDeliveryPVZTarif.value = result.tarif; 1301 } 1302 1303 athis.updateOrder({'CDEK_PVZ_CITY': result.cityName}); 1304 } 1305 1306 window.obPopupWinCdek.close(); 1307 1308 if(BX('cdek_forpvz')){ 1309 BX.adjust(BX('cdek_forpvz'), {html: ''}); 1310 } 1311 1312 } 1313 }); 1314 } 1315 }, 1316 1317 initCDEKCourier: function(){ 1318 var defaultCity = this.obDefaultCity.value, 1319 city = (this.obCity.value != '' ? this.obCity.value : 'ÐоÑонеж'), 1320 athis = this; 1321 1322 var obDeliverCalc = $('[name="DELIVERY_CALC"]'), 1323 deliverCalc = obDeliverCalc.val(); 1324 1325 if(deliverCalc == 'N'){ 1326 var widjetPVD = new ISDEKWidjet({ 1327 defaultCity: city, 1328 cityFrom: defaultCity, 1329 country: 'РоÑÑиÑ', 1330 link: 'delivery_courier_map', 1331 path: this.path.COMPONENT + '/scripts/SDEK/scripts/', 1332 onCalculate: function(result){ 1333 1334 if(!athis.useFixDeliveryPrice){ 1335 var deliveryPrice = (!!result.profiles.courier.price ? result.profiles.courier.price*1 : 0), 1336 deliveryPriceFormated = (deliveryPrice > 0 ? BX.Currency.currencyFormat(deliveryPrice, athis.totals.CURRENCY, true) : 'беÑплаÑно'), 1337 orderSumm = athis.totals.DISCOUNT_PRICE*1 + deliveryPrice*1, 1338 orderSummFormated = BX.Currency.currencyFormat(orderSumm, athis.totals.CURRENCY, true); 1339 1340 athis.obDeliveryPrice.value = deliveryPrice; 1341 for(var i in athis.obTotalDeliveryPrice){ 1342 BX.adjust(athis.obTotalDeliveryPrice[i], {html: deliveryPriceFormated}); 1343 } 1344 BX.adjust(athis.obTotalOrderSum, {html: orderSummFormated}); 1345 1346 if(!!athis.obDeliveryPVZTarif){ 1347 athis.obDeliveryPVZTarif.value = result.profiles.courier.tarif; 1348 } 1349 1350 athis.updateOrder({}); 1351 } 1352 1353 obDeliverCalc.val('Y'); 1354 1355 } 1356 1357 }); 1358 } 1359 }, 1360 /* !CDEK */ 1361 1362 /* BOXBERRY */ 1363 PVZPopupBoxberry: function(){ 1364 var api_token = '1$3wvLZbxymY5rAi5N_f1nI2DZRrnpWFI0', 1365 // var api_token = '', 1366 custom_city = (this.obCity.value != '' ? this.obCity.value : 'ÐоÑква'), 1367 orderSum = 0, 1368 orderWeight = 0; 1369 1370 var weight, price; 1371 1372 for(var i in this.basketItems){ 1373 if(typeof this.basketItems[i] != 'object') continue; 1374 1375 price = parseFloat(this.basketItems[i].PRICE.SUM); 1376 weight = parseFloat(this.basketItems[i].WEIGHT); 1377 1378 orderSum += price; 1379 orderWeight += weight; 1380 } 1381 1382 if(orderWeight == 0) orderWeight = 5; 1383 1384 boxberry.open(BX.proxy(this.boxberryCallback, this), api_token, custom_city, '', orderSum, orderWeight, 0, 20, 20, 20); 1385 }, 1386 1387 boxberryCallback: function(result){//debugger; 1388 //if(!!jOrderMakeAjax){ 1389 //var athis = jOrderMakeAjax; 1390 var athis = this; 1391 1392 athis.obDeliveryPVZAddress.value = '[' + result.id + '], ' + result.address; 1393 BX.removeClass(athis.obDeliveryPVZAddress, 'empty-value'); 1394 1395 if(!athis.useFixDeliveryPrice){ 1396 var deliveryPrice = (!!result.price ? result.price*1 : 0), 1397 deliveryPriceFormated = (deliveryPrice > 0 ? BX.Currency.currencyFormat(deliveryPrice, athis.totals.CURRENCY, true) : 'беÑплаÑно'), 1398 orderSumm = athis.totals.DISCOUNT_PRICE*1 + deliveryPrice*1, 1399 orderSummFormated = BX.Currency.currencyFormat(orderSumm, athis.totals.CURRENCY, true); 1400 1401 athis.obDeliveryPrice.value = deliveryPrice; 1402 for(var i in athis.obTotalDeliveryPrice){ 1403 BX.adjust(athis.obTotalDeliveryPrice[i], {html: deliveryPriceFormated}); 1404 } 1405 BX.adjust(athis.obTotalOrderSum, {html: orderSummFormated}); 1406 1407 athis.updateOrder({}); 1408 } 1409 1410 //} 1411 }, 1412 /* !BOXBERRY */ 1413 1414 /* DPD */ 1415 PVZPopupDpd: function(){ 1416 if (!window.obPopupWinDpd) { 1417 window.obPopupWinDpd = BX.PopupWindowManager.create('DPD', null, { 1418 autoHide: true, 1419 closeIcon: true, 1420 closeByEsc: true, 1421 offsetLeft: 0, 1422 offsetTop: 0, 1423 overlay: true, 1424 titleBar: false, 1425 contentColor: 'white', 1426 className: 'popup-dpd-container', 1427 content: '<div id="dpd_container"><div class="fb-body"><div id="dpd_forpvz" style="height:400px;width: 100%"></div></div></div>' 1428 }); 1429 } 1430 1431 this.initDPD(); 1432 }, 1433 1434 initDPD: function(){ 1435 if(BX('dpd_forpvz')){ 1436 BX.adjust(BX('dpd_forpvz'), {html: ''}); 1437 } 1438 1439 if(!!this.obDeliveryPVZBlock){ 1440 var defaultCity = this.obDefaultCity.value, 1441 city = (this.obCity.value != '' ? this.obCity.value : 'ÐоÑква'), 1442 athis = this; 1443 1444 BX.showWait(); 1445 BX.ajax({ 1446 url: this.path.COMPONENT + '/scripts/DPD/getPoints.php', 1447 method: "post", 1448 data: { 1449 AJAX: 'Y', 1450 CITY_FROM: defaultCity, 1451 CITY_TO: city 1452 }, 1453 dataType: 'json', 1454 onsuccess: BX.proxy(this.createDpdMap, this) 1455 }); 1456 1457 } 1458 }, 1459 1460 createDpdMap: function(result){ 1461 BX.closeWait(); 1462 1463 window.obPopupWinDpd.show(); 1464 1465 if(result.STATUS == 'OK'){ 1466 var logo_path = this.path.TEMPLATE + '/images/dpd_logo.png'; 1467 1468 this.dpdPrice = result.PRICE; 1469 1470 ymaps.ready(function(){ 1471 var placemarks = result.PLACEMARKS; 1472 1473 var myMap = new ymaps.Map("dpd_forpvz", { 1474 center: [result.CENTER.LAT, result.CENTER.LON], 1475 zoom: 11 1476 }, { 1477 searchControlProvider: 'yandex#search' 1478 });
1479 1480 for (var i = 0, l = placemarks.length; i < l; i++) { 1481 var item = placemarks[i]; 1482 1483 // Создаем меÑкÑ. 1484 var placemark = new ymaps.Placemark([item["LAT"], item["LON"]], { 1485 balloonContent: item["TEXT"] 1486 }, { 1487 iconLayout: 'default#image', 1488 iconImageHref: logo_path, 1489 iconImageSize: [26, 30], 1490 balloonCloseButton: true, 1491 hideIconOnBalloonOpen: true 1492 }); 1493 1494 myMap.geoObjects.add(placemark); 1495 } 1496 1497 }); 1498 }else{ 1499 if(BX('dpd_forpvz')){ 1500 BX.adjust(BX('dpd_forpvz'), {html: '<h4>ÐÑоизоÑла оÑибка пÑи полÑÑении ÑпиÑка пÑнкÑов вÑдаÑи</h4>'}); 1501 } 1502 } 1503 }, 1504 1505 dpdSetPoint: function(address){ 1506 this.obDeliveryPVZAddress.value = address; 1507 BX.removeClass(this.obDeliveryPVZAddress, 'empty-value'); 1508 1509 if(!this.useFixDeliveryPrice){ 1510 var deliveryPrice = (!!this.dpdPrice ? this.dpdPrice*1 : 0), 1511 deliveryPriceFormated = (deliveryPrice > 0 ? BX.Currency.currencyFormat(deliveryPrice, this.totals.CURRENCY, true) : 'беÑплаÑно'), 1512 orderSumm = this.totals.DISCOUNT_PRICE*1 + deliveryPrice*1, 1513 orderSummFormated = BX.Currency.currencyFormat(orderSumm, this.totals.CURRENCY, true); 1514 1515 this.obDeliveryPrice.value = deliveryPrice; 1516 for(var i in this.obTotalDeliveryPrice){ 1517 BX.adjust(this.obTotalDeliveryPrice[i], {html: deliveryPriceFormated}); 1518 } 1519 BX.adjust(this.obTotalOrderSum, {html: orderSummFormated}); 1520 1521 this.dpdPrice = false; 1522 1523 athis.updateOrder({}); 1524 } 1525 1526 window.obPopupWinDpd.close(); 1527 1528 }, 1529 /* !DPD */ 1530 1531 /* PICKPOINT */ 1532 PVZPopupPicpoint: function(){ 1533 var api_token = '', 1534 defaultCity = this.obDefaultCity.value, 1535 city = (this.obCity.value != '' ? this.obCity.value : 'ÐоÑква'); 1536 1537 PickPoint.open(this.pickpointCallback, {ikn: api_token, fromcity: defaultCity, city: city}); 1538 }, 1539 1540 pickpointCallback: function(result){ 1541 if(!!jOrderMakeAjax){ 1542 var athis = jOrderMakeAjax; 1543 1544 athis.obDeliveryPVZAddress.value = '[' + result.id + '], ' + result.name + ', ' + result.address; 1545 BX.removeClass(athis.obDeliveryPVZAddress, 'empty-value'); 1546 1547 if(!athis.useFixDeliveryPrice){ 1548 var deliveryPrice = (!!result.price ? result.price*1 : 0), 1549 deliveryPriceFormated = (deliveryPrice > 0 ? BX.Currency.currencyFormat(deliveryPrice, athis.totals.CURRENCY, true) : 'беÑплаÑно'), 1550 orderSumm = athis.totals.DISCOUNT_PRICE*1 + deliveryPrice*1, 1551 orderSummFormated = BX.Currency.currencyFormat(orderSumm, athis.totals.CURRENCY, true); 1552 1553 athis.obDeliveryPrice.value = deliveryPrice; 1554 for(var i in athis.obTotalDeliveryPrice){ 1555 BX.adjust(athis.obTotalDeliveryPrice[i], {html: deliveryPriceFormated}); 1556 } 1557 BX.adjust(athis.obTotalOrderSum, {html: orderSummFormated}); 1558 1559 athis.updateOrder({}); 1560 } 1561 } 1562 }, 1563 /* !PICKPOINT */ 1564 1565 /* ====================================================== !DELIVERY ======================================================*/ 1566 1567 refreshOrder: function(arResult){ 1568 BX.closeWait(); 1569 1570 var content = $("<div/>", {"html": arResult}).find('[id="' + this.visual.MAIN_CONTAINER + '"]').html(), 1571 success = $("<div/>", {"html": arResult}).find("[data-entity='order-success']").html(); 1572 1573 if(this.needShowSuccessPopup){ 1574 if(typeof success != "undefined"){ 1575 BX.adjust(this.obMain, {html: content}); 1576 }else{ 1577 try{ 1578 var error_content = '', 1579 error_json = JSON.parse(arResult); 1580 1581 error_content = ''; 1582 error_content += '<div class="error-conteiner">'; 1583 error_content += '<div class="error">ÐШÐÐÐÐ</div>'; 1584 error_content += '<div class="error-message">'+error_json['ERROR']+'</div>'; 1585 error_content += '</div>'; 1586 1587 if (!window.obErrorPopup) { 1588 window.obErrorPopup = BX.PopupWindowManager.create('ERROR', null, { 1589 autoHide: true, 1590 closeIcon: true, 1591 closeByEsc: true, 1592 offsetLeft: 0, 1593 offsetTop: 0, 1594 overlay: true, 1595 titleBar: true, 1596 contentColor: 'white', 1597 className: '', 1598 width: 350 1599 // content: content 1600 });
1601 } 1602 window.obErrorPopup.setContent(error_content); 1603 window.obErrorPopup.show(); 1604 }catch(e){ 1605 BX.adjust(this.obMain, {html: content}); 1606 } 1607 } 1608 1609 this.needShowSuccessPopup = false; 1610 }else{ 1611 BX.adjust(this.obMain, {html: content}); 1612 } 1613 1614 this.updateHeaderBasketCount(); 1615 1616 BX.onCustomEvent('OnBasketChange'); 1617 BX.onCustomEvent('OnChangeDelay'); 1618 }, 1619 1620 updateHeaderBasketCount: function(){ 1621 var countNode = this.obMain ? this.obMain.querySelector('[data-basket-count]') : null; 1622 if(!countNode) return; 1623 1624 var qty = parseInt(countNode.getAttribute('data-basket-count'), 10) || 0; 1625 document.cookie = 'aq_basket_count=' + qty + '; path=/; max-age=2592000; samesite=lax'; 1626 1627 var nodes = document.querySelectorAll('.header-cart-link .in-ico-counter, .mobile-bottom-bar [data-cart-qty]'); 1628 for(var i = 0; i < nodes.length; i++){ 1629 nodes[i].textContent = qty; 1630 nodes[i].style.display = ''; 1631 } 1632 }, 1633 1634 updateOrder: function(user_data){ 1635 if(typeof user_data === 'object'){ 1636 if(!user_data.CREATE_ORDER){ 1637 if(this.useFixDeliveryPrice){ 1638 this.obDeliveryPrice.value = ''; 1639 if(!!this.obDeliveryPVZTarif){ 1640 this.obDeliveryPVZTarif.value = ''; 1641 } 1642 } 1643 }else{ 1644 this.needShowSuccessPopup = true; 1645 } 1646 1647 if(!!user_data.UPDATE_LOCATION){ 1648 if(this.obLocation.value == this.defLocation) 1649 return; 1650 } 1651 1652 var data = {}; 1653 1654 data['ajax'] = 'Y'; 1655 data['template'] = this.ajax.template; 1656 data['parameters'] = this.ajax.signedParamsString; 1657 //data['user_comment'] = this.obComment.value; 1658 1659 var formValues = $('#'+this.visual.FORM_CONTAINER).serializeArray(); 1660 for(var i in formValues){ 1661 switch(formValues[i]['name']){ 1662 case 'CONSENT': 1663 formValues[i]['value'] = (this.obConsent.checked ? 'Y' : ''); 1664 break; 1665 case 'USE_BONUS': 1666 formValues[i]['value'] = (this.obBonusUse.checked ? 'Y' : 'N'); 1667 break; 1668 default: 1669 formValues[i]['value'] = $.trim(formValues[i]['value']); 1670 break; 1671 } 1672 1673 if(formValues[i]['value'] !== '') 1674 data[formValues[i]['name']] = formValues[i]['value']; 1675 } 1676 1677 if('IS_BOXBERRY_COURIER' in data && data['IS_BOXBERRY_COURIER'] == 'Y'){ 1678 data['BOXBERRY_ADDRESS'] = ('STREET' in data ? 'Ñл.' + data['STREET'] + ', ' : '') 1679 + ('HOME' in data ? 'д.' + data['HOME'] + ', ' : '') 1680 + ('FLAT' in data ? 'кв.' + data['FLAT'] : ''); 1681 } 1682 1683 if('CHANGE_DELIVERY_GROUP' in user_data && user_data.CHANGE_DELIVERY_GROUP == 'Y'){ 1684 data.DELIVERY_ID = user_data.DEF_DELIVERY_ID; 1685 } 1686 1687 for(var i in user_data){ 1688 data[i] = user_data[i]; 1689 } 1690 1691 BX.showWait(); 1692 BX.ajax({ 1693 method: 'post', 1694 url: this.path.COMPONENT + '/ajax.php', 1695 dataType: 'html', 1696 data: data, 1697 onsuccess: BX.proxy(this.refreshOrder, this) 1698 }); 1699 } 1700 } 1701 }; 1702})(window); 1703 1704function selectPointFromBaloon(id){ 1705 $('#store_container .date-store-btn[data-id="'+id+'"]').trigger('click'); 1706} 1707 1708$(document).on("change", '#PROP-LAST_NAME', function(){ 1709 setFio(); 1710}) 1711 1712$(document).on("change", '#PROP-NAME', function(){ 1713 setFio(); 1714}) 1715 1716function setFio() 1717{ 1718 let fio = $('#PROP-LAST_NAME').val() + ' ' + $('#PROP-NAME').val(); 1719 1720 $('#PROP-FIO').val(fio); 1721}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.