Authored by yangyang

解决冲突

@@ -939,14 +939,27 @@ @@ -939,14 +939,27 @@
939 ### 我的订单 939 ### 我的订单
940 { 940 {
941 order: { 941 order: {
942 - orders: [ 942 + navs: [
  943 + {
  944 + name: '',
  945 + active: true,
  946 + typeId: 1
  947 + },
943 ... 948 ...
944 - ],  
945 - //没有订单的情况不传orders  
946 - walkWayUrl: '' //随便逛逛url 949 + ]
947 } 950 }
948 } 951 }
949 952
  953 + //订单列表
  954 + {
  955 + orders: [
  956 + {
  957 + ...//订单
  958 + }
  959 + ]
  960 + //当无订单时,不传order,返回walkwayUrl
  961 + walkWayUrl: ''
  962 + }
950 963
951 //订单 964 //订单
952 { 965 {
@@ -11,36 +11,41 @@ var $ = require('jquery'), @@ -11,36 +11,41 @@ var $ = require('jquery'),
11 var $navLi = $('#order-nav > li'), 11 var $navLi = $('#order-nav > li'),
12 $orderContainer = $('#order-container'); 12 $orderContainer = $('#order-container');
13 13
14 -var $curContainer = $orderContainer.children('.orders').first();//保存当前显示的order-container 14 +var $curContainer = $orderContainer.children('.orders:not(.hide)');//保存当前显示的order-container
15 15
16 var winH = $(window).height(); 16 var winH = $(window).height();
17 17
18 -var activeIndex = 0; //当前active的项的index 18 +var activeType = $navLi.filter('.active').data('type'); //当前active的项的index
19 19
20 -var orderPage = [1, 0, 0, 0]; 20 +var orderPage = {};
21 21
22 -var loading = false; 22 +var inAjax = false;
  23 +
  24 +var loading = require('../plugin/loading');
23 25
24 var navHammer, orderHammer; 26 var navHammer, orderHammer;
25 27
26 //加载订单 28 //加载订单
27 function getOrders() { 29 function getOrders() {
28 var opt = { 30 var opt = {
29 - type: activeIndex + 1,  
30 - page: orderPage[activeIndex] + 1  
31 - },  
32 - num; 31 + type: activeType,
  32 + page: orderPage[activeType] ? (orderPage[activeType] + 1) : 1
  33 + };
33 34
34 - if (loading) { 35 + if (inAjax) {
35 return; 36 return;
36 } 37 }
37 38
  39 + inAjax = true;
  40 + loading.show();
38 41
39 $.ajax({ 42 $.ajax({
40 type: 'GET', 43 type: 'GET',
41 url: '/home/getOrders', 44 url: '/home/getOrders',
42 data: opt, 45 data: opt,
43 success: function(data) { 46 success: function(data) {
  47 + var num;
  48 +
44 if (data.code === 200) { 49 if (data.code === 200) {
45 orderPage[opt.type] = opt.page; 50 orderPage[opt.type] = opt.page;
46 51
@@ -55,35 +60,54 @@ function getOrders() { @@ -55,35 +60,54 @@ function getOrders() {
55 lazyLoad($curContainer.children('.order:gt(' + (num - 1) + ') .lazy')); 60 lazyLoad($curContainer.children('.order:gt(' + (num - 1) + ') .lazy'));
56 } 61 }
57 } 62 }
  63 +
  64 + inAjax = false;
  65 + loading.hide();
58 } 66 }
59 }); 67 });
60 } 68 }
61 69
62 lazyLoad(); 70 lazyLoad();
63 71
  72 +//初始化导航
  73 +(function() {
  74 + var liCount = $navLi.length;
  75 +
  76 + //默认4个导航项
  77 + if (liCount === 4) {
  78 + return;
  79 + }
  80 +
  81 + $navLi.width(100 / liCount + '%');
  82 +}());
  83 +
  84 +loading.init();
  85 +
64 //导航切换 86 //导航切换
65 navHammer = new Hammer(document.getElementById('order-nav')); 87 navHammer = new Hammer(document.getElementById('order-nav'));
66 navHammer.on('tap', function(e) { 88 navHammer.on('tap', function(e) {
67 - var $cur = $(e.target).closest('li'); 89 + var $cur = $(e.target).closest('li'),
  90 + index;
68 91
69 if ($cur.length === 0 || $cur.hasClass('active')) { 92 if ($cur.length === 0 || $cur.hasClass('active')) {
70 return; 93 return;
71 } 94 }
72 95
73 - activeIndex = +$cur.index(); 96 + index = $cur.index();
74 97
75 $navLi.filter('.active').removeClass('active'); 98 $navLi.filter('.active').removeClass('active');
76 $cur.addClass('active'); 99 $cur.addClass('active');
77 100
78 $curContainer.addClass('hide'); 101 $curContainer.addClass('hide');
79 - $curContainer = $orderContainer.children(':eq(' + activeIndex + ')').removeClass('hide'); 102 + $curContainer = $orderContainer.children(':eq(' + index + ')').removeClass('hide');
  103 +
  104 + activeType = $cur.data('type');
80 105
81 - if (orderPage[activeIndex] > 0) { 106 + if (orderPage[activeType]) {
82 return; 107 return;
83 } else { 108 } else {
84 getOrders(); 109 getOrders();
85 } 110 }
86 -  
87 }); 111 });
88 112
89 //点击订单区域跳转订单详情页 113 //点击订单区域跳转订单详情页
@@ -109,6 +133,13 @@ orderHammer.on('tap', function(e) { @@ -109,6 +133,13 @@ orderHammer.on('tap', function(e) {
109 url: '/home/delOrder', 133 url: '/home/delOrder',
110 data: { 134 data: {
111 id: id 135 id: id
  136 + },
  137 + success: function(data) {
  138 + if (data.code === 200) {
  139 +
  140 + //删除订单页面刷新
  141 + location.href = location.href;
  142 + }
112 } 143 }
113 }); 144 });
114 } else if ($cur.closest('.cancel').length > 0) { 145 } else if ($cur.closest('.cancel').length > 0) {
@@ -119,6 +150,13 @@ orderHammer.on('tap', function(e) { @@ -119,6 +150,13 @@ orderHammer.on('tap', function(e) {
119 url: '/home/cancelOrder', 150 url: '/home/cancelOrder',
120 data: { 151 data: {
121 id: id 152 id: id
  153 + },
  154 + success: function(data) {
  155 + if (data.code === 200) {
  156 +
  157 + //取消订单
  158 + alert('order cancel');
  159 + }
122 } 160 }
123 }); 161 });
124 } else { 162 } else {
@@ -135,3 +173,6 @@ $(window).scroll(function() { @@ -135,3 +173,6 @@ $(window).scroll(function() {
135 getOrders(); 173 getOrders();
136 } 174 }
137 }); 175 });
  176 +
  177 +//初始化请求第一页数据
  178 +getOrders();
@@ -30,26 +30,15 @@ function hotrank(page, sort, tabId, notab) { @@ -30,26 +30,15 @@ function hotrank(page, sort, tabId, notab) {
30 lazyLoad($('img.lazy')); 30 lazyLoad($('img.lazy'));
31 $('#yoho-footer').css('position', 'static'); 31 $('#yoho-footer').css('position', 'static');
32 $('.rank-main ul li:gt(2)').find('.item-content i').removeClass('top'); 32 $('.rank-main ul li:gt(2)').find('.item-content i').removeClass('top');
  33 + winH = $(window).height();
  34 + if ($('.rank-main').length !== 0) {
  35 + listTop = $('.rank-main').find('ul').offset().top;
  36 + }
33 navSwiper = new Swiper('.s-goods-nav', { 37 navSwiper = new Swiper('.s-goods-nav', {
34 grabCursor: true, 38 grabCursor: true,
35 slidesPerView: 'auto', 39 slidesPerView: 'auto',
36 slideElement: 'li' 40 slideElement: 'li'
37 }); 41 });
38 -  
39 - winH = $(window).height();  
40 - listTop = $('.rank-main').find('ul').offset().top;  
41 - $('.s-goods-nav .nav-item').each(function(index) {  
42 - hotnav = new Hammer($('.s-goods-nav .nav-item')[index]);  
43 - hotnav.on('tap', function(e) {  
44 - var navItme = $('.s-goods-nav .nav-item').eq(index);  
45 -  
46 - id = navItme.data('id') ? navItme.data('id') : '';  
47 - sort = navItme.data('sort') ? navItme.data('sort') : '';  
48 - page = 1;  
49 - notab = 1;  
50 - hotrank(page, sort, id, notab);  
51 - });  
52 - });  
53 } 42 }
54 }); 43 });
55 } 44 }
@@ -67,3 +56,18 @@ $(window).scroll(function () { @@ -67,3 +56,18 @@ $(window).scroll(function () {
67 56
68 }); 57 });
69 hotrank(page, sort, id, notab); 58 hotrank(page, sort, id, notab);
  59 +hotnav = new Hammer(document.getElementById('hotRank'));
  60 +hotnav.on('tap', function (e) {
  61 + var ev = ev || window.event;
  62 + var target = ev.target || ev.srcElement;
  63 +
  64 + if (target.nodeName.toLowerCase() === 'span') {
  65 + $('.s-goods-nav .nav-item').removeClass('active');
  66 + target.parentNode.className = 'active ' + target.parentNode.className;
  67 + id = target.getAttribute('data-id') ? target.getAttribute('data-id') : '';
  68 + sort = target.getAttribute('data-sort') ? target.getAttribute('data-sort') : '';
  69 + page = 1;
  70 + notab = 1;
  71 + hotrank(page, sort, id, notab);
  72 + }
  73 +})
@@ -74,7 +74,7 @@ @@ -74,7 +74,7 @@
74 overflow: hidden; 74 overflow: hidden;
75 white-space: nowrap; 75 white-space: nowrap;
76 76
77 - span { 77 + b {
78 text-decoration: line-through; 78 text-decoration: line-through;
79 color: #b0b0b0; 79 color: #b0b0b0;
80 margin-left: 10rem / $pxConvertRem; 80 margin-left: 10rem / $pxConvertRem;
@@ -125,12 +125,20 @@ @@ -125,12 +125,20 @@
125 } 125 }
126 126
127 .s-goods-nav { 127 .s-goods-nav {
  128 + box-sizing:border-box;
  129 + -moz-box-sizing:border-box;
  130 + -webkit-box-sizing:border-box;
128 overflow: hidden; 131 overflow: hidden;
129 132
130 li { 133 li {
131 margin: 0 0 0 (50rem / $pxConvertRem); 134 margin: 0 0 0 (50rem / $pxConvertRem);
132 width: auto; 135 width: auto;
133 - 136 + height: 95%;
  137 + color: #999;
  138 + &.active{
  139 + color: #000;
  140 + border-bottom:2px solid #000;
  141 + }
134 a { 142 a {
135 padding: 0; 143 padding: 0;
136 } 144 }
@@ -2,27 +2,17 @@ @@ -2,27 +2,17 @@
2 <div class="order-page yoho-page"> 2 <div class="order-page yoho-page">
3 {{# order}} 3 {{# order}}
4 <ul id="order-nav" class="order-nav clearfix"> 4 <ul id="order-nav" class="order-nav clearfix">
5 - <li class="active">  
6 - 全部  
7 - </li>  
8 - <li>  
9 - 待付款  
10 - </li>  
11 - <li>  
12 - 待发货  
13 - </li>  
14 - <li>  
15 - 待收货 5 + {{#each navs}}
  6 + <li {{#if active}}class="active"{{/if}} data-type="{{typeId}}">
  7 + {{name}}
16 </li> 8 </li>
  9 + {{/each}}
17 </ul> 10 </ul>
18 11
19 <div id="order-container" class="order-container"> 12 <div id="order-container" class="order-container">
20 - <div class="all orders">  
21 - {{> me/order/orders}}  
22 - </div>  
23 - <div class="unpaid orders hide"></div>  
24 - <div class="unshipped orders hide"></div>  
25 - <div class="unreceived orders hide"></div> 13 + {{#each navs}}
  14 + <div class="orders{{#unless active}} hide{{/unless}}"></div>
  15 + {{/each}}
26 </div> 16 </div>
27 {{/ order}} 17 {{/ order}}
28 </div> 18 </div>
@@ -3,8 +3,8 @@ @@ -3,8 +3,8 @@
3 <ul class="swiper-wrapper clearfix"> 3 <ul class="swiper-wrapper clearfix">
4 {{# tabs}} 4 {{# tabs}}
5 {{# title}} 5 {{# title}}
6 - <li class="swiper-slide nav-item" data-sort="{{ params}}" data-id="{{ id}}">  
7 - <span>{{ name}}</span> 6 + <li class="swiper-slide nav-item">
  7 + <span data-sort="{{ params}}" data-id="{{ id}}" >{{ name}}</span>
8 </li> 8 </li>
9 {{/ title}} 9 {{/ title}}
10 {{/ tabs}} 10 {{/ tabs}}
@@ -25,7 +25,7 @@ @@ -25,7 +25,7 @@
25 {{# active}} 25 {{# active}}
26 <p>{{.}}</p> 26 <p>{{.}}</p>
27 {{/ active}} 27 {{/ active}}
28 - <p>{{salePrice}}<span>{{price}}</span></p> 28 + <p>{{salePrice}}<b>{{price}}</b></p>
29 </div> 29 </div>
30 </a> 30 </a>
31 </li> 31 </li>
@@ -43,56 +43,6 @@ class HomeController extends AbstractAction @@ -43,56 +43,6 @@ class HomeController extends AbstractAction
43 } 43 }
44 44
45 /** 45 /**
46 - * 用户订单  
47 - */  
48 - public function ordersAction() {  
49 - // 设置网站标题  
50 - $this->setTitle('我的订单');  
51 - $this->setNavHeader('我的订单', true, SITE_MAIN);  
52 -  
53 - $uid = $this->getUid();  
54 - $uid = 8826435;  
55 - $type = $this->get('type', 1);  
56 -  
57 - $order = \Index\UserModel::getUserOrderData($uid, $type);  
58 -  
59 - $order = array(  
60 - 'orders' => array(  
61 - array(  
62 - 'orderNum' => '408539077',  
63 - 'tradingStatus' => '交易成功',  
64 - 'goods' => array(  
65 - array(  
66 - 'id' => 1,  
67 - 'thumb' => 'http://img11.static.yhbimg.com/goodsimg/2015/11/04/05/01ce2aff32fc3c90584f516167cd526d91.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',  
68 - 'name' => 'Adidas Originals ZX FLUXM22508',  
69 - 'color' => '黄',  
70 - 'size' => '43',  
71 - 'price' => '699.00',  
72 - 'count' => '2'  
73 - ),  
74 - array(  
75 - 'id' => 1,  
76 - 'thumb' => 'http://img10.static.yhbimg.com/goodsimg/2015/11/04/05/0188f1aca49ac478a565ec029b5d2d4a6c.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',  
77 - 'name' => 'B.Duck浴室玩伴mini浮水鸭',  
78 - 'gift' => true,  
79 - 'color' => '黄',  
80 - 'size' => '43',  
81 - 'price' => '0.00',  
82 - 'count' => '1'  
83 - )  
84 - ),  
85 - 'count' => 2,  
86 - 'sumCost' => '699.00',  
87 - 'unpaid' => true,  
88 - )  
89 - )  
90 - );  
91 -  
92 - $this->_view->display('order', array('order' => $order, 'orderPage' => true));  
93 - }  
94 -  
95 - /**  
96 * 用户收藏的商品 46 * 用户收藏的商品
97 */ 47 */
98 public function favoriteAction() { 48 public function favoriteAction() {
@@ -519,9 +469,9 @@ class HomeController extends AbstractAction @@ -519,9 +469,9 @@ class HomeController extends AbstractAction
519 469
520 public function orderAction() { 470 public function orderAction() {
521 //判断是不是ajax请求 471 //判断是不是ajax请求
522 - if (!$this->isAjax()) {  
523 - $this->error();  
524 - } 472 +// if (!$this->isAjax()) {
  473 +// $this->error();
  474 +// }
525 //获取基本参数:type:1=>全部,2=>待付款,3=>待发货,4=>待收货,5=>待评论 475 //获取基本参数:type:1=>全部,2=>待付款,3=>待发货,4=>待收货,5=>待评论
526 $type = $this->get('type', 1); 476 $type = $this->get('type', 1);
527 $page = $this->get('page', 1); 477 $page = $this->get('page', 1);
@@ -541,7 +491,25 @@ class HomeController extends AbstractAction @@ -541,7 +491,25 @@ class HomeController extends AbstractAction
541 } else { 491 } else {
542 $order['walkwayUrl'] = 'http://www.baidu.com'; 492 $order['walkwayUrl'] = 'http://www.baidu.com';
543 } 493 }
544 - 494 + $order['navs'] = array(
  495 + array(
  496 + 'name' => '全部',
  497 + 'active' => true,
  498 + 'typeId' => '1'
  499 + ),
  500 + array(
  501 + 'name' => '待付款',
  502 + 'typeId' => '2'
  503 + ),
  504 + array(
  505 + 'name' => '待发货',
  506 + 'typeId' => '3'
  507 + ),
  508 + array(
  509 + 'name' => '待收货',
  510 + 'typeId' => '4'
  511 + )
  512 + );
545 //渲染模板 513 //渲染模板
546 $this->_view->display('order', array( 514 $this->_view->display('order', array(
547 'order' => $order, 515 'order' => $order,