GoodsdetailsController.php
2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
// +----------------------------------------------------------------------
// | bronet [ 以客户为中心 以奋斗者为本 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2017 http://www.bronet.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
namespace app\portal\controller;
use cmf\controller\WeChatBaseController;
use think\Db;
class GoodsdetailsController extends WeChatBaseController{
/**
* 商品详情页
*/
public function Goods_details(){
$goods_id = $this -> request -> param();
$data = Db::name('goods') -> alias('a') -> field("a.*,b.name") -> join('classification b','a.classify_id = b.id','LEFT') -> where('a.id',$goods_id['goods_id']) -> find();
$price = explode('.',$data['price']);
$pricing = explode('.',$data['pricing']);
$data['price0'] = $price[0];
$data['price1'] = $price[1];
$data['pricing0'] = $pricing[0];
$data['pricing1'] = $pricing[1];
$data['det_img'] = json_decode($data['det_img'],true);
$this -> assign('det_img',$data['det_img']);
$this -> assign('data',$data);
$data_label = Db::name('label') -> alias('a') -> field("a.*,b.goods_id,b.label_id") -> join('goods_label b','a.id=b.label_id','LEFT') -> where("b.goods_id = ".$goods_id['goods_id']) -> select();
$this -> assign('data_label',$data_label);
if($data['type'] == 1){
//相关推荐
$data_recomm = Db::name('goods') -> where("classify_id =".$data['classify_id']." and is_out = 1 and type = 1") -> limit(3) -> select();
$this -> assign('data_recomm',$data_recomm);
$this -> assign('is_recomm',1);
}else{
$this -> assign('is_recomm',2);
}
return $this -> fetch();
}
/**
* 点击收藏
*/
public function goods_collection(){
$goods_id = $_POST['goods_id'];
$uid = cmf_get_current_user_id();
$arr['goods_id'] = $goods_id;
$arr['uid'] = $uid;
$data = Db::name('collect') -> insert($arr);
if($data){
return true;
}else{
return false;
}
}
}