diff --git a/app/goods/controller/GoodsController.php b/app/goods/controller/GoodsController.php index 6221bb3..e311b31 100644 --- a/app/goods/controller/GoodsController.php +++ b/app/goods/controller/GoodsController.php @@ -66,11 +66,19 @@ class GoodsController extends HomeBaseController public function detail() { $id = request()->param('id'); - $data = Db::name('zj_goods')->field('thumb,name,intro,price,content,more')->where(['id' => $id])->find(); + $data = Db::name('zj_goods')->alias('g') + ->field('thumb,name,intro,price,content,more,cid as caid') + ->join('zj_category c', 'c.id=g.cid') + ->where(['id' => $id])->find(); $data['more'] = json_decode($data['more'], true); foreach ($data['more'] as $k => $v) { $data['photo'][$k]['photo'] = cmf_get_image_url($v['url']); } + if ($data['caid'] == 2) { + $data['integral'] = '购买可获得' . $data['price'] * 2 . '积分'; + } else { + $data['integral'] = '该商品无积分奖励'; + } $data['content'] = html_entity_decode($data['content']); $total = Db::name('zj_cart')->field('sum(num) as total')->where(['uid' => session('user.id')])->select(); if ($total[0]['total'] == '') { @@ -88,7 +96,7 @@ class GoodsController extends HomeBaseController private function getCategory($cid) { - return Db::name('zj_category')->field('id,name')->where(['cid' => $cid,'delete_time'=>['eq', 0]])->select()->toArray(); + return Db::name('zj_category')->field('id,name')->where(['cid' => $cid, 'delete_time' => ['eq', 0]])->select()->toArray(); } public function getGoodsComment($gid) diff --git a/public/themes/simpleboot3/goods/detail.html b/public/themes/simpleboot3/goods/detail.html index da07703..56fbf15 100644 --- a/public/themes/simpleboot3/goods/detail.html +++ b/public/themes/simpleboot3/goods/detail.html @@ -53,7 +53,7 @@ </p> <div class="people"> <p class="people_weight"> - + {$data.integral} </p> <p class="people_money"> ¥{$data.price}