Пример #1
0
 public function index($manifest = '')
 {
     // 更新用户token(临时,新版本客户端主动触发registerPush接口)
     $user = get_user();
     if ($user && M('common_push_device')->where(['mobile' => $user['mobile']])->count() < 1) {
         $xg = new \Common\Util\XgPush();
         $xg->syncUserToken($user['mobile']);
     }
     // 顶部广告
     $ads = M('app_advertisement')->where(['status' => ['egt', 1]])->order('sort asc,id desc')->field('id,pic,title,url')->select();
     foreach ($ads as &$vo) {
         $vo['url'] = $vo['url'] ?: '/public/page/type/app_ad/id/' . $vo['id'];
     }
     $this->assign('ad_list', $ads);
     // 模块
     $modules = M('app_module')->where(['status' => ['egt', 1]])->order('sort asc,id desc')->field('id,pic,name,url,background')->select();
     foreach ($ads as &$vo) {
         $vo['url'] = $vo['url'] ?: '/public/page/type/app_ad/id/' . $vo['id'];
     }
     $modules[0]['size'] = 'big';
     $modules[1]['size'] = 'wide';
     $modules[2]['size'] = 'wide';
     $modules[3]['size'] = 'mid';
     $modules[4]['size'] = 'mid';
     $modules[5]['size'] = 'mid';
     $modules[6]['size'] = 'wide';
     $modules[7]['size'] = 'wide';
     $this->assign('modules', $modules);
     if ($manifest) {
         $this->assign('tag', md5(serialize($ads + $modules)));
         $this->display('manifest', 'utf-8', 'text/cache-manifest');
     } else {
         $this->display();
     }
 }
Пример #2
0
 /**
  * @title 获取“校园”配置
  *
  * @method get
  */
 public function campus()
 {
     $data = [];
     // 顶部广告
     $ads = M('app_advertisement')->where(['status' => 1])->order('sort asc,id desc')->field('id,pic,title,url')->select();
     foreach ($ads as &$vo) {
         $vo['url'] = $vo['url'] ?: U('/public/page/type/app_ad/id/' . $vo['id'] . '@mobile');
         unset($vo['id']);
     }
     $data['banner'] = $ads;
     // 模块
     $modules = M('app_module')->where(['status' => 1])->order('sort asc,id desc')->field('id,pic,name title,url_v2 url,background')->limit(10)->select();
     foreach ($modules as &$vo) {
         unset($vo['id']);
     }
     $data['module'] = $modules;
     // 预留的校园webview链接
     $data['url'] = '';
     // 更新用户token(临时,新版本客户端主动触发registerPush接口)
     $user = get_user();
     if ($user && M('common_push_device')->where(['mobile' => $user['mobile']])->count() < 1) {
         $xg = new \Common\Util\XgPush();
         $xg->syncUserToken($user['mobile']);
     }
     ajax_success($data);
 }