Authored by yangyang

完成频道选择页代码

@@ -19,7 +19,6 @@ class IndexData { @@ -19,7 +19,6 @@ class IndexData {
19 { 19 {
20 $param = Yohobuy::param(); 20 $param = Yohobuy::param();
21 $param['client_secret'] = Sign::getSign($param); 21 $param['client_secret'] = Sign::getSign($param);
22 - print_r($param);  
23 - Yohobuy::post('http://service.api.yohobuy.com/operations/api/v5/entrance/getEntrance',$param); 22 + return Yohobuy::get('http://service.api.yohobuy.com/operations/api/v5/entrance/getEntrance',$param);
24 } 23 }
25 } 24 }
1 <?php 1 <?php
2 2
3 use Action\AbstractAction; 3 use Action\AbstractAction;
  4 +use Index\IndexModel;
4 use Plugin\Helpers; 5 use Plugin\Helpers;
5 -use LibModels\Wap\Index\IndexData;  
6 6
7 /** 7 /**
8 * 频道选择 8 * 频道选择
@@ -15,25 +15,25 @@ class IndexController extends AbstractAction @@ -15,25 +15,25 @@ class IndexController extends AbstractAction
15 */ 15 */
16 public function indexAction() 16 public function indexAction()
17 { 17 {
18 -// if (null !== $this->get('go')) {  
19 -// // 先检查COOKIE是否有访问过, 有则跳转到相应的频道页  
20 -// Index\HomeModel::goSwitchChannel();  
21 -// } else {  
22 -// // 设置客户端浏览器1小时内不改变,  
23 -// $this->setLastModified(mktime(date('H'), 0, 0, date('n'), date('j'), date('Y')));  
24 -// // 设置浏览器缓存5分钟  
25 -// $this->setExpires(300);  
26 -// }  
27 - var_dump(IndexData::channelData()); 18 + if (null !== $this->get('go')) {
  19 + // 先检查COOKIE是否有访问过, 有则跳转到相应的频道页
  20 + Index\HomeModel::goSwitchChannel();
  21 + } else {
  22 + // 设置客户端浏览器1小时内不改变,
  23 + $this->setLastModified(mktime(date('H'), 0, 0, date('n'), date('j'), date('Y')));
  24 + // 设置浏览器缓存5分钟
  25 + $this->setExpires(300);
  26 + }
  27 + $result = IndexModel::getChannel();
  28 + $result['background'] = Index\HomeModel::getBgImage();
  29 + $result['channelPage'] = true;
  30 + $result['showDownloadApp'] = true;
  31 + $result['searchUrl'] = Helpers::url('', null, 'search');
  32 + $result['pageFooter'] = true;
28 // 渲染模板 33 // 渲染模板
29 - $this->_view->display('index', array(  
30 - 'background' => Index\HomeModel::getBgImage(),  
31 - 'channelPage' => true,  
32 - 'showDownloadApp'=>true,  
33 - 'searchUrl' => Helpers::url('', null, 'search'),  
34 - 'pageFooter' => true,  
35 - )); 34 + $this->_view->display('index', $result);
36 } 35 }
  36 +
37 /** 37 /**
38 * 设置升级公告路由 38 * 设置升级公告路由
39 * 39 *
  1 +<?php
  2 +namespace Index;
  3 +
  4 +use LibModels\Wap\Index\IndexData;
  5 +/*
  6 + * To change this license header, choose License Headers in Project Properties.
  7 + * To change this template file, choose Tools | Templates
  8 + * and open the template in the editor.
  9 + */
  10 +
  11 +/**
  12 + * Description of Index
  13 + *
  14 + * @author Administrator
  15 + */
  16 +class IndexModel
  17 +{
  18 + public function getChannel(){
  19 + $result = array();
  20 + $result['showYohood'] = false;
  21 +
  22 + $data = IndexData::channelData();
  23 +
  24 + $channelList = array();
  25 + if($data['code'] == 200 && isset($data['data']['list'])){
  26 + foreach($data['data']['list'] as $key => $value){
  27 + switch ($value['channel_id']) {
  28 + case 5:
  29 + $result['showYohood'] = true;
  30 + break;
  31 + case 1:
  32 + $channelList[$key]['href'] = '/boys';
  33 + $channelList[$key]['title'] = '男生';
  34 + $channelList[$key]['entitle'] = 'BOYS';
  35 + break;
  36 + case 2:
  37 + $channelList[$key]['href'] = '/girls';
  38 + $channelList[$key]['title'] = '女生';
  39 + $channelList[$key]['entitle'] = 'GIRLS';
  40 + break;
  41 + case 3:
  42 + $channelList[$key]['href'] = '/kids';
  43 + $channelList[$key]['title'] = '潮童';
  44 + $channelList[$key]['entitle'] = 'KIDS';
  45 + break;
  46 + case 4:
  47 + $channelList[$key]['href'] = '/lifestyle';
  48 + $channelList[$key]['title'] = '创意生活';
  49 + $channelList[$key]['entitle'] = 'LIFESTYLE';
  50 + break;
  51 + default:
  52 + break;
  53 + }
  54 + }
  55 + $result['channelList'] = $channelList;
  56 + }
  57 +
  58 + return $result;
  59 + }
  60 +
  61 +}