Authored by 陈峰

Merge branch 'hotfix/change-yoluck-interface' into 'release/6.8.7'

yoluck上线



See merge request !1706
Showing 54 changed files with 2356 additions and 114 deletions
  1 +const _ = require('lodash');
  2 +
  3 +const {YOLUCK_LIST_TYPE, YoLuckService} = require('../models/yoluck-service-back');
  4 +
  5 +function _handelErrorMessage(e) {
  6 + if (e && e.statusCode === 503) {
  7 + e.title = '人数过多。。。';
  8 + e.message = '目前参与人数过多请点击刷新';
  9 + }
  10 +
  11 + return e;
  12 +}
  13 +
  14 +function index(req, res, next) {
  15 + let type = +req.query.type || YOLUCK_LIST_TYPE.running;
  16 + let uid = req.user.uid;
  17 +
  18 + if (!Object.values(YOLUCK_LIST_TYPE).includes(type)) {
  19 + type = YOLUCK_LIST_TYPE.running;
  20 + }
  21 +
  22 + req.ctx(YoLuckService).index(type, uid).then(result => {
  23 + if (result.error) {
  24 + if (type === YOLUCK_LIST_TYPE.joined && result.error === 401) {
  25 + return res.redirect(
  26 + `/signin.html?refer=//m.yohobuy.com/activity/yoluck/index.html?type=${YOLUCK_LIST_TYPE.joined}`
  27 + );
  28 + } else {
  29 + return Promise.reject(result.error);
  30 + }
  31 + }
  32 +
  33 + res.render('yoluck-back/list', {
  34 + title: 'YO!LUCK',
  35 + page: 'yoluck-list-back',
  36 + tabpanel: result,
  37 + localCss: true,
  38 + nodownload: true,
  39 + width750: true,
  40 + wechatShare: true
  41 + });
  42 + }).catch(e => next(_handelErrorMessage(e)));
  43 +}
  44 +
  45 +function nextPage(req, res, next) {
  46 + const page = req.query.page || 1;
  47 + const type = Number(req.query.type || 0);
  48 + const uid = _.get(req.user, 'uid', '');
  49 +
  50 + if (!Object.values(YOLUCK_LIST_TYPE).includes(type)) {
  51 + return res.json({
  52 + code: 404,
  53 + message: '参数错误'
  54 + });
  55 + }
  56 +
  57 + req.ctx(YoLuckService).getList({page, type, uid}).then(result => {
  58 + if (result.error) {
  59 + if (result.error === 400) {
  60 + return res.json({code: 400, message: '用户未登录'});
  61 + } else {
  62 + return res.json({code: 404, message: '参数错误'});
  63 + }
  64 + }
  65 +
  66 + res.json({code: 200, data: result});
  67 + }).catch(next);
  68 +}
  69 +
  70 +function detail(req, res, next) {
  71 + const id = req.params.id;
  72 + const uid = req.user.uid;
  73 +
  74 + if (!id) {
  75 + return next(Error('页面不存在'));
  76 + }
  77 +
  78 + req.ctx(YoLuckService).getDetail(id, uid).then(result => {
  79 + if (result.error) {
  80 + return Promise.reject(result.error);
  81 + }
  82 +
  83 + res.render('yoluck-back/detail', {
  84 + title: 'YO!LUCK',
  85 + page: 'yoluck-detail-back',
  86 + result,
  87 + localCss: true,
  88 + nodownload: true,
  89 + width750: true,
  90 + wechatShare: true
  91 + });
  92 +
  93 + }).catch(e => next(_handelErrorMessage(e)));
  94 +}
  95 +
  96 +
  97 +function getCode(req, res, next) {
  98 + const shareUid = req.body.shareUid;
  99 + const actPrizeId = req.params.id;
  100 + const uid = req.user.uid;
  101 +
  102 + if (!actPrizeId) {
  103 + return res.json({
  104 + error: '活动参数错误'
  105 + });
  106 + }
  107 +
  108 + req.ctx(YoLuckService).getCode({shareUid, uid, actPrizeId}).then(result => {
  109 + if (result.error) {
  110 + return res.json({code: 404, message: result.error});
  111 + }
  112 +
  113 + res.json({code: 200, data: result});
  114 + }).catch(next);
  115 +}
  116 +
  117 +function getActivityCodeList(req, res, next) {
  118 + const actPrizeId = req.body.id;
  119 + const uid = req.user.uid;
  120 +
  121 + if (!actPrizeId || !uid) {
  122 + return res.json({code: 200, data: []});
  123 + }
  124 +
  125 + req.ctx(YoLuckService).getActivityCodeList(req.user.uid, actPrizeId).then(result => {
  126 + if (result.error) {
  127 + return res.json({code: 404, message: result.error});
  128 + }
  129 +
  130 + res.json({code: 200, data: result});
  131 + }).catch(next);
  132 +}
  133 +
  134 +module.exports = {
  135 + index,
  136 + nextPage,
  137 +
  138 + detail,
  139 +
  140 + getCode,
  141 +
  142 + getActivityCodeList
  143 +};
@@ -42,6 +42,7 @@ function index(req, res, next) { @@ -42,6 +42,7 @@ function index(req, res, next) {
42 }).catch(e => next(_handelErrorMessage(e))); 42 }).catch(e => next(_handelErrorMessage(e)));
43 } 43 }
44 44
  45 +// 列表页分页
45 function nextPage(req, res, next) { 46 function nextPage(req, res, next) {
46 const page = req.query.page || 1; 47 const page = req.query.page || 1;
47 const type = Number(req.query.type || 0); 48 const type = Number(req.query.type || 0);
  1 +const MODULE = '/activity/zerobuy';
  2 +const serviceAPI = global.yoho.ServiceAPI;
  3 +
  4 +const yoLuckApi = new global.yoho.ApiBase(global.yoho.config.domains.yoLuck, {
  5 + name: 'yoLuck',
  6 + cache: global.yoho.cache,
  7 + useCache: false
  8 +});
  9 +
  10 +function productTime(p) {
  11 + if (p.status === 1) {
  12 + p.end_time = 0;
  13 + }
  14 +
  15 + p.price = p.price.replace('¥', '¥');
  16 +
  17 + return p;
  18 +}
  19 +
  20 +function formatCountDown(end) {
  21 + if (end === 0 || (end * 1000 - Date.now() < 0)) {
  22 + return '00000000';
  23 + }
  24 +
  25 + let timeInSecond = (end * 1000 - Date.now()) / 1000;
  26 +
  27 + let day = 24 * 60 * 60;
  28 + let numberOfDay = Math.floor(timeInSecond / day);
  29 +
  30 + timeInSecond = timeInSecond - numberOfDay * day;
  31 + numberOfDay = Math.min(numberOfDay, 99);
  32 +
  33 + let hour = 60 * 60;
  34 + let numberOfHour = Math.floor(timeInSecond / hour);
  35 +
  36 + timeInSecond = timeInSecond - numberOfHour * hour;
  37 +
  38 + let minute = 60;
  39 + let numberOfMinute = Math.floor(timeInSecond / minute);
  40 +
  41 + timeInSecond = timeInSecond - numberOfMinute * minute;
  42 +
  43 + let numberOfSecond = parseInt(timeInSecond, 10);
  44 +
  45 + let list = [numberOfDay, numberOfHour, numberOfMinute, numberOfSecond];
  46 +
  47 + for (let i = 0; i < list.length; i++) {
  48 + let item = list[i];
  49 +
  50 + if (item < 10) {
  51 + list[i] = '0' + item;
  52 + } else {
  53 + list[i] = '' + item;
  54 + }
  55 + }
  56 + return list;
  57 +}
  58 +
  59 +class YoLuckApi extends global.yoho.BaseModel {
  60 + constructor(ctx) {
  61 + super(ctx);
  62 + }
  63 +
  64 + /**
  65 + * 列表页
  66 + * @param page
  67 + * @param type
  68 + * @returns {Promise}
  69 + */
  70 + getList({page, type}) {
  71 + return yoLuckApi.get(MODULE + '/list', {
  72 + page,
  73 + type,
  74 + channel: 0
  75 + }).then(result => {
  76 + if (result.code === 200) {
  77 + const products = result.data;
  78 + const newProducts = products.map((p) => {
  79 + p = productTime(p);
  80 + p.countdown = formatCountDown(p.end_time);
  81 +
  82 + return p;
  83 + });
  84 +
  85 + result.data = newProducts;
  86 + return result;
  87 + }
  88 +
  89 + return result;
  90 + });
  91 +
  92 + }
  93 +
  94 + /**
  95 + * 详情页
  96 + * @param actPrizeId
  97 + * @returns {Promise}
  98 + */
  99 + getDetail({actPrizeId, uid}) {
  100 + return yoLuckApi.get(MODULE + '/content', {actPrizeId, uid}).then(result => {
  101 + if (result.code === 200) {
  102 + productTime(result.data);
  103 + result.data.countdown = formatCountDown(result.data.end_time);
  104 + }
  105 +
  106 + return result;
  107 + });
  108 + }
  109 +
  110 + /**
  111 + * 推荐列表
  112 + * @param actPrizeId
  113 + * @returns {Promise}
  114 + */
  115 + getRecommend({actPrizeId}) {
  116 + return yoLuckApi.get(MODULE + '/list/recommend', {
  117 + actPrizeId,
  118 + channel: 0
  119 + }).then(result => {
  120 + if (result.code === 200) {
  121 + const products = result.data;
  122 + const newProducts = products.map((p) => {
  123 + p = productTime(p);
  124 + p.countdown = formatCountDown(p.end_time);
  125 +
  126 + return p;
  127 + });
  128 +
  129 + result.data = newProducts;
  130 + return result;
  131 + }
  132 +
  133 + return result;
  134 + });
  135 + }
  136 +
  137 + /**
  138 + * 已参加用户
  139 + * @param actPrizeId
  140 + * @returns {Promise}
  141 + */
  142 + getRecentAvatars({actPrizeId}) {
  143 + return yoLuckApi.get(MODULE + '/code/recent', {actPrizeId});
  144 + }
  145 +
  146 + /**
  147 + * 我的列表
  148 + * @param page
  149 + * @param type
  150 + * @returns {Promise}
  151 + */
  152 + getMyList({page, type, limit, uid}) {
  153 + return yoLuckApi.get(MODULE + '/list/mine', {type, page, uid, limit, channel: 0});
  154 + }
  155 +
  156 + /**
  157 + * 我的抽奖码列表(单个活动)
  158 + * @param uid
  159 + * @param actPrizeId
  160 + * @returns {Promise}
  161 + */
  162 + getMyListWithActid(uid, actPrizeId) {
  163 + return yoLuckApi.get(MODULE + '/code/mine', {uid, actPrizeId});
  164 + }
  165 +
  166 + /**
  167 + * 获得分享码
  168 + * @param shareUid
  169 + * @param uid
  170 + * @param actPrizeId
  171 + * @param userThumb
  172 + * @param userName
  173 + * @returns {Promise}
  174 + */
  175 + fetchCode({shareUid, uid, actPrizeId, userThumb, userName}) {
  176 + return yoLuckApi.post(MODULE + '/code/gain', {
  177 + shareUid,
  178 + uid,
  179 + actPrizeId,
  180 + userThumb,
  181 + userName
  182 + });
  183 + }
  184 +
  185 + _getResourceCode(param) {
  186 + return this.get({
  187 + api: serviceAPI,
  188 + url: 'operations/api/v5/resource/get',
  189 + data: {
  190 + content_code: param.contentCode,
  191 + platform: 'iphone'
  192 + },
  193 + param: {code: 200}
  194 + }).then((result) => {
  195 + result = result.data;
  196 +
  197 + return result;
  198 + });
  199 + }
  200 +
  201 + _getUsreInfo(uid) {
  202 + if (!uid) {
  203 + return Promise.resolve({
  204 + code: 400
  205 + });
  206 + }
  207 +
  208 + return this.get({
  209 + data: {
  210 + method: 'app.passport.profile',
  211 + uid: uid
  212 + },
  213 + param: {
  214 + code: 200
  215 + }
  216 + });
  217 + }
  218 +
  219 +}
  220 +
  221 +module.exports = YoLuckApi;
1 -const MODULE = '/activity/zerobuy';  
2 const serviceAPI = global.yoho.ServiceAPI; 1 const serviceAPI = global.yoho.ServiceAPI;
3 2
4 -const yoLuckApi = new global.yoho.ApiBase(global.yoho.config.domains.yoLuck, {  
5 - name: 'yoLuck',  
6 - cache: global.yoho.cache,  
7 - useCache: false  
8 -});  
9 -  
10 function productTime(p) { 3 function productTime(p) {
11 if (p.status === 1) { 4 if (p.status === 1) {
12 p.end_time = 0; 5 p.end_time = 0;
@@ -68,27 +61,31 @@ class YoLuckApi extends global.yoho.BaseModel { @@ -68,27 +61,31 @@ class YoLuckApi extends global.yoho.BaseModel {
68 * @returns {Promise} 61 * @returns {Promise}
69 */ 62 */
70 getList({page, type}) { 63 getList({page, type}) {
71 - return yoLuckApi.get(MODULE + '/list', {  
72 - page,  
73 - type,  
74 - channel: 0 64 + // 已改成java接口,数据结构改变,字段名改变
  65 + return this.get({
  66 + data: {
  67 + method: 'app.yoluck.activityList',
  68 + type,
  69 + page,
  70 + channel: 0,
  71 + size: 10
  72 + }
75 }).then(result => { 73 }).then(result => {
76 if (result.code === 200) { 74 if (result.code === 200) {
77 - const products = result.data; 75 + const products = result.data.list;
78 const newProducts = products.map((p) => { 76 const newProducts = products.map((p) => {
79 p = productTime(p); 77 p = productTime(p);
80 - p.countdown = formatCountDown(p.end_time); 78 + p.countdown = formatCountDown(p.endTime);
81 79
82 return p; 80 return p;
83 }); 81 });
84 82
85 - result.data = newProducts; 83 + result.data.list = newProducts;
86 return result; 84 return result;
87 } 85 }
88 86
89 return result; 87 return result;
90 }); 88 });
91 -  
92 } 89 }
93 90
94 /** 91 /**
@@ -97,10 +94,16 @@ class YoLuckApi extends global.yoho.BaseModel { @@ -97,10 +94,16 @@ class YoLuckApi extends global.yoho.BaseModel {
97 * @returns {Promise} 94 * @returns {Promise}
98 */ 95 */
99 getDetail({actPrizeId, uid}) { 96 getDetail({actPrizeId, uid}) {
100 - return yoLuckApi.get(MODULE + '/content', {actPrizeId, uid}).then(result => { 97 + return this.get({
  98 + data: {
  99 + method: 'app.yoluck.getContent',
  100 + uid,
  101 + actPrizeId
  102 + }
  103 + }).then(result => {
101 if (result.code === 200) { 104 if (result.code === 200) {
102 productTime(result.data); 105 productTime(result.data);
103 - result.data.countdown = formatCountDown(result.data.end_time); 106 + result.data.countdown = formatCountDown(result.data.endTime);
104 } 107 }
105 108
106 return result; 109 return result;
@@ -113,9 +116,12 @@ class YoLuckApi extends global.yoho.BaseModel { @@ -113,9 +116,12 @@ class YoLuckApi extends global.yoho.BaseModel {
113 * @returns {Promise} 116 * @returns {Promise}
114 */ 117 */
115 getRecommend({actPrizeId}) { 118 getRecommend({actPrizeId}) {
116 - return yoLuckApi.get(MODULE + '/list/recommend', {  
117 - actPrizeId,  
118 - channel: 0 119 + return this.get({
  120 + data: {
  121 + method: 'app.yoluck.recommendList',
  122 + actPrizeId,
  123 + channel: 0
  124 + }
119 }).then(result => { 125 }).then(result => {
120 if (result.code === 200) { 126 if (result.code === 200) {
121 const products = result.data; 127 const products = result.data;
@@ -140,7 +146,12 @@ class YoLuckApi extends global.yoho.BaseModel { @@ -140,7 +146,12 @@ class YoLuckApi extends global.yoho.BaseModel {
140 * @returns {Promise} 146 * @returns {Promise}
141 */ 147 */
142 getRecentAvatars({actPrizeId}) { 148 getRecentAvatars({actPrizeId}) {
143 - return yoLuckApi.get(MODULE + '/code/recent', {actPrizeId}); 149 + return this.get({
  150 + data: {
  151 + method: 'app.yoluck.recent',
  152 + actPrizeId
  153 + }
  154 + });
144 } 155 }
145 156
146 /** 157 /**
@@ -150,7 +161,16 @@ class YoLuckApi extends global.yoho.BaseModel { @@ -150,7 +161,16 @@ class YoLuckApi extends global.yoho.BaseModel {
150 * @returns {Promise} 161 * @returns {Promise}
151 */ 162 */
152 getMyList({page, type, limit, uid}) { 163 getMyList({page, type, limit, uid}) {
153 - return yoLuckApi.get(MODULE + '/list/mine', {type, page, uid, limit, channel: 0}); 164 + return this.get({
  165 + data: {
  166 + method: 'app.yoluck.participationList',
  167 + type,
  168 + page,
  169 + uid,
  170 + size: limit,
  171 + channel: 0
  172 + }
  173 + });
154 } 174 }
155 175
156 /** 176 /**
@@ -160,7 +180,13 @@ class YoLuckApi extends global.yoho.BaseModel { @@ -160,7 +180,13 @@ class YoLuckApi extends global.yoho.BaseModel {
160 * @returns {Promise} 180 * @returns {Promise}
161 */ 181 */
162 getMyListWithActid(uid, actPrizeId) { 182 getMyListWithActid(uid, actPrizeId) {
163 - return yoLuckApi.get(MODULE + '/code/mine', {uid, actPrizeId}); 183 + return this.get({
  184 + data: {
  185 + method: 'app.yoluck.userCode',
  186 + uid,
  187 + actPrizeId
  188 + }
  189 + });
164 } 190 }
165 191
166 /** 192 /**
@@ -173,12 +199,15 @@ class YoLuckApi extends global.yoho.BaseModel { @@ -173,12 +199,15 @@ class YoLuckApi extends global.yoho.BaseModel {
173 * @returns {Promise} 199 * @returns {Promise}
174 */ 200 */
175 fetchCode({shareUid, uid, actPrizeId, userThumb, userName}) { 201 fetchCode({shareUid, uid, actPrizeId, userThumb, userName}) {
176 - return yoLuckApi.post(MODULE + '/code/gain', {  
177 - shareUid,  
178 - uid,  
179 - actPrizeId,  
180 - userThumb,  
181 - userName 202 + return this.get({
  203 + data: {
  204 + method: 'app.yoluck.getCode',
  205 + actPrizeId,
  206 + uid,
  207 + shareUid,
  208 + userName,
  209 + userThumb
  210 + }
182 }); 211 });
183 } 212 }
184 213
  1 +const YoLuckApi = require('./yoluck-api-back');
  2 +const _ = require('lodash');
  3 +const logger = global.yoho.logger;
  4 +
  5 +const YOLUCK_LIST_TYPE = {
  6 + running: 0,
  7 + ready: 1,
  8 + finished: 2,
  9 + joined: 3
  10 +};
  11 +
  12 +const YOLUCK_MYLIST_TYPE = {
  13 + running: 0,
  14 + finished: 1
  15 +};
  16 +
  17 +const ACTIVITY = {
  18 + UNKNOWN: 0,
  19 + READY: 1, // 活动未开始
  20 + START: 2, // 活动开始
  21 + END: 3, // 活动结束
  22 + LUCK: 4, // 抽奖结束
  23 + END_LESS_PEOPLE: 5 // 人数不足
  24 +};
  25 +
  26 +const STEP = {
  27 + ZERO: 0,
  28 + FIRST: 1,
  29 + SECOND: 2,
  30 + THIRD: 3,
  31 + FOURTH: 4,
  32 +};
  33 +
  34 +const ACTION_BAR_STATUS = {
  35 + UNKNOWN: 0,
  36 + READY: 1, // 未开始
  37 + START: 2, // 参加
  38 + ALEADY: 3, // 已参加活动
  39 + WAIT: 4, // 等待抽奖中
  40 + LUCK: 5, // 抽奖结束
  41 + END: 6, // 活动结束
  42 +};
  43 +
  44 +class YoLuckService extends global.yoho.BaseModel {
  45 + constructor(ctx) {
  46 + super(ctx);
  47 + this.api = new YoLuckApi(ctx);
  48 + }
  49 +
  50 + async index(type = YOLUCK_LIST_TYPE.running, uid) {
  51 + try {
  52 + const [r1, r2] = await Promise.all([
  53 + this.getList({page: 1, type, uid}),
  54 + this.getBottomBanner()
  55 + ]);
  56 +
  57 + if (r1.error) {
  58 + return r1;
  59 + }
  60 +
  61 + const desc = {
  62 + [YOLUCK_LIST_TYPE.running]: '进行中',
  63 + [YOLUCK_LIST_TYPE.ready]: '即将开始',
  64 + [YOLUCK_LIST_TYPE.finished]: '已结束',
  65 + [YOLUCK_LIST_TYPE.joined]: '已参加',
  66 + };
  67 +
  68 + const pages = {
  69 + tabs: [{
  70 + type: YOLUCK_LIST_TYPE.running,
  71 + active: false,
  72 + key: desc[YOLUCK_LIST_TYPE.running]
  73 + }, {
  74 + type: YOLUCK_LIST_TYPE.ready,
  75 + active: false,
  76 + key: desc[YOLUCK_LIST_TYPE.ready]
  77 + }, {
  78 + type: YOLUCK_LIST_TYPE.finished,
  79 + active: false,
  80 + key: desc[YOLUCK_LIST_TYPE.finished]
  81 + }, {
  82 + type: YOLUCK_LIST_TYPE.joined,
  83 + active: false,
  84 + key: desc[YOLUCK_LIST_TYPE.joined]
  85 + }],
  86 + panels: [{
  87 + type: YOLUCK_LIST_TYPE.running,
  88 + active: false,
  89 + list: [],
  90 + key: desc[YOLUCK_LIST_TYPE.running]
  91 + }, {
  92 + type: YOLUCK_LIST_TYPE.ready,
  93 + active: false,
  94 + list: []
  95 + }, {
  96 + type: YOLUCK_LIST_TYPE.finished,
  97 + active: false,
  98 + list: [],
  99 + key: desc[YOLUCK_LIST_TYPE.running]
  100 + }, {
  101 + type: YOLUCK_LIST_TYPE.joined,
  102 + active: false,
  103 + list: [],
  104 + key: desc[YOLUCK_LIST_TYPE.joined]
  105 + }],
  106 + resource: r2,
  107 + currentType: type
  108 + };
  109 +
  110 + for (let t of Object.keys(pages.tabs)) {
  111 + let tab = pages.tabs[t];
  112 + let panel = pages.panels[t];
  113 +
  114 + if (tab.type === type) {
  115 + tab.active = true;
  116 + panel.active = true;
  117 + panel.list = r1;
  118 + }
  119 + }
  120 +
  121 + return pages;
  122 + } catch (e) {
  123 + return {
  124 + error: e
  125 + };
  126 + }
  127 + }
  128 +
  129 + async getList({page, type, uid}) {
  130 + try {
  131 + let result;
  132 +
  133 + if (type === YOLUCK_LIST_TYPE.joined) {
  134 + if (!uid) {
  135 + return {
  136 + error: 400,
  137 + };
  138 + }
  139 +
  140 + const [resRunning, resFinished] = await Promise.all([
  141 + this.getMyListNext({page: 1, limit: 1000, type: YOLUCK_MYLIST_TYPE.running, uid}),
  142 + await this.getMyListNext({page: 1, limit: 1000, type: YOLUCK_MYLIST_TYPE.finished, uid})
  143 + ]);
  144 +
  145 + result = [];
  146 +
  147 + if (resRunning.error) {
  148 + result.push([]);
  149 + } else {
  150 + result.push(resRunning);
  151 + }
  152 +
  153 + if (resFinished.error) {
  154 + result.push([]);
  155 + } else {
  156 + result.push(resFinished);
  157 + }
  158 +
  159 + return result;
  160 + } else {
  161 + result = await this.api.getList({page, type});
  162 + }
  163 +
  164 + if (result.code !== 200) {
  165 + return {
  166 + error: '出错了'
  167 + };
  168 + }
  169 +
  170 + return result.data;
  171 + } catch (e) {
  172 + return {
  173 + error: e
  174 + };
  175 + }
  176 + }
  177 +
  178 + async _getDetail(actPrizeId, uid) {
  179 + try {
  180 + const result = await this.api.getDetail({actPrizeId, uid});
  181 +
  182 + if (result.code !== 200) {
  183 + return {
  184 + error: 'error'
  185 + };
  186 + }
  187 +
  188 + return result.data;
  189 + } catch (e) {
  190 + return {
  191 + error: e
  192 + };
  193 + }
  194 + }
  195 +
  196 + async _getRecentAvatars(actPrizeId) {
  197 + try {
  198 + const result = await this.api.getRecentAvatars({actPrizeId});
  199 +
  200 + if (result.code !== 200) {
  201 + return {
  202 + error: 'error'
  203 + };
  204 + }
  205 +
  206 + return result.data;
  207 + } catch (e) {
  208 + return {
  209 + error: '出错了'
  210 + };
  211 + }
  212 + }
  213 +
  214 + async getDetail(actPrizeId, uid) {
  215 + let userName = uid && _.get(this.ctx.req, 'user.NAME');
  216 +
  217 + const [r1, r2, r3, r4] = await Promise.all([
  218 + this._getDetail(actPrizeId, uid),
  219 + this._getRecentAvatars(actPrizeId),
  220 + this.getDetailBanner(),
  221 + userName ? Promise.resolve({}) : this.api._getUsreInfo(uid)
  222 + ]);
  223 +
  224 + const result = {};
  225 +
  226 + if (r1.error) {
  227 + result.error = r1.error;
  228 + return result;
  229 + }
  230 +
  231 + result.userName = userName || _.get(r4, 'data.nickname', '') || '';
  232 + result.actPrizeId = actPrizeId;
  233 + result.product = !r1.error ? r1 : {};
  234 + result.avatars = !r2.error ? r2.map(i => {
  235 + i.user_name = this.wrapperName(i.user_name);
  236 + i.user_thumb = i.user_thumb || 'http://img12.static.yhbimg.com/sns/2018/08/02/15/0237a5305f921865764e8409fcffbd3299.png';
  237 + return i;
  238 + }) : [];
  239 +
  240 + result.myPrizeCount = !r1.error ? r1.myCodeNum : 0;
  241 + result.product.myPrizeCount = result.myPrizeCount;
  242 +
  243 + let participantCount = !r1.error ? r1.joinNum : 0;
  244 +
  245 + if (r1.status === ACTIVITY.END || r1.status === ACTIVITY.LUCK) {
  246 + participantCount = r1.limit;
  247 + }
  248 +
  249 + let notice;
  250 +
  251 + try {
  252 + notice = JSON.parse(result.product.notice);
  253 + } catch (e) {} // eslint-disable-line
  254 +
  255 + notice = _.assign({}, notice);
  256 + notice.content = notice.content || '关注公众号“潮流有货”,发送“开奖”查看中奖结果';
  257 + notice.h5BtnName = notice.h5BtnName || '关注';
  258 +
  259 + result.product.notice = notice;
  260 +
  261 + result.product.participantCount = participantCount;
  262 + result.actionStatus = this.setActionStatus(result.product);
  263 + result.resource = r3;
  264 +
  265 + this.setStep(result);
  266 +
  267 + return result;
  268 + }
  269 +
  270 + wrapperName(name) {
  271 + if (!name) {
  272 + return '';
  273 + }
  274 +
  275 + let nL = name.length;
  276 + let newName = [];
  277 +
  278 + if (nL > 5) {
  279 + newName.push(name[0]);
  280 + newName.push(name[1]);
  281 + newName.push('*');
  282 + newName.push('*');
  283 + newName.push(name[nL - 1]);
  284 +
  285 + return newName.join('');
  286 + } else {
  287 + return name;
  288 + }
  289 + }
  290 +
  291 + formatN(format, num) {
  292 + let n = num + '';
  293 + let nList = n.split('');
  294 + let l = nList.length;
  295 + let fl = format.length;
  296 +
  297 + if (format.length < nList.length) {
  298 + return nList;
  299 + }
  300 +
  301 + let el = fl - l;
  302 +
  303 + for (let i = 0; i < el; i++) {
  304 + nList.splice(0, 0, '0');
  305 + }
  306 +
  307 + return nList.join('');
  308 + }
  309 +
  310 + setActionStatus(product) {
  311 + let status = ACTION_BAR_STATUS.START;
  312 + let activityStatus = product.status;
  313 +
  314 + if (activityStatus === ACTIVITY.UNKNOWN) {
  315 + status = ACTION_BAR_STATUS.END;
  316 + } else if (activityStatus === ACTIVITY.READY) {
  317 + status = ACTION_BAR_STATUS.READY;
  318 + } else if (activityStatus >= ACTIVITY.END) {
  319 + if (this.isInActivity(product)) {
  320 + if (activityStatus === ACTIVITY.LUCK) {
  321 + status = ACTION_BAR_STATUS.LUCK;
  322 + } else {
  323 + status = ACTION_BAR_STATUS.WAIT;
  324 + }
  325 + } else {
  326 + status = ACTION_BAR_STATUS.END;
  327 + }
  328 + } else {
  329 + if (this.isInActivity(product)) {
  330 + status = ACTION_BAR_STATUS.ALEADY;
  331 + } else {
  332 + status = ACTION_BAR_STATUS.START;
  333 + }
  334 + }
  335 +
  336 + return status;
  337 + }
  338 +
  339 + isInActivity(p) {
  340 + return p.myPrizeCount > 0;
  341 + }
  342 +
  343 + setStep(result) {
  344 + let step = STEP.ZERO;
  345 + let activityStatus = result.product.status;
  346 + let myPrizeCount = result.product.myPrizeCount;
  347 +
  348 + if (myPrizeCount === 0) {
  349 + step = STEP.ZERO;
  350 + } else {
  351 + if (activityStatus === ACTIVITY.START) {
  352 + myPrizeCount = result.myPrizeCount;
  353 +
  354 + if (myPrizeCount === 0) {
  355 + step = STEP.ZERO;
  356 + } else if (myPrizeCount === 1) {
  357 + step = STEP.FIRST;
  358 + } else if (myPrizeCount >= 2) {
  359 + step = STEP.SECOND;
  360 + } else {
  361 + step = STEP.ZERO;
  362 + }
  363 + } else if (activityStatus === ACTIVITY.END || activityStatus === ACTIVITY.LUCK) {
  364 + step = STEP.THIRD;
  365 + } else if (activityStatus === ACTIVITY.END_LESS_PEOPLE) {
  366 + step = STEP.FOURTH;
  367 + } else {
  368 + step = STEP.ZERO;
  369 + }
  370 + }
  371 +
  372 + result.step = step;
  373 + }
  374 +
  375 +
  376 + async getMyListNext({page, type, limit, uid}) {
  377 + try {
  378 + const result = await this.api.getMyList({page, type, uid, limit});
  379 +
  380 + if (result.code !== 200) {
  381 + return {
  382 + error: '出错了'
  383 + };
  384 + }
  385 +
  386 + return result.data;
  387 + } catch (e) {
  388 + return {
  389 + error: e
  390 + };
  391 + }
  392 + }
  393 +
  394 + async getResourceCode(params) {
  395 + const result = await this.api._getResourceCode(params);
  396 + const url = _.get(result, '[0].data.list[0]', {});
  397 +
  398 + url.width = _.get(result, '[0].data.imageWidth', 0);
  399 + url.height = _.get(result, '[0].data.imageHeight', 0);
  400 +
  401 + return url;
  402 + }
  403 +
  404 + async getDetailBanner() {
  405 + try {
  406 + const result = await this.getResourceCode({
  407 + contentCode: 'ccc32dbedf164a52b4efa34383878860'
  408 + });
  409 +
  410 + if (!result.width) {
  411 + result.width = 750;
  412 + result.height = 140;
  413 + }
  414 +
  415 + return result;
  416 + } catch (e) {
  417 + return {
  418 + error: '出错了'
  419 + };
  420 + }
  421 + }
  422 +
  423 + async getBottomBanner() {
  424 + try {
  425 + const result = await this.getResourceCode({
  426 + contentCode: '5a2203f5656fbc9788bd8af70f2823d3'
  427 + });
  428 +
  429 + if (!result.width) {
  430 + result.width = 750;
  431 + result.height = 234;
  432 + }
  433 +
  434 + return result;
  435 + } catch (e) {
  436 + return {
  437 + error: '出错了'
  438 + };
  439 + }
  440 + }
  441 +
  442 + async getCode({shareUid, uid, actPrizeId}) {
  443 + try {
  444 + let userInfo = await this.api._getUsreInfo(uid);
  445 +
  446 + let userName = _.get(userInfo, 'data.nickname', '');
  447 + let userThumb = _.get(userInfo, 'data.head_ico', '');
  448 +
  449 + const result = await this.api.fetchCode({
  450 + shareUid,
  451 + uid,
  452 + actPrizeId,
  453 + userThumb,
  454 + userName
  455 + });
  456 +
  457 + if (result.code !== 200) {
  458 + logger.error(result);
  459 +
  460 + return {
  461 + error: '错误'
  462 + };
  463 + }
  464 +
  465 + if (userThumb.indexOf('?') > 0) {
  466 + userThumb = _.split(userThumb, '?')[0] + '?imageView2/2/w/70/h/70/q/60';
  467 + }
  468 +
  469 + return _.assign({userThumb}, result.data);
  470 + } catch (e) {
  471 + logger.error(e);
  472 +
  473 + return {
  474 + error: '出错了'
  475 + };
  476 + }
  477 + }
  478 +
  479 + async getActivityCodeList(uid, actPrizeId) {
  480 + let result = await this.api.getMyListWithActid(uid, actPrizeId);
  481 +
  482 + let codeList = [];
  483 + let nearAvatar = '//img10.static.yhbimg.com/headimg/2013/11/28/09/01cae078abe5fe320c88cdf4c220212688.gif?imageView/2/w/100/h/100'; // eslint-disable-line
  484 +
  485 + _.forEach(_.get(result, 'data', []), value => {
  486 + if (value.prize_code) {
  487 + if (value.user_thumb.indexOf('headimg') > 0) {
  488 + value.user_thumb = nearAvatar;
  489 + } else {
  490 + if (value.user_thumb.indexOf('?') > 0) {
  491 + value.user_thumb = _.split(value.user_thumb, '?')[0] + '?imageView2/2/w/70/h/70/q/60';
  492 + }
  493 + nearAvatar = value.user_thumb;
  494 + }
  495 +
  496 + codeList.push({
  497 + prizeCode: value.prize_code,
  498 + userThumb: value.user_thumb
  499 + });
  500 + }
  501 + });
  502 +
  503 + return codeList;
  504 + }
  505 +}
  506 +
  507 +module.exports = {
  508 + YOLUCK_LIST_TYPE,
  509 + YoLuckService
  510 +};
@@ -138,7 +138,7 @@ class YoLuckService extends global.yoho.BaseModel { @@ -138,7 +138,7 @@ class YoLuckService extends global.yoho.BaseModel {
138 } 138 }
139 139
140 const [resRunning, resFinished] = await Promise.all([ 140 const [resRunning, resFinished] = await Promise.all([
141 - this.getMyListNext({page: 1, limit: 1000, type: YOLUCK_MYLIST_TYPE.running, uid}), 141 + await this.getMyListNext({page: 1, limit: 1000, type: YOLUCK_MYLIST_TYPE.running, uid}),
142 await this.getMyListNext({page: 1, limit: 1000, type: YOLUCK_MYLIST_TYPE.finished, uid}) 142 await this.getMyListNext({page: 1, limit: 1000, type: YOLUCK_MYLIST_TYPE.finished, uid})
143 ]); 143 ]);
144 144
@@ -166,7 +166,6 @@ class YoLuckService extends global.yoho.BaseModel { @@ -166,7 +166,6 @@ class YoLuckService extends global.yoho.BaseModel {
166 error: '出错了' 166 error: '出错了'
167 }; 167 };
168 } 168 }
169 -  
170 return result.data; 169 return result.data;
171 } catch (e) { 170 } catch (e) {
172 return { 171 return {
@@ -232,8 +231,8 @@ class YoLuckService extends global.yoho.BaseModel { @@ -232,8 +231,8 @@ class YoLuckService extends global.yoho.BaseModel {
232 result.actPrizeId = actPrizeId; 231 result.actPrizeId = actPrizeId;
233 result.product = !r1.error ? r1 : {}; 232 result.product = !r1.error ? r1 : {};
234 result.avatars = !r2.error ? r2.map(i => { 233 result.avatars = !r2.error ? r2.map(i => {
235 - i.user_name = this.wrapperName(i.user_name);  
236 - i.user_thumb = i.user_thumb || 'http://img12.static.yhbimg.com/sns/2018/08/02/15/0237a5305f921865764e8409fcffbd3299.png'; 234 + i.userName = this.wrapperName(i.userName);
  235 + i.userThumb = i.userThumb || 'http://img12.static.yhbimg.com/sns/2018/08/02/15/0237a5305f921865764e8409fcffbd3299.png';
237 return i; 236 return i;
238 }) : []; 237 }) : [];
239 238
@@ -383,7 +382,7 @@ class YoLuckService extends global.yoho.BaseModel { @@ -383,7 +382,7 @@ class YoLuckService extends global.yoho.BaseModel {
383 }; 382 };
384 } 383 }
385 384
386 - return result.data; 385 + return result;
387 } catch (e) { 386 } catch (e) {
388 return { 387 return {
389 error: e 388 error: e
@@ -442,7 +441,6 @@ class YoLuckService extends global.yoho.BaseModel { @@ -442,7 +441,6 @@ class YoLuckService extends global.yoho.BaseModel {
442 async getCode({shareUid, uid, actPrizeId}) { 441 async getCode({shareUid, uid, actPrizeId}) {
443 try { 442 try {
444 let userInfo = await this.api._getUsreInfo(uid); 443 let userInfo = await this.api._getUsreInfo(uid);
445 -  
446 let userName = _.get(userInfo, 'data.nickname', ''); 444 let userName = _.get(userInfo, 'data.nickname', '');
447 let userThumb = _.get(userInfo, 'data.head_ico', ''); 445 let userThumb = _.get(userInfo, 'data.head_ico', '');
448 446
@@ -478,24 +476,23 @@ class YoLuckService extends global.yoho.BaseModel { @@ -478,24 +476,23 @@ class YoLuckService extends global.yoho.BaseModel {
478 476
479 async getActivityCodeList(uid, actPrizeId) { 477 async getActivityCodeList(uid, actPrizeId) {
480 let result = await this.api.getMyListWithActid(uid, actPrizeId); 478 let result = await this.api.getMyListWithActid(uid, actPrizeId);
481 -  
482 let codeList = []; 479 let codeList = [];
483 let nearAvatar = '//img10.static.yhbimg.com/headimg/2013/11/28/09/01cae078abe5fe320c88cdf4c220212688.gif?imageView/2/w/100/h/100'; // eslint-disable-line 480 let nearAvatar = '//img10.static.yhbimg.com/headimg/2013/11/28/09/01cae078abe5fe320c88cdf4c220212688.gif?imageView/2/w/100/h/100'; // eslint-disable-line
484 481
485 _.forEach(_.get(result, 'data', []), value => { 482 _.forEach(_.get(result, 'data', []), value => {
486 - if (value.prize_code) {  
487 - if (value.user_thumb.indexOf('headimg') > 0) {  
488 - value.user_thumb = nearAvatar; 483 + if (value.prizeCode) {
  484 + if (value.userThumb.indexOf('01cae078abe5fe320c88cdf4c220212688') > 0) {
  485 + value.userThumb = nearAvatar;
489 } else { 486 } else {
490 - if (value.user_thumb.indexOf('?') > 0) {  
491 - value.user_thumb = _.split(value.user_thumb, '?')[0] + '?imageView2/2/w/70/h/70/q/60'; 487 + if (value.userThumb.indexOf('?') > 0) {
  488 + value.userThumb = _.split(value.userThumb, '?')[0] + '?imageView2/2/w/70/h/70/q/60';
492 } 489 }
493 - nearAvatar = value.user_thumb; 490 + nearAvatar = value.userThumb;
494 } 491 }
495 492
496 codeList.push({ 493 codeList.push({
497 - prizeCode: value.prize_code,  
498 - userThumb: value.user_thumb 494 + prizeCode: value.prizeCode,
  495 + userThumb: value.userThumb
499 }); 496 });
500 } 497 }
501 }); 498 });
@@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
6 6
7 'use strict'; 7 'use strict';
8 8
  9 +const _ = require('lodash');
9 const router = require('express').Router(); // eslint-disable-line 10 const router = require('express').Router(); // eslint-disable-line
10 const cRoot = './controllers'; 11 const cRoot = './controllers';
11 const auth = require('../../doraemon/middleware/auth'); 12 const auth = require('../../doraemon/middleware/auth');
@@ -72,8 +73,12 @@ const haveGain = require(`${cRoot}/have-gain`); @@ -72,8 +73,12 @@ const haveGain = require(`${cRoot}/have-gain`);
72 const redPack = require(`${cRoot}/red-envelope`); 73 const redPack = require(`${cRoot}/red-envelope`);
73 74
74 const yoluck = require(`${cRoot}/yoluck`); 75 const yoluck = require(`${cRoot}/yoluck`);
  76 +
  77 +const yoluckBack = require(`${cRoot}/yoluck-back`);
  78 +
75 const group = require(`${cRoot}/group`); 79 const group = require(`${cRoot}/group`);
76 80
  81 +
77 // routers 82 // routers
78 83
79 router.get('/demo', demo.index); 84 router.get('/demo', demo.index);
@@ -357,14 +362,24 @@ router.post('/red-envelope/submitWxCode', auth, redPack.submitWxCode); @@ -357,14 +362,24 @@ router.post('/red-envelope/submitWxCode', auth, redPack.submitWxCode);
357 router.get('/have-gain/promo/:id.html', haveGain.promoDetail); 362 router.get('/have-gain/promo/:id.html', haveGain.promoDetail);
358 router.post('/have-gain/promo/:id', auth, haveGain.promoSubmit); 363 router.post('/have-gain/promo/:id', auth, haveGain.promoSubmit);
359 364
  365 +function swtichYoLuck(newMiddleware, oldMiddleware) {
  366 + return (req, res, next) => {
  367 + if (_.get(req.app.locals, 'wap.open.yoluck-down', false)) {
  368 + res.setHeader('yoluck-down', 'true');
  369 + return oldMiddleware(req, res, next);
  370 + }
  371 + return newMiddleware(req, res, next);
  372 + };
  373 +}
  374 +
360 // yoluck 375 // yoluck
361 -router.get('/yoluck/index.html', yoluck.index);  
362 -router.get('/yoluck/mylist.html', auth, yoluck.index);  
363 -router.get('/yoluck/next', yoluck.nextPage); 376 +router.get('/yoluck/index.html', swtichYoLuck(yoluck.index, yoluckBack.index));
  377 +router.get('/yoluck/mylist.html', auth, swtichYoLuck(yoluck.index, yoluckBack.index));
  378 +router.get('/yoluck/next', swtichYoLuck(yoluck.nextPage, yoluckBack.nextPage));
364 379
365 -router.get('/yoluck/:id.html', yoluck.detail);  
366 -router.post('/yoluck/:id.html', auth, yoluck.getCode);  
367 -router.post('/yoluck/detail/mylist.html', yoluck.getActivityCodeList); 380 +router.get('/yoluck/:id.html', swtichYoLuck(yoluck.detail, yoluckBack.detail));
  381 +router.post('/yoluck/:id.html', auth, swtichYoLuck(yoluck.getCode, yoluckBack.getCode));
  382 +router.post('/yoluck/detail/mylist.html', swtichYoLuck(yoluck.getActivityCodeList, yoluckBack.getActivityCodeList));
368 383
369 // 拼团 384 // 拼团
370 router.get('/group', group.index); // 拼团首页 385 router.get('/group', group.index); // 拼团首页
@@ -3,9 +3,24 @@ @@ -3,9 +3,24 @@
3 <div class="section"> 3 <div class="section">
4 <div class="apply-title">基本信息</div> 4 <div class="apply-title">基本信息</div>
5 <ul class="section-ul"> 5 <ul class="section-ul">
6 - <li><span>姓名</span><input type="text" class="name" placeholder="请输入姓名" /></li>  
7 - <li><span>手机号码</span><input type="number" class="mobile" placeholder="请输入手机号码" /></li>  
8 - <li><span>微信号</span><input type="text" class="wechat" placeholder="请输入微信号(选填)" /></li> 6 + <li>
  7 + <div class="label">姓名</div>
  8 + <div class="text">
  9 + <input type="text" class="name" placeholder="请输入姓名" />
  10 + </div>
  11 + </li>
  12 + <li>
  13 + <div class="label">手机号码</div>
  14 + <div class="text">
  15 + <input type="number" class="mobile" placeholder="请输入手机号码" />
  16 + </div>
  17 + </li>
  18 + <li>
  19 + <div class="label">微信号</div>
  20 + <div class="text">
  21 + <input type="text" class="wechat" placeholder="请输入微信号(选填)" />
  22 + </div>
  23 + </li>
9 </ul> 24 </ul>
10 <p class="other">提供微信号,方便邀您加入达人微信群,赚钱秘籍、特殊福利享不停!<br/>添加关注公众号“有货有赚”,申请状态、高佣活动早知道。<em class="added">点击添加</em></p> 25 <p class="other">提供微信号,方便邀您加入达人微信群,赚钱秘籍、特殊福利享不停!<br/>添加关注公众号“有货有赚”,申请状态、高佣活动早知道。<em class="added">点击添加</em></p>
11 </div> 26 </div>
  1 +{{#result}}
  2 + <div id="hide-info" data-username="{{userName}}"></div>
  3 +
  4 + {{#if product.status}}
  5 + {{#unless @root.isApp}}
  6 + <div class="fellow-bar-wrap">
  7 + {{> yoluck-back/fellow-bar}}
  8 + </div>
  9 + {{/unless}}
  10 + {{/if}}
  11 +
  12 + <div class="header">
  13 + {{> yoluck-back/product-detail-header product=product avatars=avatars}}
  14 + </div>
  15 +
  16 + {{> yoluck-back/lottery-machine}}
  17 +
  18 + <div class="help">
  19 + {{> yoluck-back/help}}
  20 + </div>
  21 +
  22 + {{> yoluck-back/desc list=product.content resource=resource}}
  23 +
  24 + <div class="line"></div>
  25 +
  26 + <div class="action-bar-wrap">
  27 + {{> yoluck-back/action-bar status=actionStatus num=myPrizeCount actPrizeId=actPrizeId lotteryInfo=product.lottery_info}}
  28 + </div>
  29 +
  30 + <div class="foot"></div>
  31 +
  32 + <div class="js-luck-alert">
  33 + </div>
  34 +
  35 + <div class="js-clipbroad"></div>
  36 +{{/result}}
  1 +{{#tabpanel}}
  2 + <div class="js-tab-comp" data-type="{{currentType}}">
  3 + <!--tab切-->
  4 + <div class="js-tabs tabs tabs-class">
  5 + {{#each tabs}}
  6 + <div class="js-tab tab {{#if active}}active{{/if}}" data-key="{{key}}" data-index="{{@index}}">
  7 + {{key}}
  8 + </div>
  9 + {{/each}}
  10 + </div>
  11 +
  12 + <div class="list-top-blank"></div>
  13 +
  14 + <!--panel体-->
  15 + <div class="js-panels panel-body">
  16 + {{#each panels}}
  17 + <div class="js-panel panel {{#if active}}active{{^}}inactive{{/if}}">
  18 +
  19 + <!--头部-->
  20 + {{#ifcond @index '===' 0}}
  21 + {{#ifcond list.length '!==' 0}}
  22 + <div class="js-panel-header">
  23 + <img
  24 + src="//img11.static.yhbimg.com/yhb-img01/2018/12/07/15/0188307712613ce043d4b68a94761ee1ff.gif"
  25 + alt="">
  26 + </div>
  27 + {{/ifcond}}
  28 + {{/ifcond}}
  29 +
  30 + <!--数据部-->
  31 + <div class="js-panel-body">
  32 + {{#ifcond @index '===' 3}}
  33 + {{> yoluck-back/prize-list running=list.[0] finished=list.[1] }}
  34 + {{^}}
  35 + {{#each list}}
  36 + {{> yoluck-back/product-item .}}
  37 + {{/each}}
  38 + {{/ifcond}}
  39 + </div>
  40 +
  41 + <!--尾部-->
  42 + {{#ifcond @index '!==' 3}}
  43 + <div class="js-panel-footer">
  44 + {{#if ../resource.url}}
  45 + <a class="bottom-banner" href="{{../resource.url}}">
  46 + <img src="{{image2 ../resource.src w=../resource.width h=../resource.height}}" alt="">
  47 + </a>
  48 + {{/if}}
  49 + </div>
  50 + {{/ifcond}}
  51 + </div>
  52 + {{/each}}
  53 + </div>
  54 +
  55 + <!--加载更多-->
  56 + <div class="list-foot-blank">暂无更多内容</div>
  57 +
  58 + </div>
  59 +
  60 + <div class="js-clipbroad"></div>
  61 +
  62 +{{/tabpanel}}
  63 +
  64 +
  1 +
  2 +{{#tabpanel}}
  3 + <div class="js-tab-comp">
  4 + <div class="js-tabs tabs tabs-class">
  5 + {{#each tabs}}
  6 + <div class="js-tab tab {{#if active}}active{{/if}}" data-key="{{key}}" data-index="{{@index}}">
  7 + {{key}}
  8 + </div>
  9 + {{/each}}
  10 + </div>
  11 +
  12 + <div class="fellow-bar">
  13 + {{> yoluck-back/fellow-bar}}
  14 + </div>
  15 +
  16 + <div class="list-head-blank"></div>
  17 +
  18 + <div class="js-panels panel-body">
  19 + {{#each panels}}
  20 + <div class="js-panel panel {{#if active}}active{{^}}inactive{{/if}}">
  21 + {{#each list}}
  22 + {{> yoluck-back/prize-item .}}
  23 + {{/each}}
  24 + </div>
  25 + {{/each}}
  26 + </div>
  27 +
  28 + <div class="list-foot-blank">暂无更多内容</div>
  29 + </div>
  30 +{{/tabpanel}}
@@ -24,7 +24,7 @@ @@ -24,7 +24,7 @@
24 <div class="line"></div> 24 <div class="line"></div>
25 25
26 <div class="action-bar-wrap"> 26 <div class="action-bar-wrap">
27 - {{> yoluck/action-bar status=actionStatus num=myPrizeCount actPrizeId=actPrizeId lotteryInfo=product.lottery_info}} 27 + {{> yoluck/action-bar status=actionStatus num=myPrizeCount actPrizeId=actPrizeId lotteryInfo=product.lotteryInfo}}
28 </div> 28 </div>
29 29
30 <div class="foot"></div> 30 <div class="foot"></div>
@@ -20,8 +20,7 @@ @@ -20,8 +20,7 @@
20 {{#ifcond @index '===' 0}} 20 {{#ifcond @index '===' 0}}
21 {{#ifcond list.length '!==' 0}} 21 {{#ifcond list.length '!==' 0}}
22 <div class="js-panel-header"> 22 <div class="js-panel-header">
23 - <img  
24 - src="//img11.static.yhbimg.com/yhb-img01/2018/12/07/15/0188307712613ce043d4b68a94761ee1ff.gif" 23 + <img src="//img11.static.yhbimg.com/yhb-img01/2018/12/07/15/0188307712613ce043d4b68a94761ee1ff.gif"
25 alt=""> 24 alt="">
26 </div> 25 </div>
27 {{/ifcond}} 26 {{/ifcond}}
@@ -32,7 +31,7 @@ @@ -32,7 +31,7 @@
32 {{#ifcond @index '===' 3}} 31 {{#ifcond @index '===' 3}}
33 {{> yoluck/prize-list running=list.[0] finished=list.[1] }} 32 {{> yoluck/prize-list running=list.[0] finished=list.[1] }}
34 {{^}} 33 {{^}}
35 - {{#each list}} 34 + {{#each list.list}}
36 {{> yoluck/product-item .}} 35 {{> yoluck/product-item .}}
37 {{/each}} 36 {{/each}}
38 {{/ifcond}} 37 {{/ifcond}}
  1 +<div class="action-bar-comp">
  2 + <div class="action-bar">
  3 + <a class="action-item action-list" href="/activity/yoluck/index.html">
  4 + <div class="action-image action-icon"></div>
  5 + </a>
  6 +
  7 + {{#ifcond status '===' 1}}
  8 + <div class="action-item over">即将开始</div>
  9 + {{/ifcond}}
  10 +
  11 + {{#ifcond status '===' 2}}
  12 + <div class="action-item ok js-join auth">
  13 + 0元参加抽奖
  14 + </div>
  15 + {{/ifcond}}
  16 +
  17 + {{#ifcond status '===' 3}}
  18 + <a class="action-item ok js-share auth" >
  19 + 分享得更多抽奖码,增加中奖率
  20 + </a>
  21 + {{/ifcond}}
  22 +
  23 + {{#ifcond status '===' 4}}
  24 + <a class="action-item confirm auth" href="/activity/yoluck/mylist.html?type=3">
  25 + 我的抽奖码({{num}})
  26 + </a>
  27 + {{/ifcond}}
  28 +
  29 + {{#ifcond status '===' 5}}
  30 + <a class="action-item confirm auth" href="/activity/yoluck/mylist.html?type=3">
  31 + 我的抽奖码({{num}})
  32 + </a>
  33 +
  34 + <div class="action-item ok js-lottery" data-lottery='{{lotteryInfo}}'>
  35 + 查看开奖结果
  36 + </div>
  37 + {{/ifcond}}
  38 +
  39 + {{#ifcond status '===' 6}}
  40 + <div class="action-item over">活动已结束</div>
  41 + {{/ifcond}}
  42 + </div>
  43 +</div>
  44 +
  45 +
  1 +<div class="avatar-comp">
  2 + <div class="swiper-container swiper">
  3 + <div class="swiper-wrapper">
  4 + {{#each list}}
  5 + <div class="swiper-slide avatar-item">
  6 + <img src="{{image2 user_thumb w=70 h=70 q=60}}"
  7 + class="avatar-image"/>
  8 + <div class="avatar-desc">{{user_name}}参与了抽奖</div>
  9 + </div>
  10 + {{/each}}
  11 + </div>
  12 + </div>
  13 +</div>
  1 +
  2 +<div class="head-counter">
  3 + <div class="title">
  4 + <div class="txt">已有</div>
  5 +
  6 + {{#each count}}
  7 + <div class="num-wrapper">
  8 + <span>{{.}}</span>
  9 + <div class="mask"></div>
  10 + </div>
  11 + {{/each}}
  12 + <div class="txt">参与</div>
  13 + </div>
  14 +
  15 + {{#isEqualOr status 0}}
  16 + <div class="counter-num"> 活动结束 </div>
  17 + {{/isEqualOr}}
  18 +
  19 + {{#isEqualOr status 1 2}}
  20 + <div class="counter-num"> 达到 {{num}} 人开奖 </div>
  21 + {{/isEqualOr}}
  22 +
  23 + {{#isEqualOr status 3}}
  24 + <div class="counter-num" > 待开奖 </div>
  25 + {{/isEqualOr}}
  26 +
  27 + {{#isEqualOr status 4}}
  28 + <div class="counter-num" > 已开奖 </div>
  29 + {{/isEqualOr}}
  30 +
  31 + {{#isEqualOr status 5}}
  32 + <div class="counter-num" > 待开奖 </div>
  33 + {{/isEqualOr}}
  34 +
  35 +</div>
  1 +<div class="desc-comp">
  2 + <div class="desc">
  3 + <div style="width: 100%;text-align: center;">
  4 + <div class="title">商品详情</div>
  5 + </div>
  6 +
  7 + {{#if resource.url}}
  8 + <a class="banner" href="{{resource.url}}">
  9 + <img class="banner-img" src="{{image2 resource.src w=resource.width h=resource.height}}" alt="">
  10 + </a>
  11 + {{/if}}
  12 +
  13 + <div class="desc-content">
  14 + {{#each list}}
  15 + {{#ifcond floor_type '===' 1}}
  16 + <div>{{content}}</div>
  17 + {{/ifcond}}
  18 +
  19 + {{#ifcond floor_type '===' 2}}
  20 + <img class="desc-image" src="{{image2 content q=60}}" width="100%">
  21 + {{/ifcond}}
  22 +
  23 + {{#ifcond floor_type '===' 3}}
  24 + <video class="desc-video" controls="controls">
  25 + <source src="{{content}}" type="video/mp4" />
  26 + </video>
  27 + {{/ifcond}}
  28 + {{/each}}
  29 + </div>
  30 + </div>
  31 +</div>
  1 +<div class="fellow-bar-comp">
  2 + <div id="fellow-bar" class="fellow-bar" data-type='{{product.notice.h5BtnType}}' data-tip='{{product.notice.h5Tip}}' data-copy='{{product.notice.h5Copy}}' data-link='{{product.notice.h5Link}}'>
  3 + <div class="title">{{product.notice.content}}</div>
  4 + <div class="btn js-fellow">{{product.notice.h5BtnName}}</div>
  5 + </div>
  6 +</div>
  1 +
  2 + <i class="iconfont" style="font-size: 1rem; vertical-align: middle;">&#xe73b;</i>
  3 +<a class="help-comp" href="https://activity.yoho.cn/feature/2765.html?title=%E6%B4%BB%E5%8A%A8%E8%AF%B4%E6%98%8E&nodownload=1">
  4 + 查看活动说明
  5 +</a>
  1 +<div class="lottery-machine">
  2 + <div class="machine">
  3 + <img src="//img12.static.yhbimg.com/sns/2018/12/21/14/0231fa07f32886117eccea846e03f453a3.png">
  4 + <div class="lottery-block">
  5 + <div id="lottery-list" class="lottery-list">
  6 + <div class="lottery lottery-tpl">
  7 + <div class="l-thumb"></div>
  8 + <p class="l-title">我的<br>抽奖码</p>
  9 + <p class="l-code"></p>
  10 + </div>
  11 + <p class="more-lottery">
  12 + <a href="/activity/yoluck/index.html?type=3">
  13 + <span class="iconfont">&#xe64f;</span>
  14 + </a>
  15 + </p>
  16 + </div>
  17 + </div>
  18 + </div>
  19 +</div>
  1 +<div class="modal-mask"></div>
  2 +<div class="modal-dialog">
  3 + <div class="modal-dialog-bg"></div>
  4 +
  5 + <div class="code-alert">
  6 + <text class="code-title">参加抽奖成功</text>
  7 + <div class="code-bg">
  8 + <div class="title">你的抽奖码是</div>
  9 + <div class="code">{{code}}</div>
  10 + </div>
  11 + <a class="share">分享一下,中奖概率立马double</a>
  12 + <div class="share-desc">1个好友参加=1个抽奖码=中奖几率UP!</div>
  13 + </div>
  14 +</div>
  1 +<div class="more-comp">
  2 + <div class="more">
  3 + <div class='title'>更多活动</div>
  4 + </div>
  5 +
  6 + {{#each list}}
  7 + {{> ./product-item .}}
  8 + {{/each}}
  9 +</div>
  1 +<div class="prize-item-comp">
  2 + <div class="prize-item js-prizeitem" data-id="{{act_prize_id}}">
  3 + <img class="product-image" src="{{cover_img}}" alt="">
  4 +
  5 + <div class="content">
  6 + <div class="code">抽奖码
  7 + <text style="color: black;">{{prize_code}}</text>
  8 + </div>
  9 + <div class="product-name">{{name}}</div>
  10 +
  11 + {{#ifcond status '===' 0}}
  12 + <div class="btn">活动结束</div>
  13 + {{/ifcond}}
  14 +
  15 + {{#ifcond status '===' 3}}
  16 + <div class="btn">待开奖</div>
  17 + {{/ifcond}}
  18 +
  19 + {{#ifcond status '===' 4}}
  20 + <div class="btn more js-fellow" data-id="{{act_prize_id}}" data-lottery="{{lottery_info}}">查看中奖信息</div>
  21 + {{/ifcond}}
  22 +
  23 + {{#ifcond status '===' 5}}
  24 + <div class="btn">待开奖</div>
  25 + {{/ifcond}}
  26 +
  27 + {{#isEqualOr status 1 2 6}}
  28 + <div class="btn more js-share"
  29 + data-img="{{cover_img}}"
  30 + data-name="{{name}}"
  31 + data-price="{{price}}"
  32 + data-id="{{act_prize_id}}"
  33 + >
  34 + 获得更多抽奖码
  35 + </div>
  36 + {{/isEqualOr}}
  37 +
  38 + </div>
  39 + </div>
  40 +</div>
  1 +<div style="width: 100%;background: white;">
  2 + <div class="title-view">
  3 + <span class="space-line"></span>
  4 + <span class="title">进行中</span>
  5 + </div>
  6 +</div>
  7 +
  8 +{{#ifcond running.length '>' 0}}
  9 + {{#each running}}
  10 + {{> yoluck-back/prize-item .}}
  11 + {{/each}}
  12 +{{^}}
  13 + <div class="empty"> 您尚未参加任何活动 </div>
  14 +{{/ifcond}}
  15 +
  16 +<div style="width: 100%;background: white;">
  17 + <div class="title-view">
  18 + <span class="space-line"></span>
  19 + <span class="title">已公布</span>
  20 + </div>
  21 +</div>
  22 +
  23 +{{#ifcond finished.length '>' 0}}
  24 + {{#each finished}}
  25 + {{> yoluck-back/prize-item .}}
  26 + {{/each}}
  27 +{{^}}
  28 + <div class="empty"> 您尚未参加任何活动 </div>
  29 +{{/ifcond}}
  1 +
  2 +
  3 +<div class="prize-progress-comp">
  4 + <div class="prize-progress">
  5 + <div class="step">
  6 + {{#isEqualOr step 0}}
  7 + <div class="step-image step0"></div>
  8 + {{/isEqualOr}}
  9 +
  10 + {{#isEqualOr step 1}}
  11 + <div class="step-image step1"></div>
  12 + {{/isEqualOr}}
  13 +
  14 + {{#isEqualOr step 2}}
  15 + <div class="step-image step2"></div>
  16 + {{/isEqualOr}}
  17 +
  18 + {{#isEqualOr step 3 4}}
  19 + <img class="step-image step3"></div>
  20 + {{/isEqualOr}}
  21 + </div>
  22 +
  23 + <div class="desc">
  24 + <div class="title {{#ifcond step '>=' 1}}active{{/ifcond}}">参加抽奖</div>
  25 + <div class="title {{#ifcond step '>=' 2}}active{{/ifcond}}">邀请好友</div>
  26 + <div class="title {{#ifcond step '>=' 3}}active{{/ifcond}}">{{#ifcond step '===' 4}}人数不足{{^}}人满开奖{{/ifcond}}</div>
  27 + </div>
  28 + </div>
  29 +</div>
  1 +{{#ifcond product.status '===' 2}}
  2 + <div class="countdown_label">
  3 + <text class="countdown_labeltext">抽奖</text>
  4 + <text class="countdown_labeltext">倒计时</text>
  5 + </div>
  6 +
  7 + <div class="product_countdown" data-endtime="{{product.end_time}}">
  8 + {{> yoluck-back/time-countdown time=product.countdown}}
  9 + </div>
  10 +{{/ifcond}}
  11 +
  12 +<div class="avatarcontainer">
  13 + {{#ifcond product.status '===' 2}}
  14 + {{#ifcond avatars.length '>' 0}}
  15 + <div class="avatars">
  16 + {{> yoluck-back/avatar list=avatars}}
  17 + </div>
  18 + {{/ifcond}}
  19 + {{/ifcond}}
  20 +
  21 + <img class="product_image" src="{{image2 product.cover_img q=60}}"/>
  22 +</div>
  23 +
  24 +<div class="product_name"
  25 + data-id="{{product.id}}"
  26 + data-name="{{product.name}}"
  27 + data-img="{{image2 product.cover_img q=60}}"
  28 + data-price="{{product.price}}"
  29 +>
  30 + {{product.name}}
  31 +</div>
  32 +
  33 +<div class="product_lucky_bg">
  34 + <div class="product_lucky">
  35 + <span>抽奖价¥<span class="lucky">0</span>
  36 + </span>
  37 + </div>
  38 + <div class="product_price">{{product.price}}</div>
  39 +</div>
  40 +
  41 +{{#ifcond product.status '!==' 2}}
  42 + <div class="product_time">{{formatTime product.start_time product.end_time}}</div>
  43 +{{/ifcond}}
  44 +
  45 +<div class="product_margin"></div>
  1 +{{#ifcond status '===' 2}}
  2 + <div class="product_countdown" data-endtime="{{end_time}}">
  3 + {{>yoluck-back/time-countdown time=countdown}}
  4 + </div>
  5 +{{/ifcond}}
  6 +
  7 +<img class="product_image" src="{{image2 cover_img w=760 h=470 q=60}}" alt="" data-id="{{id}}">
  8 +<div class="product_name">{{name}}</div>
  9 +
  10 +<div class="product_lucky_bg">
  11 + <div class="product_lucky"><span>抽奖价¥<span class="lucky">0</span></span></div>
  12 + <div class="product_price">{{price}}</div>
  13 +</div>
  14 +
  15 +{{#ifcond status '!==' 2}}
  16 + <div class="product_time">{{formatTime start_time end_time}}</div>
  17 +{{/ifcond}}
  18 +
  19 +<div class="product_margin"></div>
  1 +<div class="product-status">
  2 + {{#isEqualOr status 0}}
  3 + <div class="btn cancel">活动结束</div>
  4 + {{/isEqualOr}}
  5 +
  6 + {{#isEqualOr status 1}}
  7 + <div class="btn cancel">即将开始</div>
  8 + {{/isEqualOr}}
  9 +
  10 + {{#isEqualOr status 2}}
  11 + <a class="btn ok js-join" data-id="{{id}}">参加抽奖</a>
  12 + {{/isEqualOr}}
  13 + {{#isEqualOr status 3}}
  14 + <div class="btn cancel">待开奖</div>
  15 + {{/isEqualOr}}
  16 + {{#isEqualOr status 4}}
  17 + <div class="btn cancel">活动结束</div>
  18 + {{/isEqualOr}}
  19 +
  20 + {{#isEqualOr status 5}}
  21 + <div class="btn cancel">待开奖</div>
  22 + {{/isEqualOr}}
  23 +</div>
  1 +
  2 +
  3 +<div class="product">
  4 + {{>yoluck-back/product-item-header}}
  5 + {{>yoluck-back/product-item-status}}
  6 +</div>
  1 +
  2 +<div class="time-countdown-comp">
  3 + {{#each time}}
  4 + <div class="num-wrapper">
  5 + <div class="mask"></div>
  6 + <text class="num-text">{{.}}</text>
  7 + <div class="mask-left"></div>
  8 + <div class="mask-right"></div>
  9 + </div>
  10 +
  11 + {{#ifcond @index "!==" 3}}
  12 + <div class="number-seprator">
  13 + :
  14 + </div>
  15 + {{/ifcond}}
  16 + {{/each}}
  17 +</div>
@@ -3,9 +3,9 @@ @@ -3,9 +3,9 @@
3 <div class="swiper-wrapper"> 3 <div class="swiper-wrapper">
4 {{#each list}} 4 {{#each list}}
5 <div class="swiper-slide avatar-item"> 5 <div class="swiper-slide avatar-item">
6 - <img src="{{image2 user_thumb w=70 h=70 q=60}}" 6 + <img src="{{image2 userThumb w=70 h=70 q=60}}"
7 class="avatar-image"/> 7 class="avatar-image"/>
8 - <div class="avatar-desc">{{user_name}}参与了抽奖</div> 8 + <div class="avatar-desc">{{userName}}参与了抽奖</div>
9 </div> 9 </div>
10 {{/each}} 10 {{/each}}
11 </div> 11 </div>
@@ -3,7 +3,6 @@ @@ -3,7 +3,6 @@
3 <div style="width: 100%;text-align: center;"> 3 <div style="width: 100%;text-align: center;">
4 <div class="title">商品详情</div> 4 <div class="title">商品详情</div>
5 </div> 5 </div>
6 -  
7 {{#if resource.url}} 6 {{#if resource.url}}
8 <a class="banner" href="{{resource.url}}"> 7 <a class="banner" href="{{resource.url}}">
9 <img class="banner-img" src="{{image2 resource.src w=resource.width h=resource.height}}" alt=""> 8 <img class="banner-img" src="{{image2 resource.src w=resource.width h=resource.height}}" alt="">
@@ -12,15 +11,15 @@ @@ -12,15 +11,15 @@
12 11
13 <div class="desc-content"> 12 <div class="desc-content">
14 {{#each list}} 13 {{#each list}}
15 - {{#ifcond floor_type '===' 1}} 14 + {{#ifcond floorType '===' 1}}
16 <div>{{content}}</div> 15 <div>{{content}}</div>
17 {{/ifcond}} 16 {{/ifcond}}
18 17
19 - {{#ifcond floor_type '===' 2}} 18 + {{#ifcond floorType '===' 2}}
20 <img class="desc-image" src="{{image2 content q=60}}" width="100%"> 19 <img class="desc-image" src="{{image2 content q=60}}" width="100%">
21 {{/ifcond}} 20 {{/ifcond}}
22 21
23 - {{#ifcond floor_type '===' 3}} 22 + {{#ifcond floorType '===' 3}}
24 <video class="desc-video" controls="controls"> 23 <video class="desc-video" controls="controls">
25 <source src="{{content}}" type="video/mp4" /> 24 <source src="{{content}}" type="video/mp4" />
26 </video> 25 </video>
1 <div class="prize-item-comp"> 1 <div class="prize-item-comp">
2 - <div class="prize-item js-prizeitem" data-id="{{act_prize_id}}">  
3 - <img class="product-image" src="{{cover_img}}" alt=""> 2 + <div class="prize-item js-prizeitem" data-id="{{id}}">
  3 + <img class="product-image" src="{{coverImg}}" alt="">
4 4
5 <div class="content"> 5 <div class="content">
6 <div class="code">抽奖码 6 <div class="code">抽奖码
7 - <text style="color: black;">{{prize_code}}</text> 7 + <text style="color: black;">{{prizeCode}}</text>
8 </div> 8 </div>
9 <div class="product-name">{{name}}</div> 9 <div class="product-name">{{name}}</div>
10 -  
11 {{#ifcond status '===' 0}} 10 {{#ifcond status '===' 0}}
12 <div class="btn">活动结束</div> 11 <div class="btn">活动结束</div>
13 {{/ifcond}} 12 {{/ifcond}}
@@ -17,7 +16,7 @@ @@ -17,7 +16,7 @@
17 {{/ifcond}} 16 {{/ifcond}}
18 17
19 {{#ifcond status '===' 4}} 18 {{#ifcond status '===' 4}}
20 - <div class="btn more js-fellow" data-id="{{act_prize_id}}" data-lottery="{{lottery_info}}">查看中奖信息</div> 19 + <div class="btn more js-fellow" data-id="{{id}}" data-lottery="{{lotteryInfo}}">查看中奖信息</div>
21 {{/ifcond}} 20 {{/ifcond}}
22 21
23 {{#ifcond status '===' 5}} 22 {{#ifcond status '===' 5}}
@@ -26,10 +25,10 @@ @@ -26,10 +25,10 @@
26 25
27 {{#isEqualOr status 1 2 6}} 26 {{#isEqualOr status 1 2 6}}
28 <div class="btn more js-share" 27 <div class="btn more js-share"
29 - data-img="{{cover_img}}" 28 + data-img="{{coverImg}}"
30 data-name="{{name}}" 29 data-name="{{name}}"
31 data-price="{{price}}" 30 data-price="{{price}}"
32 - data-id="{{act_prize_id}}" 31 + data-id="{{id}}"
33 > 32 >
34 获得更多抽奖码 33 获得更多抽奖码
35 </div> 34 </div>
@@ -4,9 +4,8 @@ @@ -4,9 +4,8 @@
4 <span class="title">进行中</span> 4 <span class="title">进行中</span>
5 </div> 5 </div>
6 </div> 6 </div>
7 -  
8 -{{#ifcond running.length '>' 0}}  
9 - {{#each running}} 7 +{{#ifcond running.data.list.length '>' 0}}
  8 + {{#each running.data.list}}
10 {{> yoluck/prize-item .}} 9 {{> yoluck/prize-item .}}
11 {{/each}} 10 {{/each}}
12 {{^}} 11 {{^}}
@@ -20,8 +19,8 @@ @@ -20,8 +19,8 @@
20 </div> 19 </div>
21 </div> 20 </div>
22 21
23 -{{#ifcond finished.length '>' 0}}  
24 - {{#each finished}} 22 +{{#ifcond finished.data.list.length '>' 0}}
  23 + {{#each finished.data.list}}
25 {{> yoluck/prize-item .}} 24 {{> yoluck/prize-item .}}
26 {{/each}} 25 {{/each}}
27 {{^}} 26 {{^}}
@@ -23,7 +23,7 @@ @@ -23,7 +23,7 @@
23 <div class="desc"> 23 <div class="desc">
24 <div class="title {{#ifcond step '>=' 1}}active{{/ifcond}}">参加抽奖</div> 24 <div class="title {{#ifcond step '>=' 1}}active{{/ifcond}}">参加抽奖</div>
25 <div class="title {{#ifcond step '>=' 2}}active{{/ifcond}}">邀请好友</div> 25 <div class="title {{#ifcond step '>=' 2}}active{{/ifcond}}">邀请好友</div>
26 - <div class="title {{#ifcond step '>=' 3}}active{{/ifcond}}">{{#ifcond step '===' 4}}人数不足{{^}}人满开奖{{/ifcond}}</div> 26 + <div class="title {{#ifcond step '>=' 3}}active{{/ifcond}}">{{#ifcond step '===' 4}}待开奖{{^}}开奖{{/ifcond}}</div>
27 </div> 27 </div>
28 </div> 28 </div>
29 </div> 29 </div>
@@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
4 <text class="countdown_labeltext">倒计时</text> 4 <text class="countdown_labeltext">倒计时</text>
5 </div> 5 </div>
6 6
7 - <div class="product_countdown" data-endtime="{{product.end_time}}"> 7 + <div class="product_countdown" data-endtime="{{product.endTime}}">
8 {{> yoluck/time-countdown time=product.countdown}} 8 {{> yoluck/time-countdown time=product.countdown}}
9 </div> 9 </div>
10 {{/ifcond}} 10 {{/ifcond}}
@@ -18,13 +18,13 @@ @@ -18,13 +18,13 @@
18 {{/ifcond}} 18 {{/ifcond}}
19 {{/ifcond}} 19 {{/ifcond}}
20 20
21 - <img class="product_image" src="{{image2 product.cover_img q=60}}"/> 21 + <img class="product_image" src="{{image2 product.coverImg q=60}}"/>
22 </div> 22 </div>
23 23
24 <div class="product_name" 24 <div class="product_name"
25 data-id="{{product.id}}" 25 data-id="{{product.id}}"
26 data-name="{{product.name}}" 26 data-name="{{product.name}}"
27 - data-img="{{image2 product.cover_img q=60}}" 27 + data-img="{{image2 product.coverImg q=60}}"
28 data-price="{{product.price}}" 28 data-price="{{product.price}}"
29 > 29 >
30 {{product.name}} 30 {{product.name}}
@@ -39,7 +39,7 @@ @@ -39,7 +39,7 @@
39 </div> 39 </div>
40 40
41 {{#ifcond product.status '!==' 2}} 41 {{#ifcond product.status '!==' 2}}
42 - <div class="product_time">{{formatTime product.start_time product.end_time}}</div> 42 + <div class="product_time">{{formatTime product.startTime product.endTime}}</div>
43 {{/ifcond}} 43 {{/ifcond}}
44 44
45 <div class="product_margin"></div> 45 <div class="product_margin"></div>
1 {{#ifcond status '===' 2}} 1 {{#ifcond status '===' 2}}
2 - <div class="product_countdown" data-endtime="{{end_time}}"> 2 + <div class="product_countdown" data-endtime="{{endTime}}">
3 {{>yoluck/time-countdown time=countdown}} 3 {{>yoluck/time-countdown time=countdown}}
4 </div> 4 </div>
5 {{/ifcond}} 5 {{/ifcond}}
6 6
7 -<img class="product_image" src="{{image2 cover_img w=760 h=470 q=60}}" alt="" data-id="{{id}}"> 7 +<img class="product_image" src="{{image2 coverImg w=760 h=470 q=60}}" alt="" data-id="{{id}}">
8 <div class="product_name">{{name}}</div> 8 <div class="product_name">{{name}}</div>
9 9
10 <div class="product_lucky_bg"> 10 <div class="product_lucky_bg">
@@ -13,7 +13,7 @@ @@ -13,7 +13,7 @@
13 </div> 13 </div>
14 14
15 {{#ifcond status '!==' 2}} 15 {{#ifcond status '!==' 2}}
16 - <div class="product_time">{{formatTime start_time end_time}}</div> 16 + <div class="product_time">{{formatTime startTime endTime}}</div>
17 {{/ifcond}} 17 {{/ifcond}}
18 18
19 <div class="product_margin"></div> 19 <div class="product_margin"></div>
@@ -14,6 +14,7 @@ const isTest = process.env.NODE_ENV === 'test3' || process.env.NODE_ENV === 'tes @@ -14,6 +14,7 @@ const isTest = process.env.NODE_ENV === 'test3' || process.env.NODE_ENV === 'tes
14 const domains = { 14 const domains = {
15 15
16 // api: 'http://api.yoho.cn/', 16 // api: 'http://api.yoho.cn/',
  17 +
17 // service: 'http://service.yoho.cn/', 18 // service: 'http://service.yoho.cn/',
18 // yoLuck: 'https://action.yoho.cn', 19 // yoLuck: 'https://action.yoho.cn',
19 20
  1 +<div class="modal-mask"></div>
  2 +<div class="modal-dialog">
  3 + <div class="modal-dialog-bg"></div>
  4 +
  5 + <div class="code-alert">
  6 + <text class="code-title">参加抽奖成功</text>
  7 + <div class="code-bg">
  8 + <div class="title">你的抽奖码是</div>
  9 + <div class="code">{{code}}</div>
  10 + </div>
  11 + <a class="share">分享一下,中奖概率立马double</a>
  12 + <div class="share-desc">1个好友参加=1个抽奖码=中奖几率UP!</div>
  13 + </div>
  14 +</div>
  1 +<div class="prize-item-comp">
  2 + <div class="prize-item js-prizeitem" data-id="{{act_prize_id}}">
  3 + <img class="product-image" src="{{cover_img}}" alt="">
  4 +
  5 + <div class="content">
  6 + <div class="code">抽奖码
  7 + <text style="color: black;">{{prize_code}}</text>
  8 + </div>
  9 + <div class="product-name">{{name}}</div>
  10 +
  11 + {{#ifcond status '===' 0}}
  12 + <div class="btn">活动结束</div>
  13 + {{/ifcond}}
  14 +
  15 + {{#ifcond status '===' 3}}
  16 + <div class="btn">待开奖</div>
  17 + {{/ifcond}}
  18 +
  19 + {{#ifcond status '===' 4}}
  20 + <div class="btn more js-fellow" data-id="{{act_prize_id}}">查看中奖信息</div>
  21 + {{/ifcond}}
  22 +
  23 + {{#ifcond status '===' 5}}
  24 + <div class="btn">待开奖</div>
  25 + {{/ifcond}}
  26 +
  27 + {{#is-equal-or status 1 2 6}}
  28 + <div class="btn more js-share"
  29 + data-img="{{cover_img}}"
  30 + data-name="{{name}}"
  31 + data-price="{{price}}"
  32 + data-id="{{act_prize_id}}"
  33 + >
  34 + 获得更多抽奖码
  35 + </div>
  36 + {{/is-equal-or}}
  37 +
  38 + </div>
  39 + </div>
  40 +</div>
  1 +<div style="width: 100%;background: white;">
  2 + <div class="title-view">
  3 + <span class="space-line"></span>
  4 + <span class="title">进行中</span>
  5 + </div>
  6 +</div>
  7 +
  8 +
  9 +{{#ifcond running.length '>' 0}}
  10 + {{#each running}}
  11 + {{> ./prize-item .}}
  12 + {{/each}}
  13 +{{^}}
  14 + <div class="empty"> 您尚未参加任何活动 </div>
  15 +{{/ifcond}}
  16 +
  17 +<div style="width: 100%;background: white;">
  18 + <div class="title-view">
  19 + <span class="space-line"></span>
  20 + <span class="title">已公布</span>
  21 + </div>
  22 +</div>
  23 +
  24 +{{#ifcond finished.length '>' 0}}
  25 + {{#each finished}}
  26 + {{> ./prize-item .}}
  27 + {{/each}}
  28 +{{^}}
  29 + <div class="empty"> 您尚未参加任何活动 </div>
  30 +{{/ifcond}}
  1 +
  2 +
  3 +{{#ifcond status '===' 2}}
  4 + <div class="product_countdown">
  5 + {{>./time-countdown time=countdown}}
  6 + </div>
  7 +{{/ifcond}}
  8 +
  9 +<img class="product_image" src="{{image2 cover_img w=760 h=470 q=60}}" alt="" data-id="{{id}}">
  10 +<div class="product_name">{{name}}</div>
  11 +
  12 +<div class="product_lucky_bg">
  13 + <div class="product_lucky"><span>抽奖价¥<span class="lucky">0</span></span></div>
  14 + <div class="product_price" >{{price}}</div>
  15 +</div>
  16 +
  17 +{{#ifcond status '!==' 2}}
  18 +<div class="product_time">{{formatTime start_time end_time}}</div>
  19 +{{/ifcond}}
  20 +
  21 +<div class="product_margin"></div>
  1 +<div class="product-status">
  2 + {{#is-equal-or status 0}}
  3 + <div class="btn cancel">活动结束</div>
  4 + {{/is-equal-or}}
  5 +
  6 + {{#is-equal-or status 1}}
  7 + <div class="btn cancel">即将开始</div>
  8 + {{/is-equal-or}}
  9 +
  10 + {{#is-equal-or status 2}}
  11 + <a class="btn ok js-join" data-id="{{id}}">参加抽奖</a>
  12 + {{/is-equal-or}}
  13 +
  14 + {{#is-equal-or status 3}}
  15 + <div class="btn cancel">待开奖</div>
  16 + {{/is-equal-or}}
  17 +
  18 + {{#is-equal-or status 4}}
  19 + <div class="btn cancel">活动结束</div>
  20 + {{/is-equal-or}}
  21 +
  22 + {{#is-equal-or status 5}}
  23 + <div class="btn cancel">待开奖</div>
  24 + {{/is-equal-or}}
  25 +</div>
  1 +
  2 +
  3 +<div class="product">
  4 + {{> ./product-item-header}}
  5 + {{> ./product-item-status}}
  6 +</div>
  1 +<div class="time-countdown-comp">
  2 + {{#each time}}
  3 + <div class="num-wrapper">
  4 + <div class="mask"></div>
  5 + <text class="num-text">{{.}}</text>
  6 + <div class="mask-left"></div>
  7 + <div class="mask-right"></div>
  8 + </div>
  9 +
  10 + {{#ifcond @index "!==" 3}}
  11 + <div class="number-seprator">
  12 + :
  13 + </div>
  14 + {{/ifcond}}
  15 + {{/each}}
  16 +</div>
1 <div class="prize-item-comp"> 1 <div class="prize-item-comp">
2 - <div class="prize-item js-prizeitem" data-id="{{act_prize_id}}">  
3 - <img class="product-image" src="{{cover_img}}" alt="">  
4 - 2 + <div class="prize-item js-prizeitem" data-id="{{id}}">
  3 + <img class="product-image" src="{{coverImg}}" alt="">
5 <div class="content"> 4 <div class="content">
6 <div class="code">抽奖码 5 <div class="code">抽奖码
7 - <text style="color: black;">{{prize_code}}</text> 6 + <text style="color: black;">{{prizeCode}}</text>
8 </div> 7 </div>
9 <div class="product-name">{{name}}</div> 8 <div class="product-name">{{name}}</div>
10 9
@@ -17,7 +16,7 @@ @@ -17,7 +16,7 @@
17 {{/ifcond}} 16 {{/ifcond}}
18 17
19 {{#ifcond status '===' 4}} 18 {{#ifcond status '===' 4}}
20 - <div class="btn more js-fellow" data-id="{{act_prize_id}}">查看中奖信息</div> 19 + <div class="btn more js-fellow" data-id="{{id}}" data-lottery="{{lotteryInfo}}">查看中奖信息</div>
21 {{/ifcond}} 20 {{/ifcond}}
22 21
23 {{#ifcond status '===' 5}} 22 {{#ifcond status '===' 5}}
@@ -26,10 +25,10 @@ @@ -26,10 +25,10 @@
26 25
27 {{#is-equal-or status 1 2 6}} 26 {{#is-equal-or status 1 2 6}}
28 <div class="btn more js-share" 27 <div class="btn more js-share"
29 - data-img="{{cover_img}}" 28 + data-img="{{coverImg}}"
30 data-name="{{name}}" 29 data-name="{{name}}"
31 data-price="{{price}}" 30 data-price="{{price}}"
32 - data-id="{{act_prize_id}}" 31 + data-id="{{id}}"
33 > 32 >
34 获得更多抽奖码 33 获得更多抽奖码
35 </div> 34 </div>
@@ -5,9 +5,8 @@ @@ -5,9 +5,8 @@
5 </div> 5 </div>
6 </div> 6 </div>
7 7
8 -  
9 -{{#ifcond running.length '>' 0}}  
10 - {{#each running}} 8 +{{#ifcond running.data.list.length '>' 0}}
  9 + {{#each running.data.list}}
11 {{> ./prize-item .}} 10 {{> ./prize-item .}}
12 {{/each}} 11 {{/each}}
13 {{^}} 12 {{^}}
@@ -21,8 +20,8 @@ @@ -21,8 +20,8 @@
21 </div> 20 </div>
22 </div> 21 </div>
23 22
24 -{{#ifcond finished.length '>' 0}}  
25 - {{#each finished}} 23 +{{#ifcond finished.data.list.length '>' 0}}
  24 + {{#each finished.data.list}}
26 {{> ./prize-item .}} 25 {{> ./prize-item .}}
27 {{/each}} 26 {{/each}}
28 {{^}} 27 {{^}}
@@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
6 </div> 6 </div>
7 {{/ifcond}} 7 {{/ifcond}}
8 8
9 -<img class="product_image" src="{{image2 cover_img w=760 h=470 q=60}}" alt="" data-id="{{id}}"> 9 +<img class="product_image" src="{{image2 coverImg w=760 h=470 q=60}}" alt="" data-id="{{id}}">
10 <div class="product_name">{{name}}</div> 10 <div class="product_name">{{name}}</div>
11 11
12 <div class="product_lucky_bg"> 12 <div class="product_lucky_bg">
@@ -15,7 +15,7 @@ @@ -15,7 +15,7 @@
15 </div> 15 </div>
16 16
17 {{#ifcond status '!==' 2}} 17 {{#ifcond status '!==' 2}}
18 -<div class="product_time">{{formatTime start_time end_time}}</div> 18 +<div class="product_time">{{formatTime startTime endTime}}</div>
19 {{/ifcond}} 19 {{/ifcond}}
20 20
21 <div class="product_margin"></div> 21 <div class="product_margin"></div>
  1 +import 'scss/activity/yoluck/yoluck-detail.page.scss';
  2 +
  3 +const cookie = require('yoho-cookie');
  4 +let Swiper = require('yoho-swiper');
  5 +const loading = require('js/plugin/loading');
  6 +let timeCountDownTpl = require('hbs/activity/yoluck-back/time-countdown.hbs');
  7 +let luckAlertTpl = require('hbs/activity/yoluck-back/luck-alert.hbs');
  8 +let formatCountDown = require('./yoluck/formatCountDown');
  9 +let YolukcApi = require('./yoluck/api');
  10 +let api = new YolukcApi();
  11 +let tip = require('js/plugin/tip');
  12 +let dialog = require('js/plugin/dialog');
  13 +let yoSdk = require('yoho-activity-sdk');
  14 +let yoho = require('js/yoho-app');
  15 +
  16 +let Clipboard = require('clipboard');
  17 +let makeShareData = require('./yoluck/share');
  18 +let Lottery = require('./yoluck/lottery');
  19 +let versionCompare = require('./yoluck/version');
  20 +
  21 +function reload() {
  22 + window.location && window.location.reload(); //eslint-disable-line
  23 +}
  24 +
  25 +require('js/plugin/modal.alert');
  26 +require('js/common');
  27 +
  28 +let store = {
  29 + running: false,
  30 + shareUid: window.queryString.shareUid || '',
  31 + currentVersion: cookie.get('app_version'),
  32 + targetVersion: '6.8.3',
  33 +};
  34 +
  35 +let hideInfo = $('#hide-info').remove().data();
  36 +
  37 +let $fellowBar = $('#fellow-bar');
  38 +let $product = $('.product_name');
  39 +let name = $product.data('name');
  40 +let img = $product.data('img');
  41 +let price = $product.data('price');
  42 +let id = $product.data('id');
  43 +let user;
  44 +let shareData;
  45 +
  46 +let lottery = new Lottery('#lottery-list');
  47 +let sharePlugin = require('js/common/share');
  48 +
  49 +loading.init($(document.body), {timeout: 20000});
  50 +new Swiper('.swiper-container', {
  51 + direction: 'vertical',
  52 + lazyLoading: true,
  53 + lazyLoadingInPrevNext: true,
  54 + paginationClickable: true,
  55 + autoplay: 4000
  56 +});
  57 +
  58 +function fellow(content) {
  59 + if (content) {
  60 + $.yAlert({
  61 + content: `<div class="fellow-tip-content">${content}</div>` // eslint-disable-line
  62 + });
  63 + return;
  64 + }
  65 +
  66 + $.yAlert({
  67 + content: `<div>公众号
  68 + <span style="font-weight: bolder">“潮流有货”</span>已经复制成功,</div>
  69 + <div>打开微信搜索去添加吧~</div>` // eslint-disable-line
  70 + });
  71 +}
  72 +
  73 +function alertVersion() {
  74 + $.yAlert({content: '您的版本较低,请更新最新版本体验'});
  75 +}
  76 +
  77 +function getUser() {
  78 + try {
  79 + if (user) {
  80 + return Promise.resolve();
  81 + }
  82 +
  83 + return yoSdk.getUser().then(u => {
  84 + user = u;
  85 + shareData = makeShareData({
  86 + name: name,
  87 + imgUrl: img,
  88 + price: price,
  89 + shareUid: user && user.uid,
  90 + userName: hideInfo && hideInfo.username,
  91 + actPrizeId: id
  92 + });
  93 +
  94 + sharePlugin(shareData.h5);
  95 + });
  96 + } catch (e) {
  97 + return Promise.resolve();
  98 + }
  99 +}
  100 +
  101 +getUser();
  102 +
  103 +(function() {
  104 + if (!lottery.$list || !lottery.$list.length) {
  105 + return;
  106 + }
  107 +
  108 + api.getDetailMyCode({id}).then(res => {
  109 + if (res.code !== 200) {
  110 + return;
  111 + }
  112 +
  113 + lottery.print(res.data);
  114 + });
  115 +}());
  116 +
  117 +function share() {
  118 + if (yoSdk.env === 'app') {
  119 + // 由于app版本兼容性问题
  120 + if (versionCompare(store.currentVersion, store.targetVersion) < 0) {
  121 + alertVersion();
  122 + return;
  123 + }
  124 +
  125 + loading.showLoading();
  126 +
  127 + if (store.running) {
  128 + return;
  129 + }
  130 +
  131 + store.running = true;
  132 +
  133 + getUser().then(() => {
  134 + yoho.invokeMethod('go.showshareaction', shareData && shareData.app);
  135 + loading.hideLoading();
  136 + store.running = false;
  137 + });
  138 + } else if (/QQ/i.test(navigator.userAgent) ||
  139 + /MicroMessenger/i.test(navigator.userAgent)) {
  140 + dialog.showDialog({hasClass: 'yoluck-guide-mask'});
  141 + } else if (yoSdk.env === 'h5') {
  142 + $('.js-clipbroad').trigger('click');
  143 + }
  144 +}
  145 +
  146 +let luckAlert = {
  147 + $el: $('.js-luck-alert'),
  148 + init() {
  149 + this.bindEvent();
  150 + },
  151 + show(code) {
  152 + if (this.$el.find('.modal-mask').length === 0) {
  153 + this.$el.html(luckAlertTpl({
  154 + code
  155 + }));
  156 + } else {
  157 + this.$el.show();
  158 + }
  159 + },
  160 + hide() {
  161 + this.$el.hide();
  162 + },
  163 + bindEvent() {
  164 + this.$el.on('click', '.modal-mask', () => {
  165 + this.hide();
  166 + reload();
  167 + return true;
  168 + });
  169 +
  170 + this.$el.on('click', '.share', function() {
  171 + share();
  172 + });
  173 + }
  174 +};
  175 +
  176 +let fellowInfo = $fellowBar.data() || {};
  177 +
  178 +if (+fellowInfo.type === 2) {
  179 + $fellowBar.on('click', '.js-fellow', function() {
  180 + if (fellowInfo.link) {
  181 + window.location.href = fellowInfo.link;
  182 + }
  183 + });
  184 +} else {
  185 + let clipboardFellow = new Clipboard('.js-fellow', {
  186 + text: function() {
  187 + return fellowInfo.copy || '潮流有货';
  188 + }
  189 + });
  190 +
  191 + clipboardFellow.on('success', function(e) {
  192 + fellow(fellowInfo.tip);
  193 + tip.show('内容已复制', 2000);
  194 + e.clearSelection();
  195 + });
  196 +}
  197 +
  198 +(function() {
  199 + let lotteryInfo = $('.js-lottery').data('lottery') || {};
  200 + let clipboardLottery = new Clipboard('.js-lottery', {
  201 + text: function() {
  202 + return lotteryInfo.h5Copy || '潮流有货';
  203 + }
  204 + });
  205 +
  206 + clipboardLottery.on('success', function(e) {
  207 + fellow(lotteryInfo.h5Tip);
  208 + tip.show('内容已复制', 2000);
  209 + e.clearSelection();
  210 + });
  211 +
  212 + let clickFn;
  213 +
  214 + if (lotteryInfo) {
  215 + if (yoSdk.env === 'app' && lotteryInfo.app) {
  216 + clickFn = function() {
  217 + $.yAlert({
  218 + content: `<div>本期中奖号码: <span style="font-weight: bolder;">${lotteryInfo.app}</span></div>` // eslint-disable-line
  219 + });
  220 + };
  221 + } else if (yoSdk.env === 'h5' && +lotteryInfo.h5Type) {
  222 + if (+lotteryInfo.h5Type === 2 && lotteryInfo.h5Link) {
  223 + clickFn = function() {
  224 + window.location.href = lotteryInfo.h5Link;
  225 + };
  226 + }
  227 + }
  228 + }
  229 +
  230 + if (clickFn) {
  231 + clipboardLottery.destroy();
  232 + $('.js-lottery').on('click', clickFn);
  233 + }
  234 +}());
  235 +
  236 +let clipboardShare = new Clipboard('.js-clipbroad', {
  237 + text: function() {
  238 + return shareData && shareData.h5.copyDeac;
  239 + }
  240 +});
  241 +
  242 +clipboardShare.on('success', function(e) {
  243 + if (yoSdk.env === 'app') {
  244 + return;
  245 + }
  246 +
  247 + tip.show('复制成功,发送给好友为您助力', 3500);
  248 + e.clearSelection();
  249 +});
  250 +
  251 +if (window.cookie('yoluck_share') && store.shareUid) {
  252 + window.setCookie('yoluck_share', null);
  253 + share();
  254 +}
  255 +
  256 +luckAlert.init();
  257 +
  258 +setInterval(() => {
  259 + let $countdown = $('.product_countdown');
  260 +
  261 + const time = $countdown.data('endtime');
  262 + const formatTime = formatCountDown(time);
  263 +
  264 + $countdown.html(timeCountDownTpl({
  265 + time: formatTime
  266 + }));
  267 +}, 1000);
  268 +
  269 +// 助力
  270 +$('.action-bar-comp').on('click', '.js-join', function() {
  271 + if (store.running) {
  272 + return;
  273 + }
  274 +
  275 + store.running = true;
  276 + api.getCode({shareUid: store.shareUid, ...yoSdk.getQueryObj()}).then(result => {
  277 + if (result.code === 200) {
  278 + lottery.print(result.data);
  279 + luckAlert.show(result.data.prizeCode);
  280 + } else {
  281 + if (result.code === 400) {
  282 + yoSdk.goLogin();
  283 + } else {
  284 + tip.show(result.message, 3500);
  285 + }
  286 + }
  287 + }).always(() => {
  288 + store.running = false;
  289 + });
  290 +});
  291 +
  292 +// 分享
  293 +$('.action-bar-comp').on('click', '.js-share', function() {
  294 + share();
  295 +});
  296 +
@@ -197,6 +197,7 @@ if (+fellowInfo.type === 2) { @@ -197,6 +197,7 @@ if (+fellowInfo.type === 2) {
197 197
198 (function() { 198 (function() {
199 let lotteryInfo = $('.js-lottery').data('lottery') || {}; 199 let lotteryInfo = $('.js-lottery').data('lottery') || {};
  200 +
200 let clipboardLottery = new Clipboard('.js-lottery', { 201 let clipboardLottery = new Clipboard('.js-lottery', {
201 text: function() { 202 text: function() {
202 return lotteryInfo.h5Copy || '潮流有货'; 203 return lotteryInfo.h5Copy || '潮流有货';
  1 +import 'scss/activity/yoluck/yoluck-list.page.scss';
  2 +
  3 +const loading = require('js/plugin/loading');
  4 +let $ = require('yoho-jquery');
  5 +let Api = require('./yoluck/api');
  6 +let productTpl = require('hbs/activity/yoluck-back/product-item.hbs');
  7 +let prizeListTpl = require('hbs/activity/yoluck-back/prize-list.hbs');
  8 +let timeCountDownTpl = require('hbs/activity/yoluck-back/time-countdown.hbs');
  9 +let formatCountDown = require('./yoluck/formatCountDown');
  10 +let yoSdk = require('yoho-activity-sdk');
  11 +let yoho = require('js/yoho-app');
  12 +const DETAIL_URI = location.protocol + '//m.yohobuy.com/activity/yoluck';
  13 +
  14 +let tip = require('js/plugin/tip');
  15 +let Clipboard = require('clipboard');
  16 +let publicCopyInfo = '';
  17 +
  18 +require('js/plugin/modal.alert');
  19 +
  20 +loading.init($(document.body), {timeout: 20000});
  21 +let footerText = ['内容加载中...', '暂无更多内容'];
  22 +
  23 +let store = {
  24 + list: [{
  25 + page: 0,
  26 + }, {
  27 + page: 0,
  28 + }, {
  29 + page: 0,
  30 + }, {
  31 + page: 0
  32 + }],
  33 + tabIndex: 0,
  34 +
  35 + footText: '',
  36 + running: false,
  37 + countDown: $(),
  38 + user: null,
  39 + shareData: null
  40 +};
  41 +
  42 +let api = new Api();
  43 +let bus$ = $.Callbacks(); // eslint-disable-line
  44 +let $tabpanel = $('.js-tab-comp');
  45 +let tabpanelStore = {
  46 + tabs: [],
  47 + key: 0,
  48 + nodes: [],
  49 + currentKey: 0,
  50 + footer: null
  51 +};
  52 +
  53 +let prizeListStore = {
  54 + push(arr) {
  55 + if (!arr || !arr.length) {
  56 + return;
  57 + }
  58 +
  59 + this.list = this.list || {};
  60 +
  61 + $.each(arr, (index, value) => {
  62 + if (value && value.act_prize_id) {
  63 + this.list[value.act_prize_id] = value;
  64 + }
  65 + });
  66 + },
  67 + get(id) {
  68 + return this.list && this.list[id];
  69 + }
  70 +};
  71 +
  72 +function initStore() {
  73 + // 初始化为
  74 + let tabIndex = +$tabpanel.data('type');
  75 +
  76 + store.list[tabIndex].page = 1;
  77 + store.tabIndex = tabIndex;
  78 + tabpanelStore.currentKey = tabIndex;
  79 +}
  80 +
  81 +tabpanelStore.nodes = $tabpanel.find('.js-panel');
  82 +tabpanelStore.tabs = $tabpanel.find('.js-tab');
  83 +tabpanelStore.footer = $tabpanel.find('.list-foot-blank');
  84 +store.countDown = $tabpanel.find('.product_countdown');
  85 +
  86 +function updateFooter(msg) {
  87 + tabpanelStore.footer.text(msg);
  88 +}
  89 +
  90 +function updateTabs() {
  91 + tabpanelStore.nodes.each(function(index) {
  92 + let $this = $(this);
  93 +
  94 + let active = index === tabpanelStore.key;
  95 +
  96 + if (active) {
  97 + $this.addClass('active').removeClass('inactive');
  98 + } else {
  99 + $this.addClass('inactive').removeClass('active');
  100 + }
  101 + });
  102 +
  103 + tabpanelStore.tabs.each(function() {
  104 + let $this = $(this);
  105 + let active = $this.data('index') === tabpanelStore.key;
  106 +
  107 + if (active) {
  108 + $this.addClass('active').removeClass('inactive');
  109 + } else {
  110 + $this.addClass('inactive').removeClass('active');
  111 + }
  112 + });
  113 +}
  114 +
  115 +function fetchPage(page, index) {
  116 + if (store.running) {
  117 + return;
  118 + }
  119 +
  120 + store.running = true;
  121 + page++;
  122 +
  123 + updateFooter(footerText[0]);
  124 +
  125 + return api.getPage(page, index)
  126 + .then(result => {
  127 + if (result.code !== 200) {
  128 + if (result.code === 400) {
  129 + return yoSdk.goLogin();
  130 + }
  131 + return;
  132 + }
  133 +
  134 + if (result.data.length === 0) {
  135 + return;
  136 + }
  137 +
  138 + if (index === 3) {
  139 + let $node = tabpanelStore.nodes.eq(index);
  140 + let $products = prizeListTpl({running: result.data[0], finished: result.data[1]});
  141 +
  142 + prizeListStore.push(result.data[1]);
  143 +
  144 + $node.find('.js-panel-body').html($products);
  145 + } else {
  146 + let $node = tabpanelStore.nodes.eq(index);
  147 + let $products = result.data.map(r => {
  148 + const p = productTpl(r);
  149 +
  150 + store.countDown = store.countDown.add($(p).find('.product_countdown'));
  151 + return p;
  152 + });
  153 +
  154 + store.list[index].page = page;
  155 + $node.find('.js-panel-body').append($products);
  156 + }
  157 + })
  158 + .always(() => {
  159 + updateFooter(footerText[1]);
  160 + store.running = false;
  161 + });
  162 +}
  163 +
  164 +function onTabClick(type, index) {
  165 + if (type !== 'tabClick') {
  166 + return;
  167 + }
  168 +
  169 + store.tabIndex = index;
  170 + let page = store.list[index].page;
  171 +
  172 + // 点击未开始则下走
  173 + if (page !== 0) {
  174 + return;
  175 + }
  176 +
  177 + // 下一页
  178 + // page = 0
  179 + fetchPage(page, store.tabIndex);
  180 +}
  181 +
  182 +function onReachBottom(type) {
  183 + if (type !== 'reachBottom') {
  184 + return;
  185 + }
  186 +
  187 + let index = store.tabIndex;
  188 + let page = store.list[index].page;
  189 +
  190 + if (page === 0) {
  191 + return;
  192 + }
  193 +
  194 + // 下一页
  195 + // page != 0
  196 + fetchPage(page, store.tabIndex);
  197 +}
  198 +
  199 +function fellow(id, lottery) {
  200 + let info = prizeListStore.get(id);
  201 + let lotteryInfo;
  202 +
  203 + if (info && info.lottery_info) {
  204 + try {
  205 + lotteryInfo = $.parseJSON(info.lottery_info);
  206 + } catch(e) {} // eslint-disable-line
  207 + }
  208 +
  209 + lotteryInfo = lotteryInfo || lottery;
  210 +
  211 + if (lotteryInfo) {
  212 + if (yoSdk.env === 'app' && lotteryInfo.app) {
  213 + $.yAlert({
  214 + content: `<div class="modal-view-lottery">本期中奖号码: <span style="font-weight: bolder;">${lotteryInfo.app}</span></div>` // eslint-disable-line
  215 + });
  216 + return;
  217 + } else if (yoSdk.env === 'h5' && +lotteryInfo.h5Type) {
  218 + if (+lotteryInfo.h5Type === 1) {
  219 + $.yAlert({
  220 + content: `<div class="modal-view-lottery">${lotteryInfo.h5Tip}</div>` // eslint-disable-line
  221 + });
  222 +
  223 + publicCopyInfo = lotteryInfo.h5Copy || '';
  224 + $('.js-clipbroad').trigger('click');
  225 + } else if (lotteryInfo.h5Link) {
  226 + window.location.href = lotteryInfo.h5Link;
  227 + }
  228 +
  229 + return;
  230 + }
  231 + }
  232 +
  233 + $.yAlert({
  234 + content: `<div>微信搜索公众号</div>
  235 + <div><span style="font-weight: bolder;">“潮流有货”</span>并关注,发送</div>
  236 + <div>关键词<span style="font-weight: bolder;">“开奖”</span>查询中奖信息</div>`
  237 + });
  238 +}
  239 +
  240 +function getUser() {
  241 + try {
  242 + if (store.user) {
  243 + return Promise.resolve();
  244 + }
  245 +
  246 + return yoSdk.getUser().then(u => {
  247 + store.user = u;
  248 + });
  249 +
  250 + } catch (e) {
  251 + // pass
  252 +
  253 + return Promise.resolve();
  254 + }
  255 +}
  256 +
  257 +bus$.add(onTabClick);
  258 +bus$.add(onReachBottom);
  259 +
  260 +function initClipboard() {
  261 + let _clipboard = new Clipboard('.js-clipbroad', {
  262 + text: function() {
  263 + return publicCopyInfo;
  264 + }
  265 + });
  266 +
  267 + _clipboard.on('success', function() {
  268 + if (publicCopyInfo) {
  269 + tip.show('内容已复制', 2000);
  270 + }
  271 + });
  272 +}
  273 +
  274 +initClipboard();
  275 +getUser();
  276 +
  277 +$tabpanel.on('click', '.js-tab', function() {
  278 + let $tab = $(this);
  279 + let index = $tab.data('index');
  280 +
  281 + if (index === tabpanelStore.key) {
  282 + return;
  283 + }
  284 +
  285 + tabpanelStore.key = index;
  286 + updateTabs();
  287 + bus$.fire('tabClick', index);
  288 +});
  289 +
  290 +$tabpanel
  291 + .on('click', '.js-prizeitem,.js-join,.product_image', function() {
  292 + let id = $(this).data('id');
  293 + let href = DETAIL_URI + '/' + id + '.html?t=1';
  294 +
  295 + if (yoSdk.env === 'app') {
  296 + let link = yoho.parseUrl(href);
  297 +
  298 + yoho.goH5(href, JSON.stringify({
  299 + action: 'go.h5',
  300 + params: {
  301 + islogin: 'N',
  302 + type: 0,
  303 + updateflag: Date.now() + '',
  304 + url: link.path,
  305 + param: link.query
  306 + }
  307 + }));
  308 + } else {
  309 + window.location.href = href;
  310 + }
  311 +
  312 +
  313 + return false;
  314 + })
  315 + .on('click', '.js-fellow', function() {
  316 + fellow($(this).data('id'), $(this).data('lottery'));
  317 + return false;
  318 + });
  319 +
  320 +$(window).on('scroll', function() {
  321 + if ((($(document).height() - ($(window).height() + $(window).scrollTop())) / $(document).height()) === 0) {
  322 + bus$.fire('reachBottom');
  323 + }
  324 +});
  325 +
  326 +setInterval(() => {
  327 + store.countDown.each(function() {
  328 + let $this = $(this);
  329 +
  330 + const time = $this.data('endtime');
  331 + const formatTime = formatCountDown(time);
  332 +
  333 + $this.html(timeCountDownTpl({
  334 + time: formatTime
  335 + }));
  336 + });
  337 +}, 1000);
  338 +
  339 +initStore();
  340 +
@@ -131,7 +131,9 @@ function fetchPage(page, index) { @@ -131,7 +131,9 @@ function fetchPage(page, index) {
131 return; 131 return;
132 } 132 }
133 133
134 - if (result.data.length === 0) { 134 + // 当前page > 结果的最大page时不处理
  135 + if (page > result.data.page_total || result.data.length === 0) {
  136 + page--;
135 return; 137 return;
136 } 138 }
137 139
@@ -144,7 +146,7 @@ function fetchPage(page, index) { @@ -144,7 +146,7 @@ function fetchPage(page, index) {
144 $node.find('.js-panel-body').html($products); 146 $node.find('.js-panel-body').html($products);
145 } else { 147 } else {
146 let $node = tabpanelStore.nodes.eq(index); 148 let $node = tabpanelStore.nodes.eq(index);
147 - let $products = result.data.map(r => { 149 + let $products = result.data.list.map(r => {
148 const p = productTpl(r); 150 const p = productTpl(r);
149 151
150 store.countDown = store.countDown.add($(p).find('.product_countdown')); 152 store.countDown = store.countDown.add($(p).find('.product_countdown'));
@@ -198,11 +200,12 @@ function onReachBottom(type) { @@ -198,11 +200,12 @@ function onReachBottom(type) {
198 200
199 function fellow(id, lottery) { 201 function fellow(id, lottery) {
200 let info = prizeListStore.get(id); 202 let info = prizeListStore.get(id);
  203 +
201 let lotteryInfo; 204 let lotteryInfo;
202 205
203 - if (info && info.lottery_info) { 206 + if (info && info.lotteryInfo) {
204 try { 207 try {
205 - lotteryInfo = $.parseJSON(info.lottery_info); 208 + lotteryInfo = $.parseJSON(info.lotteryInfo);
206 } catch(e) {} // eslint-disable-line 209 } catch(e) {} // eslint-disable-line
207 } 210 }
208 211
@@ -21,34 +21,40 @@ body { @@ -21,34 +21,40 @@ body {
21 21
22 li { 22 li {
23 display: flex; 23 display: flex;
24 - flex-direction: row;  
25 - align-items: center;  
26 height: 120px; 24 height: 120px;
27 border-bottom: 1px solid #e0e0e0; 25 border-bottom: 1px solid #e0e0e0;
28 color: #444; 26 color: #444;
29 font-size: 28px; 27 font-size: 28px;
30 - line-height: 120px; 28 +
  29 + .label {
  30 + width: 150px;
  31 + white-space: nowrap;
  32 + font-size: 32px;
  33 + color: #444;
  34 + align-content: center;
  35 + display: flex;
  36 + justify-content: flex-end;
  37 + align-items: center;
  38 + }
  39 +
  40 + .text {
  41 + margin-left: 20px;
  42 + flex: 1;
  43 + display: flex;
  44 + justify-content: flex-start;
  45 + align-items: center;
  46 + }
31 47
32 input { 48 input {
33 border: none; 49 border: none;
34 color: #444; 50 color: #444;
35 - margin-left: 20px;  
36 font-size: 28px; 51 font-size: 28px;
37 - line-height: 120px;  
38 background-color: transparent; 52 background-color: transparent;
39 } 53 }
40 54
41 input::-webkit-input-placeholder { 55 input::-webkit-input-placeholder {
42 color: #b0b0b0; 56 color: #b0b0b0;
43 } 57 }
44 -  
45 - span {  
46 - display: inline-block;  
47 - width: 130px;  
48 - font-size: 32px;  
49 - color: #444;  
50 - letter-spacing: 0;  
51 - }  
52 } 58 }
53 59
54 .party-icon-item { 60 .party-icon-item {
@@ -14,6 +14,9 @@ @@ -14,6 +14,9 @@
14 display: inline-block; 14 display: inline-block;
15 margin-left: 30px; 15 margin-left: 30px;
16 vertical-align: top; 16 vertical-align: top;
  17 + white-space: nowrap;
  18 + overflow: hidden;
  19 + width: 75%;
17 } 20 }
18 21
19 .swiper { 22 .swiper {