Showing
10 changed files
with
110 additions
and
48 deletions
@@ -8,7 +8,12 @@ exports.index = (req, res, next) => { | @@ -8,7 +8,12 @@ exports.index = (req, res, next) => { | ||
8 | module: 'activity', | 8 | module: 'activity', |
9 | page: 'user-recommend', | 9 | page: 'user-recommend', |
10 | width750: true, | 10 | width750: true, |
11 | - localCss: true | 11 | + localCss: true, |
12 | + loadJs: [ | ||
13 | + { | ||
14 | + src: global.yoho.config.jsSdk | ||
15 | + } | ||
16 | + ] | ||
12 | }; | 17 | }; |
13 | 18 | ||
14 | let params = { | 19 | let params = { |
@@ -56,8 +56,8 @@ module.exports = class extends global.yoho.BaseModel { | @@ -56,8 +56,8 @@ module.exports = class extends global.yoho.BaseModel { | ||
56 | }; | 56 | }; |
57 | 57 | ||
58 | if (result) { | 58 | if (result) { |
59 | - if (result[0] && result[0].data && result[0].data.list) { | ||
60 | - if (result[0].data.list[0] && result[0].data.list[0].data && result[0].data.list[0].data[0]) { | 59 | + if (_.get(result, '[0].data.list', false)) { |
60 | + if (_.get(result[0].data.list[0], 'data[0]', false)) { | ||
61 | let val = result[0].data.list[0].data[0]; | 61 | let val = result[0].data.list[0].data[0]; |
62 | 62 | ||
63 | resu.bigPic = { | 63 | resu.bigPic = { |
@@ -67,22 +67,36 @@ module.exports = class extends global.yoho.BaseModel { | @@ -67,22 +67,36 @@ module.exports = class extends global.yoho.BaseModel { | ||
67 | } | 67 | } |
68 | } | 68 | } |
69 | 69 | ||
70 | - if (result[1] && result[1].data && result[1].data.product_list) { | 70 | + if (_.get(result, '[1].data.product_list', false)) { |
71 | let build = []; | 71 | let build = []; |
72 | let data = result[1].data.product_list; | 72 | let data = result[1].data.product_list; |
73 | 73 | ||
74 | _.forEach(data, (val) => { | 74 | _.forEach(data, (val) => { |
75 | + let discount = this.getDiscound(val.sales_price, val.market_price); | ||
76 | + | ||
75 | build.push({ | 77 | build.push({ |
76 | productName: val.product_name, | 78 | productName: val.product_name, |
77 | salesPrice: val.sales_price, | 79 | salesPrice: val.sales_price, |
78 | - marketPrice: val.market_price, | 80 | + marketPrice: val.market_price === val.sales_price ? '' : val.market_price, |
79 | defaultImages: val.default_images ? val.default_images.split(',')[0] : '', | 81 | defaultImages: val.default_images ? val.default_images.split(',')[0] : '', |
80 | - productSkn: val.product_skn | 82 | + productSkn: val.product_skn, |
83 | + discount: discount | ||
81 | }); | 84 | }); |
82 | }); | 85 | }); |
83 | 86 | ||
84 | resu.goodList = build; | 87 | resu.goodList = build; |
85 | } | 88 | } |
89 | + | ||
90 | + if (_.get(result, '[1].data.coupon_list', false)) { | ||
91 | + let couponNum = result[1].data.coupon_list.length; | ||
92 | + | ||
93 | + if (couponNum % 2 !== 0) { | ||
94 | + resu.odd = true; | ||
95 | + } else { | ||
96 | + resu.odd = false; | ||
97 | + } | ||
98 | + resu.couponList = result[1].data.coupon_list; | ||
99 | + } | ||
86 | } | 100 | } |
87 | return resu; | 101 | return resu; |
88 | }); | 102 | }); |
@@ -96,17 +110,20 @@ module.exports = class extends global.yoho.BaseModel { | @@ -96,17 +110,20 @@ module.exports = class extends global.yoho.BaseModel { | ||
96 | goodList: [] | 110 | goodList: [] |
97 | }; | 111 | }; |
98 | 112 | ||
99 | - if (result[0] && result[0].data && result[0].data.product_list) { | 113 | + if (_.get(result, '[0].data.product_list', false)) { |
100 | let build = []; | 114 | let build = []; |
101 | let data = result[0].data.product_list; | 115 | let data = result[0].data.product_list; |
102 | 116 | ||
103 | _.forEach(data, (val) => { | 117 | _.forEach(data, (val) => { |
118 | + let discount = this.getDiscound(val.sales_price, val.market_price); | ||
119 | + | ||
104 | build.push({ | 120 | build.push({ |
105 | productName: val.product_name, | 121 | productName: val.product_name, |
106 | salesPrice: val.sales_price, | 122 | salesPrice: val.sales_price, |
107 | - marketPrice: val.market_price, | 123 | + marketPrice: val.market_price === val.sales_price ? '' : val.market_price, |
108 | defaultImages: val.default_images ? val.default_images.split(',')[0] : '', | 124 | defaultImages: val.default_images ? val.default_images.split(',')[0] : '', |
109 | - productSkn: val.product_skn | 125 | + productSkn: val.product_skn, |
126 | + discount: discount | ||
110 | }); | 127 | }); |
111 | }); | 128 | }); |
112 | 129 | ||
@@ -115,4 +132,47 @@ module.exports = class extends global.yoho.BaseModel { | @@ -115,4 +132,47 @@ module.exports = class extends global.yoho.BaseModel { | ||
115 | return resu; | 132 | return resu; |
116 | }); | 133 | }); |
117 | } | 134 | } |
135 | + | ||
136 | + getDiscound(salesPrice, marketPrice) { | ||
137 | + let dis = Math.ceil(parseInt(salesPrice, 10) / parseInt(marketPrice, 10) * 10); | ||
138 | + let disMes = ''; | ||
139 | + | ||
140 | + switch (dis) { | ||
141 | + case 0: | ||
142 | + disMes = '<span>1</span>折'; | ||
143 | + break; | ||
144 | + case 1: | ||
145 | + disMes = '<span>1</span>折'; | ||
146 | + break; | ||
147 | + case 2: | ||
148 | + disMes = '<span>2</span>折'; | ||
149 | + break; | ||
150 | + case 3: | ||
151 | + disMes = '<span>3</span>折'; | ||
152 | + break; | ||
153 | + case 4: | ||
154 | + disMes = '<span>4</span>折'; | ||
155 | + break; | ||
156 | + case 5: | ||
157 | + disMes = '<span>5</span>折'; | ||
158 | + break; | ||
159 | + case 6: | ||
160 | + disMes = '<span>6</span>折'; | ||
161 | + break; | ||
162 | + case 7: | ||
163 | + disMes = '<span>7</span>折'; | ||
164 | + break; | ||
165 | + case 8: | ||
166 | + disMes = '<span>8</span>折'; | ||
167 | + break; | ||
168 | + case 9: | ||
169 | + disMes = '<span>9</span>折'; | ||
170 | + break; | ||
171 | + default: | ||
172 | + disMes = '热卖'; | ||
173 | + break; | ||
174 | + } | ||
175 | + | ||
176 | + return disMes; | ||
177 | + } | ||
118 | }; | 178 | }; |
@@ -5,48 +5,22 @@ | @@ -5,48 +5,22 @@ | ||
5 | </a> | 5 | </a> |
6 | {{/ bigPic}} | 6 | {{/ bigPic}} |
7 | <div class="big-title">领取优惠卷 | 7 | <div class="big-title">领取优惠卷 |
8 | - <a class="more"> | 8 | + <a class="more" href='//m.yohobuy.com/coupon/floor?title=领券中心&share_id=1037&code=b78b32ed81b18dde8ac84fd33602b88b&type=5&openby:yohobuy={"action":"go.couponCenter", "params":{"share":"/operations/api/v5/webshare/getShare","share_id":"1037","title":"领券中心"}}'> |
9 | 更多优惠卷 | 9 | 更多优惠卷 |
10 | <span class="iconfont"></span> | 10 | <span class="iconfont"></span> |
11 | </a> | 11 | </a> |
12 | </div> | 12 | </div> |
13 | - <div class="ticket-c clearfix"> | ||
14 | - <div class="ticket-item"> | 13 | + <div class="ticket-c clearfix{{#if odd}} odd{{/if}}"> |
14 | + {{# couponList}} | ||
15 | + <a class="ticket-item yoho-conpon" data-token="{{id}}:0" href="javascript:;"> | ||
15 | <div class="tip"> | 16 | <div class="tip"> |
16 | <div class="price"> | 17 | <div class="price"> |
17 | - <span class="ico">¥</span>50 | 18 | + <span class="ico">¥</span>{{couponAmount}} |
18 | </div> | 19 | </div> |
19 | - <div class="name">VANS.品牌卷</div> | ||
20 | - <div class="num">满399减50</div> | 20 | + <div class="name line-clamp-2">{{couponName}}</div> |
21 | </div> | 21 | </div> |
22 | - </div> | ||
23 | - <div class="ticket-item disable"> | ||
24 | - <div class="tip"> | ||
25 | - <div class="price"> | ||
26 | - <span class="ico">¥</span>50 | ||
27 | - </div> | ||
28 | - <div class="name">VANS.品牌卷</div> | ||
29 | - <div class="num">满399减50</div> | ||
30 | - </div> | ||
31 | - </div> | ||
32 | - <div class="ticket-item"> | ||
33 | - <div class="tip"> | ||
34 | - <div class="price"> | ||
35 | - <span class="ico">¥</span>50 | ||
36 | - </div> | ||
37 | - <div class="name">VANS.品牌卷</div> | ||
38 | - <div class="num">满399减50</div> | ||
39 | - </div> | ||
40 | - </div> | ||
41 | - <div class="ticket-item"> | ||
42 | - <div class="tip"> | ||
43 | - <div class="price"> | ||
44 | - <span class="ico">¥</span>50 | ||
45 | - </div> | ||
46 | - <div class="name">VANS.品牌卷</div> | ||
47 | - <div class="num">满399减50</div> | ||
48 | - </div> | ||
49 | - </div> | 22 | + </a> |
23 | + {{/ couponList}} | ||
50 | </div> | 24 | </div> |
51 | <div class="big-title">潮流优选</div> | 25 | <div class="big-title">潮流优选</div> |
52 | <div class="goods clearfix"> | 26 | <div class="goods clearfix"> |
@@ -56,7 +30,9 @@ | @@ -56,7 +30,9 @@ | ||
56 | <img src="{{image2 defaultImages w=330 h=379 q=90}}" /> | 30 | <img src="{{image2 defaultImages w=330 h=379 q=90}}" /> |
57 | </div> | 31 | </div> |
58 | <div class="price">¥{{salesPrice}} | 32 | <div class="price">¥{{salesPrice}} |
33 | + {{#if marketPrice}} | ||
59 | <span>¥{{marketPrice}}</span> | 34 | <span>¥{{marketPrice}}</span> |
35 | + {{/if}} | ||
60 | </div> | 36 | </div> |
61 | <div class="tip"> | 37 | <div class="tip"> |
62 | <div class="tip-c"> | 38 | <div class="tip-c"> |
@@ -64,7 +40,7 @@ | @@ -64,7 +40,7 @@ | ||
64 | </div> | 40 | </div> |
65 | <div class="ico"></div> | 41 | <div class="ico"></div> |
66 | </div> | 42 | </div> |
67 | - <div class="discount"></div> | 43 | + <div class="discount">{{{discount}}}</div> |
68 | </a> | 44 | </a> |
69 | {{/ goodList}} | 45 | {{/ goodList}} |
70 | </div> | 46 | </div> |
@@ -99,7 +99,8 @@ module.exports = { | @@ -99,7 +99,8 @@ module.exports = { | ||
99 | notifyUrl: domains.service + 'payment/weixin_notify', | 99 | notifyUrl: domains.service + 'payment/weixin_notify', |
100 | }, | 100 | }, |
101 | maxQps: 1200, | 101 | maxQps: 1200, |
102 | - geetestJs: '//static.geetest.com/static/tools/gt.js' | 102 | + geetestJs: '//static.geetest.com/static/tools/gt.js', |
103 | + jsSdk: '//cdn.yoho.cn/js-sdk/1.2.2/jssdk.js' | ||
103 | }; | 104 | }; |
104 | 105 | ||
105 | if (isProduction) { | 106 | if (isProduction) { |
@@ -4,7 +4,9 @@ | @@ -4,7 +4,9 @@ | ||
4 | <img src="{{image2 defaultImages w=330 h=379 q=90}}" /> | 4 | <img src="{{image2 defaultImages w=330 h=379 q=90}}" /> |
5 | </div> | 5 | </div> |
6 | <div class="price">¥{{salesPrice}} | 6 | <div class="price">¥{{salesPrice}} |
7 | + {{#if marketPrice}} | ||
7 | <span>¥{{marketPrice}}</span> | 8 | <span>¥{{marketPrice}}</span> |
9 | + {{/if}} | ||
8 | </div> | 10 | </div> |
9 | <div class="tip"> | 11 | <div class="tip"> |
10 | <div class="tip-c"> | 12 | <div class="tip-c"> |
@@ -12,6 +14,6 @@ | @@ -12,6 +14,6 @@ | ||
12 | </div> | 14 | </div> |
13 | <div class="ico"></div> | 15 | <div class="ico"></div> |
14 | </div> | 16 | </div> |
15 | - <div class="discount"></div> | 17 | + <div class="discount">{{{discount}}}</div> |
16 | </a> | 18 | </a> |
17 | {{/ goodList}} | 19 | {{/ goodList}} |
@@ -12,6 +12,8 @@ import { | @@ -12,6 +12,8 @@ import { | ||
12 | moreGoods as getMore | 12 | moreGoods as getMore |
13 | } from './model'; | 13 | } from './model'; |
14 | 14 | ||
15 | +let $ = require('yoho-jquery'); | ||
16 | + | ||
15 | let goodContent = require('activity/user-recommend/recommend-goods.hbs'); | 17 | let goodContent = require('activity/user-recommend/recommend-goods.hbs'); |
16 | 18 | ||
17 | class ActController extends Controller { | 19 | class ActController extends Controller { |
@@ -21,6 +23,7 @@ class ActController extends Controller { | @@ -21,6 +23,7 @@ class ActController extends Controller { | ||
21 | this.more.on('more', this.doMore.bind(this)); | 23 | this.more.on('more', this.doMore.bind(this)); |
22 | this.page = 1; | 24 | this.page = 1; |
23 | this.loading = false; | 25 | this.loading = false; |
26 | + global.jQuery = $; | ||
24 | } | 27 | } |
25 | 28 | ||
26 | doMore() { | 29 | doMore() { |
@@ -44,7 +44,7 @@ | @@ -44,7 +44,7 @@ | ||
44 | height: 154px; | 44 | height: 154px; |
45 | float: left; | 45 | float: left; |
46 | background-image: resolve("activity/user-recommend/ticket-1.jpg"); | 46 | background-image: resolve("activity/user-recommend/ticket-1.jpg"); |
47 | - background-size: 100%; | 47 | + background-size: 100% 100%; |
48 | margin-bottom: 30px; | 48 | margin-bottom: 30px; |
49 | 49 | ||
50 | &:nth-child(odd) { | 50 | &:nth-child(odd) { |
@@ -60,7 +60,6 @@ | @@ -60,7 +60,6 @@ | ||
60 | } | 60 | } |
61 | 61 | ||
62 | .tip { | 62 | .tip { |
63 | - width: 226px; | ||
64 | height: 154px; | 63 | height: 154px; |
65 | padding: 0 30px; | 64 | padding: 0 30px; |
66 | color: #fff; | 65 | color: #fff; |
@@ -89,6 +88,12 @@ | @@ -89,6 +88,12 @@ | ||
89 | } | 88 | } |
90 | } | 89 | } |
91 | 90 | ||
91 | + .odd { | ||
92 | + .ticket-item:last-child { | ||
93 | + width: 100%; | ||
94 | + } | ||
95 | + } | ||
96 | + | ||
92 | .goods { | 97 | .goods { |
93 | padding: 0 30px; | 98 | padding: 0 30px; |
94 | 99 | ||
@@ -176,6 +181,16 @@ | @@ -176,6 +181,16 @@ | ||
176 | position: absolute; | 181 | position: absolute; |
177 | top: -9px; | 182 | top: -9px; |
178 | left: 20px; | 183 | left: 20px; |
184 | + color: #fff; | ||
185 | + text-align: center; | ||
186 | + line-height: 63px; | ||
187 | + padding-left: 8px; | ||
188 | + font-size: 20px; | ||
189 | + | ||
190 | + span { | ||
191 | + font-size: 30px; | ||
192 | + font-weight: bold; | ||
193 | + } | ||
179 | } | 194 | } |
180 | } | 195 | } |
181 | } | 196 | } |
-
Please register or login to post a comment