|
@@ -11,72 +11,84 @@ module.exports = class extends global.yoho.BaseModel { |
|
@@ -11,72 +11,84 @@ module.exports = class extends global.yoho.BaseModel { |
11
|
/**
|
11
|
/**
|
12
|
* 首页数据
|
12
|
* 首页数据
|
13
|
*/
|
13
|
*/
|
14
|
- shareIndex(activityId, isApp) {
|
|
|
15
|
-
|
|
|
16
|
- return api.all([this._CouponInfo(activityId), this._redeatList(), this._banner()]).then(result => {
|
|
|
17
|
- const indexData = {
|
|
|
18
|
- newsFlash: []
|
|
|
19
|
- };
|
|
|
20
|
-
|
|
|
21
|
- const rebeatUrl = '//m.yohobuy.com/activity/share-buy/my-rebeat',
|
|
|
22
|
- strategyUrl = 'http://activity.yoho.cn/feature/115.html?share_id=2023&title=分享购攻略';
|
|
|
23
|
-
|
|
|
24
|
- if (result[0] && result[0].data && result[0].data.userCouponBoList) {
|
|
|
25
|
- _.forEach(result[0].data.userCouponBoList, function(val) {
|
|
|
26
|
-
|
|
|
27
|
- if (val.sortNames) {
|
|
|
28
|
- val.couponDescribe = '限' + val.sortNames + '使用';
|
|
|
29
|
- val.detailDes = '限品类: ' + val.sortNames;
|
|
|
30
|
- } else if (val.brandNames) {
|
|
|
31
|
- val.couponDescribe = '限' + val.brandNames + '使用';
|
|
|
32
|
- val.detailDes = '限品牌: ' + val.brandNames;
|
|
|
33
|
- } else if (val.shareCoupon === '全场通用') {
|
|
|
34
|
- val.couponDescribe = '任意商品使用';
|
|
|
35
|
- val.detailDes = val.shareCoupon;
|
|
|
36
|
- } else if (val.shopNames) {
|
|
|
37
|
- val.couponDescribe = '限' + val.shopNames + '使用';
|
|
|
38
|
- val.detailDes = val.shareCoupon;
|
|
|
39
|
- }
|
|
|
40
|
-
|
|
|
41
|
-
|
|
|
42
|
- val.detailUrl = helpers.urlFormat('/activity/share-buy/detail', {
|
|
|
43
|
- counum: val.couponValue,
|
|
|
44
|
- couponType: val.shareCouponType,
|
|
|
45
|
- detailDes: val.detailDes,
|
|
|
46
|
- couponId: val.couponId
|
14
|
+ shareIndex(activityId, isApp, uid) {
|
|
|
15
|
+
|
|
|
16
|
+ return api.all([this._CouponInfo(activityId), this._redeatList(), this._banner(),
|
|
|
17
|
+ this._checkStudent(uid)]).then(result => {
|
|
|
18
|
+
|
|
|
19
|
+ const indexData = {
|
|
|
20
|
+ newsFlash: []
|
|
|
21
|
+ };
|
|
|
22
|
+
|
|
|
23
|
+ const rebeatUrl = '//m.yohobuy.com/activity/share-buy/my-rebeat',
|
|
|
24
|
+ strategyUrl = 'http://activity.yoho.cn/feature/115.html?share_id=2023&title=分享购攻略';
|
|
|
25
|
+
|
|
|
26
|
+ if (result[3]) {
|
|
|
27
|
+ indexData.isStudent = parseInt(result[3].isStudent, 10) === 1 ? true : false;
|
|
|
28
|
+ }
|
|
|
29
|
+
|
|
|
30
|
+ if (result[0] && result[0].data && result[0].data.userCouponBoList) {
|
|
|
31
|
+ _.forEach(result[0].data.userCouponBoList, function(val) {
|
|
|
32
|
+
|
|
|
33
|
+ if (val.sortNames) {
|
|
|
34
|
+ val.couponDescribe = '限' + val.sortNames + '使用';
|
|
|
35
|
+ val.detailDes = '限品类: ' + val.sortNames;
|
|
|
36
|
+ } else if (val.brandNames) {
|
|
|
37
|
+ val.couponDescribe = '限' + val.brandNames + '使用';
|
|
|
38
|
+ val.detailDes = '限品牌: ' + val.brandNames;
|
|
|
39
|
+ } else if (val.shareCoupon === '全场通用') {
|
|
|
40
|
+ val.couponDescribe = '任意商品使用';
|
|
|
41
|
+ val.detailDes = val.shareCoupon;
|
|
|
42
|
+ } else if (val.shopNames) {
|
|
|
43
|
+ val.couponDescribe = '限' + val.shopNames + '使用';
|
|
|
44
|
+ val.detailDes = val.shareCoupon;
|
|
|
45
|
+ }
|
|
|
46
|
+
|
|
|
47
|
+ val.detailUrl = helpers.urlFormat('/activity/share-buy/detail', {
|
|
|
48
|
+ counum: val.couponValue,
|
|
|
49
|
+ couponType: val.shareCouponType,
|
|
|
50
|
+ detailDes: val.detailDes,
|
|
|
51
|
+ couponId: val.couponId,
|
|
|
52
|
+ useCode: uid.toString()
|
|
|
53
|
+ });
|
|
|
54
|
+
|
|
|
55
|
+ if (isApp) {
|
|
|
56
|
+ val.detailUrl = val.detailUrl +
|
|
|
57
|
+ '&openby:yohobuy={"action":"go.h5","params":{"islogin":"N","url":"http:' + val.detailUrl +
|
|
|
58
|
+ '","params":{"counum":"' + val.couponValue + '","couponType":"' + val.shareCouponType +
|
|
|
59
|
+ '","detailDes":"' + val.detailDes + '","couponId":"' + val.couponId + '","useCode":"' +
|
|
|
60
|
+ uid + '"}}}';
|
|
|
61
|
+ }
|
|
|
62
|
+
|
|
|
63
|
+ if (!indexData.isStudent) {
|
|
|
64
|
+ val.detailUrl = '';
|
|
|
65
|
+ }
|
47
|
});
|
66
|
});
|
48
|
|
67
|
|
49
|
- if (isApp) {
|
|
|
50
|
- val.detailUrl = val.detailUrl +
|
|
|
51
|
- '&openby:yohobuy={"action":"go.h5","params":{"islogin":"N","url":"http:' + val.detailUrl +
|
|
|
52
|
- '","params":{"counum":"' + val.couponValue + '","couponType":"' + val.shareCouponType +
|
|
|
53
|
- '","detailDes":"' + val.detailDes + '","couponId":"' + val.couponId + '"}}}';
|
|
|
54
|
- }
|
|
|
55
|
- });
|
|
|
56
|
-
|
|
|
57
|
- indexData.userCouponBoList = result[0].data.userCouponBoList;
|
|
|
58
|
- }
|
68
|
+ indexData.userCouponBoList = result[0].data.userCouponBoList;
|
|
|
69
|
+ }
|
59
|
|
70
|
|
60
|
- if (result[1] && result[1].data && result[1].data.detail) {
|
|
|
61
|
- _.forEach(result[1].data.detail, function(data) {
|
|
|
62
|
- indexData.newsFlash.push({
|
|
|
63
|
- flashDetail: '用户' + data.nickName + ' 今日返利' + data.coinNum + '个有货币'
|
71
|
+ if (result[1] && result[1].data && result[1].data.detail) {
|
|
|
72
|
+ _.forEach(result[1].data.detail, function(data) {
|
|
|
73
|
+ indexData.newsFlash.push({
|
|
|
74
|
+ flashDetail: '用户' + data.nickName + ' 今日返利' + data.coinNum + '个有货币'
|
|
|
75
|
+ });
|
64
|
});
|
76
|
});
|
65
|
- });
|
|
|
66
|
- }
|
77
|
+ }
|
67
|
|
78
|
|
68
|
- if (result[2]) {
|
|
|
69
|
- indexData.banner = result[2].data[0].src;
|
|
|
70
|
- }
|
79
|
+ if (result[2]) {
|
|
|
80
|
+ indexData.banner = result[2].data[0].src;
|
|
|
81
|
+ }
|
71
|
|
82
|
|
72
|
- indexData.rebeatUrl = isApp ? rebeatUrl +
|
|
|
73
|
- '?openby:yohobuy={"action":"go.h5","params":{"islogin":"N","url":"http:' + rebeatUrl + '"}}' : rebeatUrl;
|
83
|
+ indexData.rebeatUrl = isApp ? rebeatUrl +
|
|
|
84
|
+ '?openby:yohobuy={"action":"go.h5","params":{"islogin":"N","url":"http:' + rebeatUrl + '"}}' :
|
|
|
85
|
+ rebeatUrl;
|
74
|
|
86
|
|
75
|
- indexData.strategyUrl = isApp ? strategyUrl +
|
|
|
76
|
- '&openby:yohobuy={"action":"go.h5","params":{"islogin":"N","url":"' + strategyUrl + '"}}' : strategyUrl;
|
87
|
+ indexData.strategyUrl = isApp ? strategyUrl +
|
|
|
88
|
+ '&openby:yohobuy={"action":"go.h5","params":{"islogin":"N","url":"' + strategyUrl + '"}}' : strategyUrl;
|
77
|
|
89
|
|
78
|
- return indexData;
|
|
|
79
|
- });
|
90
|
+ return indexData;
|
|
|
91
|
+ });
|
80
|
}
|
92
|
}
|
81
|
|
93
|
|
82
|
/**
|
94
|
/**
|
|
@@ -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
|
|