Authored by 张孝茹

兑换

@@ -170,7 +170,9 @@ exports.getList = (req, res, next) => { @@ -170,7 +170,9 @@ exports.getList = (req, res, next) => {
170 uid: req.user.uid, 170 uid: req.user.uid,
171 type: req.query.type, 171 type: req.query.type,
172 page: req.query.page, 172 page: req.query.page,
173 - limit: req.query.limit 173 + limit: req.query.limit,
  174 + isMarsApp: req.yoho.isMarsApp,
  175 + isNowApp: req.yoho.isNowApp
174 }; 176 };
175 177
176 req.ctx(family).getList(params).then((result) => { 178 req.ctx(family).getList(params).then((result) => {
@@ -624,6 +624,17 @@ class familyModel extends global.yoho.BaseModel { @@ -624,6 +624,17 @@ class familyModel extends global.yoho.BaseModel {
624 if (_.get(result, 'data.list')) { 624 if (_.get(result, 'data.list')) {
625 resu.list = result.data.list; 625 resu.list = result.data.list;
626 } 626 }
  627 +
  628 + _.forEach(resu.list, function(val) {
  629 + if (params.isMarsApp && params.type === 'mars') {
  630 + val.usable = true;
  631 + }
  632 +
  633 + if (params.isNowApp && params.type === 'now') {
  634 + val.usable = true;
  635 + }
  636 + });
  637 +
627 return resu; 638 return resu;
628 }); 639 });
629 } 640 }
@@ -25,8 +25,7 @@ @@ -25,8 +25,7 @@
25 <div class="remain">仅剩{{#if stock}}{{stock}}{{/if}}{{#if num}}{{num}}{{/if}}</div> 25 <div class="remain">仅剩{{#if stock}}{{stock}}{{/if}}{{#if num}}{{num}}{{/if}}</div>
26 </div> 26 </div>
27 <div class="right"> 27 <div class="right">
28 - <a class="go-btn yohonow" href="yohoefashion4In1://yoho.cn/">兑换</a>  
29 - <a class="go-btn mars" href="yohomars://yohomars.com/goapp?openby:mars=">兑换</a> 28 + <span class="go-btn{{#if usable}} usable{{/if}}" data-id="{{id}}" data-level="{{level}}">兑换</span>
30 </div> 29 </div>
31 </div> 30 </div>
32 </div> 31 </div>
@@ -74,6 +74,10 @@ class IconMall extends Page { @@ -74,6 +74,10 @@ class IconMall extends Page {
74 this.selector.$marsTab.append($result); 74 this.selector.$marsTab.append($result);
75 } 75 }
76 this.loading = false; 76 this.loading = false;
  77 +
  78 + this.selector.$goBtn = $('.go-btn');
  79 + this.selector.$goBtn.on('click', this.goConversion.bind(this));
  80 +
77 lazyLoad($result.find('img.lazy')); 81 lazyLoad($result.find('img.lazy'));
78 } else { 82 } else {
79 this.end = true; 83 this.end = true;
@@ -148,6 +152,28 @@ class IconMall extends Page { @@ -148,6 +152,28 @@ class IconMall extends Page {
148 yoho.invokeMethod('go.point_detail'); 152 yoho.invokeMethod('go.point_detail');
149 } 153 }
150 } 154 }
  155 +
  156 + goConversion(e) {
  157 + let $this = $(e.currentTarget);
  158 + let type = $this.closest('.tab-item-c').attr('id');
  159 + let goodId = $this.data('id');
  160 + let goodsLevel = $this.data('level');
  161 +
  162 +
  163 + if ($this.hasClass('usable')) {
  164 + if (yoho && yoho.isMarsApp) {
  165 + yoho.invokeMethod('go.mars_point', {goodId: goodId, goods_level: goodsLevel});
  166 + } else if (yoho && yoho.isNowApp) {
  167 + yoho.invokeMethod('go.yohoCoins', {goodId: goodId});
  168 + }
  169 + } else {
  170 + if (type === 'yohonow-tab') {
  171 + tip.show('请到yohonowapp打开');
  172 + } else if (type === 'mars-tab') {
  173 + tip.show('请到mars打开');
  174 + }
  175 + }
  176 + }
151 } 177 }
152 178
153 $(() => { 179 $(() => {
@@ -220,10 +220,14 @@ html { @@ -220,10 +220,14 @@ html {
220 text-align: center; 220 text-align: center;
221 color: #fff; 221 color: #fff;
222 font-size: 28px; 222 font-size: 28px;
223 - background-color: #000; 223 + background-color: #b0b0b0;
224 display: block; 224 display: block;
225 margin-top: 25px; 225 margin-top: 25px;
226 } 226 }
  227 +
  228 + .usable {
  229 + background-color: #000;
  230 + }
227 } 231 }
228 } 232 }
229 } 233 }