Authored by yangyang

解决冲突

... ... @@ -939,14 +939,27 @@
### 我的订单
{
order: {
orders: [
navs: [
{
name: '',
active: true,
typeId: 1
},
...
],
//没有订单的情况不传orders
walkWayUrl: '' //随便逛逛url
]
}
}
//订单列表
{
orders: [
{
...//订单
}
]
//当无订单时,不传order,返回walkwayUrl
walkWayUrl: ''
}
//订单
{
... ...
... ... @@ -11,36 +11,41 @@ var $ = require('jquery'),
var $navLi = $('#order-nav > li'),
$orderContainer = $('#order-container');
var $curContainer = $orderContainer.children('.orders').first();//保存当前显示的order-container
var $curContainer = $orderContainer.children('.orders:not(.hide)');//保存当前显示的order-container
var winH = $(window).height();
var activeIndex = 0; //当前active的项的index
var activeType = $navLi.filter('.active').data('type'); //当前active的项的index
var orderPage = [1, 0, 0, 0];
var orderPage = {};
var loading = false;
var inAjax = false;
var loading = require('../plugin/loading');
var navHammer, orderHammer;
//加载订单
function getOrders() {
var opt = {
type: activeIndex + 1,
page: orderPage[activeIndex] + 1
},
num;
type: activeType,
page: orderPage[activeType] ? (orderPage[activeType] + 1) : 1
};
if (loading) {
if (inAjax) {
return;
}
inAjax = true;
loading.show();
$.ajax({
type: 'GET',
url: '/home/getOrders',
data: opt,
success: function(data) {
var num;
if (data.code === 200) {
orderPage[opt.type] = opt.page;
... ... @@ -55,35 +60,54 @@ function getOrders() {
lazyLoad($curContainer.children('.order:gt(' + (num - 1) + ') .lazy'));
}
}
inAjax = false;
loading.hide();
}
});
}
lazyLoad();
//初始化导航
(function() {
var liCount = $navLi.length;
//默认4个导航项
if (liCount === 4) {
return;
}
$navLi.width(100 / liCount + '%');
}());
loading.init();
//导航切换
navHammer = new Hammer(document.getElementById('order-nav'));
navHammer.on('tap', function(e) {
var $cur = $(e.target).closest('li');
var $cur = $(e.target).closest('li'),
index;
if ($cur.length === 0 || $cur.hasClass('active')) {
return;
}
activeIndex = +$cur.index();
index = $cur.index();
$navLi.filter('.active').removeClass('active');
$cur.addClass('active');
$curContainer.addClass('hide');
$curContainer = $orderContainer.children(':eq(' + activeIndex + ')').removeClass('hide');
$curContainer = $orderContainer.children(':eq(' + index + ')').removeClass('hide');
activeType = $cur.data('type');
if (orderPage[activeIndex] > 0) {
if (orderPage[activeType]) {
return;
} else {
getOrders();
}
});
//点击订单区域跳转订单详情页
... ... @@ -109,6 +133,13 @@ orderHammer.on('tap', function(e) {
url: '/home/delOrder',
data: {
id: id
},
success: function(data) {
if (data.code === 200) {
//删除订单页面刷新
location.href = location.href;
}
}
});
} else if ($cur.closest('.cancel').length > 0) {
... ... @@ -119,6 +150,13 @@ orderHammer.on('tap', function(e) {
url: '/home/cancelOrder',
data: {
id: id
},
success: function(data) {
if (data.code === 200) {
//取消订单
alert('order cancel');
}
}
});
} else {
... ... @@ -135,3 +173,6 @@ $(window).scroll(function() {
getOrders();
}
});
//初始化请求第一页数据
getOrders();
\ No newline at end of file
... ...
... ... @@ -30,26 +30,15 @@ function hotrank(page, sort, tabId, notab) {
lazyLoad($('img.lazy'));
$('#yoho-footer').css('position', 'static');
$('.rank-main ul li:gt(2)').find('.item-content i').removeClass('top');
winH = $(window).height();
if ($('.rank-main').length !== 0) {
listTop = $('.rank-main').find('ul').offset().top;
}
navSwiper = new Swiper('.s-goods-nav', {
grabCursor: true,
slidesPerView: 'auto',
slideElement: 'li'
});
winH = $(window).height();
listTop = $('.rank-main').find('ul').offset().top;
$('.s-goods-nav .nav-item').each(function(index) {
hotnav = new Hammer($('.s-goods-nav .nav-item')[index]);
hotnav.on('tap', function(e) {
var navItme = $('.s-goods-nav .nav-item').eq(index);
id = navItme.data('id') ? navItme.data('id') : '';
sort = navItme.data('sort') ? navItme.data('sort') : '';
page = 1;
notab = 1;
hotrank(page, sort, id, notab);
});
});
}
});
}
... ... @@ -67,3 +56,18 @@ $(window).scroll(function () {
});
hotrank(page, sort, id, notab);
hotnav = new Hammer(document.getElementById('hotRank'));
hotnav.on('tap', function (e) {
var ev = ev || window.event;
var target = ev.target || ev.srcElement;
if (target.nodeName.toLowerCase() === 'span') {
$('.s-goods-nav .nav-item').removeClass('active');
target.parentNode.className = 'active ' + target.parentNode.className;
id = target.getAttribute('data-id') ? target.getAttribute('data-id') : '';
sort = target.getAttribute('data-sort') ? target.getAttribute('data-sort') : '';
page = 1;
notab = 1;
hotrank(page, sort, id, notab);
}
})
... ...
... ... @@ -74,7 +74,7 @@
overflow: hidden;
white-space: nowrap;
span {
b {
text-decoration: line-through;
color: #b0b0b0;
margin-left: 10rem / $pxConvertRem;
... ... @@ -125,12 +125,20 @@
}
.s-goods-nav {
box-sizing:border-box;
-moz-box-sizing:border-box;
-webkit-box-sizing:border-box;
overflow: hidden;
li {
margin: 0 0 0 (50rem / $pxConvertRem);
width: auto;
height: 95%;
color: #999;
&.active{
color: #000;
border-bottom:2px solid #000;
}
a {
padding: 0;
}
... ...
... ... @@ -2,27 +2,17 @@
<div class="order-page yoho-page">
{{# order}}
<ul id="order-nav" class="order-nav clearfix">
<li class="active">
全部
</li>
<li>
待付款
</li>
<li>
待发货
</li>
<li>
待收货
{{#each navs}}
<li {{#if active}}class="active"{{/if}} data-type="{{typeId}}">
{{name}}
</li>
{{/each}}
</ul>
<div id="order-container" class="order-container">
<div class="all orders">
{{> me/order/orders}}
</div>
<div class="unpaid orders hide"></div>
<div class="unshipped orders hide"></div>
<div class="unreceived orders hide"></div>
{{#each navs}}
<div class="orders{{#unless active}} hide{{/unless}}"></div>
{{/each}}
</div>
{{/ order}}
</div>
... ...
... ... @@ -3,8 +3,8 @@
<ul class="swiper-wrapper clearfix">
{{# tabs}}
{{# title}}
<li class="swiper-slide nav-item" data-sort="{{ params}}" data-id="{{ id}}">
<span>{{ name}}</span>
<li class="swiper-slide nav-item">
<span data-sort="{{ params}}" data-id="{{ id}}" >{{ name}}</span>
</li>
{{/ title}}
{{/ tabs}}
... ... @@ -25,7 +25,7 @@
{{# active}}
<p>{{.}}</p>
{{/ active}}
<p>{{salePrice}}<span>{{price}}</span></p>
<p>{{salePrice}}<b>{{price}}</b></p>
</div>
</a>
</li>
... ...
... ... @@ -43,56 +43,6 @@ class HomeController extends AbstractAction
}
/**
* 用户订单
*/
public function ordersAction() {
// 设置网站标题
$this->setTitle('我的订单');
$this->setNavHeader('我的订单', true, SITE_MAIN);
$uid = $this->getUid();
$uid = 8826435;
$type = $this->get('type', 1);
$order = \Index\UserModel::getUserOrderData($uid, $type);
$order = array(
'orders' => array(
array(
'orderNum' => '408539077',
'tradingStatus' => '交易成功',
'goods' => array(
array(
'id' => 1,
'thumb' => 'http://img11.static.yhbimg.com/goodsimg/2015/11/04/05/01ce2aff32fc3c90584f516167cd526d91.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
'name' => 'Adidas Originals ZX FLUXM22508',
'color' => '黄',
'size' => '43',
'price' => '699.00',
'count' => '2'
),
array(
'id' => 1,
'thumb' => 'http://img10.static.yhbimg.com/goodsimg/2015/11/04/05/0188f1aca49ac478a565ec029b5d2d4a6c.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
'name' => 'B.Duck浴室玩伴mini浮水鸭',
'gift' => true,
'color' => '黄',
'size' => '43',
'price' => '0.00',
'count' => '1'
)
),
'count' => 2,
'sumCost' => '699.00',
'unpaid' => true,
)
)
);
$this->_view->display('order', array('order' => $order, 'orderPage' => true));
}
/**
* 用户收藏的商品
*/
public function favoriteAction() {
... ... @@ -519,9 +469,9 @@ class HomeController extends AbstractAction
public function orderAction() {
//判断是不是ajax请求
if (!$this->isAjax()) {
$this->error();
}
// if (!$this->isAjax()) {
// $this->error();
// }
//获取基本参数:type:1=>全部,2=>待付款,3=>待发货,4=>待收货,5=>待评论
$type = $this->get('type', 1);
$page = $this->get('page', 1);
... ... @@ -541,7 +491,25 @@ class HomeController extends AbstractAction
} else {
$order['walkwayUrl'] = 'http://www.baidu.com';
}
$order['navs'] = array(
array(
'name' => '全部',
'active' => true,
'typeId' => '1'
),
array(
'name' => '待付款',
'typeId' => '2'
),
array(
'name' => '待发货',
'typeId' => '3'
),
array(
'name' => '待收货',
'typeId' => '4'
)
);
//渲染模板
$this->_view->display('order', array(
'order' => $order,
... ...