Authored by xuqi

footer jsonp .Review by:@xuqi

@@ -98,7 +98,7 @@ @@ -98,7 +98,7 @@
98 <li class="hide" key="2"> 98 <li class="hide" key="2">
99 <form class="feed-back-form" action="#"> 99 <form class="feed-back-form" action="#">
100 <div>您对新版还有哪些意见或建议?</div> 100 <div>您对新版还有哪些意见或建议?</div>
101 - <textarea name="answer" id="feedback-answer"></textarea> 101 + <textarea name="answer" id="feedback-answer" class="feedback-answer"></textarea>
102 <div> 102 <div>
103 <span class="feed-back-btn button">提交</span> 103 <span class="feed-back-btn button">提交</span>
104 </div> 104 </div>
@@ -8,8 +8,6 @@ var $ = require('yoho.jquery'); @@ -8,8 +8,6 @@ var $ = require('yoho.jquery');
8 8
9 var $returnTop = $('.return-top'); 9 var $returnTop = $('.return-top');
10 10
11 -var apiDomain;  
12 -  
13 /** 11 /**
14 * 订阅 12 * 订阅
15 * @return {[type]} [description] 13 * @return {[type]} [description]
@@ -19,41 +17,36 @@ function actionSubscription() { @@ -19,41 +17,36 @@ function actionSubscription() {
19 $subscriberBtn = $('#subscriber-btn'), 17 $subscriberBtn = $('#subscriber-btn'),
20 emailReg = /^[.\-_a-zA-Z0-9]+@[\-_a-zA-Z0-9]+\.[a-zA-Z0-9]/; 18 emailReg = /^[.\-_a-zA-Z0-9]+@[\-_a-zA-Z0-9]+\.[a-zA-Z0-9]/;
21 19
22 - var subscribeParam = {  
23 - method: 'open.subscriber.subscriber',  
24 - v: 1,  
25 - return_type: 'jsonp',  
26 - open_key: '12345'  
27 - };  
28 -  
29 var iconCode = { 20 var iconCode = {
30 mail: '&#xe61b;', 21 mail: '&#xe61b;',
31 tick: '&#xe61a' 22 tick: '&#xe61a'
32 }; 23 };
33 24
34 - var email = $.trim($subscriberBox.val());  
35 -  
36 - var params = {};  
37 -  
38 $subscriberBox.focus(function() { 25 $subscriberBox.focus(function() {
39 $(this).val('').css('color', ''); 26 $(this).val('').css('color', '');
40 $subscriberBtn.removeClass('done').html(iconCode.mail); 27 $subscriberBtn.removeClass('done').html(iconCode.mail);
41 }); 28 });
42 29
43 $subscriberBtn.click(function() { 30 $subscriberBtn.click(function() {
  31 + var email = $.trim($subscriberBox.val());
  32 +
44 if (email !== '' && emailReg.test(email)) { 33 if (email !== '' && emailReg.test(email)) {
45 - $.extend(params, subscribeParam, {  
46 - email: email,  
47 - tmp: Math.random(),  
48 - uid: $.uid('_UID')  
49 - });  
50 try { 34 try {
51 - $.getJSON('http://test.open.yohobuy.com' + '/?callback=?', params, function(data) {  
52 - if (data.data.result === 1) {  
53 - $subscriberBox.val('已订阅到:' + email);  
54 - $subscriberBtn.addClass('done').html(iconCode.tick);  
55 - } else {  
56 - $subscriberBox.css('color', 'red'); 35 + $.ajax({
  36 + url: 'http://www.yohobuy.com/common/emailsubscriber',
  37 + dataType: 'jsonp',
  38 + data: {
  39 + email: email,
  40 + tmp: Math.random(),
  41 + uid: window.getUid()
  42 + },
  43 + success: function(data) {
  44 + if (data.data.result === 1) {
  45 + $subscriberBox.val('已订阅到:' + email);
  46 + $subscriberBtn.addClass('done').html(iconCode.tick);
  47 + } else {
  48 + $subscriberBox.css('color', 'red');
  49 + }
57 } 50 }
58 }); 51 });
59 } catch (e) { 52 } catch (e) {
@@ -90,7 +83,6 @@ function actionhomeFootChange() { @@ -90,7 +83,6 @@ function actionhomeFootChange() {
90 var $this = $(this), 83 var $this = $(this),
91 $li = $this.closest('li'), 84 $li = $this.closest('li'),
92 index = $li.index(), 85 index = $li.index(),
93 - params = {},  
94 _solution = []; 86 _solution = [];
95 87
96 var _answer = $li.find('.feedback-answer').val(), 88 var _answer = $li.find('.feedback-answer').val(),
@@ -101,28 +93,30 @@ function actionhomeFootChange() { @@ -101,28 +93,30 @@ function actionhomeFootChange() {
101 _solution.push($(this).val()); 93 _solution.push($(this).val());
102 }); 94 });
103 95
104 - params = {  
105 - method: 'open.feedback.submit',  
106 - feedback: _feedback || 0,  
107 - question: _question || 0,  
108 - answer: _answer || '',  
109 - solution: _solution.join(',')  
110 - };  
111 -  
112 - $.getData(apiDomain, params, function(data) {  
113 - var next = index + 1;  
114 -  
115 - if (data.result === 1) {  
116 - if (index === count - 1) {  
117 - alert('感谢您的参与!');  
118 - return;  
119 - } 96 + $.ajax({
  97 + url: 'http://www.yohobuy.com/common/suggestfeedback',
  98 + dataType: 'jsonp',
  99 + data: {
  100 + feedback_id: _feedback || 0,
  101 + question_id: _question || 0,
  102 + answer: _answer || '',
  103 + solution: _solution.join(',')
  104 + },
  105 + success: function(data) {
  106 + var next = index + 1;
  107 +
  108 + if (~~data.data.result === 1) {
  109 + if (index === count - 1) {
  110 + alert('感谢您的参与!');
  111 + return;
  112 + }
120 113
121 - $li.addClass('hide'); 114 + $li.addClass('hide');
122 115
123 - $vote.eq(index + 1).removeClass('hide');  
124 - $feedBackPage.children('.cur').removeClass('cur');  
125 - $feedBackPage.eq(next).addClass('cur'); 116 + $vote.children(':eq(' + (index + 1) + ')').removeClass('hide');
  117 + $feedBackPage.children('.cur').removeClass('cur');
  118 + $feedBackPage.children(':eq(' + next + ')').addClass('cur');
  119 + }
126 } 120 }
127 }); 121 });
128 }); 122 });