Commit f60eed5 1 parent c67f7c8 commit f60eed5 Copy full SHA for f60eed5
File tree 8 files changed +38
-15
lines changed
theme/base/front/catalog/product
theme/base/html5/catalog/product
8 files changed +38
-15
lines changed Original file line number Diff line number Diff line change 17
17
*/
18
18
class FavoriteproductController extends AppfrontController
19
19
{
20
- public $ enableCsrfValidation = true ;
20
+ public $ enableCsrfValidation = false ;
21
21
// 增加收藏
22
22
public function actionAdd ()
23
23
{
Original file line number Diff line number Diff line change 19
19
class CartController extends AppfrontController
20
20
{
21
21
public $ enableCsrfValidation = true ;
22
+ public $ noCsrfActions = ['add ' ];
23
+
24
+ public function beforeAction ($ action )
25
+ {
26
+ if (in_array ($ action ->id , $ this ->noCsrfActions )) {
27
+ $ this ->enableCsrfValidation = false ;
28
+ }
29
+ return parent ::beforeAction ($ action );
30
+ }
22
31
23
32
public function actionIndex ()
24
33
{
Original file line number Diff line number Diff line change @@ -43,10 +43,10 @@ public function actionIndex()
43
43
}
44
44
if ($ product_id ) {
45
45
// 添加csrf数据
46
- $ csrfName = \fec \helpers \CRequest::getCsrfName ();
47
- $ csrfVal = \fec \helpers \CRequest::getCsrfValue ();
48
- $ result_arr ['csrfName ' ] = $ csrfName ;
49
- $ result_arr ['csrfVal ' ] = $ csrfVal ;
46
+ // $csrfName = \fec\helpers\CRequest::getCsrfName();
47
+ // $csrfVal = \fec\helpers\CRequest::getCsrfValue();
48
+ // $result_arr['csrfName'] = $csrfName;
49
+ // $result_arr['csrfVal'] = $csrfVal;
50
50
$ result_arr ['product_id ' ] = $ product_id ;
51
51
}
52
52
$ cartQty = Yii::$ service ->cart ->getCartItemQty ();
Original file line number Diff line number Diff line change 255
255
$data['custom_option'] = custom_option_json;
256
256
$data['product_id'] = "<?= $ _id ?> ";
257
257
$data['qty'] = qty;
258
- $data[csrfName] = csrfVal;
258
+ if (csrfName && csrfVal) {
259
+ $data[csrfName] = csrfVal;
260
+ }
259
261
jQuery.ajax({
260
262
async:true,
261
263
timeout: 6000,
293
295
csrfVal = $(".product_csrf").val();
294
296
param = {};
295
297
param["product_id"] = product_id;
296
- param[csrfName] = csrfVal;
298
+ if (csrfName && csrfVal) {
299
+ param[csrfName] = csrfVal;
300
+ }
297
301
doPost(url, param);
298
302
}
299
303
});
352
356
<?php $ this ->endBlock (); ?>
353
357
<?php $ this ->registerJs ($ this ->blocks ['add_to_cart ' ],\yii \web \View::POS_END );//将编写的js代码注册到页面底部 ?>
354
358
355
-
356
359
//tab 切换js
357
360
<?php $ this ->beginBlock ('product_info_tab ' ) ?>
358
361
var navContainer = document.getElementById("nav-container");
Original file line number Diff line number Diff line change 17
17
*/
18
18
class FavoriteproductController extends AppfrontController
19
19
{
20
- public $ enableCsrfValidation = true ;
20
+ public $ enableCsrfValidation = false ;
21
21
22
22
// 增加收藏
23
23
public function actionAdd ()
@@ -30,7 +30,7 @@ public function actionAdd()
30
30
31
31
public function actionLists ()
32
32
{
33
- $ data = $ this ->getBlock ()->getLastData ($ editForm );
33
+ $ data = $ this ->getBlock ()->getLastData ();
34
34
35
35
return $ this ->render ($ this ->action ->id , $ data );
36
36
}
Original file line number Diff line number Diff line change 19
19
class CartController extends AppfrontController
20
20
{
21
21
public $ enableCsrfValidation = true ;
22
+ public $ noCsrfActions = ['add ' ];
23
+
24
+ public function beforeAction ($ action )
25
+ {
26
+ if (in_array ($ action ->id , $ this ->noCsrfActions )) {
27
+ $ this ->enableCsrfValidation = false ;
28
+ }
29
+ return parent ::beforeAction ($ action );
30
+ }
22
31
23
32
public function actionIndex ()
24
33
{
Original file line number Diff line number Diff line change @@ -72,10 +72,10 @@ public function actionProduct()
72
72
}
73
73
if ($ product_id ) {
74
74
// 添加csrf数据
75
- $ csrfName = \fec \helpers \CRequest::getCsrfName ();
76
- $ csrfVal = \fec \helpers \CRequest::getCsrfValue ();
77
- $ result_arr ['csrfName ' ] = $ csrfName ;
78
- $ result_arr ['csrfVal ' ] = $ csrfVal ;
75
+ // $csrfName = \fec\helpers\CRequest::getCsrfName();
76
+ // $csrfVal = \fec\helpers\CRequest::getCsrfValue();
77
+ // $result_arr['csrfName'] = $csrfName;
78
+ // $result_arr['csrfVal'] = $csrfVal;
79
79
$ result_arr ['product_id ' ] = $ product_id ;
80
80
}
81
81
}
Original file line number Diff line number Diff line change 290
290
$data['custom_option'] = custom_option_json;
291
291
$data['product_id'] = "<?= $ _id ?> ";
292
292
$data['qty'] = qty;
293
- $data[csrfName] = csrfVal;
293
+ if (csrfName && csrfVal) {
294
+ $data[csrfName] = csrfVal;
295
+ }
294
296
$.ajax({
295
297
async:true,
296
298
timeout: 6000,
You can’t perform that action at this time.
0 commit comments