Authored by baoss

根据tab请求数据

... ... @@ -58,6 +58,7 @@ function groupList(req, res, next) {
});
}).catch(next);
}
function filter(req, res, next) {
let params = Object.assign({}, req.query);
... ... @@ -69,12 +70,35 @@ function filter(req, res, next) {
});
}).catch(next);
}
function searchList(req, res, next) {
let params = Object.assign({}, req.query);
console.log(params);
req.ctx(GroupService).filterGroupList(params)
.then(result => {
return res.render('group/search-list', {
page: 'group',
layout: false,
localCss: true,
nodownload: true,
width750: true,
wechatShare: true,
filterList: result
});
}).catch(next);
}
function progress(req, res, next) {
const uid = req.user.uid;
const groupNo = req.query.groupNo;
const activityId = req.query.activityId;
req.ctx(GroupService).groupResult({groupNo, activityId, uid})
req.ctx(GroupService).groupResult({
groupNo,
activityId,
uid
})
.then(renderData => {
return res.render('group/progress', {
title: '拼团详情',
... ... @@ -123,7 +147,10 @@ function goodsDetail(req, res, next) {
function order(req, res, next) {
const uid = req.user.uid;
const { type, selectIndex } = req.query;
const {
type,
selectIndex
} = req.query;
const param = {
page: 1,
limit: 50,
... ... @@ -141,15 +168,14 @@ function order(req, res, next) {
width750: true,
wechatShare: true,
result,
navs: [
{
title: '进行中',
src: '/activity/group/order?type=2&selectIndex=0'
},
{
title: '全部',
src: '/activity/group/order?type=1&selectIndex=1'
}
navs: [{
title: '进行中',
src: '/activity/group/order?type=2&selectIndex=0'
},
{
title: '全部',
src: '/activity/group/order?type=1&selectIndex=1'
}
],
selectIndex: Number(selectIndex) || 0
});
... ... @@ -163,5 +189,6 @@ module.exports = {
progress,
goodsDetail,
order,
filter
filter,
searchList
};
... ...
... ... @@ -137,6 +137,7 @@ class GroupService extends global.yoho.BaseModel {
}
return finalResult;
}
async groupList(params) {
const initParams = {
page: 1,
... ...
... ... @@ -369,7 +369,8 @@ router.post('/yoluck/detail/mylist.html', yoluck.getActivityCodeList);
router.get('/group', group.index); // 拼团首页
router.get('/group/list', group.groupListIndex); // 拼团列表页
router.get('/group/goods-list', group.groupList); // 拼团列表
router.get('/group/filter', group.filter); // 首页筛选结果
router.get('/group/filter', group.filter); // 首页筛选结果页
router.get('/group/search', group.searchList); // 首页筛选列表
router.get('/group/progress', auth, group.progress); // 拼团状态详情页
router.get('/group/goodsDetail', group.goodsDetail);
router.get('/group/order', auth, group.order); // 我的拼团
... ...
{{#each filterList}}
{{> group/resources/filter-list-item}}
{{/each}}
\ No newline at end of file
... ...
... ... @@ -6,8 +6,8 @@ import filter from 'js/plugin/filter';
let innerScroll = require('js/plugin/inner-scroll');
// import lazyLoad from 'yoho-jquery-lazyload';
// import tip from 'js/plugin/tip';
// import loading from 'js/plugin/loading';
import tip from 'js/plugin/tip';
import loading from 'js/plugin/loading';
class Group extends Page {
constructor() {
... ... @@ -189,6 +189,10 @@ class Group extends Page {
}
}
// 清除筛选页存储的数据
this.filterPage.newGroup = {};
this.filterPage.normalGroup = {};
// 根据条件重置筛选页面及商品列表
this.filterInit();
this.search();
... ... @@ -217,35 +221,47 @@ class Group extends Page {
* @param opt
*/
search() {
let params = this.filterTab[this.selectedChannel];
console.log('searchParam', params);
let params = {
...this.filterTab[this.selectedChannel]
};
let pageParams = this.filterPage[this.selectedChannel];
let groupListContent = this.selector.groupListContent;
// let setting;
delete params.$pre;
console.log('searchParam', params);
console.log('pageParams', this.filterPage[this.selectedChannel]);
// loading.showLoadingMask();
loading.showLoadingMask();
// $.ajax({
// type: 'GET',
// url: '/product/sale/search',
// data: setting,
// success: function() {
// },
// error: function() {
// tip.show('网络断开连接了~');
// loading.hideLoadingMask();
// }
// });
$.ajax({
type: 'GET',
url: '/activity/group/search',
data: {
...params,
...pageParams
},
success: function(data) {
console.log(data);
groupListContent.html(data);
loading.hideLoadingMask();
},
error: function() {
tip.show('网络断开连接了~');
loading.hideLoadingMask();
}
});
}
// 筛选初始化
filterInit() {
let selectedChannel = this.selectedChannel;
let requestParams = {
...this.filterTab[this.selectedChannel]
...this.filterTab[selectedChannel]
};
let filterTab = this.selector.filterTab;
let filterPage = this.filterPage;
let search = this.search.bind(this);
delete requestParams.$pre;
... ... @@ -260,7 +276,13 @@ class Group extends Page {
// 初始化filter&注册filter回调
filter.initFilter({
fCbFn: search,
fCbFn: function(params) {
console.log(params);
// 存储筛选页数据
filterPage[selectedChannel][params.type] = params.id;
search();
},
hCbFn: function() {
filterTab.children('.filter').removeClass('active');
innerScroll.enableScroll($('body'));
... ...