view->assign('adminconfig',$this->adminconfig); $is_show_tabbar = 0; $showBookShelf = 0; //$isAdPick = 0; if($this->user->isLogin()){ $showBookShelf = BookService::instance()->showBookShelfFun(); $is_show_tabbar = model("ChannelSpecialManage")->isWhite("show_tabbar", $this->user->channel_id); $this->assign('channel_id', $this->user->channel_id); //渠道是否开启了广告功能 //$isAdPick = model("ChannelSpecialManage")->isWhite("ad_pick", $this->user->channel_id); } //$this->assign('isAdPick', $isAdPick); $this->assign('showBookShelf', $showBookShelf); $this->assign('is_show_tabbar', $is_show_tabbar); } //用户个人中心 public function index() { $this->assign('tab_choice', 'my'); $flag = 0; $kandian = 0; $kandian_permanent = 0; $kandian_fee = 0; //分享活动标记 $is_share_open = 0; $share_url = ''; $guideArr = []; if ($this->user->isLogin()) { $guideArr = AppGuideService::instance()->getAppGuideInfo($this->user->channel_id); if (ActiveShareService::instance()->checkChannel($this->user->channel_id)) { $is_share_open = 1; $share_url = ActiveShareService::instance()->getActiveUrl($this->user->channel_id, 2); } $this->assign('user', $this->user->getUserModel()->getUserInfo($this->user->id)); $kandian_permanent = FinancialService::instance()->getTotalKandian($this->user->id)->data; #永久可用的看点数 $kandian_fee = FinancialService::instance()->getTotalFreeKandian($this->user->id)->data; #带有效期的免费看点数 $kandian = $kandian_permanent + $kandian_fee; #总可用的看点 $flag = 1; } $this->view->assign('sex', $this->user->sex ? $this->user->sex : '1'); $hasGuide = count($guideArr) ?? 0 ; //最新的竞赛信息 $latestCampaign = CampaignService::instance()->getLatestCampaign($this->user); // 保存用户IP地址信息到Redis,跳转到消耗活动后,直充直销 户画像打点使用 $ip_redis_key = CacheConstants::USER_IP_PREFIX . Cookie::get('user_id'); Redis::instance()->set( $ip_redis_key, json_encode([ 'ip' => Ip::ip(), 'country' => Ip::country(Ip::ip()), 'province' => Ip::province(Ip::ip()), 'city' => Ip::city(Ip::ip()), 'ua' => Ua::getUa() ]), 300 ); $good_desc = ''; $vip = false; $show_vip_at_home = ArrayHelper::array_get($this->adminconfig, 'show_vip_at_home'); if ($show_vip_at_home && $this->adminconfig['vip_state'] && $this->adminconfig['vip_goods_id']) { $goods_info = GoodsService::instance()->getGoodsModel()->getGoodsInfoById($this->adminconfig['vip_goods_id']); if ($goods_info && GoodsService::instance()->checkGoodsTypeValid($goods_info['show_type'], UserService::instance()->getUserInfo())->data) { $vip = true; $good_desc = $goods_info['desc']; } } //翻牌活动的banner $cardInfo = CardFlipService::instance()->getBannerImage($this->user); $this->assign('cardInfo',$cardInfo); //查看用户是否参加过订阅活动 $isSubActUser = SubscripService::instance()->checkUserSign($this->user); $subBannerImg = SubscripService::instance()->checkSubBanner($this->user); $this->assign('isSubActUser',$isSubActUser); $this->assign('subBannerImg',$subBannerImg); $this->assign('vip', $vip); $this->assign('good_desc', $good_desc); $this->assign('share_url', $share_url); $this->assign('is_share_open', $is_share_open); $this->assign('latestCampaign', $latestCampaign); $this->assign('hasGuideArr', $hasGuide); $this->assign('flag', $flag); $this->assign('kandian', $kandian); $this->assign('kandian_permanent', $kandian_permanent); $this->assign('kandian_fee', $kandian_fee); return $this->view->fetch(); } //用户最近阅读 public function recent() { $this->assign('tab_choice', 'bookshelf'); $res = []; $res['totalNum'] = 0; $recently = []; $userId = UserService::instance()->getUserInfo()->id; $channelId = UserService::instance()->getUserChannelId()->data; $isWater = WaterBookService::instance()->showBook($channelId, $userId, Ip::ip()); if (Cookie::has('user_id')) { //已支付用户 $res = model('UserRecentlyRead')->getRecentlyRead(0, 10, null, true); $recently = $res['totalNum'] == 0 ? [] : $res['data']; foreach ($recently as &$item) { if (empty($item['chapter_id'])) { unset($item); } if($isWater){ $bookinfo = model('Book')->BookInfo($item['book_id']); if((!isset($bookinfo['classify_white_list']) || $bookinfo['classify_white_list'] != 1)){ $item['state'] = 0; } } } $this->view->assign('login', 1);//登录 }else { $cookread = Cookie::has('read')?Cookie::get('read'):[]; $recently = array_reverse($cookread); $res['totalNum'] = count($recently); foreach ($recently as &$value) { $bookinfo = model('Book')->BookInfo($value['book_id']); $value['image'] = empty($bookinfo['image']) ? '' : $bookinfo['image']; $value['state'] = $bookinfo['state']; if ($isWater && (!isset($bookinfo['classify_white_list']) || $bookinfo['classify_white_list'] != 1)) { $value['state'] = 0; } $value['book_name'] = $bookinfo['name']; $value['last_chapter_name'] = empty($bookinfo['last_chapter_name']) ? '' : $bookinfo['last_chapter_name']; $value['last_chapter_utime'] = $bookinfo['last_chapter_utime']; } $this->view->assign('login', 0);//未登录 } $this->assign('rencently', $recently); $this->assign('totalNum', $res['totalNum']); Cookie::set('rc', $res['totalNum']);//阅读书籍数 $this->view->assign('sex', $this->user->sex ? $this->user->sex : '1'); $showBookShelf = BookService::instance()->showBookShelfFun(); $this->view->assign('ranklist', ['idx' => []]); $this->view->assign('type', 'recently'); $this->view->assign('avatar', $this->user->avatar ?: cdnurl('/assets/img/frontend/icon/nav_icon_4.png')); $this->view->assign('isVip', $this->user->vip_endtime > time()); $this->view->assign('show_book_shelf', $showBookShelf); return $this->view->fetch(); } public function bookselfremove(){ $uid = Cookie::get('user_id'); $book_id = $this->request->get('book_id'); $chapter_id = $this->request->get('chapter_id'); if($uid){ model('UserRecentlyRead')->setConnect($uid)->remove($book_id,$chapter_id,$uid); } } /** * 签到 * @return string|\think\response\Json * @throws \Exception * err:0 签到成功,1 用户今日已签到,2 签到失败,3 用户未登录 */ public function sign() { $isSign = $this->isSign(); //判断用户今日是否签到 $this->assign('isSign',$isSign); return $this->view->fetch(); } /** * 判断当前用户今日有没有签到 * @return bool */ public function isSign(){ $uid = Cookie::get('user_id'); $todayDate = Date('Ymd',time()); if(Cookie::get('sign'.$todayDate)=='1'){ return true; }else{ $isSign = model('Sign')->setConnect($uid)->where(['uid'=>$uid,'createdate'=>$todayDate])->find(); if(empty($isSign)){ return false; }else{ return true; } } } public function recommend() { return ''; } public function readlist() { } /* * 登录页 */ public function login(){ return $this->view->fetch(); } /** * 跳转到智齿客服 */ public function visitZhiChi() { //$url = "https://www.sobot.com/chat/h5/index.html?sysNum=50d393e83a4d46d8857e8395e774f18d&source=1"; //$url = "https://chat.sobot.com/chat/h5/v2/index.html?sysnum=50d393e83a4d46d8857e8395e774f18d&source=1"; $url = "https://zc.sobot.com/chat/h5/v2/index.html?sysnum=50d393e83a4d46d8857e8395e774f18d&source=1"; if ($this->user->isLogin()) { $userInfo = $this->user->getUserInfo(true)->toArray(); $platename = Config::get('site.theme') ?? ''; $servicename = $this->adminconfig['json']['authorizer_info']['nick_name'] ?? ''; $url .= "&uname={$userInfo['nickname']}&face={$userInfo['avatar']}"; $url .= "&customer_fields={'customField1':'$platename-$servicename'}"; } header('Location: ' . $url); exit; } /** * 客户端绑定动态码 * @return string * @throws \think\Exception */ public function dycode() { if ($this->user->isLogin()) { $channel_id = Cookie::get('channel_id') ?? 0; $user_id = Cookie::get('user_id') ?? 0; $user_info = ClientuserService::instance()->getUserInfoByUid($user_id); // 引导位访问展示打点 AppGuideService::instance()->appGuideViewDot($channel_id, $user_id, MqConstants::APP_GUIDE_POSITION_IDX_3); $this->assign('channel_id', $channel_id); $this->assign('user_id', $user_id); $this->assign('mobile', $user_info['mobile']); return $this->view->fetch(); }else{ echo '请先登录'; exit(); } } /** * 头条支付测试 */ public function ttpaytest() { if (UserService::instance()->isLogin()) { $id = UserService::instance()->getUserInfo()->id; if ($link = Redis::instance()->get(CacheConstants::getGuideWxPay($id))) { ToutiaoNotifyService::instance()->notify($link, $id, ToutiaoNotifyService::EVENT_TYPE_PAY, 1); echo "

支付测试成功!

"; } else { echo "

用户非头条引导用户或已过引导期

"; } } else { echo "

未登陆!

"; } } /** * 高级群发消息 继续阅读 */ public function keepReading(){ $data = model('UserRecentlyRead')->getRecentlyRead(0,1,UserService::instance()->getUserInfo()->id); if(empty($data['data'])){ $this->redirect('/index/user/recent'); }else { $url = '/index/book/chapter?book_id=' . $data['data'][0]['book_id'] . '&chapter_id=' . $data['data'][0]['chapter_id']; $this->redirect($url); } } /* * uc支付测试 */ public function ucpaytest() { if (UserService::instance()->isLogin()) { $id = UserService::instance()->getUserInfo()->id; if ($link = Redis::instance()->get(UcCacheConstants::getGuideWxPay($id))) { //UC回传 UcNotifyService::instance()->notify(UserService::instance()->getUserInfo(), $link, UcNotifyService::EVENT_TYPE_PAY, 1); echo "

支付测试成功!

"; } else { echo "

用户非头条引导用户或已过引导期

"; } } else { echo "

未登陆!

"; } } }