Authored by 陈峰

Merge branch 'feature/import' of http://git.yoho.cn/fe/yoho-miniapp-eshop into feature/import

... ... @@ -24,7 +24,7 @@ Page({
},
expandItem: function(e) {
const {idx} = e.currentTarget.dataset;
const sub = this.data.cateList[idx].sub;
const sub = this._subCate(idx);
if (!this.data.expand) {
this.setData({
... ... @@ -47,7 +47,30 @@ Page({
}
}
},
toProductList: function() {
_subCate: function(idx) {
const parent = this.data.cateList[idx];
let sub = parent.sub.slice();
sub.unshift({
category_name: `全部${parent.category_name}`
});
return sub;
},
goAll: function() {
router.go('shopProductList', {title: '全部商品'});
},
goItemList: function(e) {
const subIdx = e.target.dataset.idx;
const subItem = this.data.subCateList[subIdx];
let params = {};
if (!subIdx) {
params.sort = this.data.cateList[this.data.expandIndex].relation_parameter.sort;
} else {
params.sort = subItem.relation_parameter.sort;
}
params.title = subItem.category_name;
router.go('shopProductList', params);
}
});
... ...
<wxs src="../../../wxs/helper.wxs" module="helper" />
<view class="container category">
<view class="gap"></view>
<view class="all" bindtap="toProductList">全部商品</view>
<view class="all" bindtap="goAll">全部商品<text class="iconfont icon-right"></text></view>
<view class="gap"></view>
<view class="items">
<view class="item" wx:for="{{cateList}}" data-idx="{{index}}" bindtap="expandItem">
{{item.category_name}}
</view>
<view class="item-expand {{expand ? 'open' : ''}}">
<view class="sub-item" wx:for="{{subCateList}}" wx:for-item="subItem" wx:key="index">
<view class="sub-item" bindtap="goItemList" wx:for="{{subCateList}}"
wx:for-item="subItem" wx:key="index" data-idx="{{index}}">
{{subItem.category_name}}
</view>
<view wx:if="{{expand}}" class="focus-tag" style="top: {{expandIndex * 88 + 43}}rpx;"></view>
</view>
<view class="item" wx:for="{{cateList}}" data-idx="{{index}}" bindtap="expandItem">
{{item.category_name}}
</view>
</view>
</view>
... ...
... ... @@ -4,31 +4,45 @@
}
.category .all {
height: 85rpx;
height: 87rpx;
padding-left: 30rpx;
color: #444;
font-size: 28rpx;
line-height: 85rpx;
line-height: 87rpx;
background-color: #fff;
border-top: 1rpx solid #f4f4f4;
border-bottom: 1rpx solid #f4f4f4;
}
.category .all .icon-right {
float: right;
color: #e0e0e0;
font-size: 50rpx;
margin-right: 10rpx;
}
.category .items {
position: fixed;
top: 125rpx;
left: 0;
right: 0;
bottom: 0;
padding-left: 30rpx;
background-color: #fff;
border-top: 1rpx solid #f4f4f4;
}
.category .items .item {
height: 110rpx;
height: 87rpx;
color: #444;
font-size: 28rpx;
line-height: 110rpx;
border-bottom: 1rpx solid #f4f4f4;
line-height: 87rpx;
margin-left: 27rpx;
border-bottom: 1rpx solid #e0e0e0;
}
.category .items .item:last-child {
margin-left: 0;
padding-left: 27rpx;
}
.category .item-expand {
... ... @@ -42,7 +56,27 @@
}
.category .item-expand .sub-item {
position: relative;
height: 87rpx;
margin-left: 27rpx;
color: #b0b0b0;
line-height: 87rpx;
font-size: 24rpx;
min-width: 300rpx;
border-bottom: 1rpx solid #e0e0e0;
}
.category .item-expand .focus-tag {
position: absolute;
display: inline-block;
top: 0;
left: -34rpx;
width: 0;
height: 0;
margin-top: -22rpx;
border-width: 22rpx;
border-style: solid;
border-color: transparent #f4f4f4 transparent transparent;
}
.category .item-expand.open {
... ...
... ... @@ -32,12 +32,8 @@ Page({
delete options.title;
options.shop_id = app.getShopId();
if (options.brand) {
this.setBrandTitle(options.brand);
}
this.setData({
gender: options.gender || '',
urlParams: options
});
this.productList(options);
... ...