123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274 |
- <?php
- namespace app\clientweb\controller;
- use app\common\controller\ClientWeb;
- use app\main\constants\PayConstants;
- use app\main\helper\ArrayHelper;
- use app\main\service\ClientAppService;
- use app\main\service\GoodsService;
- use think\Config;
- use think\Controller;
- use think\Cookie;
- use think\Request;
- use think\Url;
- /**
- * Created by PhpStorm.
- * User: lytian
- * Date: 2019/4/11
- * Time: 18:14
- */
- class Index extends ClientWeb
- {
- protected $layout = '';
- protected $tpname = ['1' => 'lunbo', '2' => 'cainixihuan', '3' => 'remenshuangwen', '4' => 'nav', '5' => 'searchbox', '6' => 'blcoknav', '7' => 'changxiao','8'=>'recently'];
- //1=轮播,2=横4,3=竖4,4=标题导航,5=搜索,6=块导航,7=榜单
- public function index()
- {
- $rencently = [];
- $sex = '1';
- $avatar = '/assets/img/frontend/icon/nav_icon_4.png';
- $isVip = false;
- $type = 'boy';
- if ($this->isLogin) {
- if ($this->userInfo['sex'] && $this->userInfo['sex'] == 2) {
- $type = 'girl';
- $sex = '2';
- }
- if ($this->userInfo['avatar']) {
- $avatar = $this->userInfo['avatar'];
- }
- $isVip = $this->userInfo['vip_endtime'] > time();
- $res = model('UserRecentlyRead')->getRecentlyRead(0, 10, $this->userInfo['id'], true);
- $rencently = $res['totalNum'] == 0 ? [] : $res['data'];
- }
- $pagesex = isset($this->params['type']) ? $this->params['type'] : $type;
- if ($pagesex == 'boy') {
- //男频
- $tag = 1;
- } else {
- //女频
- $tag = 2;
- }
- $indexTitle = '书城';
- if ($pagesex == 'girl') {
- $sexid = 2;
- } else {
- $sexid = 1;
- }
- //运营活动位
- $pagedata = ClientAppService::instance()->pageBlockResource($pagesex);
- $ranklist = ClientAppService::instance()->rankList($pagesex);
- $this->assign('rencently', $rencently);
- $this->assign('title', $indexTitle);
- $this->view->assign('sexid', $sexid);
- $this->view->assign('type', $pagesex);
- $this->view->assign('pagedata', $pagedata);
- $this->view->assign('ranklist', $ranklist);
- $this->view->assign('sex', $sex);
- $this->view->assign('avatar', $avatar);
- $this->view->assign('isVip', $isVip);
- return $this->view->fetch();
- }
- /**
- * 搜索页
- * @param int $sex 频道标示
- */
- public function search()
- {
- $userId = 0;
- if ($this->isLogin) {
- $userId = $this->userInfo['id'];
- }
- $books = model('User')->getLike($userId);
- $categoryArr = model("BookCategory")->getCategoryList();
- foreach ($books as $k=>$v){
- $books[$k]['author'] = $categoryArr[$v['book_category_id']];
- }
- if($this->request->isAjax()){
- return json_encode($books);
- }else{
- $sex = input('sex');
- $this->assign('sex', $sex);
- $pagedata['name'] = '精彩推荐';
- $pagedata['block_resource'] = $books;
- $this->view->assign('value', $pagedata);
- return $this->view->fetch();
- }
- }
- /*
- * 主编推荐列表
- */
- public function recommendList($book_id)
- {
- $userid = 0;
- if ($this->isLogin) {
- $userid = $this->userInfo['id'];
- }
- $pagedata = ClientAppService::instance()->recommendList($book_id, $userid);
- return $pagedata;
- }
- /**
- * 弹框配置H5
- */
- public function popuptemp()
- {
- $id = $this->urlParams['id'];
- if (empty($id)) {
- $this->error("缺少参数");
- }
- $row = model("ClientConfig")->getOne($id);
- if ($row['fun_type'] != '2') {
- $this->error("类型有误");
- }
- switch ($row['type']) {
- case "1":
- //url
- $link = ClientAppService::instance()->parseAppUrl('url', ['url' => $row['url']]);
- break;
- case "2":
- //书籍详情
- $link = ClientAppService::instance()->parseAppUrl('bookinfo', ['book_id' => $row['book_id']]);
- break;
- case "3":
- //阅读器
- $link = ClientAppService::instance()->parseAppUrl('chapter', ['book_id' => $row['book_id']]);
- break;
- case "4":
- //活动
- $actUrl = '/clientWeb/activity/index?id='.$row['client_activity_id'];
- $link = ClientAppService::instance()->parseAppUrl('activity', ['url' => $actUrl]);
- break;
- }
- $this->view->engine->layout(false);
- $this->assign('img', $row['pic_url']);
- $this->assign('link', $link);
- return $this->fetch('popuptemp');
- }
- /**
- * 绑定手机弹窗
- * @return mixed
- */
- public function bindpopup()
- {
- $this->view->engine->layout(false);
- return $this->fetch('bindpopup');
- }
- /**
- * 开通VIP弹窗
- * @return mixed
- */
- public function vippopup()
- {
- //获取VIP的商品id
- $goodsId = Config::get('site.app_vip_popup');
- $this->view->engine->layout(false);
- $this->assign('goods_id', $goodsId);
- return $this->fetch('vippopup');
- }
- /**
- * 调试APPjs方法
- */
- public function appjstest()
- {
- $this->view->engine->layout(false);
- $this->assign('url1', 'http://www.baidu.com');
- $this->assign('url2', ClientAppService::instance()->parseAppUrl('url', ['url' => '/clientweb/index?type=girl', 'showTitleBar' => false]));
- $this->assign('url3', ClientAppService::instance()->parseAppUrl('bookinfo', ['book_id' => '11000000258']));
- $this->assign('url4', ClientAppService::instance()->parseAppUrl('shelf', []));
- $this->assign('url5', ClientAppService::instance()->parseAppUrl('chapter', ['book_id' => '11000000258']));
- $this->assign('url6', ClientAppService::instance()->parseAppUrl('dialog', ['url' => 'http://aa.lkety.cn/clientweb/index/vippopup']));
- $this->assign('url7', ClientAppService::instance()->parseAppUrl('account', []));
- $this->assign('url8', ClientAppService::instance()->parseAppUrl('book', []));
- $this->assign('url9', ClientAppService::instance()->parseAppUrl('dialog', ['url' => '/clientweb/index/paymethodselect?goods_id=45']));
- $this->assign('url10', ClientAppService::instance()->parseAppUrl('dialog', ['url' => '/clientweb/index/bindpopup']));
- return $this->fetch('appjstest');
- }
- /**
- * 选择充值方式
- * @return mixed
- */
- public function paymethodselect()
- {
- $aid = $this->urlParams['aid'] ?? 0;
- $goods_id = $this->urlParams['goods_id'] ?? 0;
- if (empty($goods_id)) {
- $this->error('缺少参数');
- }
- if (!$goodsInfo = GoodsService::instance()->getGoodsModel()->getGoodsInfoById($goods_id)) {
- $this->error('商品不存在');
- }
- $pay_list = model('Wxpay')->getListByBusiness(PayConstants::BUSINESS_APP);
- $pay_list = ArrayHelper::extractColumn($pay_list, ['id', 'payment_method', 'p_desc', 'icon']);
- $data = [
- 'pay_list' => $pay_list,
- 'aid' => $aid,
- 'goods_id' => $goods_id,
- 'money' => $goodsInfo['money'],
- ];
- $this->view->engine->layout(false);
- $this->view->assign('data', $data);
- return $this->fetch('paymethodselect');
- }
- /**
- * 查看cookie
- */
- public function dev()
- {
- echo '<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0,user-scalable=no">';
- echo "<a href='/clientweb/index/clear'>清除cookie</a><br><br>";
- echo '<pre>';
- var_dump(Cookie::get());
- }
- /**
- * 清除cookie
- */
- public function clear()
- {
- echo '<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0,user-scalable=no">';
- foreach (Cookie::get() as $key => $value) {
- Cookie::delete($key);
- }
- echo "<a href='/clientweb/index/dev'>访问dev</a><br><br>";
- echo "cookie已清除!";
- }
- }
|