...
|
...
|
@@ -12,7 +12,8 @@ class GroupService extends global.yoho.BaseModel { |
|
|
async index() {
|
|
|
try {
|
|
|
const result = await this.api._getResourceCode({
|
|
|
contentCode: '9eddb5c34acf6f0aa2040318ef33a846'
|
|
|
// contentCode: '9eddb5c34acf6f0aa2040318ef33a846'
|
|
|
contentCode: 'ae00dffeb10f417887c433057b0af8bb'
|
|
|
});
|
|
|
|
|
|
return result;
|
...
|
...
|
@@ -20,7 +21,17 @@ class GroupService extends global.yoho.BaseModel { |
|
|
throw new Error('Group index fail to load resources.');
|
|
|
}
|
|
|
}
|
|
|
async readyListResource() {
|
|
|
try {
|
|
|
const result = await this.api._getResourceCode({
|
|
|
contentCode: '89141506b9926010f28915a82b3db61d'
|
|
|
});
|
|
|
|
|
|
return result;
|
|
|
} catch (e) {
|
|
|
throw new Error('Group index fail to load resources.');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
async groupResult({
|
|
|
groupNo,
|
...
|
...
|
@@ -108,7 +119,16 @@ class GroupService extends global.yoho.BaseModel { |
|
|
throw new Error('Group index fail to load resources.');
|
|
|
}
|
|
|
}
|
|
|
async groupIndex() {
|
|
|
let result = {};
|
|
|
|
|
|
result.index = await this.index();
|
|
|
result.tabData = await this.tabData();
|
|
|
result.filterGroupList = await this.filterGroupList({
|
|
|
joinLimit: result.tabData.joinLimit || 1
|
|
|
});
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
async tabData() {
|
|
|
const result = await this.api._getPromoteCount();
|
...
|
...
|
@@ -119,6 +139,10 @@ class GroupService extends global.yoho.BaseModel { |
|
|
|
|
|
if (+newGroup && +normalGroup) {
|
|
|
tabsData.showTab = true;
|
|
|
} else if (+newGroup) {
|
|
|
tabsData.joinLimit = 1;
|
|
|
} else if (+normalGroup) {
|
|
|
tabsData.joinLimit = 2;
|
|
|
}
|
|
|
return tabsData;
|
|
|
}
|
...
|
...
|
@@ -160,7 +184,8 @@ class GroupService extends global.yoho.BaseModel { |
|
|
const initParams = {
|
|
|
page: 1,
|
|
|
limit: 20,
|
|
|
activityId: 78
|
|
|
activityId: '',
|
|
|
showType: 1 // 默认显示已开始的
|
|
|
};
|
|
|
let newParams = {
|
|
|
...initParams,
|
...
|
...
|
@@ -188,6 +213,7 @@ class GroupService extends global.yoho.BaseModel { |
|
|
val.salesPrice = val.salesPrice ? val.salesPrice.toFixed(2) : '';
|
|
|
val.marketPrice = val.marketPrice ? val.marketPrice.toFixed(2) : '';
|
|
|
val.collagePrice = val.collagePrice ? val.collagePrice.toFixed(2) : '';
|
|
|
val.beginTimeText = this.formatTimeByDefined(val.beginTime, 'M月D日');
|
|
|
});
|
|
|
}
|
|
|
return finalResult;
|
...
|
...
|
@@ -199,6 +225,9 @@ class GroupService extends global.yoho.BaseModel { |
|
|
async goodsDetail(params) {
|
|
|
let result = await this.api.getProductData(params);
|
|
|
|
|
|
if (result.shop_id) {
|
|
|
result.storeUrl = `/shop/${_.get(result, 'brand_info.brand_domain')}-${_.get(result, 'shop_id')}.html`;
|
|
|
}
|
|
|
result.shopInfo = await this.api.getShopInfo({brand_id: result.brand_id, shop_id: result.shop_id});
|
|
|
result.activityIdDetail = await this.api.getCollageProductInfo(params);
|
|
|
result.activityGroupDetailList = await this.api.fetchActivityGroups(params);
|
...
|
...
|
@@ -227,7 +256,9 @@ class GroupService extends global.yoho.BaseModel { |
|
|
uid
|
|
|
});
|
|
|
|
|
|
const reasons = await this.api.getRefundApplyReasons({ uid });
|
|
|
const reasons = await this.api.getRefundApplyReasons({
|
|
|
uid
|
|
|
});
|
|
|
|
|
|
result.order_list = result.order_list.map((item) => {
|
|
|
reasons.forEach(reason => {
|
...
|
...
|
@@ -247,6 +278,38 @@ class GroupService extends global.yoho.BaseModel { |
|
|
}
|
|
|
}
|
|
|
|
|
|
async delOrder({
|
|
|
orderCode,
|
|
|
uid
|
|
|
}) {
|
|
|
try {
|
|
|
const result = await this.api.delOrder({
|
|
|
orderCode,
|
|
|
uid
|
|
|
});
|
|
|
|
|
|
return result;
|
|
|
} catch (error) {
|
|
|
throw new Error('Group delOrder fail.');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
async cancelOrder({
|
|
|
orderCode,
|
|
|
uid
|
|
|
}) {
|
|
|
try {
|
|
|
const result = await this.api.cancelOrder({
|
|
|
orderCode,
|
|
|
uid
|
|
|
});
|
|
|
|
|
|
return result;
|
|
|
} catch (error) {
|
|
|
throw new Error('Group cancelOrder fail.');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
add0(m) {
|
|
|
return m < 10 ? '0' + m : m;
|
|
|
}
|
...
|
...
|
@@ -266,6 +329,34 @@ class GroupService extends global.yoho.BaseModel { |
|
|
|
|
|
return this.add0(hr) + ':' + this.add0(min) + ':' + this.add0(sec);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 时间戳转化为年 月 日 时 分 秒
|
|
|
* time: 传入时间戳
|
|
|
* format:返回格式,支持自定义,但参数必须与formateArr里保持一致
|
|
|
* formatTimeByDefined(1488481383,'Y/M/D h:m:s') => 2017/03/03 03:03:03
|
|
|
*/
|
|
|
formatTimeByDefined(time, format) {
|
|
|
|
|
|
var formateArr = ['Y', 'M', 'D', 'h', 'm', 's'];
|
|
|
var returnArr = [];
|
|
|
|
|
|
var date = new Date(time * 1000);
|
|
|
var i = 0;
|
|
|
|
|
|
returnArr.push(date.getFullYear());
|
|
|
returnArr.push(this.add0(date.getMonth() + 1));
|
|
|
returnArr.push(this.add0(date.getDate()));
|
|
|
|
|
|
returnArr.push(this.add0(date.getHours()));
|
|
|
returnArr.push(this.add0(date.getMinutes()));
|
|
|
returnArr.push(this.add0(date.getSeconds()));
|
|
|
|
|
|
for (i; i < returnArr.length; i++) {
|
|
|
format = format.replace(formateArr[i], returnArr[i]);
|
|
|
}
|
|
|
return format;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
module.exports = {
|
...
|
...
|
|