Authored by xuqi

Merge branch 'develop' of http://git.dev.yoho.cn/web/yohobuy into develop

@@ -18,9 +18,9 @@ class Yohobuy @@ -18,9 +18,9 @@ class Yohobuy
18 { 18 {
19 19
20 /* 正式环境 */ 20 /* 正式环境 */
21 -// const API_URL = 'http://api2.open.yohobuy.com/';  
22 -// const SERVICE_URL = 'http://service.api.yohobuy.com/';  
23 -// const YOHOBUY_URL = 'http://www.yohobuy.com/'; 21 + // const API_URL = 'http://api2.open.yohobuy.com/';
  22 + // const SERVICE_URL = 'http://service.api.yohobuy.com/';
  23 + // const YOHOBUY_URL = 'http://www.yohobuy.com/';
24 24
25 // /* 测试环境 */ 25 // /* 测试环境 */
26 const API_URL = 'http://test2.open.yohobuy.com/'; 26 const API_URL = 'http://test2.open.yohobuy.com/';
  1 +<?php
  2 +
  3 +namespace LibModels\Wap\Home;
  4 +
  5 +use Api\Sign;
  6 +use Api\Yohobuy;
  7 +
  8 +/**
  9 + * 购物车的数据模型
  10 + *
  11 + * @name CartData
  12 + * @package LibModels/Wap/Home
  13 + * @copyright yoho.inc
  14 + * @version 1.0 (2015-11-09 13:58:27)
  15 + * @author Gtskk <tttt6399998@126.com>
  16 + */
  17 +class CartData
  18 +{
  19 +
  20 + /**
  21 + * 购物车数据
  22 + *
  23 + * @return array 购物车接口返回的数据
  24 + */
  25 + public static function cartData($uid)
  26 + {
  27 + $param = Yohobuy::param();
  28 + $param['method'] = 'app.Shopping.cart';
  29 + $param['uid'] = $uid;
  30 + $param['client_secret'] = Sign::getSign($param);
  31 +
  32 + return Yohobuy::get(Yohobuy::API_URL, $param);
  33 + }
  34 +
  35 +}
  1 +<?php
  2 +
  3 +namespace LibModels\Wap\Home;
  4 +
  5 +use Api\Sign;
  6 +use Api\Yohobuy;
  7 +
  8 +/**
  9 + * 个人中心的数据模型
  10 + *
  11 + * @name UserData
  12 + * @package LibModels/Wap/Home
  13 + * @copyright yoho.inc
  14 + * @version 1.0 (2015-11-09 16:30:27)
  15 + * @author Gtskk <tttt6399998@126.com>
  16 + */
  17 +class UserData
  18 +{
  19 +
  20 + /**
  21 + * 个人详情数据
  22 + *
  23 + * @param int $uid 用户ID
  24 + * @return array 个人详情接口返回的数据
  25 + */
  26 + public static function userData($uid)
  27 + {
  28 + $param = Yohobuy::param();
  29 + $param['method'] = 'app.passport.profile';
  30 + $param['uid'] = $uid;
  31 + $param['client_secret'] = Sign::getSign($param);
  32 +
  33 + return Yohobuy::get(Yohobuy::API_URL, $param);
  34 + }
  35 +
  36 + /**
  37 + * 订单数据
  38 + *
  39 + * @param int $uid 用户ID
  40 + * @param int $type 订单类型,1表示全部,2表示待付款,3表示待发货,4表示待收货,5表示待评价
  41 + * @param int $page 第几页,默认1
  42 + * @param int $limit 限制读取的数目,默认10
  43 + * @return array 订单接口返回的数据
  44 + */
  45 + public static function orderData($uid, $type, $page = 1, $limit = 10)
  46 + {
  47 + $param = Yohobuy::param();
  48 + $param['method'] = 'app.SpaceOrders.get';
  49 + $param['uid'] = $uid;
  50 + $param['type'] = $type;
  51 + $param['page'] = $page;
  52 + $param['limit'] = $limit;
  53 + $param['client_secret'] = Sign::getSign($param);
  54 +
  55 + return Yohobuy::get(Yohobuy::API_URL, $param);
  56 + }
  57 +
  58 + /**
  59 + * 收藏的商品数据
  60 + *
  61 + * @param int $uid 用户ID
  62 + * @param int $page 第几页,默认1
  63 + * @param int $limit 限制读取的数目,默认10
  64 + * @return array 收藏的商品接口返回的数据
  65 + */
  66 + public static function favoriteProductData($uid, $page = 1, $limit = 10)
  67 + {
  68 + $param = Yohobuy::param();
  69 + $param['method'] = 'app.favorite.product';
  70 + $param['uid'] = $uid;
  71 + $param['page'] = $page;
  72 + $param['limit'] = $limit;
  73 + $param['client_secret'] = Sign::getSign($param);
  74 +
  75 + return Yohobuy::get(Yohobuy::API_URL, $param);
  76 + }
  77 +
  78 + /**
  79 + * 收藏的品牌数据
  80 + *
  81 + * @param int $uid 用户ID
  82 + * @param string $gender 性别 1,3表示男,2,3表示女,1,2,3表示全部
  83 + * @param int $page 第几页,默认1
  84 + * @param int $limit 限制读取的数目,默认10
  85 + * @return array 收藏的品牌接口返回的数据
  86 + */
  87 + public static function favoriteBrandData($uid, $gender, $page = 1, $limit = 10)
  88 + {
  89 + $param = Yohobuy::param();
  90 + $param['method'] = 'app.favorite.brand';
  91 + $param['uid'] = $uid;
  92 + $param['gender'] = $gender;
  93 + $param['page'] = $page;
  94 + $param['limit'] = $limit;
  95 + $param['client_secret'] = Sign::getSign($param);
  96 +
  97 + return Yohobuy::get(Yohobuy::API_URL, $param);
  98 + }
  99 +
  100 + /**
  101 + * YOHO币数据
  102 + *
  103 + * @param int $uid 用户ID
  104 + * @param int $page 第几页,默认1
  105 + * @param int $limit 限制读取的数目,默认10
  106 + * @return array YOHO币接口返回的数据
  107 + */
  108 + public static function yohoCoinData($uid, $page = 1, $limit = 10)
  109 + {
  110 + $param = Yohobuy::param();
  111 + $param['method'] = 'app.yohocoin.lists';
  112 + $param['uid'] = $uid;
  113 + $param['page'] = $page;
  114 + $param['limit'] = $limit;
  115 + $param['client_secret'] = Sign::getSign($param);
  116 +
  117 + return Yohobuy::get(Yohobuy::API_URL, $param);
  118 + }
  119 +
  120 + /**
  121 + * 优惠券数据
  122 + *
  123 + * @param int $uid 用户ID
  124 + * @param int $status 优惠券状态,0表示未使用,1表示已使用
  125 + * @param int $page 第几页,默认1
  126 + * @param int $limit 限制读取的数目,默认10
  127 + * @return array 优惠券接口返回的数据
  128 + */
  129 + public static function couponData($uid, $status, $page = 1, $limit = 10)
  130 + {
  131 + $param = Yohobuy::param();
  132 + $param['method'] = 'app.yohocoin.lists';
  133 + $param['uid'] = $uid;
  134 + $param['status'] = $status;
  135 + $param['page'] = $page;
  136 + $param['limit'] = $limit;
  137 + $param['client_secret'] = Sign::getSign($param);
  138 +
  139 + return Yohobuy::get(Yohobuy::API_URL, $param);
  140 + }
  141 +
  142 + /**
  143 + * 地址数据
  144 + *
  145 + * @param int $uid 用户ID
  146 + * @return array 地址接口返回的数据
  147 + */
  148 + public static function addressData($uid)
  149 + {
  150 + $param = Yohobuy::param();
  151 + $param['method'] = 'app.address.get';
  152 + $param['uid'] = $uid;
  153 + $param['client_secret'] = Sign::getSign($param);
  154 +
  155 + return Yohobuy::get(Yohobuy::API_URL, $param);
  156 + }
  157 +
  158 + /**
  159 + * 意见反馈数据
  160 + *
  161 + * @param string $udid 客户端唯一标识
  162 + * @param int $page 第几页,默认1
  163 + * @param int $limit 限制读取的数目,默认10
  164 + * @return array 意见反馈接口返回的数据
  165 + */
  166 + public static function suggestData($udid, $page = 1, $limit = 30)
  167 + {
  168 + $param = Yohobuy::param();
  169 + $param['udid'] = $udid;
  170 + $param['page'] = $page;
  171 + $param['limit'] = $limit;
  172 + $param['client_secret'] = Sign::getSign($param);
  173 +
  174 + return Yohobuy::get(Yohobuy::SERVICE_URL . 'suggest/api/v1/suggest/getList', $param);
  175 + }
  176 +
  177 + /**
  178 + * 提交意见反馈接口
  179 + *
  180 + * @param int $uid 用户ID
  181 + * @param string $content 意见内容
  182 + * @param int $suggest_type 意见类型
  183 + * @return array 意见反馈接口返回的数据
  184 + */
  185 + public static function savesuggestData($uid, $content, $suggest_type, $limit = 30)
  186 + {
  187 + $param = Yohobuy::param();
  188 + $param['uid'] = $uid;
  189 + $param['content'] = $content;
  190 + $param['client_secret'] = Sign::getSign($param);
  191 +
  192 + return Yohobuy::get(Yohobuy::SERVICE_URL . 'suggest/api/v1/suggest/saveSuggest', $param);
  193 + }
  194 +
  195 +}
@@ -45,9 +45,6 @@ class NewsaleData @@ -45,9 +45,6 @@ class NewsaleData
45 */ 45 */
46 public static function getNewProducts($gender, $channel, $order = 's_t_desc', $limit = 60, $page = 1) 46 public static function getNewProducts($gender, $channel, $order = 's_t_desc', $limit = 60, $page = 1)
47 { 47 {
48 - // 构建url地址列表  
49 - $urlList = array();  
50 -  
51 $param = Yohobuy::param(); 48 $param = Yohobuy::param();
52 $param['method'] = 'app.search.newProduct'; 49 $param['method'] = 'app.search.newProduct';
53 $param['gender'] = $gender; 50 $param['gender'] = $gender;
@@ -82,7 +79,6 @@ class NewsaleData @@ -82,7 +79,6 @@ class NewsaleData
82 */ 79 */
83 public static function selectNewSaleProducts($gender, $brand, $sort, $color, $size, $price, $p_d, $channel, $dayLimit = null, $limit = 60, $page = 1, $order = 's_t_desc') 80 public static function selectNewSaleProducts($gender, $brand, $sort, $color, $size, $price, $p_d, $channel, $dayLimit = null, $limit = 60, $page = 1, $order = 's_t_desc')
84 { 81 {
85 -  
86 $selectItems = array( 82 $selectItems = array(
87 'gender' => $gender, 83 'gender' => $gender,
88 'brand' => $brand, 84 'brand' => $brand,
@@ -182,4 +178,30 @@ class NewsaleData @@ -182,4 +178,30 @@ class NewsaleData
182 return Yohobuy::get(Yohobuy::API_URL, $param); 178 return Yohobuy::get(Yohobuy::API_URL, $param);
183 } 179 }
184 180
  181 +
  182 + /**
  183 + * 获取热销排行榜商品数据
  184 + *
  185 + * @param string $gender "1,3"表示男, "2,3"表示女, "1,2,3"表示全部
  186 + * @param string|null $sort 品类ID查询参数
  187 + * @param integer|null $tab_id Tab的ID
  188 + * @param integer $limit 查询返回的最大限制数, 默认为50
  189 + * @param integer $page 分页第几页, 默认第1页
  190 + * @return array 新品到着商品数据
  191 + */
  192 + public static function getTopProducts($gender, $sort = null, $tab_id = null, $limit = 50, $page = 1)
  193 + {
  194 + $param = Yohobuy::param();
  195 + $param['method'] = 'app.search.top';
  196 + $param['gender'] = $gender;
  197 + !empty($sort) && $param['sort'] = $sort;
  198 + !empty($tab_id) && $param['tab_id'] = $tab_id;
  199 + $param['page'] = $page;
  200 + $param['limit'] = $limit;
  201 +
  202 + $param['client_secret'] = Sign::getSign($param);
  203 +
  204 + return Yohobuy::get(Yohobuy::API_URL, $param);
  205 + }
  206 +
185 } 207 }
@@ -43,7 +43,7 @@ $fixTitleBar.css({ @@ -43,7 +43,7 @@ $fixTitleBar.css({
43 top: brandSwipe 43 top: brandSwipe
44 }).hide(); 44 }).hide();
45 minBrandListTop = brandSwipe + $('.hot-brand').outerHeight() + $('.banner-top').outerHeight(); 45 minBrandListTop = brandSwipe + $('.hot-brand').outerHeight() + $('.banner-top').outerHeight();
46 -$('.brand-list').last().append($fixTitleBar); 46 +$brandList.last().append($fixTitleBar);
47 47
48 $(window).scroll(function() { 48 $(window).scroll(function() {
49 var scrTop = $(window).scrollTop(); 49 var scrTop = $(window).scrollTop();
@@ -64,6 +64,19 @@ $(window).scroll(function() { @@ -64,6 +64,19 @@ $(window).scroll(function() {
64 }); 64 });
65 }); 65 });
66 66
  67 +
  68 +function changeBackground() {
  69 + var $brandList = $('.brand-list').find('p');
  70 +
  71 + $brandList.on('touchstart', function() {
  72 + $brandList.css('background', '#fff');
  73 + $(this).css('background', '#eee');
  74 + }).on('touchend touchcancel', function() {
  75 + $(this).css('background', '#fff');
  76 + });
  77 +}
  78 +changeBackground();
  79 +
67 function searchResult() { 80 function searchResult() {
68 var keyword = ($keyword.val() + '').toLowerCase(); 81 var keyword = ($keyword.val() + '').toLowerCase();
69 var result = {}, 82 var result = {},
@@ -113,6 +126,7 @@ function searchResult() { @@ -113,6 +126,7 @@ function searchResult() {
113 126
114 // 插入 dom,绑定事件 127 // 插入 dom,绑定事件
115 $('.search-result').html(html); 128 $('.search-result').html(html);
  129 + changeBackground();
116 } 130 }
117 131
118 if ($('.brand-search-page').length) { 132 if ($('.brand-search-page').length) {
@@ -11,7 +11,8 @@ var $nav = $('.category-nav'), @@ -11,7 +11,8 @@ var $nav = $('.category-nav'),
11 $categoryContainer = $('.category-container'), 11 $categoryContainer = $('.category-container'),
12 $contents = $categoryContainer.children('.content'); 12 $contents = $categoryContainer.children('.content');
13 13
14 -var $curContent = $contents.not('.hide'); 14 +var $curContent = $contents.not('.hide'),
  15 + $curClickSubLevel;
15 16
16 var navHammer, ccHammer; 17 var navHammer, ccHammer;
17 18
@@ -68,4 +69,15 @@ ccHammer.on('tap', function(e) { @@ -68,4 +69,15 @@ ccHammer.on('tap', function(e) {
68 $subLevel.not('.hide').addClass('hide'); 69 $subLevel.not('.hide').addClass('hide');
69 $subLevel.eq(index).removeClass('hide'); 70 $subLevel.eq(index).removeClass('hide');
70 } 71 }
  72 +});
  73 +
  74 +$('.sub-level').bind('touchend', function(e) {
  75 + var $cur = $(e.target);
  76 +
  77 + $cur.addClass('a-highlight');
  78 +
  79 + if ($curClickSubLevel) {
  80 + $curClickSubLevel.removeClass('a-highlight');
  81 + }
  82 + $curClickSubLevel = $cur;
71 }); 83 });
@@ -94,6 +94,20 @@ $subNav.each(function () { @@ -94,6 +94,20 @@ $subNav.each(function () {
94 } 94 }
95 }); 95 });
96 96
  97 +$sideNav.children('ul').children('li').on('touchstart', function() {
  98 + $sideNav.children('ul').children('li').css('background', '#fff');
  99 + $(this).css('background', '#eee');
  100 +}).on('touchend touchcancel', function() {
  101 + $(this).css('background', '#fff');
  102 +});
  103 +
  104 +// $sideNav.children('ul').children('li').each(function() {
  105 +// var liHammer = new Hammer($(this)[0]);
  106 +// liHammer.on('', function() {
  107 +
  108 +// });
  109 +// });
  110 +
97 //头部banner轮播 111 //头部banner轮播
98 if ($('.banner-swiper').find('li').size() > 1) { 112 if ($('.banner-swiper').find('li').size() > 1) {
99 bannerSwiper = new Swiper('.banner-swiper', { 113 bannerSwiper = new Swiper('.banner-swiper', {
@@ -8,7 +8,8 @@ var $ = require('jquery'); @@ -8,7 +8,8 @@ var $ = require('jquery');
8 var $searchBox = $('.search-box'), 8 var $searchBox = $('.search-box'),
9 $box = $('.box'), 9 $box = $('.box'),
10 $indexSearch = $('.index-search'), 10 $indexSearch = $('.index-search'),
11 - $indexLogo = $('.index-logo'); 11 + $indexLogo = $('.index-logo'),
  12 + $channelLink = $('.index-channel a');
12 13
13 var $search = $searchBox.children('input[type="text"]'), 14 var $search = $searchBox.children('input[type="text"]'),
14 $cancelSearch = $box.children('.no-search'), 15 $cancelSearch = $box.children('.no-search'),
@@ -42,6 +43,25 @@ $searchBox.children('.search-icon').on('touchstart', function() { @@ -42,6 +43,25 @@ $searchBox.children('.search-icon').on('touchstart', function() {
42 $indexSearch.submit(); 43 $indexSearch.submit();
43 }); 44 });
44 45
45 -$('.index-channel img').on('load', function() {  
46 - window.rePosFooter(); 46 +$channelLink.on('touchstart', function() {
  47 + $channelLink.css({
  48 + background: '#000',
  49 + color: '#fff',
  50 + borderColor: '#fff'
  51 + });
  52 + $(this).css({
  53 + background: 'rgba(255, 255, 255, 0.5)',
  54 + color: '#000',
  55 + borderColor: '#000'
  56 + });
  57 +}).on('touchend touchcancel', function() {
  58 + $(this).css({
  59 + background: '#000',
  60 + color: '#fff',
  61 + borderColor: '#fff'
  62 + });
  63 +});
  64 +
  65 +$('.index-channel img').on('load error', function() {
  66 + window.rePosFooter && window.rePosFooter();
47 }); 67 });
@@ -99,7 +99,6 @@ @@ -99,7 +99,6 @@
99 background: #fff; 99 background: #fff;
100 width: 60%; 100 width: 60%;
101 height: 100%; 101 height: 100%;
102 - overflow: auto;  
103 } 102 }
104 103
105 .sub-level { 104 .sub-level {
@@ -126,4 +125,8 @@ @@ -126,4 +125,8 @@
126 color: #000; 125 color: #000;
127 } 126 }
128 } 127 }
  128 +
  129 + .a-highlight {
  130 + text-decoration: underline;
  131 + }
129 } 132 }
@@ -10,13 +10,11 @@ @@ -10,13 +10,11 @@
10 line-height: 96rem / $pxConvertRem; 10 line-height: 96rem / $pxConvertRem;
11 11
12 .index-logo { 12 .index-logo {
13 - display: table-cell;  
14 float: left; 13 float: left;
15 - font-size: 50rem / $pxConvertRem;  
16 width: 216rem / $pxConvertRem; 14 width: 216rem / $pxConvertRem;
17 height: 96rem / $pxConvertRem; 15 height: 96rem / $pxConvertRem;
18 - color: #343434;  
19 - vertical-align: middle; 16 + background: url(../img/yohologo.png) left center no-repeat;
  17 + background-size: 104px 25px;
20 opacity: 1; 18 opacity: 1;
21 transition: all 400ms; 19 transition: all 400ms;
22 20
  1 +.mine-page {
  2 + .user-info {
  3 + padding: 0 30rem / $pxConvertRem;
  4 + color: #fff;
  5 + background: #ccc;
  6 + font-size: 34rem / $pxConvertRem;
  7 + line-height: 164rem / $pxConvertRem;
  8 + height: 164rem / $pxConvertRem;
  9 + .user-avatar {
  10 + display: inline;
  11 + }
  12 + }
  13 +}
1 -@import "vip-grade";  
  1 +@import "home", "vip-grade";
  1 +{{> layout/header}}
  2 + <div class="mine-page yoho-page">
  3 + <div class="mine-header">
  4 + <div class="user-info">
  5 + <img class="user-avatar" src="{{head_ico}}">
  6 + <span class="username">{{profile_name}}</span>
  7 + {{#user_info}}
  8 + <span class="user-level user-level-{{cur_level}}"></span>
  9 + {{/user_info}}
  10 + </div>
  11 + <div class="iconfont more-icon">2</div>
  12 + </div>
  13 + </div>
  14 +{{> layout/footer}}
@@ -3,7 +3,6 @@ @@ -3,7 +3,6 @@
3 <div class="index-container"> 3 <div class="index-container">
4 <div class="index-header clearfix"> 4 <div class="index-header clearfix">
5 <div class="index-logo"> 5 <div class="index-logo">
6 - <img src="http://static.dev.yohobuy.com/img/yohologo.png">  
7 </div> 6 </div>
8 <div class="box"> 7 <div class="box">
9 <a href="javascript:void(0);" class="no-search">取消</a> 8 <a href="javascript:void(0);" class="no-search">取消</a>
1 <?php 1 <?php
2 2
3 use Action\AbstractAction; 3 use Action\AbstractAction;
  4 +use Plugin\Helpers;
4 5
5 /** 6 /**
6 * 个人中心相关的控制器 7 * 个人中心相关的控制器
@@ -18,8 +19,125 @@ class HomeController extends AbstractAction @@ -18,8 +19,125 @@ class HomeController extends AbstractAction
18 */ 19 */
19 public function indexAction() 20 public function indexAction()
20 { 21 {
21 - // 目前跳到老站  
22 - // $this->go(OLD_MAIN . '/home'); 22 + // $uid = $uid = $this->getUid();
  23 + $uid = 967016;
  24 +
  25 + $data = \Index\UserModel::getUserProfileData($uid);
  26 +
  27 + // print_r($data);
  28 + $data['homeHeader'] = array('searchUrl' => Helpers::url('/search', null, 'search'));
  29 + $data['pageFooter'] = true;
  30 +
  31 + // 设置网站标题
  32 + $this->setTitle('男生首页');
  33 +
  34 + $this->_view->display('index', $data);
23 } 35 }
  36 +
  37 + /**
  38 + * 用户订单
  39 + */
  40 + public function ordersAction()
  41 + {
  42 + $uid = $this->getUid();
  43 + $type = $this->get('type', 1);
  44 +
  45 + $orders = \Index\UserModel::getUserOrderData(967016, $type);
  46 +
  47 + print_r($orders);
  48 + }
  49 +
  50 + /**
  51 + * 用户收藏的商品
  52 + */
  53 + public function favoriteAction()
  54 + {
  55 + $uid = $this->getUid();
  56 +
  57 + $favProducts = \Index\UserModel::getFavProductData($uid);
  58 +
  59 + print_r($favProducts);
  60 + }
  61 +
  62 + /**
  63 + * 用户收藏的品牌
  64 + */
  65 + public function favoritebrandAction()
  66 + {
  67 + $uid = $this->getUid();
  68 + $gender = Helpers::getGenderByCookie();
  69 +
  70 + $favBrands = \Index\UserModel::getFavBrandData($uid, $gender);
  71 +
  72 + print_r($favBrands);
  73 + }
  74 +
  75 + /**
  76 + * YOHO币
  77 + */
  78 + public function currencyAction()
  79 + {
  80 + $uid = $this->getUid();
  81 +
  82 + $favBrands = \Index\UserModel::getYohoCoinData($uid);
  83 +
  84 + print_r($favBrands);
  85 + }
  86 +
  87 + /**
  88 + * 优惠券
  89 + */
  90 + public function couponsAction()
  91 + {
  92 + $uid = $this->getUid();
  93 + $status = $this->get('status', 0);
  94 +
  95 + $coupons = \Index\UserModel::getCouponData($uid, $status);
  96 +
  97 + print_r($coupons);
  98 + }
  99 +
  100 + /**
  101 + * 地址管理
  102 + */
  103 + public function addressAction()
  104 + {
  105 + $uid = $this->getUid();
  106 +
  107 + $address = \Index\UserModel::getAddressData($uid);
  108 +
  109 + print_r($address);
  110 + }
  111 +
  112 + /**
  113 + * 意见反馈
  114 + */
  115 + public function suggestAction()
  116 + {
  117 + $udid = $this->getUdid();
  118 + $page = $this->get('page', 1);
  119 + $limit = $this->get('limit', 30);
  120 +
  121 + $suggest = \Index\UserModel::getSuggestData($udid, $page, $limit);
  122 +
  123 + print_r($suggest);
  124 + }
  125 +
  126 + /**
  127 + * 异步保存意见反馈数据
  128 + */
  129 + public function savesuggestAction()
  130 + {
  131 + if($this->isAjax()) {
  132 + $uid = $this->getUid();
  133 + $content = $this->post('content', '');
  134 + $suggest_type = $this->get('suggest_type', 2);
  135 +
  136 + $result = \Index\UserModel::saveSuggestData($uid, $content, $suggest_type);
  137 +
  138 + $this->echoJson($result);
  139 + }
  140 +
  141 + }
24 142
25 } 143 }
@@ -9,80 +9,17 @@ class ShoppingCartController extends AbstractAction @@ -9,80 +9,17 @@ class ShoppingCartController extends AbstractAction
9 { 9 {
10 public function indexAction() 10 public function indexAction()
11 { 11 {
  12 + $this->setTitle('购物车');
  13 + $this->setNavHeader('购物车');
  14 +
  15 + $uid = $this->getUid();
12 $data = array( 16 $data = array(
13 - 'cartNav' => true,  
14 - 'commonGoodsCount' => 2,  
15 - 'presellGoodsCount' => 2,  
16 - 'showLoginInfo' => true,  
17 - 'commonCart' => array(  
18 - 'goods' => array(  
19 - array(  
20 - 'id' => 1,  
21 - 'name' => '黄伟文Wyman X y yohood 联名商品YYYOHOOD圆领卫衣',  
22 - 'thumb' => 'http://img11.static.yhbimg.com/goodsimg/2015/09/17/03/014cacfa5c458b9732c68adf1af15d7a45.jpg?imageMogr2/thumbnail/120x120/extent/120x120/background/d2hpdGU=/position/center/quality/90',  
23 - 'color' => '黄色',  
24 - 'size' => 'F',  
25 - 'appearDate' => '12月',  
26 - 'price' => 399.00,  
27 - 'count' => 8,  
28 - 'lowStocks' => true  
29 - ),  
30 - array(  
31 - 'id' => 2,  
32 - 'name' => 'TYAKSHA圣诞树凭借三角领蓝色白条毛衣',  
33 - 'thumb' => 'http://img11.static.yhbimg.com/goodsimg/2015/10/03/10/01bc1878f9154e77ac4f7a6003c954f1b8.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',  
34 - 'color' => '黄色',  
35 - 'size' => 'F',  
36 - 'price' => 553.00,  
37 - 'count' => 1,  
38 - 'soldOut' => true  
39 - )  
40 - ),  
41 - 'freebieOrAdvanceBuy' => true,  
42 - 'freebie' => array(  
43 - 'url' => '',  
44 - 'count' => 2  
45 - ),  
46 - 'advanceBuy' => array(  
47 - 'url' => '',  
48 - 'count' => 3  
49 - ),  
50 - 'price' => 3192,  
51 - 'activityPrice' => 0,  
52 - 'count' => 8,  
53 - 'sumPrice' => 3192  
54 - ),  
55 - 'preSellCart' => array(  
56 - 'goods' => array(  
57 - array(  
58 - 'id' => 2,  
59 - 'name' => 'TYAKSHA圣诞树凭借三角领蓝色白条毛衣',  
60 - 'thumb' => 'http://img11.static.yhbimg.com/goodsimg/2015/10/03/10/01bc1878f9154e77ac4f7a6003c954f1b8.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',  
61 - 'color' => '黄色',  
62 - 'size' => 'F',  
63 - 'price' => 553.00,  
64 - 'count' => 1,  
65 - 'soldOut' => true  
66 - )  
67 - ),  
68 - 'freebieOrAdvanceBuy' => true,  
69 - 'freebie' => array(  
70 - 'url' => '',  
71 - 'count' => 2  
72 - ),  
73 - 'advanceBuy' => array(  
74 - 'url' => '',  
75 - 'count' => 3  
76 - ),  
77 - 'price' => 553,  
78 - 'activityPrice' => 0,  
79 - 'count' => 1,  
80 - 'sumPrice' => 553  
81 - ) 17 + 'shoppingCartPage' => true,
  18 + 'shoppingCart' => \Index\CartModel::getCartData($uid)
82 ); 19 );
  20 +
83 // 渲染模板 21 // 渲染模板
84 - $this->_view->display('index', array('shoppingCartPage' => true, 'pageHeader' => array(  
85 - 'navBack' => 'http://m.yohobuy.com', 'navTitle' => '购物车'), 'shoppingCart' => $data)); 22 + $this->_view->display('index', $data);
86 } 23 }
87 24
88 public function giftAdvanceAction() 25 public function giftAdvanceAction()
  1 +<?php
  2 +
  3 +namespace Index;
  4 +
  5 +use LibModels\Wap\Home\CartData;
  6 +use Plugin\Images;
  7 +
  8 +/**
  9 + *
  10 + * @name CartModel
  11 + * @package models/Index
  12 + * @copyright yoho.inc
  13 + * @version 1.0 (2015-11-09 14:05:09)
  14 + * @author Gtskk (tttt6399998@126.com)
  15 + */
  16 +class CartModel
  17 +{
  18 +
  19 + /**
  20 + * @param integer $uid 用户ID
  21 + * @return array|mixed 处理之后的购物车数据
  22 + */
  23 + public static function getCartData($uid)
  24 + {
  25 + $result = array(
  26 + 'cartNav' => true,
  27 + 'showLoginInfo' => true
  28 + );
  29 +
  30 + // 调用接口获取购物车的数据
  31 + $cartData = CartData::cartData($uid);
  32 +
  33 + // 处理普通购物车和预售购物车的数据
  34 + if (isset($cartData['data']) && !empty($cartData['data'])) {
  35 + $cart = $cartData['data'];
  36 +
  37 + /* 普通购物车 */
  38 + if(isset($cart['ordinary_cart_data'])) {
  39 + $result['commonGoodsCount'] = count($cart['ordinary_cart_data']['goods_list']);
  40 + $result['commonCart'] = self::procCartData($cart['ordinary_cart_data']);
  41 + }
  42 +
  43 + /* 预售购物车 */
  44 + if(isset($cart['advance_cart_data'])) {
  45 + $result['presellGoodsCount'] = count($cart['advance_cart_data']['goods_list']);
  46 + $result['preSellCart'] = self::procCartData($cart['advance_cart_data']);
  47 + }
  48 +
  49 + }
  50 +
  51 + return $result;
  52 + }
  53 +
  54 +
  55 + /**
  56 + * 处理不同类型的购物车数据
  57 + *
  58 + * @param array $data 不同类型购物车数据
  59 + * @return array $result 处理之后的不同类型购物车数据
  60 + */
  61 + private static function procCartData($data)
  62 + {
  63 + $result = array();
  64 +
  65 + $oneGoods = array();
  66 + // 购买的商品列表
  67 + foreach ($data['goods_list'] as $value) {
  68 + $oneGoods['id'] = $value['product_id'];
  69 + $oneGoods['name'] = $value['product_name'];
  70 + $oneGoods['thumb'] = Images::getImageUrl($value['goods_images'], 120, 120);
  71 + $oneGoods['color'] = $value['color_name'];
  72 + $oneGoods['size'] = $value['size_name'];
  73 + $oneGoods['appearDate'] = '12月'; // 目前app接口没有返回该数据
  74 + $oneGoods['price'] = $value['real_price'];
  75 + $oneGoods['count'] = $value['buy_number'];
  76 + $oneGoods['lowStocks'] = true;
  77 +
  78 + $result['goods'][] = $oneGoods;
  79 + }
  80 + // 赠品
  81 + count($data['gift_list']) && $result['freebieOrAdvanceBuy'] = true;
  82 + $result['freebie'] = $data['gift_list'];
  83 + // 加价购
  84 + $result['advanceBuy'] = $data['price_gift'];
  85 + // 结算数据
  86 + $result['price'] = $data['shopping_cart_data']['order_amount'];
  87 + $result['activityPrice'] = $data['shopping_cart_data']['discount_amount'];
  88 + $result['count'] = $data['shopping_cart_data']['goods_count'];
  89 + $result['sumPrice'] = $data['shopping_cart_data']['order_amount'];
  90 +
  91 + return $result;
  92 + }
  93 +
  94 +}
  1 +<?php
  2 +
  3 +namespace Index;
  4 +
  5 +use LibModels\Wap\Home\UserData;
  6 +use Plugin\Images;
  7 +
  8 +/**
  9 + *
  10 + * @name UserModel
  11 + * @package models/Index
  12 + * @copyright yoho.inc
  13 + * @version 1.0 (2015-11-09 14:05:09)
  14 + * @author Gtskk (tttt6399998@126.com)
  15 + */
  16 +class UserModel
  17 +{
  18 +
  19 + /**
  20 + * 处理用户个人详情数据
  21 + *
  22 + * @param int $uid 用户ID
  23 + * @return array|mixed 处理之后的个人详情数据
  24 + */
  25 + public static function getUserProfileData($uid)
  26 + {
  27 + $result = array();
  28 +
  29 + // 调用接口获取个人详情
  30 + $userData = UserData::userData($uid);
  31 +
  32 + // 处理个人详情数据
  33 + if (isset($userData['data']) && !empty($userData['data'])) {
  34 + $result = $userData['data'];
  35 +
  36 + $result['head_ico'] = Images::getImageUrl($result['head_ico'], 150, 150);
  37 + }
  38 +
  39 + return $result;
  40 + }
  41 +
  42 + /**
  43 + * 处理用户订单数据
  44 + *
  45 + * @param int $uid 用户ID
  46 + * @param int $type 订单类型,1表示全部,2表示待付款,3表示待发货,4表示待收货,5表示待评价
  47 + * @return array|mixed 处理之后的个人详情数据
  48 + */
  49 + public static function getUserOrderData($uid, $type)
  50 + {
  51 + $result = array();
  52 +
  53 + // 调用接口获取用户订单数据
  54 + $orderData = UserData::orderData($uid, $type);
  55 +
  56 + // 处理用户订单数据
  57 + if (isset($orderData['data']) && !empty($orderData['data'])) {
  58 + $result = $orderData['data'];
  59 + }
  60 +
  61 + return $result;
  62 + }
  63 +
  64 + /**
  65 + * 处理用户收藏的商品数据
  66 + *
  67 + * @param int $uid 用户ID
  68 + * @return array|mixed 处理之后的收藏的商品数据
  69 + */
  70 + public static function getFavProductData($uid)
  71 + {
  72 + $result = array();
  73 +
  74 + // 调用接口获取用户收藏的商品数据
  75 + $favProduct = UserData::favoriteProductData($uid);
  76 +
  77 + // 处理用户收藏的商品数据
  78 + if (isset($favProduct['data']) && !empty($favProduct['data'])) {
  79 + $result = $favProduct['data'];
  80 + }
  81 +
  82 + return $result;
  83 + }
  84 +
  85 + /**
  86 + * 处理用户收藏的品牌数据
  87 + *
  88 + * @param int $uid 用户ID
  89 + * @param string $gender 性别 1,3表示男,2,3表示女,1,2,3表示全部
  90 + * @return array|mixed 处理之后的收藏的品牌数据
  91 + */
  92 + public static function getFavBrandData($uid, $gender)
  93 + {
  94 + $result = array();
  95 +
  96 + // 调用接口获取户收藏的品牌数据
  97 + $favBrand = UserData::favoriteBrandData($uid, $gender);
  98 +
  99 + // 处理用户收藏的品牌数据
  100 + if (isset($favBrand['data']) && !empty($favBrand['data'])) {
  101 + $result = $favBrand['data'];
  102 + }
  103 +
  104 + return $result;
  105 + }
  106 +
  107 + /**
  108 + * 处理YOHO币数据
  109 + *
  110 + * @param int $uid 用户ID
  111 + * @return array|mixed 处理之后的YOHO币数据
  112 + */
  113 + public static function getYohoCoinData($uid)
  114 + {
  115 + $result = array();
  116 +
  117 + // 调用接口获取YOHO币
  118 + $yohoCoin = UserData::yohoCoinData($uid);
  119 +
  120 + // 处理YOHO币数据
  121 + if (isset($yohoCoin['data']) && !empty($yohoCoin['data'])) {
  122 + $result = $yohoCoin['data'];
  123 + }
  124 +
  125 + return $result;
  126 + }
  127 +
  128 + /**
  129 + * 处理优惠券数据
  130 + *
  131 + * @param int $uid 用户ID
  132 + * @return array|mixed 处理之后的优惠券数据
  133 + */
  134 + public static function getCouponData($uid, $status)
  135 + {
  136 + $result = array();
  137 +
  138 + // 调用接口获取优惠券数据
  139 + $coupons = UserData::couponData($uid, $status);
  140 +
  141 + // 处理优惠券数据
  142 + if (isset($coupons['data']) && !empty($coupons['data'])) {
  143 + $result = $coupons['data'];
  144 + }
  145 +
  146 + return $result;
  147 + }
  148 +
  149 + /**
  150 + * 处理地址数据
  151 + *
  152 + * @param int $uid 用户ID
  153 + * @return array|mixed 处理之后的地址数据
  154 + */
  155 + public static function getAddressData($uid)
  156 + {
  157 + $result = array();
  158 +
  159 + // 调用接口获取地址数据
  160 + $address = UserData::addressData($uid);
  161 +
  162 + // 处理地址数据
  163 + if (isset($address['data']) && !empty($address['data'])) {
  164 + $result = $address['data'];
  165 + }
  166 +
  167 + return $result;
  168 + }
  169 +
  170 + /**
  171 + * 处理意见反馈数据
  172 + *
  173 + * @param string $udid 客户端唯一标识
  174 + * @param int $page 第几页,默认1
  175 + * @param int $limit 限制读取的数目,默认10
  176 + * @return array|mixed 处理之后的意见反馈数据
  177 + */
  178 + public static function getSuggestData($udid, $page, $limit)
  179 + {
  180 + $result = array();
  181 +
  182 + // 调用接口获取地址数据
  183 + $suggest = UserData::suggestData($udid, $page, $limit);
  184 + print_r($suggest);
  185 +
  186 + // 处理意见反馈数据
  187 + if (isset($suggest['data']) && !empty($suggest['data'])) {
  188 + $result = $suggest['data'];
  189 + }
  190 +
  191 + return $result;
  192 + }
  193 +
  194 + /**
  195 + * 保存意见反馈数据
  196 + *
  197 + * @param int $uid 用户ID
  198 + * @param string $content 意见内容
  199 + * @param int $suggest_type 意见类型
  200 + * @return array|mixed 保存意见反馈数据之后的返回
  201 + */
  202 + public static function saveSuggestData($uid, $content, $suggest_type)
  203 + {
  204 + $result = array();
  205 +
  206 + // 调用接口保存意见反馈数据
  207 + return UserData::savesuggestData($uid, $content, $suggest_type);
  208 + }
  209 +
  210 +}
@@ -226,6 +226,24 @@ class NewsaleModel @@ -226,6 +226,24 @@ class NewsaleModel
226 return $result; 226 return $result;
227 } 227 }
228 228
  229 + /**
  230 + * 筛选出来的热销排行榜商品数据处理
  231 + *
  232 + * @param array $data 筛选出来的原数据
  233 + * @return array 处理之后的数据
  234 + */
  235 + public static function selectTopData($data)
  236 + {
  237 + $result = array();
  238 +
  239 + if (isset($data['code']) && $data['code'] === 200 && isset($data['data']['product_list'])) {
  240 + $result = NewSaleProcess::newSaleData($data['data']);
  241 + unset($result['filter']);
  242 + }
  243 +
  244 + return $result;
  245 + }
  246 +
229 247
230 /** 248 /**
231 * 获取筛选数据 249 * 获取筛选数据
@@ -79,23 +79,48 @@ class NewsaleController extends AbstractAction @@ -79,23 +79,48 @@ class NewsaleController extends AbstractAction
79 $this->setTitle('热销排行榜'); 79 $this->setTitle('热销排行榜');
80 $this->setNavHeader('热销排行榜'); 80 $this->setNavHeader('热销排行榜');
81 81
  82 + $channel = Helpers::getChannelByCookie();
82 // 设置一些默认参数 83 // 设置一些默认参数
83 $data = array( 84 $data = array(
84 'discountPage' => true, 85 'discountPage' => true,
  86 + 'headerBanner' => \Product\NewsaleModel::getNewFocus($channel),
85 'showDownloadApp' => true, 87 'showDownloadApp' => true,
86 'pageFooter' => true, 88 'pageFooter' => true,
87 - 'brand' => '0',  
88 - 'sort' => '0',  
89 - 'gender' => Helpers::getGenderByCookie(),  
90 - 'price' => '0',  
91 - 'size' => '0',  
92 - 'discount' => '0.1,0.9',  
93 'cartUrl' => Helpers::url('/cart/index/index', null), 89 'cartUrl' => Helpers::url('/cart/index/index', null),
94 ); 90 );
95 91
96 $this->_view->display('hotrank', $data); 92 $this->_view->display('hotrank', $data);
97 } 93 }
98 94
  95 + /**
  96 + * Ajax方式获取热销排行榜商品
  97 + *
  98 + * @return array 根据指定条件筛选之后的商品
  99 + */
  100 + public function selectHotrankAction()
  101 + {
  102 + $result = array();
  103 +
  104 + if ($this->isAjax()) {
  105 + $sort = $this->get('sort', null);
  106 + $tab_id = $this->get('tab_id', null);
  107 + $limit = $this->get('limit', 50);
  108 + $page = $this->get('page', 1);
  109 +
  110 + // 获取性别
  111 + $gender = Helpers::getGenderByCookie();
  112 +
  113 + $data = NewsaleData::getTopProducts($gender, $sort, $tab_id, $limit, $page);
  114 + $result = \Product\NewsaleModel::selectTopData($data);
  115 + }
  116 +
  117 + if (empty($result)) {
  118 + echo ' ';
  119 + } else {
  120 + $this->_view->display('product', $result);
  121 + }
  122 + }
  123 +
99 /** 124 /**
100 * Ajax方式筛选新品到着、折扣专区商品 125 * Ajax方式筛选新品到着、折扣专区商品
101 * 126 *