Authored by 邱骏

修改yoluck接口及字段

... ... @@ -42,6 +42,7 @@ function index(req, res, next) {
}).catch(e => next(_handelErrorMessage(e)));
}
// 列表页分页
function nextPage(req, res, next) {
const page = req.query.page || 1;
const type = Number(req.query.type || 0);
... ...
const MODULE = '/activity/zerobuy';
// const MODULE = '/activity/zerobuy';
const serviceAPI = global.yoho.ServiceAPI;
const yoLuckApi = new global.yoho.ApiBase(global.yoho.config.domains.yoLuck, {
name: 'yoLuck',
cache: global.yoho.cache,
useCache: false
});
/* 旧的api
const yoLuckApi = new global.yoho.ApiBase(global.yoho.config.domains.yoLuck, {
name: 'yoLuck',
cache: global.yoho.cache,
useCache: false
});
*/
function productTime(p) {
if (p.status === 1) {
... ... @@ -68,27 +70,31 @@ class YoLuckApi extends global.yoho.BaseModel {
* @returns {Promise}
*/
getList({page, type}) {
return yoLuckApi.get(MODULE + '/list', {
page,
type,
channel: 0
// 已改成java接口,数据结构改变,字段名改变
return this.get({
data: {
method: 'app.yoluck.activityList',
type,
page,
channel: 0,
size: 10
}
}).then(result => {
if (result.code === 200) {
const products = result.data;
const products = result.data.list;
const newProducts = products.map((p) => {
p = productTime(p);
p.countdown = formatCountDown(p.end_time);
p.countdown = formatCountDown(p.endTime);
return p;
});
result.data = newProducts;
result.data.list = newProducts;
return result;
}
return result;
});
}
/**
... ... @@ -97,13 +103,29 @@ class YoLuckApi extends global.yoho.BaseModel {
* @returns {Promise}
*/
getDetail({actPrizeId, uid}) {
return yoLuckApi.get(MODULE + '/content', {actPrizeId, uid}).then(result => {
/* return yoLuckApi.get(MODULE + '/content', {actPrizeId, uid}).then(result => {
if (result.code === 200) {
productTime(result.data);
result.data.countdown = formatCountDown(result.data.end_time);
}
return result;
});*/
return this.get({
data: {
method: 'app.yoluck.getContent',
uid,
actPrizeId
}
}).then(result => {
// console.log('detail:', result);
if (result.code === 200) {
productTime(result.data);
result.data.countdown = formatCountDown(result.data.endTime);
}
return result;
});
}
... ... @@ -113,7 +135,7 @@ class YoLuckApi extends global.yoho.BaseModel {
* @returns {Promise}
*/
getRecommend({actPrizeId}) {
return yoLuckApi.get(MODULE + '/list/recommend', {
/* return yoLuckApi.get(MODULE + '/list/recommend', {
actPrizeId,
channel: 0
}).then(result => {
... ... @@ -131,6 +153,30 @@ class YoLuckApi extends global.yoho.BaseModel {
}
return result;
});*/
return this.get({
data: {
method: 'app.yoluck.recommendList',
actPrizeId,
channel: 0
}
}).then(result => {
if (result.code === 200) {
console.log('recomment=', result);
const products = result.data;
const newProducts = products.map((p) => {
p = productTime(p);
p.countdown = formatCountDown(p.end_time);
return p;
});
result.data = newProducts;
return result;
}
return result;
});
}
... ... @@ -140,7 +186,13 @@ class YoLuckApi extends global.yoho.BaseModel {
* @returns {Promise}
*/
getRecentAvatars({actPrizeId}) {
return yoLuckApi.get(MODULE + '/code/recent', {actPrizeId});
// return yoLuckApi.get(MODULE + '/code/recent', {actPrizeId});
return this.get({
data: {
method: 'app.yoluck.recent',
actPrizeId
}
});
}
/**
... ... @@ -150,7 +202,17 @@ class YoLuckApi extends global.yoho.BaseModel {
* @returns {Promise}
*/
getMyList({page, type, limit, uid}) {
return yoLuckApi.get(MODULE + '/list/mine', {type, page, uid, limit, channel: 0});
// return yoLuckApi.get(MODULE + '/list/mine', {type, page, uid, limit, channel: 0});
return this.get({
data: {
method: 'app.yoluck.participationList',
type,
page,
uid,
size: limit,
channel: 0
}
});
}
/**
... ... @@ -160,7 +222,14 @@ class YoLuckApi extends global.yoho.BaseModel {
* @returns {Promise}
*/
getMyListWithActid(uid, actPrizeId) {
return yoLuckApi.get(MODULE + '/code/mine', {uid, actPrizeId});
// return yoLuckApi.get(MODULE + '/code/mine', {uid, actPrizeId});
return this.get({
data: {
method: 'app.yoluck.userCode',
uid,
actPrizeId
}
});
}
/**
... ... @@ -173,12 +242,23 @@ class YoLuckApi extends global.yoho.BaseModel {
* @returns {Promise}
*/
fetchCode({shareUid, uid, actPrizeId, userThumb, userName}) {
return yoLuckApi.post(MODULE + '/code/gain', {
/* return yoLuckApi.post(MODULE + '/code/gain', {
shareUid,
uid,
actPrizeId,
userThumb,
userName
});*/
return this.get({
data: {
method: 'app.yoluck.getCode',
actPrizeId,
uid,
shareUid,
userName,
userThumb
}
});
}
... ...
... ... @@ -138,7 +138,7 @@ class YoLuckService extends global.yoho.BaseModel {
}
const [resRunning, resFinished] = await Promise.all([
this.getMyListNext({page: 1, limit: 1000, type: YOLUCK_MYLIST_TYPE.running, uid}),
await this.getMyListNext({page: 1, limit: 1000, type: YOLUCK_MYLIST_TYPE.running, uid}),
await this.getMyListNext({page: 1, limit: 1000, type: YOLUCK_MYLIST_TYPE.finished, uid})
]);
... ... @@ -155,7 +155,7 @@ class YoLuckService extends global.yoho.BaseModel {
} else {
result.push(resFinished);
}
console.log('已参加:', result);
return result;
} else {
result = await this.api.getList({page, type});
... ... @@ -166,7 +166,6 @@ class YoLuckService extends global.yoho.BaseModel {
error: '出错了'
};
}
return result.data;
} catch (e) {
return {
... ... @@ -176,6 +175,7 @@ class YoLuckService extends global.yoho.BaseModel {
}
async _getDetail(actPrizeId, uid) {
console.log('uid', uid);
try {
const result = await this.api.getDetail({actPrizeId, uid});
... ... @@ -377,13 +377,15 @@ class YoLuckService extends global.yoho.BaseModel {
try {
const result = await this.api.getMyList({page, type, uid, limit});
// console.log('已参加列表:', result.data.list);
if (result.code !== 200) {
return {
error: '出错了'
};
}
return result.data;
return result;
} catch (e) {
return {
error: e
... ... @@ -479,6 +481,8 @@ class YoLuckService extends global.yoho.BaseModel {
async getActivityCodeList(uid, actPrizeId) {
let result = await this.api.getMyListWithActid(uid, actPrizeId);
console.log('myresult:', result);
let codeList = [];
let nearAvatar = '//img10.static.yhbimg.com/headimg/2013/11/28/09/01cae078abe5fe320c88cdf4c220212688.gif?imageView/2/w/100/h/100'; // eslint-disable-line
... ... @@ -499,7 +503,7 @@ class YoLuckService extends global.yoho.BaseModel {
});
}
});
console.log('mycode:', codeList);
return codeList;
}
}
... ...
... ... @@ -20,8 +20,7 @@
{{#ifcond @index '===' 0}}
{{#ifcond list.length '!==' 0}}
<div class="js-panel-header">
<img
src="//img11.static.yhbimg.com/yhb-img01/2018/12/07/15/0188307712613ce043d4b68a94761ee1ff.gif"
<img src="//img11.static.yhbimg.com/yhb-img01/2018/12/07/15/0188307712613ce043d4b68a94761ee1ff.gif"
alt="">
</div>
{{/ifcond}}
... ... @@ -30,9 +29,10 @@
<!--数据部-->
<div class="js-panel-body">
{{#ifcond @index '===' 3}}
{{log list}}
{{> yoluck/prize-list running=list.[0] finished=list.[1] }}
{{^}}
{{#each list}}
{{#each list.list}}
{{> yoluck/product-item .}}
{{/each}}
{{/ifcond}}
... ...
... ... @@ -29,7 +29,7 @@
{{/isEqualOr}}
{{#isEqualOr status 5}}
<div class="counter-num" > 人数不足 活动结束 </div>
<div class="counter-num" > 等待开奖 </div>
{{/isEqualOr}}
</div>
... ...
<div class="prize-item-comp">
<div class="prize-item js-prizeitem" data-id="{{act_prize_id}}">
<img class="product-image" src="{{cover_img}}" alt="">
<div class="prize-item js-prizeitem" data-id="{{id}}">
<img class="product-image" src="{{coverImg}}" alt="">
<div class="content">
<div class="code">抽奖码
<text style="color: black;">{{prize_code}}</text>
<text style="color: black;">{{prizeCode}}</text>
</div>
<div class="product-name">{{name}}</div>
... ... @@ -17,7 +17,7 @@
{{/ifcond}}
{{#ifcond status '===' 4}}
<div class="btn more js-fellow" data-id="{{act_prize_id}}" data-lottery="{{lottery_info}}">查看中奖信息</div>
<div class="btn more js-fellow" data-id="{{id}}" data-lottery="{{lotteryInfo}}">查看中奖信息</div>
{{/ifcond}}
{{#ifcond status '===' 5}}
... ... @@ -26,10 +26,10 @@
{{#isEqualOr status 1 2 6}}
<div class="btn more js-share"
data-img="{{cover_img}}"
data-img="{{coverImg}}"
data-name="{{name}}"
data-price="{{price}}"
data-id="{{act_prize_id}}"
data-id="{{id}}"
>
获得更多抽奖码
</div>
... ...
... ... @@ -4,9 +4,9 @@
<span class="title">进行中</span>
</div>
</div>
{{#ifcond running.length '>' 0}}
{{#each running}}
{{log .}}
{{#ifcond running.data.list.length '>' 0}}
{{#each running.data.list}}
{{> yoluck/prize-item .}}
{{/each}}
{{^}}
... ... @@ -20,8 +20,8 @@
</div>
</div>
{{#ifcond finished.length '>' 0}}
{{#each finished}}
{{#ifcond finished.data.list.length '>' 0}}
{{#each finished.data.list}}
{{> yoluck/prize-item .}}
{{/each}}
{{^}}
... ...
... ... @@ -23,7 +23,7 @@
<div class="desc">
<div class="title {{#ifcond step '>=' 1}}active{{/ifcond}}">参加抽奖</div>
<div class="title {{#ifcond step '>=' 2}}active{{/ifcond}}">邀请好友</div>
<div class="title {{#ifcond step '>=' 3}}active{{/ifcond}}">{{#ifcond step '===' 4}}人数不足{{^}}人满开奖{{/ifcond}}</div>
<div class="title {{#ifcond step '>=' 3}}active{{/ifcond}}">{{#ifcond step '===' 4}}等待开奖{{^}}等待开奖{{/ifcond}}</div>
</div>
</div>
</div>
... ...
... ... @@ -4,7 +4,7 @@
<text class="countdown_labeltext">倒计时</text>
</div>
<div class="product_countdown" data-endtime="{{product.end_time}}">
<div class="product_countdown" data-endtime="{{product.endTime}}">
{{> yoluck/time-countdown time=product.countdown}}
</div>
{{/ifcond}}
... ... @@ -18,13 +18,13 @@
{{/ifcond}}
{{/ifcond}}
<img class="product_image" src="{{image2 product.cover_img q=60}}"/>
<img class="product_image" src="{{image2 product.coverImg q=60}}"/>
</div>
<div class="product_name"
data-id="{{product.id}}"
data-name="{{product.name}}"
data-img="{{image2 product.cover_img q=60}}"
data-img="{{image2 product.coverImg q=60}}"
data-price="{{product.price}}"
>
{{product.name}}
... ... @@ -39,7 +39,7 @@
</div>
{{#ifcond product.status '!==' 2}}
<div class="product_time">{{formatTime product.start_time product.end_time}}</div>
<div class="product_time">{{formatTime product.startTime product.endTime}}</div>
{{/ifcond}}
<div class="product_margin"></div>
... ...
{{#ifcond status '===' 2}}
<div class="product_countdown" data-endtime="{{end_time}}">
<div class="product_countdown" data-endtime="{{endTime}}">
{{>yoluck/time-countdown time=countdown}}
</div>
{{/ifcond}}
<img class="product_image" src="{{image2 cover_img w=760 h=470 q=60}}" alt="" data-id="{{id}}">
<img class="product_image" src="{{image2 coverImg w=760 h=470 q=60}}" alt="" data-id="{{id}}">
<div class="product_name">{{name}}</div>
<div class="product_lucky_bg">
... ... @@ -13,7 +13,7 @@
</div>
{{#ifcond status '!==' 2}}
<div class="product_time">{{formatTime start_time end_time}}</div>
<div class="product_time">{{formatTime startTime endTime}}</div>
{{/ifcond}}
<div class="product_margin"></div>
... ...
... ... @@ -18,6 +18,6 @@
{{/isEqualOr}}
{{#isEqualOr status 5}}
<div class="btn cancel">人数不足 活动结束</div>
<div class="btn cancel">待开奖</div>
{{/isEqualOr}}
</div>
... ...
... ... @@ -31,7 +31,7 @@ const domains = {
liveApi: 'http://testapi.live.yohops.com:9999/',
singleApi: 'http://api-test3.dev.yohocorp.com/',
ufo: 'http://java-yohoufo-fore.test3.ingress.dev.yohocorp.com/ufo-gateway/',
yoLuck: 'http://limit-yoho-activity-platform.test3.ingress.dev.yohocorp.com',
yoLuck: 'http://yoho-activity-platform.test3.ingress.dev.yohocorp.com',
imSocket: 'wss://imsocket.yohobuy.com:443',
imCs: 'https://imhttp.yohobuy.com/api',
... ...
<div class="prize-item-comp">
<div class="prize-item js-prizeitem" data-id="{{act_prize_id}}">
<img class="product-image" src="{{cover_img}}" alt="">
<div class="prize-item js-prizeitem" data-id="{{id}}">
<img class="product-image" src="{{coverImg}}" alt="">
<div class="content">
<div class="code">抽奖码
<text style="color: black;">{{prize_code}}</text>
<text style="color: black;">{{prizeCode}}</text>
</div>
<div class="product-name">{{name}}</div>
... ... @@ -17,19 +17,19 @@
{{/ifcond}}
{{#ifcond status '===' 4}}
<div class="btn more js-fellow" data-id="{{act_prize_id}}">查看中奖信息</div>
<div class="btn more js-fellow" data-id="{{id}}">查看中奖信息</div>
{{/ifcond}}
{{#ifcond status '===' 5}}
<div class="btn">人数不足 活动结束</div>
<div class="btn">等待开奖</div>
{{/ifcond}}
{{#is-equal-or status 1 2 6}}
<div class="btn more js-share"
data-img="{{cover_img}}"
data-img="{{coverImg}}"
data-name="{{name}}"
data-price="{{price}}"
data-id="{{act_prize_id}}"
data-id="{{id}}"
>
获得更多抽奖码
</div>
... ...
... ... @@ -5,9 +5,9 @@
</div>
</div>
{{#ifcond running.length '>' 0}}
{{#each running}}
{{log .}}
{{#ifcond running.data.list.length '>' 0}}
{{#each running.data.list}}
{{> ./prize-item .}}
{{/each}}
{{^}}
... ... @@ -21,8 +21,8 @@
</div>
</div>
{{#ifcond finished.length '>' 0}}
{{#each finished}}
{{#ifcond finished.data.list.length '>' 0}}
{{#each finished.data.list}}
{{> ./prize-item .}}
{{/each}}
{{^}}
... ...
... ... @@ -6,7 +6,7 @@
</div>
{{/ifcond}}
<img class="product_image" src="{{image2 cover_img w=760 h=470 q=60}}" alt="" data-id="{{id}}">
<img class="product_image" src="{{image2 coverImg w=760 h=470 q=60}}" alt="" data-id="{{id}}">
<div class="product_name">{{name}}</div>
<div class="product_lucky_bg">
... ... @@ -15,7 +15,7 @@
</div>
{{#ifcond status '!==' 2}}
<div class="product_time">{{formatTime start_time end_time}}</div>
<div class="product_time">{{formatTime startTime endTime}}</div>
{{/ifcond}}
<div class="product_margin"></div>
... ...
... ... @@ -18,6 +18,6 @@
{{/is-equal-or}}
{{#is-equal-or status 5}}
<div class="btn cancel">人数不足 活动结束</div>
<div class="btn cancel">等待开奖</div>
{{/is-equal-or}}
</div>
... ...
... ... @@ -131,7 +131,9 @@ function fetchPage(page, index) {
return;
}
if (result.data.length === 0) {
// 当前page > 结果的最大page时不处理
if (page > result.data.page_total || result.data.length === 0) {
page--;
return;
}
... ... @@ -144,7 +146,7 @@ function fetchPage(page, index) {
$node.find('.js-panel-body').html($products);
} else {
let $node = tabpanelStore.nodes.eq(index);
let $products = result.data.map(r => {
let $products = result.data.list.map(r => {
const p = productTpl(r);
store.countDown = store.countDown.add($(p).find('.product_countdown'));
... ...