...
|
...
|
@@ -5,6 +5,7 @@ const headerModel = require('../../../doraemon/models/header'); // 头部model |
|
|
const _ = require('lodash');
|
|
|
const utils = '../../../utils';
|
|
|
const detailProcess = require(`${utils}/detail-process`);
|
|
|
const helpers = global.yoho.helpers;
|
|
|
|
|
|
function index(req, res, next) {
|
|
|
req.ctx(GroupService).groupIndex().then(result => {
|
...
|
...
|
@@ -133,6 +134,7 @@ function goodsDetail(req, res, next) { |
|
|
req.ctx(GroupService).goodsDetail({
|
|
|
activityId: param.activityId,
|
|
|
productSkn: param.productSkn,
|
|
|
groupNo: param.groupNo
|
|
|
}).then((result) => {
|
|
|
if (_.isEmpty(result)) {
|
|
|
return next();
|
...
|
...
|
@@ -145,6 +147,9 @@ function goodsDetail(req, res, next) { |
|
|
finalResult.support = result.support;
|
|
|
finalResult.floor = result.floor;
|
|
|
finalResult.storage_sum = result.storage_sum;
|
|
|
finalResult.groupNo = param.groupNo;
|
|
|
finalResult.activityId = param.activityId;
|
|
|
finalResult.isShowPop = result.activityIdDetail.joinLimit === 1 ? true : false;
|
|
|
return res.render('group/goodsDetail', {
|
|
|
page: 'group-goodsDetail',
|
|
|
nodownload: true,
|
...
|
...
|
@@ -161,6 +166,65 @@ function goodsDetail(req, res, next) { |
|
|
}).catch(next);
|
|
|
}
|
|
|
|
|
|
function delOrder(req, res, next) {
|
|
|
let orderCode = req.query.id;
|
|
|
let uid = req.user.uid;
|
|
|
|
|
|
req.ctx(GroupService).delOrder({ orderCode, uid }).then((result) => {
|
|
|
res.json(result);
|
|
|
}).catch(next);
|
|
|
}
|
|
|
|
|
|
function cancelOrder(req, res, next) {
|
|
|
let orderCode = req.query.id;
|
|
|
let uid = req.user.uid;
|
|
|
|
|
|
req.ctx(GroupService).cancelOrder({ orderCode, uid }).then((result) => {
|
|
|
res.json(result);
|
|
|
}).catch(next);
|
|
|
}
|
|
|
|
|
|
function changeOrderStatus(orderItem) {
|
|
|
const orderBtn = [];
|
|
|
|
|
|
if (!orderItem) {
|
|
|
return {};
|
|
|
}
|
|
|
_.each(orderItem.links, function(val) {
|
|
|
switch (val) {
|
|
|
case 'buyNow':
|
|
|
orderBtn.push({
|
|
|
buyNow: true,
|
|
|
link: helpers.urlFormat('/home/orders/paynew', {order_code: orderItem.order_code}),
|
|
|
});
|
|
|
break;
|
|
|
case 'closeOrder':// 取消订单
|
|
|
orderBtn.push({
|
|
|
closeOrder: true
|
|
|
});
|
|
|
break;
|
|
|
case 'delOrder':// 删除订单
|
|
|
orderBtn.push({
|
|
|
delOrder: true,
|
|
|
});
|
|
|
break;
|
|
|
case 'groupInvite':
|
|
|
orderBtn.push({
|
|
|
groupInvite: true,
|
|
|
link: helpers.urlFormat('/activity/group/progress', {
|
|
|
groupNo: orderItem.group_no,
|
|
|
activityId: orderItem.activity_id
|
|
|
}),
|
|
|
});
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
});
|
|
|
return orderBtn;
|
|
|
}
|
|
|
|
|
|
function order(req, res, next) {
|
|
|
const uid = req.user.uid;
|
|
|
const {
|
...
|
...
|
@@ -170,7 +234,7 @@ function order(req, res, next) { |
|
|
const param = {
|
|
|
page: 1,
|
|
|
limit: 50,
|
|
|
type: type || 1,
|
|
|
type: type || 2,
|
|
|
uid
|
|
|
};
|
|
|
|
...
|
...
|
@@ -179,6 +243,11 @@ function order(req, res, next) { |
|
|
if (_.isEmpty(result)) {
|
|
|
return next();
|
|
|
}
|
|
|
_.each(result.order_list, function(orderItem) {
|
|
|
const orderBtn = changeOrderStatus(orderItem);
|
|
|
|
|
|
orderItem.orderBtn = orderBtn;
|
|
|
});
|
|
|
return res.render('group/order', {
|
|
|
title: '我的拼团',
|
|
|
page: 'group-order',
|
...
|
...
|
@@ -188,6 +257,7 @@ function order(req, res, next) { |
|
|
wechatShare: true,
|
|
|
pageStyle: 'group-order-page',
|
|
|
result,
|
|
|
type: type || 2,
|
|
|
navs: [{
|
|
|
title: '进行中',
|
|
|
src: '/activity/group/order?type=2&selectIndex=0'
|
...
|
...
|
@@ -211,5 +281,7 @@ module.exports = { |
|
|
goodsDetail,
|
|
|
order,
|
|
|
filter,
|
|
|
searchList
|
|
|
searchList,
|
|
|
delOrder,
|
|
|
cancelOrder
|
|
|
}; |
...
|
...
|
|