mirror of
https://gitee.com/zongzhige/shopxo.git
synced 2024-12-02 03:48:47 +08:00
web端搜索页面优化
This commit is contained in:
parent
6f64b0029e
commit
b758285530
@ -14,7 +14,7 @@ use think\facade\Hook;
|
||||
use app\service\GoodsService;
|
||||
use app\service\RegionService;
|
||||
use app\service\BrandService;
|
||||
use app\service\GoodsParamsTemplateService;
|
||||
use app\service\GoodsParamsService;
|
||||
|
||||
/**
|
||||
* 商品管理
|
||||
@ -211,7 +211,7 @@ class Goods extends Common
|
||||
],
|
||||
'field' => 'id,name',
|
||||
);
|
||||
$template = GoodsParamsTemplateService::GoodsParamsTemplateList($data_params);
|
||||
$template = GoodsParamsService::GoodsParamsTemplateList($data_params);
|
||||
$this->assign('goods_template_list', $template['data']);
|
||||
|
||||
// 是否拷贝
|
||||
|
@ -11,7 +11,7 @@
|
||||
namespace app\admin\controller;
|
||||
|
||||
use think\facade\Hook;
|
||||
use app\service\GoodsParamsTemplateService;
|
||||
use app\service\GoodsParamsService;
|
||||
|
||||
/**
|
||||
* 商品参数管理
|
||||
@ -54,7 +54,7 @@ class GoodsParamsTemplate extends Common
|
||||
public function Index()
|
||||
{
|
||||
// 总数
|
||||
$total = GoodsParamsTemplateService::GoodsParamsTemplateTotal($this->form_where);
|
||||
$total = GoodsParamsService::GoodsParamsTemplateTotal($this->form_where);
|
||||
|
||||
// 分页
|
||||
$page_params = [
|
||||
@ -73,7 +73,7 @@ class GoodsParamsTemplate extends Common
|
||||
'n' => $this->page_size,
|
||||
'order_by' => $this->form_order_by['data'],
|
||||
];
|
||||
$ret = GoodsParamsTemplateService::GoodsParamsTemplateList($data_params);
|
||||
$ret = GoodsParamsService::GoodsParamsTemplateList($data_params);
|
||||
|
||||
// 基础参数赋值
|
||||
$this->assign('params', $this->data_request);
|
||||
@ -105,7 +105,7 @@ class GoodsParamsTemplate extends Common
|
||||
'n' => 1,
|
||||
'where' => $where,
|
||||
];
|
||||
$ret = GoodsParamsTemplateService::GoodsParamsTemplateList($data_params);
|
||||
$ret = GoodsParamsService::GoodsParamsTemplateList($data_params);
|
||||
$data = (empty($ret['data']) || empty($ret['data'][0])) ? [] : $ret['data'][0];
|
||||
$this->assign('data', $data);
|
||||
|
||||
@ -142,7 +142,7 @@ class GoodsParamsTemplate extends Common
|
||||
'where' => ['id'=>intval($params['id'])],
|
||||
'field' => '*',
|
||||
);
|
||||
$ret = GoodsParamsTemplateService::GoodsParamsTemplateList($data_params);
|
||||
$ret = GoodsParamsService::GoodsParamsTemplateList($data_params);
|
||||
$data = empty($ret['data'][0]) ? [] : $ret['data'][0];
|
||||
}
|
||||
|
||||
@ -188,7 +188,7 @@ class GoodsParamsTemplate extends Common
|
||||
|
||||
// 开始处理
|
||||
$params = $this->data_request;
|
||||
return GoodsParamsTemplateService::GoodsParamsTemplateSave($params);
|
||||
return GoodsParamsService::GoodsParamsTemplateSave($params);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -210,7 +210,7 @@ class GoodsParamsTemplate extends Common
|
||||
// 开始处理
|
||||
$params = $this->data_request;
|
||||
$params['user_type'] = 'admin';
|
||||
return GoodsParamsTemplateService::GoodsParamsTemplateDelete($params);
|
||||
return GoodsParamsService::GoodsParamsTemplateDelete($params);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -231,7 +231,7 @@ class GoodsParamsTemplate extends Common
|
||||
|
||||
// 开始处理
|
||||
$params = $this->data_request;
|
||||
return GoodsParamsTemplateService::GoodsParamsTemplateStatusUpdate($params);
|
||||
return GoodsParamsService::GoodsParamsTemplateStatusUpdate($params);
|
||||
}
|
||||
}
|
||||
?>
|
@ -26,6 +26,16 @@
|
||||
<input type="text" name="{{$data.home_search_keywords.only_tag}}" placeholder="{{$data.home_search_keywords.describe}}" data-validation-message="{{$data.home_search_keywords.error_tips}}" class="am-radius" data-am-tagsinput {{if !empty($data)}}value="{{$data.home_search_keywords.value}}"{{/if}} />
|
||||
</div>
|
||||
|
||||
<div class="am-form-group">
|
||||
<label>{{$data.home_search_limit_number.name}}<span class="am-form-group-label-tips">{{$data.home_search_limit_number.describe}}</span></label>
|
||||
<div class="am-input-group am-input-group-sm">
|
||||
<input type="number" min="0" name="{{$data.home_search_limit_number.only_tag}}" placeholder="{{$data.home_search_limit_number.name}}" data-validation-message="{{$data.home_search_limit_number.error_tips}}" class="am-radius" {{if !empty($data)}}value="{{$data.home_search_limit_number.value}}"{{/if}} />
|
||||
<span class="am-input-group-btn">
|
||||
<button class="am-btn am-btn-default" type="button">条</button>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="am-form-group am-form-group-refreshing am-margin-top-lg am-padding-left-0">
|
||||
<input type="hidden" name="nav_type" value="{{$nav_type}}" />
|
||||
<input type="hidden" name="view_type" value="{{$view_type}}" />
|
||||
|
@ -628,18 +628,9 @@ class User extends Common
|
||||
}
|
||||
|
||||
// 用户信息处理
|
||||
$data = [
|
||||
'openid' => $this->data_post['openid'],
|
||||
'mobile' => $mobile,
|
||||
'nickname' => isset($this->data_post['nickname']) ? $this->data_post['nickname'] : '',
|
||||
'avatar' => isset($this->data_post['avatar']) ? $this->data_post['avatar'] : '',
|
||||
'province' => isset($this->data_post['province']) ? $this->data_post['province'] : '',
|
||||
'city' => isset($this->data_post['city']) ? $this->data_post['city'] : '',
|
||||
'gender' => isset($this->data_post['gender']) ? intval($this->data_post['gender']) : '',
|
||||
'referrer' => isset($this->data_post['referrer']) ? $this->data_post['referrer'] : 0,
|
||||
'is_onekey_mobile_bind' => 1,
|
||||
];
|
||||
return UserService::AuthUserProgram($data, APPLICATION_CLIENT_TYPE.'_openid');
|
||||
$this->data_post['mobile'] = $mobile;
|
||||
$this->data_post['is_onekey_mobile_bind'] = 1;
|
||||
return UserService::AuthUserProgram($this->data_post, APPLICATION_CLIENT_TYPE.'_openid');
|
||||
}
|
||||
}
|
||||
?>
|
@ -132,105 +132,47 @@ class Buy extends Common
|
||||
*/
|
||||
private function PluginsHook($data = [], $params = [])
|
||||
{
|
||||
// 订单确认页面顶部钩子
|
||||
$hook_name = 'plugins_view_buy_top';
|
||||
$this->assign($hook_name.'_data', Hook::listen($hook_name,
|
||||
[
|
||||
'hook_name' => $hook_name,
|
||||
'is_backend' => false,
|
||||
'data' => $data,
|
||||
'params' => $params,
|
||||
]));
|
||||
$hook_arr = [
|
||||
// 订单确认页面顶部钩子
|
||||
'plugins_view_buy_top',
|
||||
|
||||
// 订单确认页面内部顶部钩子
|
||||
$hook_name = 'plugins_view_buy_inside_top';
|
||||
$this->assign($hook_name.'_data', Hook::listen($hook_name,
|
||||
[
|
||||
'hook_name' => $hook_name,
|
||||
'is_backend' => false,
|
||||
'data' => $data,
|
||||
'params' => $params,
|
||||
]));
|
||||
// 订单确认页面内部顶部钩子
|
||||
'plugins_view_buy_inside_top',
|
||||
|
||||
// 订单确认页面地址底部钩子
|
||||
$hook_name = 'plugins_view_buy_address_bottom';
|
||||
$this->assign($hook_name.'_data', Hook::listen($hook_name,
|
||||
[
|
||||
'hook_name' => $hook_name,
|
||||
'is_backend' => false,
|
||||
'data' => $data,
|
||||
'params' => $params,
|
||||
]));
|
||||
// 订单确认页面地址底部钩子
|
||||
'plugins_view_buy_address_bottom',
|
||||
|
||||
// 订单确认页面支付方式底部钩子
|
||||
$hook_name = 'plugins_view_buy_payment_bottom';
|
||||
$this->assign($hook_name.'_data', Hook::listen($hook_name,
|
||||
[
|
||||
'hook_name' => $hook_name,
|
||||
'is_backend' => false,
|
||||
'data' => $data,
|
||||
'params' => $params,
|
||||
]));
|
||||
// 订单确认页面支付方式底部钩子
|
||||
'plugins_view_buy_payment_bottom',
|
||||
|
||||
// 订单确认页面分组商品底部钩子
|
||||
$hook_name = 'plugins_view_buy_group_goods_bottom';
|
||||
$this->assign($hook_name.'_data', Hook::listen($hook_name,
|
||||
[
|
||||
'hook_name' => $hook_name,
|
||||
'is_backend' => false,
|
||||
'data' => $data,
|
||||
'params' => $params,
|
||||
]));
|
||||
// 订单确认页面分组商品底部钩子
|
||||
'plugins_view_buy_group_goods_bottom',
|
||||
|
||||
// 订单确认页面用户留言底部钩子
|
||||
$hook_name = 'plugins_view_buy_user_note_bottom';
|
||||
$this->assign($hook_name.'_data', Hook::listen($hook_name,
|
||||
[
|
||||
'hook_name' => $hook_name,
|
||||
'is_backend' => false,
|
||||
'data' => $data,
|
||||
'params' => $params,
|
||||
]));
|
||||
// 订单确认页面用户留言底部钩子
|
||||
'plugins_view_buy_user_note_bottom',
|
||||
|
||||
// 订单确认页面订单确认信息顶部钩子
|
||||
$hook_name = 'plugins_view_buy_base_confirm_top';
|
||||
$this->assign($hook_name.'_data', Hook::listen($hook_name,
|
||||
[
|
||||
'hook_name' => $hook_name,
|
||||
'is_backend' => false,
|
||||
'data' => $data,
|
||||
'params' => $params,
|
||||
]));
|
||||
// 订单确认页面订单确认信息顶部钩子
|
||||
'plugins_view_buy_base_confirm_top',
|
||||
|
||||
// 订单确认页面提交订单表单内部钩子
|
||||
$hook_name = 'plugins_view_buy_form_inside';
|
||||
$this->assign($hook_name.'_data', Hook::listen($hook_name,
|
||||
[
|
||||
'hook_name' => $hook_name,
|
||||
'is_backend' => false,
|
||||
'data' => $data,
|
||||
'params' => $params,
|
||||
]));
|
||||
// 订单确认页面提交订单表单内部钩子
|
||||
'plugins_view_buy_form_inside',
|
||||
|
||||
// 订单确认页面内部底部钩子
|
||||
$hook_name = 'plugins_view_buy_inside_bottom';
|
||||
$this->assign($hook_name.'_data', Hook::listen($hook_name,
|
||||
[
|
||||
'hook_name' => $hook_name,
|
||||
'is_backend' => false,
|
||||
'data' => $data,
|
||||
'params' => $params,
|
||||
]));
|
||||
// 订单确认页面内部底部钩子
|
||||
'plugins_view_buy_inside_bottom',
|
||||
|
||||
// 订单确认页面底部钩子
|
||||
$hook_name = 'plugins_view_buy_bottom';
|
||||
$this->assign($hook_name.'_data', Hook::listen($hook_name,
|
||||
[
|
||||
'hook_name' => $hook_name,
|
||||
'is_backend' => false,
|
||||
'data' => $data,
|
||||
'params' => $params,
|
||||
]));
|
||||
// 订单确认页面底部钩子
|
||||
'plugins_view_buy_bottom',
|
||||
];
|
||||
foreach($hook_arr as $hook_name)
|
||||
{
|
||||
$this->assign($hook_name.'_data', Hook::listen($hook_name,
|
||||
[
|
||||
'hook_name' => $hook_name,
|
||||
'is_backend' => false,
|
||||
'data' => $data,
|
||||
'params' => $params,
|
||||
]));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -167,155 +167,62 @@ class Goods extends Common
|
||||
*/
|
||||
private function PluginsHook($goods_id, &$goods)
|
||||
{
|
||||
// 商品页面相册内部钩子
|
||||
$hook_name = 'plugins_view_goods_detail_photo_within';
|
||||
$this->assign($hook_name.'_data', Hook::listen($hook_name,
|
||||
[
|
||||
'hook_name' => $hook_name,
|
||||
'is_backend' => false,
|
||||
'goods_id' => $goods_id,
|
||||
'goods' => &$goods,
|
||||
]));
|
||||
$hook_arr = [
|
||||
// 商品页面相册内部钩子
|
||||
'plugins_view_goods_detail_photo_within',
|
||||
|
||||
// 商品页面相册底部钩子
|
||||
$hook_name = 'plugins_view_goods_detail_photo_bottom';
|
||||
$this->assign($hook_name.'_data', Hook::listen($hook_name,
|
||||
[
|
||||
'hook_name' => $hook_name,
|
||||
'is_backend' => false,
|
||||
'goods_id' => $goods_id,
|
||||
'goods' => &$goods,
|
||||
]));
|
||||
|
||||
// 商品页面基础信息顶部钩子
|
||||
$hook_name = 'plugins_view_goods_detail_base_top';
|
||||
$this->assign($hook_name.'_data', Hook::listen($hook_name,
|
||||
[
|
||||
'hook_name' => $hook_name,
|
||||
'is_backend' => false,
|
||||
'goods_id' => $goods_id,
|
||||
'goods' => &$goods,
|
||||
]));
|
||||
// 商品页面相册底部钩子
|
||||
'plugins_view_goods_detail_photo_bottom',
|
||||
|
||||
// 商品页面基础信息面板底部钩子
|
||||
$hook_name = 'plugins_view_goods_detail_panel_bottom';
|
||||
$this->assign($hook_name.'_data', Hook::listen($hook_name,
|
||||
[
|
||||
'hook_name' => $hook_name,
|
||||
'is_backend' => false,
|
||||
'goods_id' => $goods_id,
|
||||
'goods' => &$goods,
|
||||
]));
|
||||
// 商品页面基础信息顶部钩子
|
||||
'plugins_view_goods_detail_base_top',
|
||||
|
||||
// 商品页面规格顶部钩子
|
||||
$hook_name = 'plugins_view_goods_detail_base_sku_top';
|
||||
$this->assign($hook_name.'_data', Hook::listen($hook_name,
|
||||
[
|
||||
'hook_name' => $hook_name,
|
||||
'is_backend' => false,
|
||||
'goods_id' => $goods_id,
|
||||
'goods' => &$goods,
|
||||
]));
|
||||
// 商品页面基础信息面板底部钩子
|
||||
'plugins_view_goods_detail_panel_bottom',
|
||||
|
||||
// 商品页面库存数量顶部钩子
|
||||
$hook_name = 'plugins_view_goods_detail_base_inventory_top';
|
||||
$this->assign($hook_name.'_data', Hook::listen($hook_name,
|
||||
[
|
||||
'hook_name' => $hook_name,
|
||||
'is_backend' => false,
|
||||
'goods_id' => $goods_id,
|
||||
'goods' => &$goods,
|
||||
]));
|
||||
// 商品页面规格顶部钩子
|
||||
'plugins_view_goods_detail_base_sku_top',
|
||||
|
||||
// 商品页面库存数量底部钩子
|
||||
$hook_name = 'plugins_view_goods_detail_base_inventory_bottom';
|
||||
$this->assign($hook_name.'_data', Hook::listen($hook_name,
|
||||
[
|
||||
'hook_name' => $hook_name,
|
||||
'is_backend' => false,
|
||||
'goods_id' => $goods_id,
|
||||
'goods' => &$goods,
|
||||
]));
|
||||
// 商品页面库存数量顶部钩子
|
||||
'plugins_view_goods_detail_base_inventory_top',
|
||||
|
||||
// 商品页面购买导航顶部钩子
|
||||
$hook_name = 'plugins_view_goods_detail_buy_nav_top';
|
||||
$this->assign($hook_name.'_data', Hook::listen($hook_name,
|
||||
[
|
||||
'hook_name' => $hook_name,
|
||||
'is_backend' => false,
|
||||
'goods_id' => $goods_id,
|
||||
'goods' => &$goods,
|
||||
]));
|
||||
// 商品页面库存数量底部钩子
|
||||
'plugins_view_goods_detail_base_inventory_bottom',
|
||||
|
||||
// 商品页面基础信息面板底部钩子
|
||||
$hook_name = 'plugins_view_goods_detail_base_bottom';
|
||||
$this->assign($hook_name.'_data', Hook::listen($hook_name,
|
||||
[
|
||||
'hook_name' => $hook_name,
|
||||
'is_backend' => false,
|
||||
'goods_id' => $goods_id,
|
||||
'goods' => &$goods,
|
||||
]));
|
||||
// 商品页面购买导航顶部钩子
|
||||
'plugins_view_goods_detail_buy_nav_top',
|
||||
|
||||
// 商品页面tabs顶部钩子
|
||||
$hook_name = 'plugins_view_goods_detail_tabs_top';
|
||||
$this->assign($hook_name.'_data', Hook::listen($hook_name,
|
||||
[
|
||||
'hook_name' => $hook_name,
|
||||
'is_backend' => false,
|
||||
'goods_id' => $goods_id,
|
||||
'goods' => &$goods,
|
||||
]));
|
||||
// 商品页面基础信息面板底部钩子
|
||||
'plugins_view_goods_detail_base_bottom',
|
||||
|
||||
// 商品页面tabs顶部钩子
|
||||
$hook_name = 'plugins_view_goods_detail_tabs_bottom';
|
||||
$this->assign($hook_name.'_data', Hook::listen($hook_name,
|
||||
[
|
||||
'hook_name' => $hook_name,
|
||||
'is_backend' => false,
|
||||
'goods_id' => $goods_id,
|
||||
'goods' => &$goods,
|
||||
]));
|
||||
// 商品页面tabs顶部钩子
|
||||
'plugins_view_goods_detail_tabs_top',
|
||||
|
||||
// 商品页面左侧顶部钩子
|
||||
$hook_name = 'plugins_view_goods_detail_left_top';
|
||||
$this->assign($hook_name.'_data', Hook::listen($hook_name,
|
||||
[
|
||||
'hook_name' => $hook_name,
|
||||
'is_backend' => false,
|
||||
'goods_id' => $goods_id,
|
||||
'goods' => &$goods,
|
||||
]));
|
||||
// 商品页面tabs顶部钩子
|
||||
'plugins_view_goods_detail_tabs_bottom',
|
||||
|
||||
// 商品页面基础信息标题里面钩子
|
||||
$hook_name = 'plugins_view_goods_detail_title';
|
||||
$this->assign($hook_name.'_data', Hook::listen($hook_name,
|
||||
[
|
||||
'hook_name' => $hook_name,
|
||||
'is_backend' => false,
|
||||
'goods_id' => $goods_id,
|
||||
'goods' => &$goods,
|
||||
]));
|
||||
// 商品页面左侧顶部钩子
|
||||
'plugins_view_goods_detail_left_top',
|
||||
|
||||
// 商品页面基础信息面板售价顶部钩子
|
||||
$hook_name = 'plugins_view_goods_detail_panel_price_top';
|
||||
$this->assign($hook_name.'_data', Hook::listen($hook_name,
|
||||
[
|
||||
'hook_name' => $hook_name,
|
||||
'is_backend' => false,
|
||||
'goods_id' => $goods_id,
|
||||
'goods' => &$goods,
|
||||
]));
|
||||
// 商品页面基础信息标题里面钩子
|
||||
'plugins_view_goods_detail_title',
|
||||
|
||||
// 商品页面基础信息购买小导航里面钩子
|
||||
$hook_name = 'plugins_view_goods_detail_base_buy_nav_min_inside';
|
||||
$this->assign($hook_name.'_data', Hook::listen($hook_name,
|
||||
[
|
||||
'hook_name' => $hook_name,
|
||||
'is_backend' => false,
|
||||
'goods_id' => $goods_id,
|
||||
'goods' => &$goods,
|
||||
]));
|
||||
// 商品页面基础信息面板售价顶部钩子
|
||||
'plugins_view_goods_detail_panel_price_top',
|
||||
|
||||
// 商品页面基础信息购买小导航里面钩子
|
||||
'plugins_view_goods_detail_base_buy_nav_min_inside',
|
||||
];
|
||||
foreach($hook_arr as $hook_name)
|
||||
{
|
||||
$this->assign($hook_name.'_data', Hook::listen($hook_name,
|
||||
[
|
||||
'hook_name' => $hook_name,
|
||||
'is_backend' => false,
|
||||
'goods_id' => $goods_id,
|
||||
'goods' => &$goods,
|
||||
]));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -96,32 +96,25 @@ class Index extends Common
|
||||
*/
|
||||
private function PluginsHook($params = [])
|
||||
{
|
||||
// 楼层数据顶部钩子
|
||||
$hook_name = 'plugins_view_home_floor_top';
|
||||
$this->assign($hook_name.'_data', Hook::listen($hook_name,
|
||||
[
|
||||
'hook_name' => $hook_name,
|
||||
'is_backend' => false,
|
||||
'user' => $this->user,
|
||||
]));
|
||||
$hook_arr = [
|
||||
// 楼层数据顶部钩子
|
||||
'plugins_view_home_floor_top',
|
||||
|
||||
// 楼层数据底部钩子
|
||||
$hook_name = 'plugins_view_home_floor_bottom';
|
||||
$this->assign($hook_name.'_data', Hook::listen($hook_name,
|
||||
[
|
||||
'hook_name' => $hook_name,
|
||||
'is_backend' => false,
|
||||
'user' => $this->user,
|
||||
]));
|
||||
// 楼层数据底部钩子
|
||||
'plugins_view_home_floor_bottom',
|
||||
|
||||
// 轮播混合数据底部钩子
|
||||
$hook_name = 'plugins_view_home_banner_mixed_bottom';
|
||||
$this->assign($hook_name.'_data', Hook::listen($hook_name,
|
||||
[
|
||||
'hook_name' => $hook_name,
|
||||
'is_backend' => false,
|
||||
'user' => $this->user,
|
||||
]));
|
||||
// 轮播混合数据底部钩子
|
||||
'plugins_view_home_banner_mixed_bottom',
|
||||
];
|
||||
foreach($hook_arr as $hook_name)
|
||||
{
|
||||
$this->assign($hook_name.'_data', Hook::listen($hook_name,
|
||||
[
|
||||
'hook_name' => $hook_name,
|
||||
'is_backend' => false,
|
||||
'user' => $this->user,
|
||||
]));
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
@ -11,9 +11,8 @@
|
||||
namespace app\index\controller;
|
||||
|
||||
use think\facade\Hook;
|
||||
use app\service\SearchService;
|
||||
use app\service\BrandService;
|
||||
use app\service\SeoService;
|
||||
use app\service\SearchService;
|
||||
use app\service\GoodsService;
|
||||
|
||||
/**
|
||||
@ -36,6 +35,25 @@ class Search extends Common
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
// 参数初始化
|
||||
$this->ParamsInit();
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数初始化
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @datetime 2019-06-02T01:38:27+0800
|
||||
*/
|
||||
private function ParamsInit()
|
||||
{
|
||||
// 当前用户id
|
||||
$this->data_request['user_id'] = empty($this->user) ? 0 : $this->user['id'];
|
||||
|
||||
// 搜索关键字
|
||||
$this->data_request['wd'] = empty($this->data_request['wd']) ? '' : (IS_AJAX ? trim($this->data_request['wd']) : AsciiToStr($this->data_request['wd']));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -52,17 +70,25 @@ class Search extends Common
|
||||
{
|
||||
return redirect(MyUrl('index/search/index', ['wd'=>StrToAscii($keywords)]));
|
||||
} else {
|
||||
// 参数初始化
|
||||
$this->ParamsInit();
|
||||
|
||||
// 品牌列表
|
||||
$this->assign('brand_list', BrandService::CategoryBrandList(['category_id'=>$this->data_request['category_id'], 'keywords'=>$this->data_request['wd']]));
|
||||
$brand_list = SearchService::CategoryBrandList($this->data_request);
|
||||
$this->assign('brand_list', $brand_list);
|
||||
|
||||
// 商品分类
|
||||
$this->assign('category_list', SearchService::GoodsCategoryList(['category_id'=>$this->data_request['category_id']]));
|
||||
$category_list = SearchService::GoodsCategoryList($this->data_request);
|
||||
$this->assign('category_list', $category_list);
|
||||
|
||||
// 筛选价格区间
|
||||
$this->assign('screening_price_list', SearchService::ScreeningPriceList(['field'=>'id,name']));
|
||||
$screening_price_list = SearchService::ScreeningPriceList($this->data_request);
|
||||
$this->assign('screening_price_list', $screening_price_list);
|
||||
|
||||
// 商品参数
|
||||
$goods_params_list = SearchService::SearchGoodsParamsValueList($this->data_request);
|
||||
$this->assign('goods_params_list', $goods_params_list);
|
||||
|
||||
// 商品规格
|
||||
$goods_spec_list = SearchService::SearchGoodsSpecValueList($this->data_request);
|
||||
$this->assign('goods_spec_list', $goods_spec_list);
|
||||
|
||||
// 参数
|
||||
$this->assign('params', $this->data_request);
|
||||
@ -108,35 +134,6 @@ class Search extends Common
|
||||
$this->assign('home_seo_site_title', SeoService::BrowserSeoTitle(empty($seo_title) ? '商品搜索' : $seo_title, 1));
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数初始化
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @datetime 2019-06-02T01:38:27+0800
|
||||
*/
|
||||
private function ParamsInit()
|
||||
{
|
||||
// 品牌id
|
||||
$this->data_request['brand_id'] = isset($this->data_request['brand_id']) ? intval($this->data_request['brand_id']) : 0;
|
||||
|
||||
// 分类id
|
||||
$this->data_request['category_id'] = isset($this->data_request['category_id']) ? intval($this->data_request['category_id']) : 0;
|
||||
|
||||
// 筛选价格id
|
||||
$this->data_request['screening_price_id'] = isset($this->data_request['screening_price_id']) ? intval($this->data_request['screening_price_id']) : 0;
|
||||
|
||||
// 搜索关键字
|
||||
$this->data_request['wd'] = empty($this->data_request['wd']) ? '' : (IS_AJAX ? trim($this->data_request['wd']) : AsciiToStr($this->data_request['wd']));
|
||||
|
||||
// 排序方式
|
||||
$this->data_request['order_by_field'] = empty($this->data_request['order_by_field']) ? 'default' : $this->data_request['order_by_field'];
|
||||
$this->data_request['order_by_type'] = empty($this->data_request['order_by_type']) ? 'desc' : $this->data_request['order_by_type'];
|
||||
|
||||
// 用户信息
|
||||
$this->data_request['user_id'] = isset($this->user['id']) ? $this->user['id'] : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品列表
|
||||
* @author Devil
|
||||
@ -152,19 +149,16 @@ class Search extends Common
|
||||
{
|
||||
$this->error('非法访问');
|
||||
}
|
||||
|
||||
// 参数初始化
|
||||
$this->ParamsInit();
|
||||
|
||||
// 获取商品列表
|
||||
$this->data_request['keywords'] = $this->data_request['wd'];
|
||||
$ret = SearchService::GoodsList($this->data_request);
|
||||
|
||||
// 搜索记录
|
||||
$this->data_request['search_result_data'] = $ret['data'];
|
||||
SearchService::SearchAdd($this->data_request);
|
||||
|
||||
// 无数据直接返回
|
||||
if(empty($ret['data']['data']) || $ret['code'] != 0)
|
||||
if($ret['code'] != 0 || empty($ret['data']['data']))
|
||||
{
|
||||
return DataReturn('没有更多数据啦', -100);
|
||||
}
|
||||
@ -185,85 +179,54 @@ class Search extends Common
|
||||
*/
|
||||
private function PluginsHook()
|
||||
{
|
||||
// 搜索页面顶部钩子
|
||||
$hook_name = 'plugins_view_search_top';
|
||||
$this->assign($hook_name.'_data', Hook::listen($hook_name,
|
||||
[
|
||||
'hook_name' => $hook_name,
|
||||
'is_backend' => false,
|
||||
]));
|
||||
$hook_arr = [
|
||||
// 搜索页面顶部钩子
|
||||
'plugins_view_search_top',
|
||||
|
||||
// 搜索页面底部钩子
|
||||
$hook_name = 'plugins_view_search_bottom';
|
||||
$this->assign($hook_name.'_data', Hook::listen($hook_name,
|
||||
[
|
||||
'hook_name' => $hook_name,
|
||||
'is_backend' => false,
|
||||
]));
|
||||
// 搜索页面底部钩子
|
||||
'plugins_view_search_bottom',
|
||||
|
||||
// 搜索页面顶部内部结构里面钩子
|
||||
$hook_name = 'plugins_view_search_inside_top';
|
||||
$this->assign($hook_name.'_data', Hook::listen($hook_name,
|
||||
[
|
||||
'hook_name' => $hook_name,
|
||||
'is_backend' => false,
|
||||
]));
|
||||
// 搜索页面顶部内部结构里面钩子
|
||||
'plugins_view_search_inside_top',
|
||||
|
||||
// 搜索页面底部内部结构里面钩子
|
||||
$hook_name = 'plugins_view_search_inside_bottom';
|
||||
$this->assign($hook_name.'_data', Hook::listen($hook_name,
|
||||
[
|
||||
'hook_name' => $hook_name,
|
||||
'is_backend' => false,
|
||||
]));
|
||||
// 搜索页面底部内部结构里面钩子
|
||||
'plugins_view_search_inside_bottom',
|
||||
|
||||
// 搜索页面数据容器顶部钩子
|
||||
$hook_name = 'plugins_view_search_data_top';
|
||||
$this->assign($hook_name.'_data', Hook::listen($hook_name,
|
||||
[
|
||||
'hook_name' => $hook_name,
|
||||
'is_backend' => false,
|
||||
]));
|
||||
// 搜索页面数据容器顶部钩子
|
||||
'plugins_view_search_data_top',
|
||||
|
||||
// 搜索页面数据容器底部钩子
|
||||
$hook_name = 'plugins_view_search_data_bottom';
|
||||
$this->assign($hook_name.'_data', Hook::listen($hook_name,
|
||||
[
|
||||
'hook_name' => $hook_name,
|
||||
'is_backend' => false,
|
||||
]));
|
||||
// 搜索页面数据容器底部钩子
|
||||
'plugins_view_search_data_bottom',
|
||||
|
||||
// 搜索页面搜索导航条顶部钩子
|
||||
$hook_name = 'plugins_view_search_nav_top';
|
||||
$this->assign($hook_name.'_data', Hook::listen($hook_name,
|
||||
[
|
||||
'hook_name' => $hook_name,
|
||||
'is_backend' => false,
|
||||
]));
|
||||
// 搜索条件顶部钩子
|
||||
'plugins_view_search_map_top',
|
||||
|
||||
// 搜索页面搜索导航条内前面钩子
|
||||
$hook_name = 'plugins_view_search_nav_inside_begin';
|
||||
$this->assign($hook_name.'_data', Hook::listen($hook_name,
|
||||
[
|
||||
'hook_name' => $hook_name,
|
||||
'is_backend' => false,
|
||||
]));
|
||||
// 搜索页面搜索导航条顶部钩子
|
||||
'plugins_view_search_nav_top',
|
||||
|
||||
// 搜索页面搜索导航条内尾部钩子
|
||||
$hook_name = 'plugins_view_search_nav_inside_end';
|
||||
$this->assign($hook_name.'_data', Hook::listen($hook_name,
|
||||
[
|
||||
'hook_name' => $hook_name,
|
||||
'is_backend' => false,
|
||||
]));
|
||||
// 搜索页面搜索导航条内前面钩子
|
||||
'plugins_view_search_nav_inside_begin',
|
||||
|
||||
// 搜索页面筛选条件内尾部钩子
|
||||
$hook_name = 'plugins_view_search_screen_inside_end';
|
||||
$this->assign($hook_name.'_data', Hook::listen($hook_name,
|
||||
[
|
||||
'hook_name' => $hook_name,
|
||||
'is_backend' => false,
|
||||
]));
|
||||
// 搜索页面搜索导航条内尾部钩子
|
||||
'plugins_view_search_nav_inside_end',
|
||||
|
||||
// 搜索页面筛选条件内前面钩子
|
||||
'plugins_view_search_map_inside_begin',
|
||||
|
||||
// 搜索页面筛选条件内基础底部钩子
|
||||
'plugins_view_search_map_inside_base_bottom',
|
||||
|
||||
// 搜索页面筛选条件内尾部钩子
|
||||
'plugins_view_search_map_inside_end',
|
||||
];
|
||||
foreach($hook_arr as $hook_name)
|
||||
{
|
||||
$this->assign($hook_name.'_data', Hook::listen($hook_name,
|
||||
[
|
||||
'hook_name' => $hook_name,
|
||||
'is_backend' => false,
|
||||
]));
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
@ -161,23 +161,34 @@ class User extends Common
|
||||
*/
|
||||
private function PluginsHook()
|
||||
{
|
||||
// 顶部钩子
|
||||
$this->assign('plugins_view_user_center_top_data', Hook::listen('plugins_view_user_center_top', ['hook_name'=>'plugins_view_user_center_top', 'is_backend'=>false, 'user'=>$this->user]));
|
||||
$hook_arr = [
|
||||
// 顶部钩子
|
||||
'plugins_view_user_center_top',
|
||||
|
||||
// 基础信息底部钩子
|
||||
$this->assign('plugins_view_user_base_bottom_data', Hook::listen('plugins_view_user_base_bottom', ['hook_name'=>'plugins_view_user_base_bottom', 'is_backend'=>false, 'user'=>$this->user]));
|
||||
// 基础信息底部钩子
|
||||
'plugins_view_user_base_bottom',
|
||||
|
||||
// 聚合内容顶部钩子
|
||||
$this->assign('plugins_view_user_various_top_data', Hook::listen('plugins_view_user_various_top', ['hook_name'=>'plugins_view_user_various_top', 'is_backend'=>false, 'user'=>$this->user]));
|
||||
// 聚合内容顶部钩子
|
||||
'plugins_view_user_various_top',
|
||||
|
||||
// 聚合内容底部钩子
|
||||
$this->assign('plugins_view_user_various_bottom_data', Hook::listen('plugins_view_user_various_bottom', ['hook_name'=>'plugins_view_user_various_bottom', 'is_backend'=>false, 'user'=>$this->user]));
|
||||
// 聚合内容底部钩子
|
||||
'plugins_view_user_various_bottom',
|
||||
|
||||
// 聚合内容里面顶部钩子
|
||||
$this->assign('plugins_view_user_various_inside_top_data', Hook::listen('plugins_view_user_various_inside_top', ['hook_name'=>'plugins_view_user_various_inside_top', 'is_backend'=>false, 'user'=>$this->user]));
|
||||
// 聚合内容里面顶部钩子
|
||||
'plugins_view_user_various_inside_top',
|
||||
|
||||
// 聚合内容里面底部钩子
|
||||
$this->assign('plugins_view_user_various_bottom_data', Hook::listen('plugins_view_user_various_bottom', ['hook_name'=>'plugins_view_user_various_bottom', 'is_backend'=>false, 'user'=>$this->user]));
|
||||
// 聚合内容里面底部钩子
|
||||
'plugins_view_user_various_inside_bottom',
|
||||
];
|
||||
foreach($hook_arr as $hook_name)
|
||||
{
|
||||
$this->assign($hook_name.'_data', Hook::listen($hook_name,
|
||||
[
|
||||
'hook_name' => $hook_name,
|
||||
'is_backend' => false,
|
||||
'user' => $this->user,
|
||||
]));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -42,81 +42,186 @@
|
||||
{{/foreach}}
|
||||
{{/if}}
|
||||
|
||||
<div class="search-container am-u-sm-12 am-u-md-12 am-padding-left-0 am-padding-right-0" data-category-id="{{$params.category_id}}">
|
||||
<div class="theme-popover">
|
||||
<ul class="select am-cf">
|
||||
<p class="title-tips">
|
||||
<span>筛选出</span>
|
||||
<strong>...</strong>
|
||||
<span>条数据</span>
|
||||
</p>
|
||||
<li class="select-result">
|
||||
<dl>
|
||||
<dt>已选</dt>
|
||||
<dd class="select-no"></dd>
|
||||
<p class="screening-remove-submit">清除</p>
|
||||
</dl>
|
||||
</li>
|
||||
<li class="select-list">
|
||||
<dl id="screening-brand-dl">
|
||||
<dt class="am-badge am-round">品牌</dt>
|
||||
<div class="dd-conent" data-selected-tag="screening-brand">
|
||||
<dd class="select-all selected"><a href="javascript:;">不限</a></dd>
|
||||
{{if !empty($brand_list)}}
|
||||
{{foreach $brand_list as $brand}}
|
||||
<dd><a href="javascript:;" data-value="{{$brand.id}}" data-field="brand_id">{{$brand.name}}</a></dd>
|
||||
{{/foreach}}
|
||||
{{else /}}
|
||||
<span class="not-tips">没有相关品牌</span>
|
||||
{{/if}}
|
||||
</div>
|
||||
</dl>
|
||||
</li>
|
||||
<li class="select-list">
|
||||
<dl id="screening-category-dl">
|
||||
<dt class="am-badge am-round">分类</dt>
|
||||
<div class="dd-conent" data-selected-tag="screening-category">
|
||||
<dd class="select-all selected"><a href="javascript:;">不限</a></dd>
|
||||
{{if !empty($category_list)}}
|
||||
{{foreach $category_list as $category}}
|
||||
<dd><a href="javascript:;" data-value="{{$category.id}}" data-field="category_id">{{$category.name}}</a></dd>
|
||||
{{/foreach}}
|
||||
{{else /}}
|
||||
<span class="not-tips">没有相关分类</span>
|
||||
{{/if}}
|
||||
</div>
|
||||
</dl>
|
||||
</li>
|
||||
<li class="select-list">
|
||||
<dl id="screening-price-dl">
|
||||
<dt class="am-badge am-round">价格</dt>
|
||||
<div class="dd-conent" data-selected-tag="screening-price">
|
||||
<dd class="select-all selected"><a href="javascript:;">不限</a></dd>
|
||||
{{if !empty($screening_price_list)}}
|
||||
{{foreach $screening_price_list as $screening_price}}
|
||||
<dd><a href="javascript:;" data-value="{{$screening_price.id}}" data-field="screening_price_id">{{$screening_price.name}}</a></dd>
|
||||
{{/foreach}}
|
||||
{{else /}}
|
||||
<span class="not-tips">没有相关价格</span>
|
||||
{{/if}}
|
||||
</div>
|
||||
</dl>
|
||||
</li>
|
||||
<div class="search-container am-u-sm-12 am-u-md-12 am-padding-left-0 am-padding-right-0" data-category-id="{{if !empty($params['category_id'])}}{{$params.category_id}}{{/if}}">
|
||||
<!-- 手机模式下基础信息+搜索条件按钮 -->
|
||||
<div class="map-base-tips am-nbfc am-padding-horizontal-xs am-padding-vertical-sm am-show-sm">
|
||||
<p class="am-fl">
|
||||
<span>筛选出</span>
|
||||
<strong class="map-result-count am-text-danger">...</strong>
|
||||
<span>条数据</span>
|
||||
</p>
|
||||
<button class="am-btn am-btn-primary am-icon-th-large map-offcanvas-submit" data-am-offcanvas="{target: '#search-map'}"></button>
|
||||
</div>
|
||||
|
||||
<!-- 搜索页面筛选条件内尾部钩子 -->
|
||||
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}}
|
||||
<div class="plugins-tag">
|
||||
<span>plugins_view_search_screen_inside_end</span>
|
||||
</div>
|
||||
<!-- 搜索条件顶部钩子 -->
|
||||
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}}
|
||||
<div class="plugins-tag">
|
||||
<span>plugins_view_search_map_top</span>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{if !empty($plugins_view_search_map_top_data) and is_array($plugins_view_search_map_top_data)}}
|
||||
{{foreach $plugins_view_search_map_top_data as $hook}}
|
||||
{{if is_string($hook) or is_int($hook)}}
|
||||
{{$hook|raw}}
|
||||
{{/if}}
|
||||
{{if !empty($plugins_view_search_screen_inside_end_data) and is_array($plugins_view_search_screen_inside_end_data)}}
|
||||
{{foreach $plugins_view_search_screen_inside_end_data as $hook}}
|
||||
{{if is_string($hook) or is_int($hook)}}
|
||||
{{$hook|raw}}
|
||||
{{/foreach}}
|
||||
{{/if}}
|
||||
|
||||
<!-- 搜索条件内容、侧边栏内容 -->
|
||||
<div id="search-map" class="am-offcanvas">
|
||||
<div class="am-offcanvas-bar">
|
||||
<div class="am-offcanvas-content">
|
||||
<ul class="map-item am-list am-list-border am-margin-top-sm am-margin-bottom-0">
|
||||
<!-- 搜索页面筛选条件内前面钩子 -->
|
||||
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}}
|
||||
<div class="plugins-tag">
|
||||
<span>plugins_view_search_map_inside_begin</span>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
{{/if}}
|
||||
</ul>
|
||||
{{if !empty($plugins_view_search_map_inside_begin_data) and is_array($plugins_view_search_map_inside_begin_data)}}
|
||||
{{foreach $plugins_view_search_map_inside_begin_data as $hook}}
|
||||
{{if is_string($hook) or is_int($hook)}}
|
||||
{{$hook|raw}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
{{/if}}
|
||||
|
||||
<!-- 基础数据 -->
|
||||
<li class="am-nbfc">
|
||||
<p class="am-fl am-margin-left-sm">
|
||||
<span>筛选出</span>
|
||||
<strong class="map-result-count am-text-danger">...</strong>
|
||||
<span>条数据</span>
|
||||
</p>
|
||||
<span class="map-remove-submit am-fr am-margin-right-sm am-hide">清除</span>
|
||||
</li>
|
||||
|
||||
<!-- 搜索页面筛选条件内基础底部钩子 -->
|
||||
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}}
|
||||
<div class="plugins-tag">
|
||||
<span>plugins_view_search_map_inside_base_bottom</span>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{if !empty($plugins_view_search_map_inside_base_bottom_data) and is_array($plugins_view_search_map_inside_base_bottom_data)}}
|
||||
{{foreach $plugins_view_search_map_inside_base_bottom_data as $hook}}
|
||||
{{if is_string($hook) or is_int($hook)}}
|
||||
{{$hook|raw}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
{{/if}}
|
||||
|
||||
<!-- 品牌 -->
|
||||
{{if !empty($brand_list)}}
|
||||
<li class="am-nbfc map-brand-container" data-field="brand_ids">
|
||||
<div class="map-left am-text-center am-fl">品牌</div>
|
||||
<div class="map-right map-images-text-items am-fr am-nbfc">
|
||||
<ul class="am-nbfc">
|
||||
{{foreach $brand_list as $v}}
|
||||
<li data-value="{{$v.id}}" title="{{$v.name}}">
|
||||
{{if empty($v['logo'])}}
|
||||
{{$v.name}}
|
||||
{{else /}}
|
||||
<img src="{{$v.logo}}" alt="{{$v.name}}" />
|
||||
{{/if}}
|
||||
</li>
|
||||
{{/foreach}}
|
||||
</ul>
|
||||
<div class="map-more-submit am-hide">
|
||||
<span>更多</span>
|
||||
<i class="am-icon-angle-down"></i>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
{{/if}}
|
||||
|
||||
<!-- 分类 -->
|
||||
{{if !empty($category_list)}}
|
||||
<li class="am-nbfc map-category-container" data-field="category_ids">
|
||||
<div class="map-left am-text-center am-fl">分类</div>
|
||||
<div class="map-right map-text-items am-fr am-nbfc">
|
||||
<ul class="am-nbfc">
|
||||
{{foreach $category_list as $v}}
|
||||
<li data-value="{{$v.id}}" title="{{$v.name}}">{{$v.name}}</li>
|
||||
{{/foreach}}
|
||||
</ul>
|
||||
<div class="map-more-submit am-hide">
|
||||
<span>更多</span>
|
||||
<i class="am-icon-angle-down"></i>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
{{/if}}
|
||||
|
||||
<!-- 价格 -->
|
||||
{{if !empty($screening_price_list)}}
|
||||
<li class="am-nbfc screening-price-container" data-field="screening_price_values">
|
||||
<div class="map-left am-text-center am-fl">价格</div>
|
||||
<div class="map-right map-text-items am-fr am-nbfc">
|
||||
<ul class="am-nbfc">
|
||||
{{foreach $screening_price_list as $v}}
|
||||
<li data-value="{{$v.min_price}}-{{$v.max_price}}" title="{{$v.name}}">{{$v.name}}</li>
|
||||
{{/foreach}}
|
||||
</ul>
|
||||
<div class="map-more-submit am-hide">
|
||||
<span>更多</span>
|
||||
<i class="am-icon-angle-down"></i>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
{{/if}}
|
||||
|
||||
<!-- 属性 -->
|
||||
{{if !empty($goods_params_list)}}
|
||||
<li class="am-nbfc goods-params-container" data-field="goods_params_values">
|
||||
<div class="map-left am-text-center am-fl">属性</div>
|
||||
<div class="map-right map-text-items am-fr am-nbfc">
|
||||
<ul class="am-nbfc">
|
||||
{{foreach $goods_params_list as $v}}
|
||||
<li data-value="{{$v}}" title="{{$v}}">{{$v}}</li>
|
||||
{{/foreach}}
|
||||
</ul>
|
||||
<div class="map-more-submit am-hide">
|
||||
<span>更多</span>
|
||||
<i class="am-icon-angle-down"></i>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
{{/if}}
|
||||
|
||||
<!-- 规格 -->
|
||||
{{if !empty($goods_spec_list)}}
|
||||
<li class="am-nbfc goods-spec-container" data-field="goods_spec_values">
|
||||
<div class="map-left am-text-center am-fl">规格</div>
|
||||
<div class="map-right map-text-items am-fr am-nbfc">
|
||||
<ul class="am-nbfc">
|
||||
{{foreach $goods_spec_list as $v}}
|
||||
<li data-value="{{$v}}" title="{{$v}}">{{$v}}</li>
|
||||
{{/foreach}}
|
||||
</ul>
|
||||
<div class="map-more-submit am-hide">
|
||||
<span>更多</span>
|
||||
<i class="am-icon-angle-down"></i>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
{{/if}}
|
||||
|
||||
<!-- 搜索页面筛选条件内尾部钩子 -->
|
||||
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}}
|
||||
<div class="plugins-tag">
|
||||
<span>plugins_view_search_map_inside_end</span>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{if !empty($plugins_view_search_map_inside_end_data) and is_array($plugins_view_search_map_inside_end_data)}}
|
||||
{{foreach $plugins_view_search_map_inside_end_data as $hook}}
|
||||
{{if is_string($hook) or is_int($hook)}}
|
||||
{{$hook|raw}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
{{/if}}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 搜索页面搜索导航条顶部钩子 -->
|
||||
@ -133,7 +238,8 @@
|
||||
{{/foreach}}
|
||||
{{/if}}
|
||||
|
||||
<div class="search-content search-nav">
|
||||
<!-- 排序方式 -->
|
||||
<div class="search-nav am-margin-top-sm">
|
||||
<ul class="sort-nav" data-am-sticky="{animation: 'slide-top'}">
|
||||
<!-- 搜索页面搜索导航条内前面钩子 -->
|
||||
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}}
|
||||
@ -179,7 +285,7 @@
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<!-- 搜索页面搜索导航条内尾部钩子 -->
|
||||
<!-- 搜索页面排序导航条内尾部钩子 -->
|
||||
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}}
|
||||
<div class="plugins-tag">
|
||||
<span>plugins_view_search_nav_inside_end</span>
|
||||
@ -210,7 +316,7 @@
|
||||
{{/if}}
|
||||
|
||||
<!-- 数据容器 -->
|
||||
<ul class="am-avg-sm-2 am-avg-md-3 am-avg-lg-5 search-list"></ul>
|
||||
<ul class="am-avg-sm-2 am-avg-md-3 am-avg-lg-5 am-margin-top-sm search-list"></ul>
|
||||
|
||||
<!-- 搜索页面数据容器底部钩子 -->
|
||||
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}}
|
||||
@ -236,7 +342,7 @@
|
||||
<div class="table-no" style="display:none;"><i class="am-icon-warning"></i> 没有相关数据</div>
|
||||
|
||||
<!-- 分页 -->
|
||||
<button type="button" class="am-btn am-btn-default am-btn-block search-pages-submit" data-url="{{:MyUrl('index/search/goodslist')}}" style="display:none;">加载更多 <i class="am-icon-angle-double-down"></i></button>
|
||||
<button type="button" class="am-btn am-btn-default am-btn-block am-margin-vertical-sm search-pages-submit" data-url="{{:MyUrl('index/search/goodslist')}}" style="display:none;">加载更多 <i class="am-icon-angle-double-down"></i></button>
|
||||
</div>
|
||||
|
||||
<!-- 搜索页面顶部内部结构里面钩子 -->
|
||||
|
@ -108,52 +108,6 @@ class BrandService
|
||||
return Db::name('Brand')->field('id,name')->where(['is_enable'=>1])->order('sort asc')->select();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分类下品牌列表
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-08-29
|
||||
* @desc description
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public static function CategoryBrandList($params = [])
|
||||
{
|
||||
$brand_where = ['is_enable'=>1];
|
||||
|
||||
// 分类id
|
||||
if(!empty($params['category_id']))
|
||||
{
|
||||
// 根据分类获取品牌id
|
||||
$category_ids = GoodsService::GoodsCategoryItemsIds([$params['category_id']], 1);
|
||||
$category_ids[] = $params['category_id'];
|
||||
$where = ['g.is_delete_time'=>0, 'g.is_shelves'=>1, 'gci.category_id'=>$category_ids];
|
||||
$brand_where['id'] = Db::name('Goods')->alias('g')->join(['__GOODS_CATEGORY_JOIN__'=>'gci'], 'g.id=gci.goods_id')->field('g.brand_id')->where($where)->group('g.brand_id')->column('brand_id');
|
||||
}
|
||||
|
||||
// 关键字
|
||||
if(!empty($params['keywords']))
|
||||
{
|
||||
$where = [
|
||||
['title', 'like', '%'.$params['keywords'].'%']
|
||||
];
|
||||
$brand_where['id'] = Db::name('Goods')->where($where)->group('brand_id')->column('brand_id');
|
||||
}
|
||||
|
||||
// 获取品牌列表
|
||||
$brand = Db::name('Brand')->where($brand_where)->field('id,name,logo,website_url')->select();
|
||||
if(!empty($brand))
|
||||
{
|
||||
foreach($brand as &$v)
|
||||
{
|
||||
$v['logo_old'] = $v['logo'];
|
||||
$v['logo'] = ResourcesService::AttachmentPathViewHandle($v['logo']);
|
||||
$v['website_url'] = empty($v['website_url']) ? null : $v['website_url'];
|
||||
}
|
||||
}
|
||||
return $brand;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取品牌名称
|
||||
* @author Devil
|
||||
|
@ -21,7 +21,7 @@ use think\facade\Hook;
|
||||
* @date 2020-11-27
|
||||
* @desc description
|
||||
*/
|
||||
class GoodsParamsTemplateService
|
||||
class GoodsParamsService
|
||||
{
|
||||
/**
|
||||
* 列表
|
@ -16,7 +16,7 @@ use app\service\ResourcesService;
|
||||
use app\service\BrandService;
|
||||
use app\service\RegionService;
|
||||
use app\service\WarehouseGoodsService;
|
||||
use app\service\GoodsParamsTemplateService;
|
||||
use app\service\GoodsParamsService;
|
||||
|
||||
/**
|
||||
* 商品服务层
|
||||
@ -142,7 +142,7 @@ class GoodsService
|
||||
// 排序
|
||||
$order_by = empty($params['order_by']) ? 'sort asc' : trim($params['order_by']);
|
||||
|
||||
$field = 'id,pid,icon,name,vice_name,describe,bg_color,big_images,sort,is_home_recommended,seo_title,seo_keywords,seo_desc';
|
||||
$field = empty($params['field']) ? 'id,pid,icon,name,vice_name,describe,bg_color,big_images,sort,is_home_recommended,seo_title,seo_keywords,seo_desc' : $params['field'];
|
||||
$data = Db::name('GoodsCategory')->field($field)->where($where)->order($order_by)->limit($m, $n)->select();
|
||||
return self::GoodsCategoryDataDealWith($data);
|
||||
}
|
||||
@ -361,6 +361,10 @@ class GoodsService
|
||||
*/
|
||||
public static function GoodsCategoryItemsIds($ids = [], $is_enable = null, $order_by = 'sort asc')
|
||||
{
|
||||
if(!is_array($ids))
|
||||
{
|
||||
$ids = explode(',', $ids);
|
||||
}
|
||||
$where = ['pid'=>$ids];
|
||||
if($is_enable !== null)
|
||||
{
|
||||
@ -1224,7 +1228,7 @@ class GoodsService
|
||||
Db::name('GoodsParams')->where(['goods_id'=>$goods_id])->delete();
|
||||
|
||||
// 获取参数解析并添加
|
||||
$config = GoodsParamsTemplateService::GoodsParamsTemplateHandle($params);
|
||||
$config = GoodsParamsService::GoodsParamsTemplateHandle($params);
|
||||
if($config['code'] == 0 && !empty($config['data']))
|
||||
{
|
||||
foreach($config['data'] as &$v)
|
||||
@ -1773,41 +1777,56 @@ class GoodsService
|
||||
$params['ids'] = explode(',', $params['ids']);
|
||||
}
|
||||
|
||||
// 开启事务
|
||||
// 启动事务
|
||||
Db::startTrans();
|
||||
|
||||
// 删除商品
|
||||
if(Db::name('Goods')->where(['id'=>$params['ids']])->delete())
|
||||
{
|
||||
// 捕获异常
|
||||
try {
|
||||
// 删除商品
|
||||
if(!Db::name('Goods')->where(['id'=>$params['ids']])->delete())
|
||||
{
|
||||
throw new \Exception('商品删除失败');
|
||||
}
|
||||
// 商品规格
|
||||
if(Db::name('GoodsSpecType')->where(['goods_id'=>$params['ids']])->delete() === false)
|
||||
{
|
||||
Db::rollback();
|
||||
return DataReturn('规格类型删除失败', -100);
|
||||
throw new \Exception('规格类型删除失败');
|
||||
}
|
||||
if(Db::name('GoodsSpecValue')->where(['goods_id'=>$params['ids']])->delete() === false)
|
||||
{
|
||||
Db::rollback();
|
||||
return DataReturn('规格值删除失败', -100);
|
||||
throw new \Exception('规格值删除失败');
|
||||
}
|
||||
if(Db::name('GoodsSpecBase')->where(['goods_id'=>$params['ids']])->delete() === false)
|
||||
{
|
||||
Db::rollback();
|
||||
return DataReturn('规格基础删除失败', -100);
|
||||
throw new \Exception('规格基础删除失败');
|
||||
}
|
||||
|
||||
// 相册
|
||||
if(Db::name('GoodsPhoto')->where(['goods_id'=>$params['ids']])->delete() === false)
|
||||
{
|
||||
Db::rollback();
|
||||
return DataReturn('相册删除失败', -100);
|
||||
throw new \Exception('相册删除失败');
|
||||
}
|
||||
|
||||
// app内容
|
||||
if(Db::name('GoodsContentApp')->where(['goods_id'=>$params['ids']])->delete() === false)
|
||||
{
|
||||
Db::rollback();
|
||||
return DataReturn('相册删除失败', -100);
|
||||
throw new \Exception('手机端内容删除失败');
|
||||
}
|
||||
|
||||
// 商品参数
|
||||
if(Db::name('GoodsParams')->where(['goods_id'=>$params['ids']])->delete() === false)
|
||||
{
|
||||
throw new \Exception('规格参数删除失败');
|
||||
}
|
||||
|
||||
// 商品关联仓库信息+库存
|
||||
if(Db::name('WarehouseGoods')->where(['goods_id'=>$params['ids']])->delete() === false)
|
||||
{
|
||||
throw new \Exception('仓库商品删除失败');
|
||||
}
|
||||
if(Db::name('WarehouseGoodsSpec')->where(['goods_id'=>$params['ids']])->delete() === false)
|
||||
{
|
||||
throw new \Exception('仓库商品库存删除失败');
|
||||
}
|
||||
|
||||
// 商品删除钩子
|
||||
@ -1822,10 +1841,10 @@ class GoodsService
|
||||
// 提交事务
|
||||
Db::commit();
|
||||
return DataReturn('删除成功', 0);
|
||||
} catch(\Exception $e) {
|
||||
Db::rollback();
|
||||
return DataReturn($e->getMessage(), -1);
|
||||
}
|
||||
|
||||
Db::rollback();
|
||||
return DataReturn('删除失败', -100);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -13,6 +13,7 @@ namespace app\service;
|
||||
use think\Db;
|
||||
use think\facade\Hook;
|
||||
use app\service\GoodsService;
|
||||
use app\service\ResourcesService;
|
||||
|
||||
/**
|
||||
* 搜索服务层
|
||||
@ -23,35 +24,6 @@ use app\service\GoodsService;
|
||||
*/
|
||||
class SearchService
|
||||
{
|
||||
/**
|
||||
* 根据分类id获取下级列表
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-08-29
|
||||
* @desc description
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public static function GoodsCategoryList($params = [])
|
||||
{
|
||||
return GoodsService::GoodsCategoryList(['where'=>['pid'=>$params['category_id']]]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品价格筛选列表
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-09-07
|
||||
* @desc description
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public static function ScreeningPriceList($params = [])
|
||||
{
|
||||
$field = empty($params['field']) ? '*' : $params['field'];
|
||||
return Db::name('ScreeningPrice')->field($field)->where(['is_enable'=>1])->order('sort asc')->select();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品列表
|
||||
* @author Devil
|
||||
@ -63,59 +35,18 @@ class SearchService
|
||||
*/
|
||||
public static function GoodsList($params = [])
|
||||
{
|
||||
// 返回格式
|
||||
$result = [
|
||||
'page_total' => 0,
|
||||
'total' => 0,
|
||||
'data' => [],
|
||||
];
|
||||
$where = [
|
||||
['g.is_delete_time', '=', 0],
|
||||
['g.is_shelves', '=', 1]
|
||||
];
|
||||
|
||||
// 关键字
|
||||
$where_keywords = [];
|
||||
if(!empty($params['keywords']))
|
||||
{
|
||||
$keywords = explode(' ', $params['keywords']);
|
||||
foreach($keywords as $kv)
|
||||
{
|
||||
$where_keywords[] = ['g.title|g.model|g.simple_desc|g.seo_title|g.seo_keywords|g.seo_keywords', 'like', '%'.$kv.'%'];
|
||||
}
|
||||
}
|
||||
|
||||
// 品牌
|
||||
if(!empty($params['brand_id']))
|
||||
{
|
||||
$where[] = ['g.brand_id', '=', intval($params['brand_id'])];
|
||||
}
|
||||
|
||||
// 分类id
|
||||
if(!empty($params['category_id']))
|
||||
{
|
||||
$category_ids = GoodsService::GoodsCategoryItemsIds([$params['category_id']], 1);
|
||||
$category_ids[] = $params['category_id'];
|
||||
$where[] = ['gci.category_id', 'in', $category_ids];
|
||||
}
|
||||
|
||||
// 筛选价格
|
||||
if(!empty($params['screening_price_id']))
|
||||
{
|
||||
$price = Db::name('ScreeningPrice')->field('min_price,max_price')->where(['is_enable'=>1, 'id'=>intval($params['screening_price_id'])])->find();
|
||||
if(!empty($price))
|
||||
{
|
||||
$params['min_price'] = $price['min_price'];
|
||||
$params['max_price'] = $price['max_price'];
|
||||
}
|
||||
}
|
||||
if(!empty($params['min_price']))
|
||||
{
|
||||
$where[] = ['g.min_price', 'EGT', $params['min_price']];
|
||||
}
|
||||
if(!empty($params['max_price']))
|
||||
{
|
||||
$where[] = ['g.min_price', 'LT', $params['max_price']];
|
||||
}
|
||||
|
||||
// 搜索条件
|
||||
$where = self::SearchWhereHandle($params);
|
||||
$base_where = $where['base'];
|
||||
$where_keywords = $where['keywords'];
|
||||
$where_screening_price = $where['screening_price'];
|
||||
|
||||
// 排序
|
||||
if(!empty($params['order_by_field']) && !empty($params['order_by_type']) && $params['order_by_field'] != 'default')
|
||||
@ -128,34 +59,40 @@ class SearchService
|
||||
// 分页计算
|
||||
$field = 'g.*';
|
||||
$page = max(1, isset($params['page']) ? intval($params['page']) : 1);
|
||||
$n = 20;
|
||||
$n = MyC('home_search_limit_number', 20, true);
|
||||
$m = intval(($page-1)*$n);
|
||||
|
||||
// 搜索商品列表读取前钩子
|
||||
$hook_name = 'plugins_service_search_goods_list_begin';
|
||||
Hook::listen($hook_name, [
|
||||
'hook_name' => $hook_name,
|
||||
'is_backend' => true,
|
||||
'params' => &$params,
|
||||
'where' => &$where,
|
||||
'where_keywords'=> &$where_keywords,
|
||||
'field' => &$field,
|
||||
'order_by' => &$order_by,
|
||||
'm' => &$m,
|
||||
'n' => &$n,
|
||||
'hook_name' => $hook_name,
|
||||
'is_backend' => true,
|
||||
'params' => &$params,
|
||||
'base_where' => &$base_where,
|
||||
'where_keywords' => &$where_keywords,
|
||||
'where_screening_price' => &$where_screening_price,
|
||||
'field' => &$field,
|
||||
'order_by' => &$order_by,
|
||||
'page' => &$page,
|
||||
'm' => &$m,
|
||||
'n' => &$n,
|
||||
]);
|
||||
|
||||
// 获取商品总数
|
||||
$result['total'] = (int) Db::name('Goods')->alias('g')->join(['__GOODS_CATEGORY_JOIN__'=>'gci'], 'g.id=gci.goods_id')->where($where)->where(function($query) use($where_keywords) {
|
||||
$result['total'] = (int) Db::name('Goods')->alias('g')->join(['__GOODS_CATEGORY_JOIN__'=>'gci'], 'g.id=gci.goods_id')->where($base_where)->where(function($query) use($where_keywords) {
|
||||
$query->whereOr($where_keywords);
|
||||
})->where(function($query) use($where_screening_price) {
|
||||
$query->whereOr($where_screening_price);
|
||||
})->count('DISTINCT g.id');
|
||||
|
||||
// 获取商品列表
|
||||
if($result['total'] > 0)
|
||||
{
|
||||
// 查询数据
|
||||
$data = Db::name('Goods')->alias('g')->join(['__GOODS_CATEGORY_JOIN__'=>'gci'], 'g.id=gci.goods_id')->field($field)->where($where)->where(function($query) use($where_keywords) {
|
||||
$data = Db::name('Goods')->alias('g')->join(['__GOODS_CATEGORY_JOIN__'=>'gci'], 'g.id=gci.goods_id')->field($field)->where($base_where)->where(function($query) use($where_keywords) {
|
||||
$query->whereOr($where_keywords);
|
||||
})->where(function($query) use($where_screening_price) {
|
||||
$query->whereOr($where_screening_price);
|
||||
})->group('g.id')->order($order_by)->limit($m, $n)->select();
|
||||
|
||||
// 数据处理
|
||||
@ -169,7 +106,104 @@ class SearchService
|
||||
}
|
||||
|
||||
/**
|
||||
* [SearchAdd 搜索记录添加]
|
||||
* 搜索条件处理
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2021-01-08
|
||||
* @desc description
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public static function SearchWhereHandle($params = [])
|
||||
{
|
||||
// 基础条件
|
||||
$where_base = [
|
||||
['g.is_delete_time', '=', 0],
|
||||
['g.is_shelves', '=', 1]
|
||||
];
|
||||
|
||||
// 关键字
|
||||
$where_keywords = [];
|
||||
if(!empty($params['wd']))
|
||||
{
|
||||
$keywords = explode(' ', $params['wd']);
|
||||
foreach($keywords as $kv)
|
||||
{
|
||||
$where_keywords[] = ['g.title|g.model|g.simple_desc|g.seo_title|g.seo_keywords|g.seo_keywords', 'like', '%'.$kv.'%'];
|
||||
}
|
||||
}
|
||||
|
||||
// 品牌
|
||||
if(!empty($params['brand_ids']))
|
||||
{
|
||||
$where_base[] = ['g.brand_id', 'in', $params['brand_ids']];
|
||||
}
|
||||
|
||||
// 分类id
|
||||
// 单个进来指定分类id+搜索条件分类id
|
||||
$category_ids = [];
|
||||
if(!empty($params['category_id']))
|
||||
{
|
||||
$ids = GoodsService::GoodsCategoryItemsIds([intval($params['category_id'])], 1);
|
||||
$category_ids = array_merge($category_ids, $ids);
|
||||
}
|
||||
if(!empty($params['category_ids']))
|
||||
{
|
||||
$ids = GoodsService::GoodsCategoryItemsIds($params['category_ids'], 1);
|
||||
$ids[] = $params['category_id'];
|
||||
$category_ids = array_merge($category_ids, $ids);
|
||||
}
|
||||
if(!empty($category_ids))
|
||||
{
|
||||
$where_base[] = ['gci.category_id', 'in', array_unique($category_ids)];
|
||||
}
|
||||
|
||||
// 筛选价格
|
||||
$where_screening_price = [];
|
||||
if(!empty($params['screening_price_values']))
|
||||
{
|
||||
foreach($params['screening_price_values'] as $v)
|
||||
{
|
||||
$temp = explode('-', $v);
|
||||
if(count($temp) == 2)
|
||||
{
|
||||
$where_screening_price[] = [
|
||||
['min_price', 'EGT', $temp[0]],
|
||||
['min_price', 'LT', $temp[1]],
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 商品参数、属性
|
||||
if(!empty($params['goods_params_values']))
|
||||
{
|
||||
$ids = Db::name('GoodsParams')->where(['value'=>$params['goods_params_values']])->column('goods_id');
|
||||
if(!empty($ids))
|
||||
{
|
||||
$where_base[] = ['g.id', 'in', $ids];
|
||||
}
|
||||
}
|
||||
|
||||
// 商品规格
|
||||
if(!empty($params['goods_spec_values']))
|
||||
{
|
||||
$ids = Db::name('GoodsSpecValue')->where(['value'=>$params['goods_spec_values']])->column('goods_id');
|
||||
if(!empty($ids))
|
||||
{
|
||||
$where_base[] = ['g.id', 'in', $ids];
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'base' => $where_base,
|
||||
'keywords' => $where_keywords,
|
||||
'screening_price' => $where_screening_price,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索记录添加
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
@ -178,34 +212,41 @@ class SearchService
|
||||
*/
|
||||
public static function SearchAdd($params = [])
|
||||
{
|
||||
// 筛选价格
|
||||
$screening_price = '';
|
||||
if(!empty($params['screening_price_id']))
|
||||
// 搜索数据结果
|
||||
if(!empty($params['search_result_data']))
|
||||
{
|
||||
$price = Db::name('ScreeningPrice')->field('min_price,max_price')->where(['is_enable'=>1, 'id'=>intval($params['screening_price_id'])])->find();
|
||||
} else {
|
||||
$price = [
|
||||
'min_price' => !empty($params['min_price']) ? $params['min_price'] : 0,
|
||||
'max_price' => !empty($params['max_price']) ? $params['max_price'] : 0,
|
||||
$search_result = [
|
||||
'total' => empty($params['search_result_data']['total']) ? 0 : $params['search_result_data']['total'],
|
||||
'data_count' => empty($params['search_result_data']['data']) ? 0 : count($params['search_result_data']['data']),
|
||||
'page' => empty($params['page']) ? 1 : intval($params['page']),
|
||||
'page_total' => empty($params['search_result_data']['page_total']) ? 0 : $params['search_result_data']['page_total'],
|
||||
];
|
||||
}
|
||||
if(!empty($price))
|
||||
{
|
||||
$screening_price = $price['min_price'].'-'.$price['max_price'];
|
||||
}
|
||||
|
||||
// 添加日志
|
||||
|
||||
// 日志数据
|
||||
$data = [
|
||||
'user_id' => isset($params['user_id']) ? intval($params['user_id']) : 0,
|
||||
'brand_id' => isset($params['brand_id']) ? intval($params['brand_id']) : 0,
|
||||
'category_id' => isset($params['category_id']) ? intval($params['category_id']) : 0,
|
||||
'keywords' => empty($params['keywords']) ? '' : $params['keywords'],
|
||||
'order_by_field' => empty($params['order_by_field']) ? '' : $params['order_by_field'],
|
||||
'order_by_type' => empty($params['order_by_type']) ? '' : $params['order_by_type'],
|
||||
'screening_price' => $screening_price,
|
||||
'ymd' => date('Ymd'),
|
||||
'add_time' => time(),
|
||||
'user_id' => isset($params['user_id']) ? intval($params['user_id']) : 0,
|
||||
'keywords' => empty($params['wd']) ? '' : $params['wd'],
|
||||
'order_by_field' => empty($params['order_by_field']) ? '' : $params['order_by_field'],
|
||||
'order_by_type' => empty($params['order_by_type']) ? '' : $params['order_by_type'],
|
||||
'search_result' => empty($search_result) ? '' : json_encode($search_result, JSON_UNESCAPED_UNICODE),
|
||||
'ymd' => date('Ymd'),
|
||||
'add_time' => time(),
|
||||
];
|
||||
|
||||
// 参数处理
|
||||
$field_arr = [
|
||||
'brand_ids',
|
||||
'category_ids',
|
||||
'screening_price_values',
|
||||
'goods_params_values',
|
||||
'goods_spec_values',
|
||||
];
|
||||
foreach($field_arr as $v)
|
||||
{
|
||||
$data[$v] = empty($params[$v]) ? '' : (is_array($params[$v]) ? json_encode($params[$v], JSON_UNESCAPED_UNICODE) : $params[$v]);
|
||||
}
|
||||
|
||||
Db::name('SearchHistory')->insert($data);
|
||||
}
|
||||
|
||||
@ -237,5 +278,133 @@ class SearchService
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分类下品牌列表
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-08-29
|
||||
* @desc description
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public static function CategoryBrandList($params = [])
|
||||
{
|
||||
// 基础条件
|
||||
$brand_where = [
|
||||
['is_enable', '=', 1],
|
||||
];
|
||||
|
||||
// 搜索条件
|
||||
$where = self::SearchWhereHandle($params);
|
||||
$base_where = $where['base'];
|
||||
$where_keywords = $where['keywords'];
|
||||
$where_screening_price = $where['screening_price'];
|
||||
|
||||
// 一维数组、参数值去重
|
||||
if(!empty($base_where) || !empty($where_keywords) || !empty($where_screening_price))
|
||||
{
|
||||
$ids = Db::name('Goods')->alias('g')->join(['__GOODS_CATEGORY_JOIN__'=>'gci'], 'g.id=gci.goods_id')->where($base_where)->where(function($query) use($where_keywords) {
|
||||
$query->whereOr($where_keywords);
|
||||
})->where(function($query) use($where_screening_price) {
|
||||
$query->whereOr($where_screening_price);
|
||||
})->group('g.brand_id')->column('g.brand_id');
|
||||
if(!empty($ids))
|
||||
{
|
||||
$brand_where[] = ['id', 'in', array_unique($ids)];
|
||||
}
|
||||
}
|
||||
|
||||
// 获取品牌列表
|
||||
$brand = Db::name('Brand')->where($brand_where)->field('id,name,logo,website_url')->select();
|
||||
if(!empty($brand))
|
||||
{
|
||||
foreach($brand as &$v)
|
||||
{
|
||||
$v['logo'] = ResourcesService::AttachmentPathViewHandle($v['logo']);
|
||||
$v['website_url'] = empty($v['website_url']) ? null : $v['website_url'];
|
||||
}
|
||||
}
|
||||
return $brand;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据分类id获取下级列表
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-08-29
|
||||
* @desc description
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public static function GoodsCategoryList($params = [])
|
||||
{
|
||||
$pid = empty($params['category_id']) ? 0 : intval($params['category_id']);
|
||||
return GoodsService::GoodsCategoryList(['where'=>['pid'=>$pid], 'field'=>'id,name']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品价格筛选列表
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-09-07
|
||||
* @desc description
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public static function ScreeningPriceList($params = [])
|
||||
{
|
||||
return Db::name('ScreeningPrice')->field('id,name,min_price,max_price')->where(['is_enable'=>1])->order('sort asc')->select();
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索商品参数列表、去重
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2021-01-08
|
||||
* @desc description
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public static function SearchGoodsParamsValueList($params = [])
|
||||
{
|
||||
// 搜索条件
|
||||
$where = self::SearchWhereHandle($params);
|
||||
$base_where = $where['base'];
|
||||
$where_keywords = $where['keywords'];
|
||||
$where_screening_price = $where['screening_price'];
|
||||
|
||||
// 一维数组、参数值去重
|
||||
return Db::name('Goods')->alias('g')->join(['__GOODS_CATEGORY_JOIN__'=>'gci'], 'g.id=gci.goods_id')->join(['__GOODS_PARAMS__'=>'gp'], 'g.id=gp.goods_id')->where($base_where)->where(function($query) use($where_keywords) {
|
||||
$query->whereOr($where_keywords);
|
||||
})->where(function($query) use($where_screening_price) {
|
||||
$query->whereOr($where_screening_price);
|
||||
})->group('gp.value')->column('gp.value');
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索商品规格列表、去重
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2021-01-08
|
||||
* @desc description
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public static function SearchGoodsSpecValueList($params = [])
|
||||
{
|
||||
// 搜索条件
|
||||
$where = self::SearchWhereHandle($params);
|
||||
$base_where = $where['base'];
|
||||
$where_keywords = $where['keywords'];
|
||||
$where_screening_price = $where['screening_price'];
|
||||
|
||||
// 一维数组、参数值去重
|
||||
return Db::name('Goods')->alias('g')->join(['__GOODS_CATEGORY_JOIN__'=>'gci'], 'g.id=gci.goods_id')->join(['__GOODS_SPEC_VALUE__'=>'gsv'], 'g.id=gsv.goods_id')->where($base_where)->where(function($query) use($where_keywords) {
|
||||
$query->whereOr($where_keywords);
|
||||
})->where(function($query) use($where_screening_price) {
|
||||
$query->whereOr($where_screening_price);
|
||||
})->group('gsv.value')->column('gsv.value');
|
||||
}
|
||||
}
|
||||
?>
|
1701
config/shopxo.sql
1701
config/shopxo.sql
File diff suppressed because one or more lines are too long
@ -1,124 +1,309 @@
|
||||
.search-container { float: none; }
|
||||
.items img{ width:100%;}
|
||||
.items .price strong{ font-size: 14px; }
|
||||
.theme-popover {z-index: 1011;background:#fff; width: 100%; }
|
||||
.sort-nav a:hover, .sort-nav a:focus { color: #d2364c; }
|
||||
.select .title-tips { font-size: 12px; color: #888; }
|
||||
.select .title-tips strong { font-weight: 500; color: #fe90a0; }
|
||||
|
||||
/* select */
|
||||
.sort-nav{padding:0px;font-size:12px}
|
||||
.suggest{ display:none;}
|
||||
.select li { margin: 5px 0px; }
|
||||
.select dl{zoom:1;position:relative;line-height:24px; }
|
||||
.select dl:after{content:" ";display:block;clear:both;height:0;overflow:hidden}
|
||||
.select dt{width:80%;margin-left:10%;margin-bottom:5px;position:absolute;cursor: pointer;height:24px;line-height:24px;}
|
||||
.select dd{float:left;display:inline;margin:0 0 5px 5px;}
|
||||
.select a{display:inline-block;white-space:nowrap;height:24px; line-height:24px;padding:0 10px;text-decoration:none;color:#000;border-radius:2px;}
|
||||
.select a:hover{color:#d2364c;}
|
||||
.select .selected a{color:#d2364c; border:1px solid #d2364c;}
|
||||
ul.pagination{display:none;}
|
||||
/*搜索显示*/
|
||||
.select-result{display: none;}
|
||||
li.select-result dl{padding: 25px 0 5px 0px;}
|
||||
li.select-result dt {left:-26px; top:0;font-weight:bold;width:50px;}
|
||||
|
||||
.select-no{color:#999}
|
||||
.select .select-result a{padding-right:20px;background: url("../images/search-close.png") right 9px no-repeat}
|
||||
.select .select-result a:hover{background-position:right -15px}
|
||||
.screening-remove-submit{display:none;line-height:21px;margin-top:4px;width:35px;float:right;color:#F00;cursor:pointer;}
|
||||
|
||||
|
||||
/*排序*/
|
||||
.sort-nav { width:100%; background: #fff; overflow: hidden; height: 30px; }
|
||||
.sort-nav li{ float:left;width:20%;height:30px; line-height:30px; text-align:center; padding:0px 0px;cursor: pointer;}
|
||||
.sort-nav li a{font-size:14px; text-decoration: none;}
|
||||
.sort-nav li.first {color: #F03726;}
|
||||
|
||||
|
||||
/*筛选条件*/
|
||||
.select-list{ float:left;display:inline; left:0;width:33.33%; height:30px;}
|
||||
.select-list dl dt{left:0px; cursor:pointer; text-align: center;}
|
||||
.select-list .dd-conent{display:none ;z-index:10; left:0; width:100%;position:fixed; background:#fff;max-height: 50%; padding-bottom: 10px; }
|
||||
.select-list .dd-conent dd{width:33.33% ;text-align: center;margin-left: 0px;height:25px ;}
|
||||
dl#select2 .dd-conent{ left:-100%; right:-100%;}
|
||||
dl#select3 .dd-conent{ left:-200%; right:0px;}
|
||||
|
||||
.search-container .am-badge{font-size:12px ;padding:0px 0px;background-color: #999999;color: #ffffff;font-weight: 600;}
|
||||
.theme-popover-mask{z-index:1001;width: 100%;height: auto;position:fixed ;background:#000 ;top:0;opacity: 0.6;bottom: 0;}
|
||||
|
||||
/*搜索结果*/
|
||||
.items {margin:5px;border: 1px #e8e8e8 solid;overflow: hidden;position: relative;cursor: pointer;}
|
||||
.items .sales-count { color: #888; }
|
||||
.items .original-price { text-decoration: line-through; color: #666; }
|
||||
|
||||
/*分页*/
|
||||
.am-pagination li{ float:none;}
|
||||
.search-side{display: none;}
|
||||
.search-pages-submit { margin: 10px 0; }
|
||||
/**
|
||||
* 条件
|
||||
*/
|
||||
.map-item > li {
|
||||
border: 1px solid #eee;
|
||||
background: #FAFAFA;
|
||||
}
|
||||
.map-item .map-left {
|
||||
width: 100px;
|
||||
font-weight: bold;
|
||||
line-height: 50px;
|
||||
}
|
||||
.map-item > li,
|
||||
.map-item .map-left {
|
||||
line-height: 50px;
|
||||
}
|
||||
.map-brand-container,
|
||||
.map-brand-container .map-left {
|
||||
line-height: 66px !important;
|
||||
}
|
||||
.map-item .map-right {
|
||||
width: calc(100% - 100px);
|
||||
background: #fff;
|
||||
}
|
||||
.map-item .map-right .text-tips {
|
||||
color: #888;
|
||||
text-align: center;
|
||||
}
|
||||
.map-item .map-right a {
|
||||
text-decoration: none;
|
||||
}
|
||||
.map-remove-submit {
|
||||
color: #e23f36;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.map-images-text-items ul,
|
||||
.map-text-items ul {
|
||||
padding: 15px 48px 0 15px;
|
||||
overflow-y: hidden;
|
||||
}
|
||||
.map-images-text-items {
|
||||
height: 66px;
|
||||
}
|
||||
.map-text-items {
|
||||
height: 56px;
|
||||
}
|
||||
.map-images-text-items ul li {
|
||||
float: left;
|
||||
vertical-align: middle;
|
||||
text-align: center;
|
||||
border: 1px solid #eee;
|
||||
width: 124px;
|
||||
height: 36px;
|
||||
margin: 0 15px 15px 0;
|
||||
line-height: 36px;
|
||||
}
|
||||
.map-images-text-items ul li,
|
||||
.map-text-items ul li {
|
||||
border-radius: 2px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.map-images-text-items ul li img {
|
||||
height: calc(100% - 4px);
|
||||
display: block;
|
||||
margin: 0 auto;
|
||||
margin-top: 2px;
|
||||
}
|
||||
.map-text-items ul li {
|
||||
float: left;
|
||||
margin: 0 15px 15px 0;
|
||||
line-height: 20px;
|
||||
padding: 2px 10px;
|
||||
border: 1px solid transparent;
|
||||
}
|
||||
.map-text-items ul li.active {
|
||||
border: 1px solid #e23f36;
|
||||
|
||||
}
|
||||
.map-images-text-items ul li.active,
|
||||
.map-images-text-items ul li:hover,
|
||||
.map-text-items ul li.active,
|
||||
.map-text-items ul li:hover {
|
||||
border: 1px solid #e23f36;
|
||||
}
|
||||
.map-images-text-items ul li.active,
|
||||
.map-images-text-items ul li:hover,
|
||||
.map-text-items ul li.active,
|
||||
.map-text-items ul li:hover,
|
||||
.map-remove-submit:hover {
|
||||
color: #e23f36;
|
||||
font-weight: bold;
|
||||
}
|
||||
.map-item > li:first-child {
|
||||
line-height: 36px;
|
||||
}
|
||||
.map-item .map-more-submit {
|
||||
position: absolute;
|
||||
top: 15px;
|
||||
right: 10px;
|
||||
height: 20px;
|
||||
line-height: 20px;
|
||||
color: #999;
|
||||
cursor: pointer;
|
||||
}
|
||||
.map-item .map-more-submit:hover {
|
||||
color: #666;
|
||||
}
|
||||
#search-map .am-offcanvas-bar {
|
||||
background: #fff;
|
||||
}
|
||||
#search-map .am-offcanvas-bar:after {
|
||||
background: transparent;
|
||||
}
|
||||
#search-map .am-offcanvas-content,
|
||||
#search-map .am-offcanvas-content a {
|
||||
padding: 0;
|
||||
color: #333;
|
||||
}
|
||||
@media only screen and (min-width: 640px) {
|
||||
/* select */
|
||||
.theme-popover { padding: 0 5px; }
|
||||
.select-list .dd-conent dd{width:auto;text-align: center;margin-left:5px;}
|
||||
|
||||
.select li.select-result{display: none;}
|
||||
.suggest,ul.pagination{ display:block;}
|
||||
.select,.sort-nav{padding:10px 10px 5px 10px;border: 1px solid #eee;margin-top:5px;background: #fff;}
|
||||
|
||||
.select-list{width:100%;padding:0px 0px;}
|
||||
.select li{list-style:none;padding:0px 0px 0px 100px;border-top:#eee 1px dashed;float: none;display: block;height: auto;}
|
||||
|
||||
.select-result dl dt{width:100px;}
|
||||
.screening-remove-submit{width:80px;float:right;margin-right:20px;}
|
||||
.search-container .am-badge{font-size:14px ;padding:0px 0px;background: none; }
|
||||
|
||||
/*排序*/
|
||||
.sort-nav{padding:0px 0px;margin:10px 5px; font-size: 12px;width:auto;overflow: hidden;}
|
||||
.sort-nav li{ display:inline; padding:0px 20px;width:auto;border-right:1px solid #eee;}
|
||||
.sort-nav li.active{background: #F5F5F5;}
|
||||
.sort-nav li.active a { color: #d2364c;}
|
||||
.select-list .dd-conent { padding-top: 10px; }
|
||||
.search-nav .am-sticky-placeholder { margin: 10px 5px !important; }
|
||||
|
||||
/*筛选条件*/
|
||||
.select-list,.select-list dl{width:100%;}
|
||||
.select dl dt{left:-100px;top:10px;}
|
||||
.select dt{width:100px;margin-left:0;text-align:center;color:#666 !important;height:24px;line-height:24px;}
|
||||
.select-list .dd-conent{ display:inline-block;float:left;background: none;width:100%;position: static;}
|
||||
dl#select2 .dd-conent,dl#select3 .dd-conent{ left:0; right:0;}
|
||||
|
||||
/*搜索结果*/
|
||||
li.select-result dl {padding: 10px 0px 0px 0px;}
|
||||
.scoll{ margin-top:70px;}
|
||||
.am-slider-default .am-direction-nav a {z-index:0;}
|
||||
span.am-icon-th-list{color:orangered;margin-right:1px ;}
|
||||
#search-map {
|
||||
display: block;
|
||||
position: relative;
|
||||
background: transparent;
|
||||
z-index: 0;
|
||||
}
|
||||
#search-map .am-offcanvas-bar {
|
||||
position: relative;
|
||||
overflow-y: hidden;
|
||||
transition: none;
|
||||
transform: none;
|
||||
width: auto;
|
||||
}
|
||||
}
|
||||
@media only screen and (max-width:1025px) {
|
||||
#search-map {
|
||||
margin: 0 5px;
|
||||
}
|
||||
}
|
||||
@media only screen and (max-width:641px) {
|
||||
#search-map .am-offcanvas-bar {
|
||||
width: 85%;
|
||||
}
|
||||
#search-map .am-offcanvas-content {
|
||||
padding: 0;
|
||||
}
|
||||
.map-item {
|
||||
margin-top: 0;
|
||||
}
|
||||
.map-item > li {
|
||||
border: 0;
|
||||
background: #f0f0f0;
|
||||
}
|
||||
.map-item .map-left,
|
||||
.map-item .map-right {
|
||||
float: none;
|
||||
width: 100%;
|
||||
}
|
||||
.map-item .map-right {
|
||||
background: #fff;
|
||||
}
|
||||
.map-item .map-left {
|
||||
line-height: 36px !important;
|
||||
}
|
||||
.map-item > li:first-child {
|
||||
border-bottom: 2px solid #e1e1e1;
|
||||
}
|
||||
.map-images-text-items ul, .map-text-items ul {
|
||||
padding: 15px 15px 0 15px;
|
||||
}
|
||||
.map-item .map-more-submit {
|
||||
top: 7px;
|
||||
}
|
||||
}
|
||||
|
||||
@media only screen and (min-width:1025px) {
|
||||
.search{margin: 0px 40px 0px 0px;padding-top:10px ;}
|
||||
.nav.white{padding-left:0px}
|
||||
.theme-popover { padding: 0px; margin-top: 10px; }
|
||||
.sort-nav { margin: 10px 0; }
|
||||
.search-nav .am-sticky-placeholder { margin: 10px 0 !important; }
|
||||
.search-list { width: calc(100% + 10px); margin-left: -5px; }
|
||||
|
||||
/*选中效果*/
|
||||
.search-container ul li:hover .items,.search-side li:hover .items.check{ -webkit-box-shadow: 0px 12px 12px -10px rgba(0,0,0,.4); box-shadow:0px 12px 12px -10px rgba(0,0,0,.4); border: 4px solid #d2364c; -webkit-transition: border-color .2s ease-in; -moz-transition: border-color .2s ease-in; -ms-transition: border-color .2s ease-in; -o-transition: border-color .2s ease-in; transition: border-color .2s ease-in; }
|
||||
/**
|
||||
* 条件基础信息
|
||||
*/
|
||||
.map-base-tips {
|
||||
background: #FAFAFA;
|
||||
border-bottom: 1px solid #eee;
|
||||
}
|
||||
.map-base-tips .map-offcanvas-submit {
|
||||
position: absolute;
|
||||
top: 5px;
|
||||
right: 5px;
|
||||
bottom: 0;
|
||||
height: 30px;
|
||||
color: #666 !important;
|
||||
background-color: transparent;
|
||||
border-color: #eee;
|
||||
}
|
||||
|
||||
/**
|
||||
* 导航
|
||||
*/
|
||||
.search-nav {
|
||||
position: relative;
|
||||
}
|
||||
.search-nav .am-sticky-placeholder .am-sticky {
|
||||
border-width: 0 1px 1px 1px;
|
||||
}
|
||||
@media only screen and (min-width: 640px) {
|
||||
.search-nav .am-sticky-placeholder {
|
||||
margin: 0 5px !important;
|
||||
}
|
||||
}
|
||||
@media only screen and (min-width: 1025px) {
|
||||
.search-nav .am-sticky-placeholder {
|
||||
margin: 0 !important;
|
||||
}
|
||||
}
|
||||
@media only screen and (max-width: 640px) {
|
||||
.search-nav .sort-nav {
|
||||
border-width: 1px 0;
|
||||
}
|
||||
.search-nav .am-sticky-placeholder .am-sticky {
|
||||
border-width: 0 1px 1px 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
.sort-nav {
|
||||
padding: 0px;
|
||||
width: 100%;
|
||||
background: #fff;
|
||||
overflow: hidden;
|
||||
height: 30px;
|
||||
border: 1px solid #eee;
|
||||
}
|
||||
.sort-nav li {
|
||||
float: left;
|
||||
height: 30px;
|
||||
line-height: 30px;
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
display: inline;
|
||||
border-right: 1px solid #eee;
|
||||
width: auto;
|
||||
padding:0px 20px;
|
||||
}
|
||||
.sort-nav li a {
|
||||
font-size: 12px;
|
||||
text-decoration: none;
|
||||
}
|
||||
.sort-nav a:hover,
|
||||
.sort-nav a:focus {
|
||||
color: #d2354c;
|
||||
}
|
||||
.sort-nav li.active {
|
||||
background: #d2354c;
|
||||
}
|
||||
.sort-nav li.active a {
|
||||
color: #fff;
|
||||
}
|
||||
@media only screen and (max-width: 640px) {
|
||||
.theme-popover { padding: 0; }
|
||||
.screening-remove-submit { margin-top: -28px; }
|
||||
.select .title-tips { padding: 5px 5px 0 5px; }
|
||||
.sort-nav li { border-bottom: 1px solid #eee; }
|
||||
.select-list .dd-conent { overflow-y: scroll;overflow-x: hidden; }
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 商品列表
|
||||
*/
|
||||
.search-list .items {
|
||||
margin: 5px;
|
||||
border: 1px #e8e8e8 solid;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
cursor: pointer;
|
||||
}
|
||||
.search-list .items img {
|
||||
width:100%;
|
||||
}
|
||||
.search-list .items .price strong {
|
||||
font-size: 14px;
|
||||
}
|
||||
.search-list .items .sales-count {
|
||||
color: #888;
|
||||
}
|
||||
.items .original-price {
|
||||
text-decoration: line-through;
|
||||
color: #666;
|
||||
}
|
||||
@media only screen and (min-width: 640px) {
|
||||
.search-container ul li:hover .items {
|
||||
-webkit-box-shadow: 0px 12px 12px -10px rgba(0,0,0,.4);
|
||||
box-shadow: 0px 12px 12px -10px rgba(0,0,0,.4);
|
||||
border: 4px solid #d2364c;
|
||||
-webkit-transition: border-color .2s ease-in;
|
||||
-moz-transition: border-color .2s ease-in;
|
||||
-ms-transition: border-color .2s ease-in;
|
||||
-o-transition: border-color .2s ease-in;
|
||||
transition: border-color .2s ease-in;
|
||||
}
|
||||
}
|
||||
@media only screen and (min-width: 1025px) {
|
||||
.search-list {
|
||||
width: calc(100% + 10px);
|
||||
margin-left: -5px;
|
||||
}
|
||||
}
|
||||
@media only screen and (max-width:1025px) {
|
||||
.search-pages-submit {
|
||||
margin: 0 auto;
|
||||
width: calc(100% - 10px);
|
||||
}
|
||||
}
|
||||
|
||||
.not-tips { color: #666; font-size: 12px; text-align: center; display: block; }
|
||||
}
|
@ -1,52 +1,170 @@
|
||||
/**
|
||||
* 获取商品列表
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2021-01-08
|
||||
* @desc description
|
||||
* @param {[int]} page [分页值]
|
||||
*/
|
||||
function GetGoodsList(page)
|
||||
{
|
||||
// 清除条件显隐
|
||||
if($('.map-item>li>.map-right>ul>li.active').length > 0)
|
||||
{
|
||||
$('.map-remove-submit').removeClass('am-hide');
|
||||
} else {
|
||||
$('.map-remove-submit').addClass('am-hide');
|
||||
}
|
||||
|
||||
// 请求参数处理
|
||||
var data = {
|
||||
"wd": $('#search-input').val() || '',
|
||||
"category_id": $('.search-container').data('category-id') || 0,
|
||||
"page": page || parseInt($('.search-pages-submit').attr('data-page')) || 1,
|
||||
"order_by_field": $('.sort-nav li.active').attr('data-field') || 'default',
|
||||
"order_by_type": $('.sort-nav li.active').attr('data-type') == 'asc' ? 'desc' : 'asc',
|
||||
};
|
||||
var index = 0;
|
||||
$('.map-item>li>.map-right>ul>li.active').each(function(k, v)
|
||||
{
|
||||
var field = $(this).parents('.map-item>li').data('field') || null;
|
||||
var value = $(this).data('value') || null;
|
||||
if(field != null && value != null)
|
||||
{
|
||||
if((data[field] || null) == null)
|
||||
{
|
||||
data[field] = {};
|
||||
index = 0;
|
||||
}
|
||||
data[field][index] = value;
|
||||
index++;
|
||||
}
|
||||
});
|
||||
|
||||
// 清空数据
|
||||
if(data.page == 1)
|
||||
{
|
||||
$('.search-list').html('');
|
||||
}
|
||||
|
||||
// 页面提示处理
|
||||
$('.loding-view').show();
|
||||
$('.search-pages-submit').hide();
|
||||
$('.table-no').hide();
|
||||
|
||||
// 请求数据
|
||||
$.ajax({
|
||||
url: $('.search-pages-submit').data('url'),
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
timeout: 30000,
|
||||
data: data,
|
||||
success:function(result)
|
||||
{
|
||||
$('.loding-view').hide();
|
||||
if(result.code == 0)
|
||||
{
|
||||
$('.search-list').append(result.data.data);
|
||||
$('.search-pages-submit').attr('data-page', data.page+1);
|
||||
$('.search-pages-submit').attr('disabled', (result.data.page_total <= 1));
|
||||
$('.search-pages-submit').show();
|
||||
$('.table-no').hide();
|
||||
} else if(result.code == -100) {
|
||||
if($('.search-list li').length == 0)
|
||||
{
|
||||
$('.table-no').show();
|
||||
$('.search-pages-submit').hide();
|
||||
} else {
|
||||
$('.table-no').hide();
|
||||
$('.search-pages-submit').show();
|
||||
$('.search-pages-submit').attr('disabled', true);
|
||||
}
|
||||
Prompt(result.msg);
|
||||
} else {
|
||||
Prompt(result.msg);
|
||||
}
|
||||
$('.map-result-count').text(result.data.total || 0);
|
||||
},
|
||||
error:function(xhr, type)
|
||||
{
|
||||
$('.loding-view').hide();
|
||||
$('.search-pages-submit').hide();
|
||||
$('.table-no').show();
|
||||
Prompt(HtmlToString(xhr.responseText) || '异常错误', null, 30);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 更多条件展开处理
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2021-01-10
|
||||
* @desc description
|
||||
*/
|
||||
function MapMoreSubmitHandle()
|
||||
{
|
||||
$('.map-images-text-items,.map-text-items').each(function(k, v)
|
||||
{
|
||||
var height = $(this).find('>ul').innerHeight();
|
||||
var max_height = $(this).hasClass('map-images-text-items') ? 66 : 56;
|
||||
if(height > max_height)
|
||||
{
|
||||
$(this).find('.map-more-submit').removeClass('am-hide');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$(function()
|
||||
{
|
||||
// 筛选操作
|
||||
$(document).on('click', '.select-list dl dd', function()
|
||||
// 更多条件展开处理
|
||||
MapMoreSubmitHandle();
|
||||
|
||||
// 默认加载数据
|
||||
GetGoodsList(1);
|
||||
|
||||
// 手机模式下更多条件开启
|
||||
$(document).on('click', '.map-offcanvas-submit', function()
|
||||
{
|
||||
$(this).addClass("selected").siblings().removeClass("selected");
|
||||
var selected_tag_name = $(this).parent('.dd-conent').attr('data-selected-tag');
|
||||
if ($(this).hasClass("select-all")) {
|
||||
$('#'+selected_tag_name).remove();
|
||||
MapMoreSubmitHandle();
|
||||
});
|
||||
|
||||
// 筛选操作
|
||||
$(document).on('click', '.map-item>li>.map-right>ul>li', function()
|
||||
{
|
||||
if($(this).hasClass('active'))
|
||||
{
|
||||
$(this).removeClass('active');
|
||||
} else {
|
||||
if ($('#'+selected_tag_name).length > 0) {
|
||||
$('#'+selected_tag_name).find('a').html($(this).find('a').text());
|
||||
$('#'+selected_tag_name).find('a').attr('data-value', $(this).find('a').attr('data-value'));
|
||||
} else {
|
||||
var copy_html = $(this).clone();
|
||||
$(".select-result dl").append(copy_html.attr("id", selected_tag_name));
|
||||
}
|
||||
$(this).addClass('active');
|
||||
}
|
||||
GetGoodsList(1);
|
||||
});
|
||||
|
||||
$(document).on('click', '.select-result dl dd', function() {
|
||||
$(this).remove();
|
||||
$('#'+$(this).attr('id')+'-dl').find('.select-all').addClass('selected').siblings().removeClass('selected');
|
||||
// 清除条件
|
||||
$(document).on('click', '.map-remove-submit', function()
|
||||
{
|
||||
$('.map-item>li>.map-right>ul>li').removeClass('active');
|
||||
GetGoodsList(1);
|
||||
});
|
||||
|
||||
$(document).on('click', 'ul.select dd', function() {
|
||||
if ($('.select-result dd').length > 1) {
|
||||
$('.select-no').hide();
|
||||
$('.screening-remove-submit').show();
|
||||
$('.select-result').show();
|
||||
// 条件展开/隐藏
|
||||
$(document).on('click', '.map-item .map-more-submit', function()
|
||||
{
|
||||
var $parents = $(this).parents('.map-right');
|
||||
var height = $parents.hasClass('map-images-text-items') ? '66px' : '56px';
|
||||
if($parents.css('height') == height)
|
||||
{
|
||||
$parents.css('height', 'auto');
|
||||
} else {
|
||||
$('.select-no').show();
|
||||
$('.select-result').hide();
|
||||
$parents.css('height', height);
|
||||
}
|
||||
});
|
||||
|
||||
$(".screening-remove-submit").on("click", function() {
|
||||
$('.select-result dd.selected').remove();
|
||||
$('.select-list .select-all').addClass('selected').siblings().removeClass('selected');
|
||||
$(this).hide();
|
||||
$('.select-result .select-no').show();
|
||||
$('.select-result').hide();
|
||||
GetGoodsList(1);
|
||||
});
|
||||
|
||||
// 排序导航
|
||||
$('.sort-nav li').on('click', function()
|
||||
// 排序
|
||||
$(document).on('click', '.sort-nav li', function()
|
||||
{
|
||||
var type = $(this).attr('data-type');
|
||||
$('.sort-nav li').attr('data-type', 'desc');
|
||||
@ -70,159 +188,9 @@ $(function()
|
||||
GetGoodsList(1);
|
||||
});
|
||||
|
||||
// 条件分类组筛选
|
||||
$(".select dt").on('click', function()
|
||||
{
|
||||
if($(window).width() < 640)
|
||||
{
|
||||
$('body,html').scrollTop(0);
|
||||
$(this).next('div.dd-conent').css('top', ($('.theme-popover').height())+'px');
|
||||
if ($(this).next('div.dd-conent').css("display") == 'none') {
|
||||
$(".theme-popover-mask").show();
|
||||
$(".theme-popover").css({"position":"fixed", "top":0});
|
||||
$(this).next('div.dd-conent').slideToggle(300);
|
||||
$('.select div.dd-conent').not($(this).next()).hide();
|
||||
} else {
|
||||
$(this).next('div.dd-conent').slideUp(300);
|
||||
$(".theme-popover-mask").hide();
|
||||
$(".theme-popover").css({"position":"static", "top":0});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// 取消条件/移除条件
|
||||
$(document).on("click", ".select dd, .screening-remove-submit", function()
|
||||
{
|
||||
if($(document).width() < 640)
|
||||
{
|
||||
$(".dd-conent").slideUp(300);
|
||||
$(".theme-popover-mask").hide();
|
||||
$(".theme-popover").css({"position":"static", "top":0});
|
||||
}
|
||||
});
|
||||
|
||||
// 关闭弹层
|
||||
$('.theme-popover-mask').on('click', function()
|
||||
{
|
||||
$(".dd-conent").slideUp(300);
|
||||
$(".theme-popover-mask").hide();
|
||||
$(".theme-popover").css({"position":"static", "top":0});
|
||||
});
|
||||
|
||||
|
||||
// 导航显示/隐藏处理
|
||||
function SearchNav()
|
||||
{
|
||||
// 滚动处理导航
|
||||
$(window).scroll(function()
|
||||
{
|
||||
if($(window).width() <= 625)
|
||||
{
|
||||
var scroll = $(document).scrollTop();
|
||||
|
||||
if($('.nav-search').length > 0)
|
||||
{
|
||||
if(scroll > 30)
|
||||
{
|
||||
$('.nav-search').css('display','none');
|
||||
} else {
|
||||
$('.nav-search').css('display','block');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 浏览器窗口实时事件
|
||||
$(window).resize(function()
|
||||
{
|
||||
// 导航
|
||||
SearchNav();
|
||||
|
||||
// 条件筛选
|
||||
if($(document).width() >= 640)
|
||||
{
|
||||
$('.dd-conent').show();
|
||||
}
|
||||
});
|
||||
SearchNav();
|
||||
|
||||
// 获取商品列表
|
||||
function GetGoodsList(page)
|
||||
{
|
||||
// 请求参数处理
|
||||
var data = {
|
||||
category_id: $('.search-container').data('category-id') || 0,
|
||||
wd: $('#search-input').val() || '',
|
||||
page: page || parseInt($('.search-pages-submit').attr('data-page')) || 1,
|
||||
order_by_field: $('.sort-nav li.active').attr('data-field') || 'default',
|
||||
order_by_type: $('.sort-nav li.active').attr('data-type') == 'asc' ? 'desc' : 'asc',
|
||||
}
|
||||
$('.select-result .selected a').each(function(k, v)
|
||||
{
|
||||
data[$(this).attr('data-field')] = $(this).attr('data-value');
|
||||
});
|
||||
|
||||
// 清空数据
|
||||
if(data.page == 1)
|
||||
{
|
||||
$('.search-list').html('');
|
||||
}
|
||||
|
||||
// 页面提示处理
|
||||
$('.loding-view').show();
|
||||
$('.search-pages-submit').hide();
|
||||
$('.table-no').hide();
|
||||
|
||||
// 请求数据
|
||||
$.ajax({
|
||||
url:$('.search-pages-submit').data('url'),
|
||||
type:'POST',
|
||||
dataType:"json",
|
||||
timeout:10000,
|
||||
data:data,
|
||||
success:function(result)
|
||||
{
|
||||
$('.loding-view').hide();
|
||||
if(result.code == 0)
|
||||
{
|
||||
$('.search-list').append(result.data.data);
|
||||
$('.search-pages-submit').attr('data-page', data.page+1);
|
||||
$('.search-pages-submit').attr('disabled', (result.data.page_total <= 1));
|
||||
$('.search-pages-submit').show();
|
||||
$('.table-no').hide();
|
||||
} else if(result.code == -100) {
|
||||
if($('.search-list li').length == 0)
|
||||
{
|
||||
$('.table-no').show();
|
||||
$('.search-pages-submit').hide();
|
||||
} else {
|
||||
$('.table-no').hide();
|
||||
$('.search-pages-submit').show();
|
||||
$('.search-pages-submit').attr('disabled', true);
|
||||
}
|
||||
Prompt(result.msg);
|
||||
} else {
|
||||
Prompt(result.msg);
|
||||
}
|
||||
$('.select .title-tips strong').text(result.data.total || 0);
|
||||
},
|
||||
error:function(xhr, type)
|
||||
{
|
||||
$('.loding-view').hide();
|
||||
$('.search-pages-submit').hide();
|
||||
$('.table-no').show();
|
||||
Prompt(HtmlToString(xhr.responseText) || '异常错误', null, 30);
|
||||
}
|
||||
});
|
||||
}
|
||||
GetGoodsList(1);
|
||||
|
||||
// 加载更多数据
|
||||
$('.search-pages-submit').on('click', function()
|
||||
$(document).on('click', '.search-pages-submit', function()
|
||||
{
|
||||
GetGoodsList();
|
||||
});
|
||||
|
||||
});
|
@ -224,8 +224,10 @@ Page({
|
||||
"province": this.data.user.province || '',
|
||||
"city": this.data.user.city || '',
|
||||
"gender": this.data.user.gender || 0,
|
||||
"weixin_unionid": this.data.user.weixin_unionid || '',
|
||||
"referrer": referrer || 0
|
||||
};
|
||||
|
||||
wx.showLoading({ title: "处理中..." });
|
||||
var self = this;
|
||||
wx.request({
|
||||
|
Loading…
Reference in New Issue
Block a user