mirror of
https://gitee.com/zongzhige/shopxo.git
synced 2026-06-07 02:12:25 +08:00
新增用户未登录不展示商品价格
This commit is contained in:
@ -74,12 +74,13 @@ class Goods extends Common
|
||||
|
||||
// 获取数据列表
|
||||
$data_params = [
|
||||
'where' => $where,
|
||||
'm' => $page->GetPageStarNumber(),
|
||||
'n' => $number,
|
||||
'is_category' => 1,
|
||||
'where' => $where,
|
||||
'm' => $page->GetPageStarNumber(),
|
||||
'n' => $number,
|
||||
'is_category' => 1,
|
||||
'is_admin_access' => 1,
|
||||
];
|
||||
$data = GoodsService::GoodsList($data_params);
|
||||
$ret = GoodsService::GoodsList($data_params);
|
||||
|
||||
// 是否上下架
|
||||
$this->assign('common_is_shelves_list', lang('common_is_shelves_list'));
|
||||
@ -89,7 +90,7 @@ class Goods extends Common
|
||||
|
||||
$this->assign('params', $params);
|
||||
$this->assign('page_html', $page->GetPageHtml());
|
||||
$this->assign('data', $data);
|
||||
$this->assign('data', $ret['data']);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
@ -116,15 +117,15 @@ class Goods extends Common
|
||||
'is_content_app' => 1,
|
||||
'is_category' => 1,
|
||||
];
|
||||
$data = GoodsService::GoodsList($data_params);
|
||||
if(empty($data[0]))
|
||||
$ret = GoodsService::GoodsList($data_params);
|
||||
if(empty($ret['data'][0]))
|
||||
{
|
||||
return $this->error('商品信息不存在', MyUrl('admin/goods/index'));
|
||||
}
|
||||
$this->assign('data', $data[0]);
|
||||
$this->assign('data', $ret['data'][0]);
|
||||
|
||||
// 获取商品编辑规格
|
||||
$specifications = GoodsService::GoodsEditSpecifications($data[0]['id']);
|
||||
$specifications = GoodsService::GoodsEditSpecifications($ret['data'][0]['id']);
|
||||
$this->assign('specifications', $specifications);
|
||||
}
|
||||
|
||||
|
||||
@ -61,16 +61,16 @@ class Goods extends Common
|
||||
'is_spec' => true,
|
||||
'is_content_app' => true,
|
||||
];
|
||||
$goods = GoodsService::GoodsList($params);
|
||||
if(empty($goods[0]) || $goods[0]['is_delete_time'] != 0)
|
||||
$ret = GoodsService::GoodsList($params);
|
||||
if(empty($ret['data'][0]) || $ret['data'][0]['is_delete_time'] != 0)
|
||||
{
|
||||
return DataReturn('商品不存在或已删除', -1);
|
||||
}
|
||||
unset($goods[0]['content_web']);
|
||||
unset($ret['data'][0]['content_web']);
|
||||
|
||||
// 当前登录用户是否已收藏
|
||||
$ret_favor = GoodsService::IsUserGoodsFavor(['goods_id'=>$goods_id, 'user'=>$this->user]);
|
||||
$goods[0]['is_favor'] = ($ret_favor['code'] == 0) ? $ret_favor['data'] : 0;
|
||||
$ret['data'][0]['is_favor'] = ($ret_favor['code'] == 0) ? $ret_favor['data'] : 0;
|
||||
|
||||
// 商品访问统计
|
||||
GoodsService::GoodsAccessCountInc(['goods_id'=>$goods_id]);
|
||||
@ -80,7 +80,7 @@ class Goods extends Common
|
||||
|
||||
// 数据返回
|
||||
$result = [
|
||||
'goods' => $goods[0],
|
||||
'goods' => $ret['data'][0],
|
||||
'common_order_is_booking' => (int) MyC('common_order_is_booking', 0),
|
||||
];
|
||||
return DataReturn('success', 0, $result);
|
||||
|
||||
@ -81,22 +81,22 @@ class Common extends Controller
|
||||
private function CommonPluginsInit()
|
||||
{
|
||||
// css钩子
|
||||
$this->assign('plugins_css_data', Hook::listen('plugins_css', ['hook_name'=>'plugins_css', 'is_control'=>false]));
|
||||
$this->assign('plugins_css_data', Hook::listen('plugins_css', ['hook_name'=>'plugins_css', 'is_backend'=>false]));
|
||||
|
||||
// js钩子
|
||||
$this->assign('plugins_js_data', Hook::listen('plugins_js', ['hook_name'=>'plugins_js', 'is_control'=>false]));
|
||||
$this->assign('plugins_js_data', Hook::listen('plugins_js', ['hook_name'=>'plugins_js', 'is_backend'=>false]));
|
||||
|
||||
// 公共header内钩子
|
||||
$this->assign('plugins_common_header_data', Hook::listen('plugins_common_header', ['hook_name'=>'plugins_common_header', 'is_control'=>false, 'user'=>$this->user]));
|
||||
$this->assign('plugins_common_header_data', Hook::listen('plugins_common_header', ['hook_name'=>'plugins_common_header', 'is_backend'=>false, 'user'=>$this->user]));
|
||||
|
||||
// 公共页面底部钩子
|
||||
$this->assign('plugins_common_page_bottom_data', Hook::listen('plugins_common_page_bottom', ['hook_name'=>'plugins_common_page_bottom', 'is_control'=>false, 'user'=>$this->user]));
|
||||
$this->assign('plugins_common_page_bottom_data', Hook::listen('plugins_common_page_bottom', ['hook_name'=>'plugins_common_page_bottom', 'is_backend'=>false, 'user'=>$this->user]));
|
||||
|
||||
// 公共顶部钩子
|
||||
$this->assign('plugins_view_common_top_data', Hook::listen('plugins_view_common_top', ['hook_name'=>'plugins_view_common_top', 'is_control'=>false, 'user'=>$this->user]));
|
||||
$this->assign('plugins_view_common_top_data', Hook::listen('plugins_view_common_top', ['hook_name'=>'plugins_view_common_top', 'is_backend'=>false, 'user'=>$this->user]));
|
||||
|
||||
// 公共底部钩子
|
||||
$this->assign('plugins_view_common_bottom_data', Hook::listen('plugins_view_common_bottom', ['hook_name'=>'plugins_view_common_bottom', 'is_control'=>false, 'user'=>$this->user]));
|
||||
$this->assign('plugins_view_common_bottom_data', Hook::listen('plugins_view_common_bottom', ['hook_name'=>'plugins_view_common_bottom', 'is_backend'=>false, 'user'=>$this->user]));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -52,24 +52,24 @@ class Goods extends Common
|
||||
'is_photo' => true,
|
||||
'is_spec' => true,
|
||||
];
|
||||
$goods = GoodsService::GoodsList($params);
|
||||
if(empty($goods[0]) || $goods[0]['is_delete_time'] != 0)
|
||||
$ret = GoodsService::GoodsList($params);
|
||||
if(empty($ret['data'][0]) || $ret['data'][0]['is_delete_time'] != 0)
|
||||
{
|
||||
$this->assign('msg', '资源不存在或已被删除');
|
||||
return $this->fetch('/public/tips_error');
|
||||
} else {
|
||||
// 当前登录用户是否已收藏
|
||||
$ret_favor = GoodsService::IsUserGoodsFavor(['goods_id'=>$id, 'user'=>$this->user]);
|
||||
$goods[0]['is_favor'] = ($ret_favor['code'] == 0) ? $ret_favor['data'] : 0;
|
||||
$ret['data'][0]['is_favor'] = ($ret_favor['code'] == 0) ? $ret_favor['data'] : 0;
|
||||
|
||||
// 商品评价总数
|
||||
$goods[0]['comments_count'] = GoodsService::GoodsCommentsTotal($id);
|
||||
$ret['data'][0]['comments_count'] = GoodsService::GoodsCommentsTotal($id);
|
||||
|
||||
// 商品收藏总数
|
||||
$goods[0]['favor_count'] = GoodsService::GoodsFavorTotal(['goods_id'=>$id]);
|
||||
$ret['data'][0]['favor_count'] = GoodsService::GoodsFavorTotal(['goods_id'=>$id]);
|
||||
|
||||
$this->assign('goods', $goods[0]);
|
||||
$this->assign('home_seo_site_title', $goods[0]['title']);
|
||||
$this->assign('goods', $ret['data'][0]);
|
||||
$this->assign('home_seo_site_title', $ret['data'][0]['title']);
|
||||
|
||||
// 二维码
|
||||
$this->assign('qrcode_url', MyUrl('index/qrcode/index', ['content'=>urlencode(base64_encode(MyUrl('index/goods/index', ['id'=>$id], true, true)))]));
|
||||
@ -90,7 +90,8 @@ class Goods extends Common
|
||||
'field' => 'id,title,title_color,price,images',
|
||||
'n' => 10,
|
||||
];
|
||||
$this->assign('left_goods', GoodsService::GoodsList($params));
|
||||
$right_goods = GoodsService::GoodsList($params);
|
||||
$this->assign('left_goods', $right_goods['data']);
|
||||
|
||||
// 详情tab商品 猜你喜欢
|
||||
$params = [
|
||||
@ -103,7 +104,8 @@ class Goods extends Common
|
||||
'field' => 'id,title,title_color,price,images,home_recommended_images',
|
||||
'n' => 16,
|
||||
];
|
||||
$this->assign('detail_like_goods', GoodsService::GoodsList($params));
|
||||
$like_goods = GoodsService::GoodsList($params);
|
||||
$this->assign('detail_like_goods', $like_goods['data']);
|
||||
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
@ -97,8 +97,8 @@ class Search extends Common
|
||||
public function GoodsList()
|
||||
{
|
||||
// 获取商品列表
|
||||
$data = SearchService::GoodsList($this->params);
|
||||
if(empty($data['data']))
|
||||
$ret = SearchService::GoodsList($this->params);
|
||||
if(empty($ret['data']))
|
||||
{
|
||||
$msg = '没有相关数据';
|
||||
$code = -100;
|
||||
@ -111,7 +111,7 @@ class Search extends Common
|
||||
SearchService::SearchAdd($this->params);
|
||||
|
||||
// 返回
|
||||
return DataReturn($msg, $code, $data);
|
||||
return DataReturn($msg, $code, $ret['data']);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@ -137,7 +137,7 @@ class User extends Common
|
||||
$this->assign('goods_browse_list', $data['data']);
|
||||
|
||||
// 用户中心顶部钩子
|
||||
$this->assign('plugins_view_user_center_top_data', Hook::listen('plugins_view_user_center_top', ['hook_name'=>'plugins_view_user_center_top', 'is_control'=>false, 'user'=>$this->user]));
|
||||
$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]));
|
||||
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
@ -91,7 +91,7 @@
|
||||
</div>
|
||||
{{/if}}
|
||||
<div class="items price iteminfo_mktprice">
|
||||
<dt>促销价</dt>
|
||||
<dt>销售价</dt>
|
||||
<dd>
|
||||
<em>¥</em>
|
||||
<b class="sys_item_price" data-original-price="{{$goods.price}}">{{$goods.price}}</b>
|
||||
|
||||
@ -33,9 +33,9 @@ class Hook extends Controller
|
||||
public function run($params = [])
|
||||
{
|
||||
// 是否控制器钩子
|
||||
// is_control 当前为控制器业务处理
|
||||
// is_backend 当前为后端业务处理
|
||||
// hook_name 钩子名称
|
||||
if(isset($params['is_control']) && $params['is_control'] === true && !empty($params['hook_name']))
|
||||
if(isset($params['is_backend']) && $params['is_backend'] === true && !empty($params['hook_name']))
|
||||
{
|
||||
// 参数一 描述
|
||||
// 参数二 0 为处理成功, 负数为失败
|
||||
|
||||
@ -33,9 +33,9 @@ class Hook extends Controller
|
||||
public function run($params = [])
|
||||
{
|
||||
// 是否控制器钩子
|
||||
// is_control 当前为控制器业务处理
|
||||
// is_backend 当前为后端业务处理
|
||||
// hook_name 钩子名称
|
||||
if(isset($params['is_control']) && $params['is_control'] === true && !empty($params['hook_name']))
|
||||
if(isset($params['is_backend']) && $params['is_backend'] === true && !empty($params['hook_name']))
|
||||
{
|
||||
// 参数一 描述
|
||||
// 参数二 0 为处理成功, 负数为失败
|
||||
|
||||
@ -34,9 +34,9 @@ class Hook extends Controller
|
||||
public function run($params = [])
|
||||
{
|
||||
// 是否控制器钩子
|
||||
// is_control 当前为控制器业务处理
|
||||
// is_backend 当前为后端业务处理
|
||||
// hook_name 钩子名称
|
||||
if(isset($params['is_control']) && $params['is_control'] === true && !empty($params['hook_name']))
|
||||
if(isset($params['is_backend']) && $params['is_backend'] === true && !empty($params['hook_name']))
|
||||
{
|
||||
// 参数一 描述
|
||||
// 参数二 0 为处理成功, 负数为失败
|
||||
|
||||
@ -31,8 +31,8 @@ class Hook extends Controller
|
||||
*/
|
||||
public function run($params = [])
|
||||
{
|
||||
// 是否控制器钩子
|
||||
if(isset($params['is_control']) && $params['is_control'] === true && !empty($params['hook_name']))
|
||||
// 是否后端钩子
|
||||
if(isset($params['is_backend']) && $params['is_backend'] === true && !empty($params['hook_name']))
|
||||
{
|
||||
return DataReturn('无需处理', 0);
|
||||
|
||||
|
||||
@ -32,8 +32,8 @@ class Hook extends Controller
|
||||
*/
|
||||
public function run($params = [])
|
||||
{
|
||||
// 是否控制器钩子
|
||||
if(isset($params['is_control']) && $params['is_control'] === true && !empty($params['hook_name']))
|
||||
// 是否后端钩子
|
||||
if(isset($params['is_backend']) && $params['is_backend'] === true && !empty($params['hook_name']))
|
||||
{
|
||||
return DataReturn('无需处理', 0);
|
||||
|
||||
|
||||
@ -32,8 +32,8 @@ class Hook extends Controller
|
||||
*/
|
||||
public function run($params = [])
|
||||
{
|
||||
// 是否控制器钩子
|
||||
if(isset($params['is_control']) && $params['is_control'] === true && !empty($params['hook_name']))
|
||||
// 是否后端钩子
|
||||
if(isset($params['is_backend']) && $params['is_backend'] === true && !empty($params['hook_name']))
|
||||
{
|
||||
return DataReturn('无需处理', 0);
|
||||
|
||||
|
||||
@ -34,15 +34,15 @@ class Hook
|
||||
*/
|
||||
public function run($params = [])
|
||||
{
|
||||
// 是否控制器钩子
|
||||
if(isset($params['is_control']) && $params['is_control'] === true && !empty($params['hook_name']))
|
||||
// 是否后端钩子
|
||||
if(isset($params['is_backend']) && $params['is_backend'] === true && !empty($params['hook_name']))
|
||||
{
|
||||
if(!empty($params['user_id']))
|
||||
{
|
||||
switch($params['hook_name'])
|
||||
{
|
||||
// 用户登录成功后赠送积分
|
||||
case 'plugins_control_user_login_end' :
|
||||
case 'plugins_service_user_login_end' :
|
||||
$ret = $this->LoginGiveIntegral($params);
|
||||
break;
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
"is_home":false
|
||||
},
|
||||
"hook":{
|
||||
"plugins_control_user_login_end":[
|
||||
"plugins_service_user_login_end":[
|
||||
"app\\plugins\\userloginrewardintegral\\Hook"
|
||||
]
|
||||
}
|
||||
|
||||
96
application/plugins/usernotloginhidegoodsprice/Admin.php
Normal file
96
application/plugins/usernotloginhidegoodsprice/Admin.php
Normal file
@ -0,0 +1,96 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | ShopXO 国内领先企业级B2C免费开源电商系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2011~2019 http://shopxo.net All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: Devil
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\plugins\usernotloginhidegoodsprice;
|
||||
|
||||
use think\Controller;
|
||||
use app\service\PluginsService;
|
||||
|
||||
/**
|
||||
* 未登录隐藏商品价格 - 后台管理
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 0.0.1
|
||||
* @datetime 2016-12-01T21:51:08+0800
|
||||
*/
|
||||
class Admin extends Controller
|
||||
{
|
||||
/**
|
||||
* 首页
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @datetime 2019-02-07T08:21:54+0800
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public function index($params = [])
|
||||
{
|
||||
$ret = PluginsService::PluginsData('usernotloginhidegoodsprice');
|
||||
if($ret['code'] == 0)
|
||||
{
|
||||
// 限制终端
|
||||
$common_platform_type = lang('common_platform_type');
|
||||
$limit_terminal_all = [];
|
||||
if(!empty($ret['data']['limit_terminal']))
|
||||
{
|
||||
foreach(explode(',', $ret['data']['limit_terminal']) as $type)
|
||||
{
|
||||
if(isset($common_platform_type[$type]))
|
||||
{
|
||||
$limit_terminal_all[] = $common_platform_type[$type]['name'];
|
||||
}
|
||||
}
|
||||
}
|
||||
$ret['data']['limit_terminal_text'] = implode(',', $limit_terminal_all);
|
||||
|
||||
$this->assign('data', $ret['data']);
|
||||
return $this->fetch('../../../plugins/view/usernotloginhidegoodsprice/admin/index');
|
||||
} else {
|
||||
return $ret['msg'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑页面
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @datetime 2019-02-07T08:21:54+0800
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public function saveinfo($params = [])
|
||||
{
|
||||
$ret = PluginsService::PluginsData('usernotloginhidegoodsprice');
|
||||
if($ret['code'] == 0)
|
||||
{
|
||||
// 限制终端
|
||||
$ret['data']['limit_terminal'] = empty($ret['data']['limit_terminal']) ? [] : explode(',', $ret['data']['limit_terminal']);
|
||||
|
||||
$this->assign('data', $ret['data']);
|
||||
return $this->fetch('../../../plugins/view/usernotloginhidegoodsprice/admin/saveinfo');
|
||||
} else {
|
||||
return $ret['msg'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据保存
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @datetime 2019-02-07T08:21:54+0800
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public function save($params = [])
|
||||
{
|
||||
return PluginsService::PluginsDataSave(['plugins'=>'usernotloginhidegoodsprice', 'data'=>$params]);
|
||||
}
|
||||
}
|
||||
?>
|
||||
116
application/plugins/usernotloginhidegoodsprice/Hook.php
Normal file
116
application/plugins/usernotloginhidegoodsprice/Hook.php
Normal file
@ -0,0 +1,116 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | ShopXO 国内领先企业级B2C免费开源电商系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2011~2019 http://shopxo.net All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: Devil
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\plugins\usernotloginhidegoodsprice;
|
||||
|
||||
use think\Controller;
|
||||
use app\service\PluginsService;
|
||||
|
||||
/**
|
||||
* 未登录隐藏商品价格 - 钩子入口
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 0.0.1
|
||||
* @datetime 2016-12-01T21:51:08+0800
|
||||
*/
|
||||
class Hook extends Controller
|
||||
{
|
||||
// 应用响应入口
|
||||
public function run($params = [])
|
||||
{
|
||||
// 是否控制器钩子
|
||||
// is_backend 当前为后端业务处理
|
||||
// hook_name 钩子名称
|
||||
if(isset($params['is_backend']) && $params['is_backend'] === true && !empty($params['hook_name']))
|
||||
{
|
||||
return $this->PriceHandle($params);
|
||||
|
||||
// 默认返回视图
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 价格处理
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @datetime 2019-02-14T22:19:08+0800
|
||||
* @param [array] $params [参数]
|
||||
*/
|
||||
private function PriceHandle($params)
|
||||
{
|
||||
// 获取应用数据
|
||||
$ret = PluginsService::PluginsData('usernotloginhidegoodsprice');
|
||||
if($ret['code'] == 0)
|
||||
{
|
||||
// 用户是否已登录
|
||||
if(session('user') != null)
|
||||
{
|
||||
return DataReturn('无需处理', 0);
|
||||
}
|
||||
|
||||
// 限制终端
|
||||
if(!empty($ret['data']['limit_terminal']))
|
||||
{
|
||||
$limit_terminal_all = explode(',', $ret['data']['limit_terminal']);
|
||||
$client_type = APPLICATION_CLIENT_TYPE;
|
||||
if($client_type == 'pc' && IsMobile())
|
||||
{
|
||||
$client_type = 'h5';
|
||||
}
|
||||
if(!in_array($client_type, $limit_terminal_all))
|
||||
{
|
||||
return DataReturn('无需处理', 0);
|
||||
}
|
||||
}
|
||||
|
||||
// 原价
|
||||
$original_price_placeholder = isset($ret['data']['original_price_placeholder']) ? $ret['data']['original_price_placeholder'] : '';
|
||||
|
||||
// 销售价
|
||||
$price_placeholder = isset($ret['data']['price_placeholder']) ? $ret['data']['price_placeholder'] : '';
|
||||
|
||||
// 商品原价
|
||||
if(isset($params['goods']['original_price']))
|
||||
{
|
||||
$params['goods']['original_price'] = $original_price_placeholder;
|
||||
}
|
||||
if(isset($params['goods']['min_original_price']))
|
||||
{
|
||||
$params['goods']['min_original_price'] = $original_price_placeholder;
|
||||
}
|
||||
if(isset($params['goods']['max_original_price']))
|
||||
{
|
||||
$params['goods']['max_original_price'] = $original_price_placeholder;
|
||||
}
|
||||
|
||||
// 销售价
|
||||
if(isset($params['goods']['price']))
|
||||
{
|
||||
$params['goods']['price'] = $price_placeholder;
|
||||
}
|
||||
if(isset($params['goods']['min_price']))
|
||||
{
|
||||
$params['goods']['min_price'] = $price_placeholder;
|
||||
}
|
||||
if(isset($params['goods']['max_price']))
|
||||
{
|
||||
$params['goods']['max_price'] = $price_placeholder;
|
||||
}
|
||||
|
||||
return DataReturn('处理成功', 0);
|
||||
} else {
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
28
application/plugins/usernotloginhidegoodsprice/config.json
Normal file
28
application/plugins/usernotloginhidegoodsprice/config.json
Normal file
@ -0,0 +1,28 @@
|
||||
{
|
||||
"base":{
|
||||
"plugins":"usernotloginhidegoodsprice",
|
||||
"name":"未登录隐藏商品价格",
|
||||
"logo":"\/static\/upload\/images\/plugins_usernotloginhidegoodsprice\/2019\/02\/26\/1551184745400164.png",
|
||||
"author":"Devil",
|
||||
"author_url":"https:\/\/shopxo.net\/",
|
||||
"version":"1.0.0",
|
||||
"desc":"用户未登录不展示商品价格",
|
||||
"apply_terminal":[
|
||||
"pc",
|
||||
"h5",
|
||||
"app",
|
||||
"alipay",
|
||||
"weixin",
|
||||
"baidu"
|
||||
],
|
||||
"apply_version":[
|
||||
"1.4.0"
|
||||
],
|
||||
"is_home":false
|
||||
},
|
||||
"hook":{
|
||||
"plugins_service_goods_handle_begin":[
|
||||
"app\\plugins\\usernotloginhidegoodsprice\\Hook"
|
||||
]
|
||||
}
|
||||
}
|
||||
51
application/plugins/view/usernotloginhidegoodsprice/admin/index.html
Executable file
51
application/plugins/view/usernotloginhidegoodsprice/admin/index.html
Executable file
@ -0,0 +1,51 @@
|
||||
{{include file="public/header" /}}
|
||||
|
||||
<!-- right content start -->
|
||||
<div class="content-right">
|
||||
<div class="content">
|
||||
<legend>
|
||||
<span class="fs-16">未登录隐藏商品价格</span>
|
||||
<a href="{{:MyUrl('admin/pluginsadmin/index')}}" class="fr fs-14 m-t-5 am-icon-mail-reply"> 返回</a>
|
||||
</legend>
|
||||
|
||||
<div class="usernotloginhidegoodsprice-content">
|
||||
<div class="items">
|
||||
<label>原价占位符</label>
|
||||
<div>
|
||||
{{if !empty($data['original_price_placeholder'])}}
|
||||
{{$data.original_price_placeholder}}
|
||||
{{else /}}
|
||||
<span class="empty-text">未填写</span>
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="items">
|
||||
<label>销售价占位符</label>
|
||||
<div>
|
||||
{{if !empty($data['price_placeholder'])}}
|
||||
{{$data.price_placeholder}}
|
||||
{{else /}}
|
||||
<span class="empty-text">未填写</span>
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="items">
|
||||
<label>限制终端<span class="fs-12 fw-100 cr-999">(留空则全部)</span></label>
|
||||
<div>
|
||||
{{if !empty($data['limit_terminal_text'])}}
|
||||
{{$data.limit_terminal_text}}
|
||||
{{else /}}
|
||||
全部
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<a href="{{:PluginsAdminUrl('usernotloginhidegoodsprice', 'admin', 'saveinfo')}}" class="am-btn am-btn-secondary am-radius btn-loading-example am-btn-sm am-btn-block edit-submit">编辑</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- right content end -->
|
||||
|
||||
<!-- footer start -->
|
||||
{{include file="public/footer" /}}
|
||||
<!-- footer end -->
|
||||
43
application/plugins/view/usernotloginhidegoodsprice/admin/saveinfo.html
Executable file
43
application/plugins/view/usernotloginhidegoodsprice/admin/saveinfo.html
Executable file
@ -0,0 +1,43 @@
|
||||
{{include file="public/header" /}}
|
||||
|
||||
<!-- right content start -->
|
||||
<div class="content-right">
|
||||
<div class="content">
|
||||
<!-- form start -->
|
||||
<form class="am-form form-validation view-save" action="{{:PluginsAdminUrl('usernotloginhidegoodsprice', 'admin', 'save')}}" method="POST" request-type="ajax-url" request-value="{{:PluginsAdminUrl('usernotloginhidegoodsprice', 'admin', 'index')}}" enctype="multipart/form-data">
|
||||
<legend>
|
||||
<span class="fs-16">未登录隐藏商品价格</span>
|
||||
<a href="{{:PluginsAdminUrl('usernotloginhidegoodsprice', 'admin', 'index')}}" class="fr fs-14 m-t-5 am-icon-mail-reply"> 返回</a>
|
||||
</legend>
|
||||
|
||||
<div class="am-form-group">
|
||||
<label>限制终端<span class="fs-12 fw-100 cr-999">(留空则全部)</span></label>
|
||||
<select name="limit_terminal" class="am-radius c-p chosen-select" multiple="multiple" minchecked="1" data-placeholder="可选择..." data-validation-message="至少选择一个限制终端">
|
||||
{{foreach :lang('common_platform_type') as $v}}
|
||||
<option value="{{$v.value}}" {{if isset($data['limit_terminal']) and in_array($v['value'], $data['limit_terminal'])}}selected{{/if}}>{{$v.name}}</option>
|
||||
{{/foreach}}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="am-form-group">
|
||||
<label>原价占位符</label>
|
||||
<input type="text" name="original_price_placeholder" placeholder="原价占位符" maxlength="16" data-validation-message="原价占位符最多16个字符" class="am-radius" value="{{if !empty($data)}}{{$data.original_price_placeholder}}{{/if}}" />
|
||||
</div>
|
||||
|
||||
<div class="am-form-group">
|
||||
<label>销售价占位符</label>
|
||||
<input type="text" name="price_placeholder" placeholder="销售价占位符" maxlength="16" data-validation-message="销售价占位符最多16个字符" class="am-radius" value="{{if !empty($data)}}{{$data.price_placeholder}}{{/if}}" />
|
||||
</div>
|
||||
|
||||
<div class="am-form-group">
|
||||
<button type="submit" class="am-btn am-btn-primary am-radius btn-loading-example am-btn-sm w100" data-am-loading="{loadingText:'处理中...'}">保存</button>
|
||||
</div>
|
||||
</form>
|
||||
<!-- form end -->
|
||||
</div>
|
||||
</div>
|
||||
<!-- right content end -->
|
||||
|
||||
<!-- footer start -->
|
||||
{{include file="public/footer" /}}
|
||||
<!-- footer end -->
|
||||
@ -371,32 +371,32 @@ class BuyService
|
||||
],
|
||||
'field' => 'id, id AS goods_id, title, images, inventory_unit, buy_min_number, buy_max_number',
|
||||
];
|
||||
$goods = GoodsService::GoodsList($p);
|
||||
if(empty($goods[0]))
|
||||
$ret = GoodsService::GoodsList($p);
|
||||
if(empty($ret['data'][0]))
|
||||
{
|
||||
return DataReturn('资源不存在或已被删除', -10);
|
||||
}
|
||||
|
||||
// 规格
|
||||
$goods[0]['spec'] = self::GoodsSpecificationsHandle($params);
|
||||
$ret['data'][0]['spec'] = self::GoodsSpecificationsHandle($params);
|
||||
|
||||
// 获取商品基础信息
|
||||
$goods_base = GoodsService::GoodsSpecDetail(['id'=>$goods[0]['goods_id'], 'spec'=>$goods[0]['spec']]);
|
||||
$goods_base = GoodsService::GoodsSpecDetail(['id'=>$ret['data'][0]['goods_id'], 'spec'=>$ret['data'][0]['spec']]);
|
||||
if($goods_base['code'] == 0)
|
||||
{
|
||||
$goods[0]['inventory'] = $goods_base['data']['inventory'];
|
||||
$goods[0]['price'] = $goods_base['data']['price'];
|
||||
$goods[0]['original_price'] = $goods_base['data']['original_price'];
|
||||
$goods[0]['spec_weight'] = $goods_base['data']['weight'];
|
||||
$goods[0]['spec_coding'] = $goods_base['data']['coding'];
|
||||
$goods[0]['spec_barcode'] = $goods_base['data']['barcode'];
|
||||
$ret['data'][0]['inventory'] = $goods_base['data']['inventory'];
|
||||
$ret['data'][0]['price'] = $goods_base['data']['price'];
|
||||
$ret['data'][0]['original_price'] = $goods_base['data']['original_price'];
|
||||
$ret['data'][0]['spec_weight'] = $goods_base['data']['weight'];
|
||||
$ret['data'][0]['spec_coding'] = $goods_base['data']['coding'];
|
||||
$ret['data'][0]['spec_barcode'] = $goods_base['data']['barcode'];
|
||||
} else {
|
||||
return $goods_base;
|
||||
}
|
||||
|
||||
// 数量/小计
|
||||
$goods[0]['stock'] = $params['stock'];
|
||||
$goods[0]['total_price'] = $params['stock']*$goods[0]['price'];
|
||||
$ret['data'][0]['stock'] = $params['stock'];
|
||||
$ret['data'][0]['total_price'] = $params['stock']*$ret['data'][0]['price'];
|
||||
|
||||
return DataReturn('操作成功', 0, $goods);
|
||||
}
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
namespace app\service;
|
||||
|
||||
use think\Db;
|
||||
use think\facade\Hook;
|
||||
use app\service\ResourcesService;
|
||||
use app\service\BrandService;
|
||||
use app\service\RegionService;
|
||||
@ -153,7 +154,8 @@ class GoodsService
|
||||
foreach($goods_category as &$v)
|
||||
{
|
||||
$category_ids = self::GoodsCategoryItemsIds([$v['id']], 1);
|
||||
$v['goods'] = self::CategoryGoodsList(['where'=>['gci.category_id'=>$category_ids, 'is_home_recommended'=>1], 'm'=>0, 'n'=>6, 'field'=>'g.id,g.title,g.title_color,g.images,g.home_recommended_images,g.original_price,g.price,g.min_price,g.max_price,g.inventory,g.buy_min_number,g.buy_max_number']);
|
||||
$goods = self::CategoryGoodsList(['where'=>['gci.category_id'=>$category_ids, 'is_home_recommended'=>1], 'm'=>0, 'n'=>6, 'field'=>'g.id,g.title,g.title_color,g.images,g.home_recommended_images,g.original_price,g.price,g.min_price,g.max_price,g.inventory,g.buy_min_number,g.buy_max_number']);
|
||||
$v['goods'] = $goods['data'];
|
||||
}
|
||||
}
|
||||
return $goods_category;
|
||||
@ -246,6 +248,20 @@ class GoodsService
|
||||
// 开始处理数据
|
||||
foreach($data as &$v)
|
||||
{
|
||||
// 商品处理前钩子
|
||||
$hook_name = 'plugins_service_goods_handle_begin';
|
||||
$ret = Hook::listen($hook_name, [
|
||||
'hook_name' => $hook_name,
|
||||
'is_backend' => true,
|
||||
'params' => &$params,
|
||||
'goods' => &$v,
|
||||
'goods_id' => $v['id']
|
||||
]);
|
||||
if(isset($ret['code']) && $ret['code'] != 0)
|
||||
{
|
||||
return $ret;
|
||||
}
|
||||
|
||||
// 商品url地址
|
||||
if(!empty($v['id']))
|
||||
{
|
||||
@ -328,9 +344,23 @@ class GoodsService
|
||||
{
|
||||
$v['content_app'] = self::GoodsContentApp(['goods_id'=>$v['id']]);
|
||||
}
|
||||
|
||||
// 商品处理前钩子
|
||||
$hook_name = 'plugins_service_goods_handle_end';
|
||||
$ret = Hook::listen($hook_name, [
|
||||
'hook_name' => $hook_name,
|
||||
'is_backend' => true,
|
||||
'params' => &$params,
|
||||
'goods' => &$v,
|
||||
'goods_id' => $v['id']
|
||||
]);
|
||||
if(isset($ret['code']) && $ret['code'] != 0)
|
||||
{
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
return DataReturn('处理成功', 0, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -486,7 +486,9 @@ class PluginsAdminService
|
||||
$admin=<<<php
|
||||
<?php
|
||||
namespace app\plugins\\$plugins;
|
||||
|
||||
use think\Controller;
|
||||
|
||||
/**
|
||||
* {$params['name']} - 后台管理
|
||||
* @author Devil
|
||||
@ -511,7 +513,9 @@ php;
|
||||
$hook=<<<php
|
||||
<?php
|
||||
namespace app\plugins\\$plugins;
|
||||
|
||||
use think\Controller;
|
||||
|
||||
/**
|
||||
* {$params['name']} - 钩子入口
|
||||
* @author Devil
|
||||
@ -525,9 +529,9 @@ class Hook extends Controller
|
||||
public function run(\$params = [])
|
||||
{
|
||||
// 是否控制器钩子
|
||||
// is_control 当前为控制器业务处理
|
||||
// is_backend 当前为后端业务处理
|
||||
// hook_name 钩子名称
|
||||
if(isset(\$params['is_control']) && \$params['is_control'] === true && !empty(\$params['hook_name']))
|
||||
if(isset(\$params['is_backend']) && \$params['is_backend'] === true && !empty(\$params['hook_name']))
|
||||
{
|
||||
// 参数一 描述
|
||||
// 参数二 0 为处理成功, 负数为失败
|
||||
@ -546,7 +550,9 @@ php;
|
||||
$index=<<<php
|
||||
<?php
|
||||
namespace app\plugins\\$plugins;
|
||||
|
||||
use think\Controller;
|
||||
|
||||
/**
|
||||
* {$params['name']} - 前端独立页面入口
|
||||
* @author Devil
|
||||
|
||||
@ -833,7 +833,13 @@ class UserService
|
||||
}
|
||||
|
||||
// 用户登录前钩子
|
||||
$ret = Hook::listen('plugins_control_user_login_begin', ['hook_name'=>'plugins_control_user_login_begin', 'is_control'=>true, 'params'=>$params, 'user_id'=>$user['id']]);
|
||||
$hook_name = 'plugins_service_user_login_begin';
|
||||
$ret = Hook::listen($hook_name, [
|
||||
'hook_name' => $hook_name,
|
||||
'is_backend' => true,
|
||||
'params' => &$params,
|
||||
'user_id' => $user['id']
|
||||
]);
|
||||
if(isset($ret['code']) && $ret['code'] != 0)
|
||||
{
|
||||
return $ret;
|
||||
@ -852,7 +858,13 @@ class UserService
|
||||
if(self::UserLoginRecord($user['id']))
|
||||
{
|
||||
// 用户登录后钩子
|
||||
$ret = Hook::listen('plugins_control_user_login_end', ['hook_name'=>'plugins_control_user_login_end', 'is_control'=>true, 'params'=>$params, 'user_id'=>$user['id']]);
|
||||
$hook_name = 'plugins_service_user_login_end';
|
||||
$ret = Hook::listen($hook_name, [
|
||||
'hook_name' => $hook_name,
|
||||
'is_backend' => true,
|
||||
'params' => &$params,
|
||||
'user_id' => $user['id']
|
||||
]);
|
||||
if(isset($ret['code']) && $ret['code'] != 0)
|
||||
{
|
||||
return $ret;
|
||||
|
||||
@ -41,7 +41,7 @@ return array (
|
||||
array (
|
||||
0 => 'app\\plugins\\usercentertopnotice\\Hook',
|
||||
),
|
||||
'plugins_control_user_login_end' =>
|
||||
'plugins_service_user_login_end' =>
|
||||
array (
|
||||
0 => 'app\\plugins\\userloginrewardintegral\\Hook',
|
||||
),
|
||||
@ -60,5 +60,9 @@ return array (
|
||||
0 => 'app\\plugins\\commonrightnavigation\\Hook',
|
||||
1 => 'app\\plugins\\commononlineservice\\Hook',
|
||||
),
|
||||
'plugins_service_goods_handle_begin' =>
|
||||
array (
|
||||
0 => 'app\\plugins\\usernotloginhidegoodsprice\\Hook',
|
||||
),
|
||||
);
|
||||
?>
|
||||
@ -15,7 +15,7 @@
|
||||
|
||||
return [
|
||||
// 开发模式
|
||||
'is_develop' => false,
|
||||
'is_develop' => true,
|
||||
|
||||
// 默认编码
|
||||
'default_charset' => 'utf-8',
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -381,7 +381,7 @@ li.am-comment{ width:100%}
|
||||
.tb-detail-price{ background: #fcf1e3 url(../images/goods_meta_bg.png); background-size: cover; -moz-background-size: cover; background-repeat: no-repeat; }
|
||||
.tb-detail-price .items {display: block;margin:0px 10px;}
|
||||
.tb-detail-price .items dt {width: 70px;float:left;text-align: left;}
|
||||
.sys_item_price{font-size: 24px;font-weight: bold;}
|
||||
.sys_item_price{font-size: 24px;font-weight: bold; line-height: 16px;}
|
||||
.sys_item_mktprice{font-size:14px ;}
|
||||
|
||||
|
||||
|
||||
15
public/static/plugins/css/usernotloginhidegoodsprice/admin.css
Executable file
15
public/static/plugins/css/usernotloginhidegoodsprice/admin.css
Executable file
@ -0,0 +1,15 @@
|
||||
/**
|
||||
* 首页
|
||||
*/
|
||||
.usernotloginhidegoodsprice-content .items {
|
||||
margin: 10px 0 20px 0;
|
||||
border-bottom: 1px dashed #f1f1f1;
|
||||
padding-bottom: 20px;
|
||||
}
|
||||
.usernotloginhidegoodsprice-content .items .empty-text {
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
.usernotloginhidegoodsprice-content .edit-submit {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 6.8 KiB |
Reference in New Issue
Block a user