Authored by 郝肖肖

去除废弃代码

@@ -6,4 +6,4 @@ @@ -6,4 +6,4 @@
6 6
7 require('./search/list'); 7 require('./search/list');
8 require('../common/footer'); 8 require('../common/footer');
9 -require('./shop/shop-coupon'); 9 +require('./shop/coupon');
1 require('./shop/shop'); 1 require('./shop/shop');
2 -require('./shop/shop-coupon'); 2 +require('./shop/coupon');
1 -var $ = require('yoho-jquery'),  
2 - Swiper = require('yoho-swiper'),  
3 - tip = require('../../plugin/tip');  
4 -  
5 -require('../../common');  
6 -  
7 -var brandCoupon = {};  
8 -  
9 -brandCoupon = {  
10 - common: {  
11 - appVersion: window.queryString.app_version || window.queryString.appVersion,  
12 - uid: window.queryString.uid,  
13 - brandId: $('.brand-header').data('id'),  
14 - couponTemplate: require('product/shop/coupon.hbs')  
15 - },  
16 - init: function() {  
17 - this.getShopCouponsList();  
18 - },  
19 - getShopCouponsList: function() {  
20 - var that = this;  
21 -  
22 - $.ajax({  
23 - method: 'GET',  
24 - url: location.protocol + '//m.yohobuy.com/product/index/getBrandCouponsList',  
25 - data: {  
26 - brandId: that.common.brandId,  
27 - uid: that.common.uid  
28 - },  
29 - xhrFields: {  
30 - withCredentials: true  
31 - },  
32 - success: function(result) {  
33 - $('.coupon-group').html(that.common.couponTemplate(result));  
34 - new Swiper('.coupon-content', {  
35 - slideElement: '.coupon-small',  
36 - slidesPerView: 'auto',  
37 - watchSlidesVisibility: true  
38 - });  
39 - that.userCoupon();  
40 - }  
41 - });  
42 - },  
43 - userCoupon: function() {  
44 - var $self = this;  
45 -  
46 - $('.coupon-content .receive-btn').closest('.swiper-slide').on('click', function() {  
47 - var that = this,  
48 - code = $(this).data('id') || '';  
49 -  
50 - if (that.isCouponClick === false) {  
51 - return false;  
52 - }  
53 -  
54 - that.isCouponClick = false;  
55 -  
56 - $.ajax({  
57 - method: 'POST',  
58 - url: location.protocol + '//m.yohobuy.com/product/index/userCoupon',  
59 - data: {  
60 - couponID: code,  
61 - uid: $self.common.uid  
62 - },  
63 - xhrFields: {  
64 - withCredentials: true  
65 - },  
66 - success: function(data) {  
67 -  
68 - that.isCouponClick = true;  
69 -  
70 - if (data.code === 200) {  
71 - tip.show('领取成功');  
72 - $(that).find('.receive-btn').html('已领取');  
73 - return true;  
74 - } else if (data.code === 4401) {  
75 - $('#shop-login').remove();  
76 - $('body').append('<a href=\'' + data.url + '\'><span id="shop-login"><span></a>');  
77 - $('#shop-login').click();  
78 - } else if (data.code === 401) {  
79 - tip.show('已领取过');  
80 - } else {  
81 - tip.show(data.message);  
82 - }  
83 - },  
84 - error: function() {  
85 - tip.show('网络断开连接了~');  
86 - that.isCouponClick = true;  
87 - }  
88 - });  
89 - });  
90 - }  
91 -};  
92 -  
93 -$(function() {  
94 - brandCoupon.init();  
95 -});  
@@ -18,7 +18,8 @@ shopCoupon = { @@ -18,7 +18,8 @@ shopCoupon = {
18 this.getShopCouponsList(); 18 this.getShopCouponsList();
19 }, 19 },
20 getShopCouponsList: function() { 20 getShopCouponsList: function() {
21 - var that = this, _url = location.protocol + '//m.yohobuy.com'; 21 + var that = this,
  22 + _url = location.protocol + '//m.yohobuy.com';
22 23
23 if (that.common.shopId === '') { 24 if (that.common.shopId === '') {
24 _url += '/product/index/getBrandCouponsList'; 25 _url += '/product/index/getBrandCouponsList';