|
@@ -14,9 +14,12 @@ use category_helper;
|
|
|
class behavior
|
|
|
{
|
|
|
private $mod_behavior;
|
|
|
+ private $method_dicts;
|
|
|
public function __construct()
|
|
|
{
|
|
|
$this->mod_behavior = Model('behavior');
|
|
|
+ $this->method_dicts = [];
|
|
|
+ $this->init_methods();
|
|
|
}
|
|
|
|
|
|
public function analyse($time)
|
|
@@ -114,23 +117,24 @@ class behavior
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
- private function type_data($act,$op,$params)
|
|
|
+ private function init_methods()
|
|
|
{
|
|
|
- if(empty($act) || empty($op)) return [];
|
|
|
-
|
|
|
- if($act == 'login')
|
|
|
+ $this->method_dicts['login'] = function ($op, $params)
|
|
|
{
|
|
|
- if($op == 'getcodex' || $op == 'getcode') {
|
|
|
+ if ($op == 'getcodex' || $op == 'getcode') {
|
|
|
$val = $params['mobile'];
|
|
|
- return ['type' => 'mobile','data' => $val];
|
|
|
+ return ['type' => 'mobile', 'data' => $val];
|
|
|
+ } else {
|
|
|
+ return [];
|
|
|
}
|
|
|
- }
|
|
|
- elseif($act == 'special')
|
|
|
- {
|
|
|
+ };
|
|
|
+
|
|
|
+ $this->method_dicts['special'] = function ($op, $params) {
|
|
|
$val = intval($params['special_id']);
|
|
|
return ['type' => 'special','data' => $val];
|
|
|
- }
|
|
|
- elseif($act == 'goods_common')
|
|
|
+ };
|
|
|
+
|
|
|
+ $this->method_dicts['goods_common'] = function ($op, $params)
|
|
|
{
|
|
|
if($op == 'index' || $op == 'detail' || $op == 'detail_ajax') {
|
|
|
$val = intval($params['goods_id']);
|
|
@@ -139,14 +143,18 @@ class behavior
|
|
|
elseif($op == 'comments') {
|
|
|
$val = intval($params['goods_commonid']);
|
|
|
return ['type' => 'goods_common','data' => $val];
|
|
|
+ } else {
|
|
|
+ return [];
|
|
|
}
|
|
|
- }
|
|
|
- elseif($act == 'search')
|
|
|
+ };
|
|
|
+
|
|
|
+ $this->method_dicts['search'] = function ($op, $params)
|
|
|
{
|
|
|
if($op == 'index' || $op == 'search_goods') {
|
|
|
$keyword = urldecode($params['keyword']);
|
|
|
$brandid = intval($params['brand_id']);
|
|
|
$hotid = intval($params['hot_id']);
|
|
|
+
|
|
|
$brand = brand_helper::instance()->name($brandid);
|
|
|
$hot = category_helper::instance()->name($hotid);
|
|
|
|
|
@@ -156,13 +164,56 @@ class behavior
|
|
|
$keyword = $params['keyword'];
|
|
|
return ['type' => 'keyword','data' => "{$keyword}"];
|
|
|
}
|
|
|
- elseif($op == 'history') {
|
|
|
+ else {
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ $this->method_dicts['cart'] = function ($op, $params)
|
|
|
+ {
|
|
|
+ if($op == 'addex') {
|
|
|
+ $bl_id = intval($params['bl_id']);
|
|
|
+ $goods_id = intval($params['goods_id']);
|
|
|
+ if($bl_id > 0) {
|
|
|
+ return ['type' => 'bl','data' => $bl_id];
|
|
|
+ } else {
|
|
|
+ return ['type' => 'goods','data' => $goods_id];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ elseif($op == 'edit') {
|
|
|
+ $cart_id = intval($params['cart_id']);
|
|
|
+ return ['type' => 'cart','data' => $cart_id];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+ };
|
|
|
|
|
|
+ $this->method_dicts['member_buy'] = function ($op, $params) {
|
|
|
+ if($op == 'step_first') {
|
|
|
+ $cart_ids = urldecode($_POST['cart_id']);
|
|
|
+ return ['type' => 'cart_ids','data' => $cart_ids];
|
|
|
}
|
|
|
- }
|
|
|
+ elseif($op == 'step_second') {
|
|
|
+ $payment = $params['payment'];
|
|
|
+ return ['type' => 'payment','data' => $payment];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ $this->method_dicts['member_bonus'] = function ($op, $params) {
|
|
|
+ return [];
|
|
|
+ };
|
|
|
+ }
|
|
|
|
|
|
+ private function type_data($act,$op,$params)
|
|
|
+ {
|
|
|
+ if(empty($act) || empty($op)) return [];
|
|
|
+ if(!array_key_exists($act,$this->method_dicts)) return [];
|
|
|
|
|
|
- return [];
|
|
|
+ return $this->method_dicts[$act]($op,$params);
|
|
|
}
|
|
|
|
|
|
private function parse_content($content)
|