Добрый день!
Подскажите, каким образом сделать ajax-переход по страницам заказов по нажатию на ссылку "показать еще"?
Меняю компонент sale.personal.order.list но при вызове ajax запроса в ответ приходит не одна страница, а от 8 до 80 страниц. подскажите что делать? как исправить?
Спасибо!
Код шаблона sale.personal.order.list
Подскажите, каким образом сделать ajax-переход по страницам заказов по нажатию на ссылку "показать еще"?
Меняю компонент sale.personal.order.list но при вызове ajax запроса в ответ приходит не одна страница, а от 8 до 80 страниц. подскажите что делать? как исправить?
Спасибо!
Код шаблона sale.personal.order.list
| Код |
|---|
<?
if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();
use Bitrix\Main,
Bitrix\Main\Localization\Loc,
Bitrix\Main\Page\Asset;
Asset::getInstance()->addJs("/bitrix/components/bitrix/sale.order.payment.change/templates/.default/script.js");
Asset::getInstance()->addCss("/bitrix/components/bitrix/sale.order.payment.change/templates/.default/style.css");
CJSCore::Init(array('clipboard'));
Loc::loadMessages(__FILE__);
CJSCore::Init(array("jquery"));
?>
<?
if (!empty($arResult['ERRORS']['FATAL']))
{
foreach($arResult['ERRORS']['FATAL'] as $error)
{
ShowError($error);
}
$component = $this->__component;
if ($arParams['AUTH_FORM_IN_TEMPLATE'] && isset($arResult['ERRORS']['FATAL'][$component::E_NOT_AUTHORIZED]))
{
$APPLICATION->AuthForm('', false, false, 'N', false);
}
}
else
{
/*if (!empty($arResult['ERRORS']['NONFATAL']))
{
foreach($arResult['ERRORS']['NONFATAL'] as $error)
{
ShowError($error);
}
}*/
/*if (!count($arResult['ORDERS']))
{
if ($_REQUEST["filter_history"] == 'Y')
{
if ($_REQUEST["show_canceled"] == 'Y')
{
?>
<h3><?= Loc::getMessage('SPOL_TPL_EMPTY_CANCELED_ORDER')?></h3>
<?
}
else
{
?>
<h3><?= Loc::getMessage('SPOL_TPL_EMPTY_HISTORY_ORDER_LIST')?></h3>
<?
}
}
else
{
?>
<h3><?= Loc::getMessage('SPOL_TPL_EMPTY_ORDER_LIST')?></h3>
<?
}
}*/
?>
<div class="row col-md-12 col-sm-12">
<?
$nothing = !isset($_REQUEST["filter_history"]) && !isset($_REQUEST["show_all"]);
$clearFromLink = array("filter_history","filter_status","show_all", "show_canceled");
if ($nothing || $_REQUEST["filter_history"] == 'N')
{
?>
<a class="sale-order-history-link" href="<?=$APPLICATION->GetCurPageParam("filter_history=Y", $clearFromLink, false)?>">
<?echo Loc::getMessage("SPOL_TPL_VIEW_ORDERS_HISTORY")?>
</a>
<?
}
if ($_REQUEST["filter_history"] == 'Y')
{
?>
<a class="sale-order-history-link" href="<?=$APPLICATION->GetCurPageParam("", $clearFromLink, false)?>">
<?echo Loc::getMessage("SPOL_TPL_CUR_ORDERS")?>
</a>
<?
if ($_REQUEST["show_canceled"] == 'Y')
{
?>
<a class="sale-order-history-link" href="<?=$APPLICATION->GetCurPageParam("filter_history=Y", $clearFromLink, false)?>">
<?echo Loc::getMessage("SPOL_TPL_VIEW_ORDERS_HISTORY")?>
</a>
<?
}
else
{
?>
<a class="sale-order-history-link" href="<?=$APPLICATION->GetCurPageParam("filter_history=Y&show_canceled=Y", $clearFromLink, false)?>">
<?echo Loc::getMessage("SPOL_TPL_VIEW_ORDERS_CANCELED")?>
</a>
<?
}
}
?>
</div>
<?
if (!count($arResult['ORDERS']))
{
?>
<div class="row col-md-12 col-sm-12">
<a href="<?=htmlspecialcharsbx($arParams['PATH_TO_CATALOG'])?>" class="sale-order-history-link">
<?=Loc::getMessage('SPOL_TPL_LINK_TO_CATALOG')?>
</a>
</div>
<?
}
/*-----------------------------------Основная область-------------------------------------*/
$orderHeaderStatus = null;
if ($_REQUEST["show_canceled"] === 'Y' && count($arResult['ORDERS']))
{
?>
<h1 class="sale-order-title">
<?= Loc::getMessage('SPOL_TPL_ORDERS_CANCELED_HEADER') ?>
</h1>
<?
}
foreach ($arResult['ORDERS'] as $key => $order)
{
if ($orderHeaderStatus !== $order['ORDER']['STATUS_ID'] && $_REQUEST["show_canceled"] !== 'Y')
{
$orderHeaderStatus = $order['ORDER']['STATUS_ID'];
?>
<h1 class="sale-order-title">
<?= Loc::getMessage('SPOL_TPL_ORDER_IN_STATUSES') ?> «<?=htmlspecialcharsbx($arResult['INFO']['STATUS'][$orderHeaderStatus]['NAME'])?>»
</h1>
<?
}
?>
<!--Заказ-->
<div class="container_list">
<table class="table table-striped">
<thead>
<tr>
<th>Номер заказа</th>
<th>Дата заказа</th>
<th>Состояние</th>
<th>Вид оплаты</th>
<th>Сумма заказа</th>
</tr>
</thead>
<tbody>
<tr>
<td><?= htmlspecialcharsbx($order['ORDER']['ACCOUNT_NUMBER'])?></td>
<td><?= $order['ORDER']['DATE_INSERT'] ?></td>
<td><span class="success">
<?= Loc::getMessage('SPOL_TPL_ORDER_FINISHED')?>
</span></td>
<td>Банковская карта</td>
<td><?= $order['ORDER']['FORMATED_PRICE'] ?></td>
</tr>
<tr>
<td><?= htmlspecialcharsbx($order['ORDER']['ACCOUNT_NUMBER'])?></td>
<td><?= $order['ORDER']['DATE_INSERT'] ?></td>
<td><span class="success">
<?= Loc::getMessage('SPOL_TPL_ORDER_FINISHED')?>
</span></td>
<td>Банковская карта</td>
<td><?= $order['ORDER']['FORMATED_PRICE'] ?></td>
</tr>
<tr>
<td><?= htmlspecialcharsbx($order['ORDER']['ACCOUNT_NUMBER'])?></td>
<td><?= $order['ORDER']['DATE_INSERT'] ?></td>
<td><span class="success">
<?= Loc::getMessage('SPOL_TPL_ORDER_FINISHED')?>
</span></td>
<td>Банковская карта</td>
<td><?= $order['ORDER']['FORMATED_PRICE'] ?></td>
</tr>
<tr>
<td><?= htmlspecialcharsbx($order['ORDER']['ACCOUNT_NUMBER'])?></td>
<td><?= $order['ORDER']['DATE_INSERT'] ?></td>
<td><span class="success">
<?= Loc::getMessage('SPOL_TPL_ORDER_FINISHED')?>
</span></td>
<td>Банковская карта</td>
<td><?= $order['ORDER']['FORMATED_PRICE'] ?></td>
</tr>
</tbody>
</table>
</div>
<div class="col-md-12 col-sm-12 sale-order-list-container">
<div class="row">
<div class="col-md-12 col-sm-12 sale-order-list-accomplished-title-container">
<div class="row">
<div class="col-md-8 col-sm-12 sale-order-list-accomplished-title-container">
<h2 class="sale-order-list-accomplished-title">
<?= Loc::getMessage('SPOL_TPL_ORDER') ?>
<?= Loc::getMessage('SPOL_TPL_NUMBER_SIGN') ?>
<?= htmlspecialcharsbx($order['ORDER']['ACCOUNT_NUMBER'])?>
<?= Loc::getMessage('SPOL_TPL_FROM_DATE') ?>
<?= $order['ORDER']['DATE_INSERT'] ?>,
<?= count($order['BASKET_ITEMS']); ?>
<?
$count = substr(count($order['BASKET_ITEMS']), -1);
if ($count == '1')
{
echo Loc::getMessage('SPOL_TPL_GOOD');
}
elseif ($count >= '2' || $count <= '4')
{
echo Loc::getMessage('SPOL_TPL_TWO_GOODS');
}
else
{
echo Loc::getMessage('SPOL_TPL_GOODS');
}
?>
<?= Loc::getMessage('SPOL_TPL_SUMOF') ?>
<?= $order['ORDER']['FORMATED_PRICE'] ?>
</h2>
</div>
<div class="col-md-4 col-sm-12 sale-order-list-accomplished-date-container">
<?
if ($_REQUEST["show_canceled"] !== 'Y')
{
?>
<span class="sale-order-list-accomplished-date">
<?= Loc::getMessage('SPOL_TPL_ORDER_FINISHED')?>
</span>
<?
}
else
{
?>
<span class="sale-order-list-accomplished-date canceled-order">
<?= Loc::getMessage('SPOL_TPL_ORDER_CANCELED')?>
</span>
<?
}
?>
<span class="sale-order-list-accomplished-date-number"><?= $order['ORDER']['DATE_STATUS_FORMATED'] ?></span>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12 sale-order-list-inner-accomplished">
<div class="row sale-order-list-inner-row">
<div class="col-md-3 col-sm-12 sale-order-list-about-accomplished">
<a class="sale-order-list-about-link" href="<?=htmlspecialcharsbx($order["ORDER"]["URL_TO_DETAIL"])?>">
<?=Loc::getMessage('SPOL_TPL_MORE_ON_ORDER')?>
</a>
</div>
<div class="col-md-3 col-md-offset-6 col-sm-12 sale-order-list-repeat-accomplished">
<a class="sale-order-list-repeat-link sale-order-link-accomplished" href="<?=htmlspecialcharsbx($order["ORDER"]["URL_TO_COPY"])?>">
<?=Loc::getMessage('SPOL_TPL_REPEAT_ORDER')?>
</a>
</div>
</div>
</div>
</div>
</div>
<!--Заказ-->
<?
}
?>
<div class="pomestit"></div>
<?/////////--------------------------------/////////////////////////////-----------------------------//////////////////////////?>
<div class="clearfix"></div>
<?
echo "<div class='pagination'> <!--style='display: none'-->" . $arResult["NAV_STRING"] . "</div>";
?>
<a class="list" href="" rel="0"> Показать еще!!!!!!!</a>
<div class="look"></div>
<sc ript>
$(document).ready(function(){
/*$('.list').prev()[1] раздел навигации
*/
console.log($($($('.list').prev()[0]).find('a')[0]).attr('href'));
var i=0;
$('.list').click(function(){
$.ajax({
url: 'test.php',//$($($('.list').prev()[0]).find('a')[0]).attr('href') ,
type:'post',
dataType: 'html',
//data: "?PAGEN_1=2",
success: function(data){
$('.container_list').append(data);
//изменять URL
},
error:function(){
alert('Что то пошло не так');
}
});
return false;
});
});
</sc ript>
<?
if ($_REQUEST["filter_history"] !== 'Y')
{
$javascriptParams = array(
"url" => CUtil::JSEscape($this->__component->GetPath().'/ajax.php'),
"templateFolder" => CUtil::JSEscape($templateFolder),
"paymentList" => $paymentChangeData
);
$javascriptParams = CUtil::PhpToJSObject($javascriptParams);
?>
<sc ript>
BX.Sale.PersonalOrderComponent.PersonalOrderList.init(<?=$javascriptParams?>);
</sc ript>
<?
}
}
?>
|