Authored by zhangxiaoru

逻辑修改

@@ -5,9 +5,10 @@ const shareBuyModel = require('../models/share-buy'), @@ -5,9 +5,10 @@ const shareBuyModel = require('../models/share-buy'),
5 5
6 exports.index = (req, res, next) => { 6 exports.index = (req, res, next) => {
7 let activityId = req.query.activity_id || 2023, 7 let activityId = req.query.activity_id || 2023,
8 - isApp = req.yoho.isApp; 8 + isApp = req.yoho.isApp,
  9 + uid = req.user.uid;
9 10
10 - req.ctx(shareBuyModel).shareIndex(activityId, isApp).then(data => { 11 + req.ctx(shareBuyModel).shareIndex(activityId, isApp, uid).then(data => {
11 res.render('share-buy/share-buy', { 12 res.render('share-buy/share-buy', {
12 pageHeader: headerModel.setNav({ 13 pageHeader: headerModel.setNav({
13 navTitle: '分享购' 14 navTitle: '分享购'
@@ -20,30 +21,25 @@ exports.index = (req, res, next) => { @@ -20,30 +21,25 @@ exports.index = (req, res, next) => {
20 newsFlash: data.newsFlash, 21 newsFlash: data.newsFlash,
21 rebeatUrl: data.rebeatUrl, 22 rebeatUrl: data.rebeatUrl,
22 strategyUrl: data.strategyUrl, 23 strategyUrl: data.strategyUrl,
23 - banner: data.banner 24 + banner: data.banner,
  25 + isStudent: data.isStudent
24 }); 26 });
25 27
26 }).catch(next); 28 }).catch(next);
27 }; 29 };
28 30
29 exports.detail = (req, res, next) => { 31 exports.detail = (req, res, next) => {
30 - let uid = req.user.uid,  
31 - param = { 32 + let param = {
32 counum: req.query.counum, 33 counum: req.query.counum,
33 couponType: req.query.couponType, 34 couponType: req.query.couponType,
34 detailDes: req.query.detailDes, 35 detailDes: req.query.detailDes,
35 - couponId: req.query.couponId 36 + couponId: req.query.couponId,
  37 + useCode: req.query.useCode
36 }, 38 },
37 isApp = req.yoho.isApp, 39 isApp = req.yoho.isApp,
38 registerUrl; 40 registerUrl;
39 41
40 - if (isApp) {  
41 - registerUrl = 'http://m.yohobuy.com/activity/student/register?sharebuy=openbuy:yohobuy={"action":"go.h5","params":{"islogin":"N","type":"13","url":"http://m.yohobuy.com/activity/student/register"}}';  
42 - } else {  
43 - registerUrl = 'http://m.yohobuy.com/activity/student/register';  
44 - }  
45 -  
46 - req.ctx(shareBuyModel).shareDetail(uid, param, isApp).then(data => { 42 + req.ctx(shareBuyModel).shareDetail(param, isApp).then(data => {
47 43
48 res.render('share-buy/share-detail', { 44 res.render('share-buy/share-detail', {
49 pageHeader: headerModel.setNav({ 45 pageHeader: headerModel.setNav({
@@ -11,9 +11,11 @@ module.exports = class extends global.yoho.BaseModel { @@ -11,9 +11,11 @@ module.exports = class extends global.yoho.BaseModel {
11 /** 11 /**
12 * 首页数据 12 * 首页数据
13 */ 13 */
14 - shareIndex(activityId, isApp) { 14 + shareIndex(activityId, isApp, uid) {
  15 +
  16 + return api.all([this._CouponInfo(activityId), this._redeatList(), this._banner(),
  17 + this._checkStudent(uid)]).then(result => {
15 18
16 - return api.all([this._CouponInfo(activityId), this._redeatList(), this._banner()]).then(result => {  
17 const indexData = { 19 const indexData = {
18 newsFlash: [] 20 newsFlash: []
19 }; 21 };
@@ -21,6 +23,10 @@ module.exports = class extends global.yoho.BaseModel { @@ -21,6 +23,10 @@ module.exports = class extends global.yoho.BaseModel {
21 const rebeatUrl = '//m.yohobuy.com/activity/share-buy/my-rebeat', 23 const rebeatUrl = '//m.yohobuy.com/activity/share-buy/my-rebeat',
22 strategyUrl = 'http://activity.yoho.cn/feature/115.html?share_id=2023&title=分享购攻略'; 24 strategyUrl = 'http://activity.yoho.cn/feature/115.html?share_id=2023&title=分享购攻略';
23 25
  26 + if (result[3]) {
  27 + indexData.isStudent = parseInt(result[3].isStudent, 10) === 1 ? true : false;
  28 + }
  29 +
24 if (result[0] && result[0].data && result[0].data.userCouponBoList) { 30 if (result[0] && result[0].data && result[0].data.userCouponBoList) {
25 _.forEach(result[0].data.userCouponBoList, function(val) { 31 _.forEach(result[0].data.userCouponBoList, function(val) {
26 32
@@ -38,19 +44,24 @@ module.exports = class extends global.yoho.BaseModel { @@ -38,19 +44,24 @@ module.exports = class extends global.yoho.BaseModel {
38 val.detailDes = val.shareCoupon; 44 val.detailDes = val.shareCoupon;
39 } 45 }
40 46
41 -  
42 val.detailUrl = helpers.urlFormat('/activity/share-buy/detail', { 47 val.detailUrl = helpers.urlFormat('/activity/share-buy/detail', {
43 counum: val.couponValue, 48 counum: val.couponValue,
44 couponType: val.shareCouponType, 49 couponType: val.shareCouponType,
45 detailDes: val.detailDes, 50 detailDes: val.detailDes,
46 - couponId: val.couponId 51 + couponId: val.couponId,
  52 + useCode: uid.toString()
47 }); 53 });
48 54
49 if (isApp) { 55 if (isApp) {
50 val.detailUrl = val.detailUrl + 56 val.detailUrl = val.detailUrl +
51 '&openby:yohobuy={"action":"go.h5","params":{"islogin":"N","url":"http:' + val.detailUrl + 57 '&openby:yohobuy={"action":"go.h5","params":{"islogin":"N","url":"http:' + val.detailUrl +
52 '","params":{"counum":"' + val.couponValue + '","couponType":"' + val.shareCouponType + 58 '","params":{"counum":"' + val.couponValue + '","couponType":"' + val.shareCouponType +
53 - '","detailDes":"' + val.detailDes + '","couponId":"' + val.couponId + '"}}}'; 59 + '","detailDes":"' + val.detailDes + '","couponId":"' + val.couponId + '","useCode":"' +
  60 + uid + '"}}}';
  61 + }
  62 +
  63 + if (!indexData.isStudent) {
  64 + val.detailUrl = '';
54 } 65 }
55 }); 66 });
56 67
@@ -70,7 +81,8 @@ module.exports = class extends global.yoho.BaseModel { @@ -70,7 +81,8 @@ module.exports = class extends global.yoho.BaseModel {
70 } 81 }
71 82
72 indexData.rebeatUrl = isApp ? rebeatUrl + 83 indexData.rebeatUrl = isApp ? rebeatUrl +
73 - '?openby:yohobuy={"action":"go.h5","params":{"islogin":"N","url":"http:' + rebeatUrl + '"}}' : rebeatUrl; 84 + '?openby:yohobuy={"action":"go.h5","params":{"islogin":"N","url":"http:' + rebeatUrl + '"}}' :
  85 + rebeatUrl;
74 86
75 indexData.strategyUrl = isApp ? strategyUrl + 87 indexData.strategyUrl = isApp ? strategyUrl +
76 '&openby:yohobuy={"action":"go.h5","params":{"islogin":"N","url":"' + strategyUrl + '"}}' : strategyUrl; 88 '&openby:yohobuy={"action":"go.h5","params":{"islogin":"N","url":"' + strategyUrl + '"}}' : strategyUrl;
@@ -129,35 +141,13 @@ module.exports = class extends global.yoho.BaseModel { @@ -129,35 +141,13 @@ module.exports = class extends global.yoho.BaseModel {
129 }); 141 });
130 } 142 }
131 143
132 - shareDetail(uid, param, isApp) {  
133 - return api.all([this._couponDetail(uid, param, isApp), this._checkStudent(uid)]).then(result => {  
134 - let finalData;  
135 -  
136 - if (result[0]) {  
137 - finalData = _.assign(finalData, result[0]);  
138 - }  
139 -  
140 - if (result[1]) {  
141 - finalData = _.assign(finalData, {  
142 - isStudent: parseInt(result[1].isStudent, 10) === 1 ? true : false  
143 - });  
144 - }  
145 -  
146 - if (!finalData.isStudent) {  
147 - finalData.couponCode = '*******';  
148 - }  
149 -  
150 - return finalData;  
151 - });  
152 - }  
153 -  
154 /** 144 /**
155 * 优惠劵详情数据 145 * 优惠劵详情数据
156 */ 146 */
157 - _couponDetail(uid, param, isApp) { 147 + shareDetail(param, isApp) {
158 return api.get('', { 148 return api.get('', {
159 method: 'app.activity.getActivityCouponCode', 149 method: 'app.activity.getActivityCouponCode',
160 - uid: uid, 150 + uid: param.useCode,
161 coupon_id: param.couponId 151 coupon_id: param.couponId
162 }, { 152 }, {
163 code: 200 153 code: 200
@@ -200,7 +190,7 @@ module.exports = class extends global.yoho.BaseModel { @@ -200,7 +190,7 @@ module.exports = class extends global.yoho.BaseModel {
200 190
201 let resu = {}; 191 let resu = {};
202 192
203 - if (result && result.data) { 193 + if (result && result.data && result.code === 200) {
204 resu = result.data; 194 resu = result.data;
205 } 195 }
206 196
@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 <img src="{{image banner 750 366}}"><img> 3 <img src="{{image banner 750 366}}"><img>
4 </div> 4 </div>
5 5
6 - <div class="coupon-list"> 6 + <div class="coupon-list" data-student="{{isStudent}}">
7 {{# userCouponBoList}} 7 {{# userCouponBoList}}
8 <div class="coupon-group"> 8 <div class="coupon-group">
9 <div class="coupon-left"> 9 <div class="coupon-left">
@@ -14,7 +14,11 @@ @@ -14,7 +14,11 @@
14 <p class="coupon-type">{{shareCouponType}}</p> 14 <p class="coupon-type">{{shareCouponType}}</p>
15 </div> 15 </div>
16 <div class="coupon-right"> 16 <div class="coupon-right">
17 - <a href="{{detailUrl}}">立即参与</a> 17 + {{#if detailUrl}}
  18 + <a href="{{detailUrl}}" class="join">立即参与</a>
  19 + {{else}}
  20 + <span class="join">立即参与</span>
  21 + {{/if}}
18 <p class="coupon-mold">{{shareCoupon}}</p> 22 <p class="coupon-mold">{{shareCoupon}}</p>
19 <p class="coupon-limit">{{couponDescribe}}</p> 23 <p class="coupon-limit">{{couponDescribe}}</p>
20 </div> 24 </div>
1 <div class="share-detail-page" > 1 <div class="share-detail-page" >
2 {{# detailData}} 2 {{# detailData}}
3 - <div class="coupon-detail" data-student="{{isStudent}}" data-app="{{isApp}}"> 3 + <div class="coupon-detail" data-app="{{isApp}}">
4 <div class="countdown"> 4 <div class="countdown">
5 <div class="title">距离活动时间还剩:</div> 5 <div class="title">距离活动时间还剩:</div>
6 {{#if finish}} 6 {{#if finish}}
@@ -62,11 +62,3 @@ @@ -62,11 +62,3 @@
62 </div> 62 </div>
63 {{/ detailData}} 63 {{/ detailData}}
64 </div> 64 </div>
65 -{{#unless detailData.isStudent}}  
66 -<div class="share-dialog-tip">  
67 - <div class="tip-box">  
68 - <div class="tip-center">完成学生认证即可参与活动哦~</div>  
69 - <a class="tip-btn" href="{{registerUrl}}">去认证</a>  
70 - </div>  
71 -</div>  
72 -{{/unless}}  
1 'use strict'; 1 'use strict';
2 require('activity/share-buy.page.css'); 2 require('activity/share-buy.page.css');
3 3
4 -let $ = require('yoho-jquery'); 4 +let $ = require('yoho-jquery'),
  5 + dialog = require('plugin/dialog'),
  6 + yoho = require('yoho-app');
5 7
6 let $news = $('.news'), 8 let $news = $('.news'),
7 newsLiL = $news.find('li').length, 9 newsLiL = $news.find('li').length,
@@ -38,3 +40,24 @@ if (newsLiL > 1) { @@ -38,3 +40,24 @@ if (newsLiL > 1) {
38 40
39 setInterval(Marquee, 100); 41 setInterval(Marquee, 100);
40 } 42 }
  43 +
  44 +$('.join').click(function() {
  45 + if ($('.coupon-list').data('student') === false) {
  46 +
  47 + dialog.showDialog({
  48 + dialogText: '完成学生认证即可参与活动哦~',
  49 + fast: true,
  50 + hasFooter: {
  51 + rightBtnText: '去认证'
  52 + }
  53 + }, function() {
  54 + if (yoho.isApp) {
  55 +
  56 + location.href = 'http://m.yohobuy.com/activity/student/register' +
  57 + '?openbuy:yohobuy={"action":"go.h5","params":{"islogin":"N","type":"13","url":"http://m.yohobuy.com/activity/student/register"}}';
  58 + } else {
  59 + location.href = '//m.yohobuy.com/activity/student/register';
  60 + }
  61 + }, null, true);
  62 + }
  63 +});
@@ -73,7 +73,7 @@ @@ -73,7 +73,7 @@
73 white-space: nowrap; 73 white-space: nowrap;
74 } 74 }
75 75
76 - a { 76 + .join {
77 float: right; 77 float: right;
78 margin: 55px 35px 0 0; 78 margin: 55px 35px 0 0;
79 display: block; 79 display: block;