data_post['goods_id']))
{
return DataReturn('参数有误', -1);
}
// 商品详情方式
$is_use_mobile_detail = intval(MyC('common_app_is_use_mobile_detail'));
// 获取商品
$goods_id = intval($this->data_post['goods_id']);
$params = [
'where' => [
'id' => $goods_id,
'is_delete_time' => 0,
],
'is_photo' => true,
'is_spec' => true,
'is_content_app' => ($is_use_mobile_detail == 1),
];
$ret = GoodsService::GoodsList($params);
if(empty($ret['data'][0]) || $ret['data'][0]['is_delete_time'] != 0)
{
return DataReturn('商品不存在或已删除', -1);
}
// 商品详情处理
if($is_use_mobile_detail == 1)
{
unset($ret['data'][0]['content_web']);
} else {
// 标签处理,兼容小程序rich-text
$search = [
'
',
'
',
'
',
];
$replace = [
'
![]()
',
'
',
'
',
];
$ret['data'][0]['content_web'] = str_replace($search, $replace, $ret['data'][0]['content_web']);
}
// 当前登录用户是否已收藏
$ret_favor = GoodsService::IsUserGoodsFavor(['goods_id'=>$goods_id, 'user'=>$this->user]);
$ret['data'][0]['is_favor'] = ($ret_favor['code'] == 0) ? $ret_favor['data'] : 0;
// 商品访问统计
GoodsService::GoodsAccessCountInc(['goods_id'=>$goods_id]);
// 用户商品浏览
GoodsService::GoodsBrowseSave(['goods_id'=>$goods_id, 'user'=>$this->user]);
// 数据返回
$result = [
'goods' => $ret['data'][0],
'common_order_is_booking' => (int) MyC('common_order_is_booking', 0),
'is_use_mobile_detail' => $is_use_mobile_detail,
];
return DataReturn('success', 0, $result);
}
/**
* 用户商品收藏
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-07-17
* @desc description
*/
public function Favor()
{
// 登录校验
$this->IsLogin();
// 开始操作
$params = $this->data_post;
$params['user'] = $this->user;
return GoodsService::GoodsFavor($params);
}
/**
* 商品规格类型
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-12-14
* @desc description
*/
public function SpecType()
{
// 开始处理
$params = $this->data_post;
return GoodsService::GoodsSpecType($params);
}
/**
* 商品规格信息
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-12-14
* @desc description
*/
public function SpecDetail()
{
// 开始处理
$params = $this->data_post;
return GoodsService::GoodsSpecDetail($params);
}
/**
* 商品分类
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-12-14
* @desc description
*/
public function Category()
{
// 开始处理
$params = $this->data_post;
$data = GoodsService::GoodsCategory($params);
return DataReturn('success', 0, $data);
}
}
?>