新手提问,如果有不准确的地方还请见谅(图片上传总是失败)
顺着代码,去找了提交表单所指向的remove页面,但是在
addons/fecmall/fecro/app/apphtml5/theme/fecro/customer/productfavorite
下并没有找到remove页面,于是remove页面出现了404错误,收藏删除的请求无法完成
想尝试通过补齐remove页面来试试看能不能实现,
如果想要补上这个页面有地方可以下载么?
<script>
<?php $this->beginBlock('customer_favorite') ?>
csrfName = "<?= CRequest::getCsrfName() ?>";
csrfVal = "<?= CRequest::getCsrfValue() ?>";
$(document).ready(function(){
$(".favorite_more").click(function(){
$(".wish-menu-bar").show();
$(".app-mask-show").show();
var productId = $(this).attr("productId");
var favoriteId = $(this).attr("favoriteId");
var productUrl = $(this).attr("productUrl");
$(".favorite_cancel").attr("productId", productId);
$(".favorite_cancel").attr("favoriteId", favoriteId);
$(".favorite_share").attr("productId", productId);
$(".favorite_share").attr("favoriteId", favoriteId);
$(".favorite_share").attr("productUrl", productUrl);
});
$(".favorite_share").click(function(){
var productId = $(this).attr("productId");
var favoriteId = $(this).attr("favoriteId");
var productUrl = $(this).attr("productUrl");
$(".share-bar").show();
});
$(".colse_cancel").click(function(){
$(".wish-menu-bar").hide();
$(".app-mask-show").hide();
$(".share-bar").hide();
});
$(".app-mask-show").click(function(){
$(".wish-menu-bar").hide();
$(".app-mask-show").hide();
$(".share-bar").hide();
});
// favorite cancel
$(".favorite_cancel").click(function(){
var productId = $(this).attr("productId");
var favoriteId = $(this).attr("favoriteId");
var customerRemoveFavorite = "<?= Yii::$service->url->getUrl('customer/productfavorite/remove'); ?>";
$data = {
favorite_id: favoriteId
};
$data[csrfName] = csrfVal;
$.ajax({
async: true,
timeout: 6000,
dataType: 'json',
type:'post',
data: $data,
url: customerRemoveFavorite,
success: function(data, textStatus){
if (data.status == 'success') {
window.location.href = "<?= Yii::$service->url->getUrl('customer/productfavorite') ?>";
} else {
alert(data.content);
}
},
error:function (XMLHttpRequest, textStatus, errorThrown){}
});
});
});
<?php $this->endBlock(); ?>
</script>
<?php $this->registerJs($this->blocks['customer_favorite'],\yii\web\View::POS_END);//将编写的js代码注册到页面底部 ?>
翻查到PC版的收藏的删除是通过javascript:doPost 来完成的,只定向到customer/productfavorite就可以完成
addons/fecmall/fecro/app/appfront/theme/fecro/customer/productfavorite/index.php
<td class="wishlist-remove-js pa-lg-20 text-center" style="width: 2rem;">
<div class="wishlist-item-remove-js btn-cursor">
<a style="color:#555" href='javascript:doPost("<?= Yii::$service->url->getUrl('customer/productfavorite') ?>", {"type":"remove", "favorite_id":"<?= $one['favorite_id'] ?>", "<?= CRequest::getCsrfName() ?>": "<?= CRequest::getCsrfValue() ?>" })' >
<i class="nc-icon nc-icon-trash"></i>
<span class="text-grey-dark-1"><?= Yii::$service->page->translate->__('Remove'); ?></span>
在以下目录还发现一段手机版的删除收藏夹方法(貌似是fecshop的版本?),也是直接dopost的方式
vendor/fancyecommerce/fecshop/app/apphtml5/theme/base/html5/customer/productfavorite/index.php
<div class="favorite-Operation addressbook " style="display:inline-block;float:right; margin-top: 0px;">
<a href='javascript:doPost("<?= Yii::$service->url->getUrl('customer/productfavorite') ?>", {"type":"remove", "favorite_id":"<?= $one['favorite_id'] ?>", "<?= CRequest::getCsrfName() ?>": "<?= CRequest::getCsrfValue() ?>" })' >
<span class="icon icon-remove"></span>