|
|
|
1
|
+/**
|
|
|
|
2
|
+ * 尾部
|
|
|
|
3
|
+ * @author: wangqing<robin.wang@yoho.cn>
|
|
|
|
4
|
+ * @date: 2015/12/01
|
|
|
|
5
|
+ */
|
|
|
|
6
|
+
|
|
|
|
7
|
+var $ = require('yoho.jquery');
|
|
|
|
8
|
+/**
|
|
|
|
9
|
+ * 订阅
|
|
|
|
10
|
+ * @return {[type]} [description]
|
|
|
|
11
|
+ */
|
|
|
|
12
|
+function actionSubscription() {
|
|
|
|
13
|
+ var $subscriberBox = $('#subscriberBox'),
|
|
|
|
14
|
+ $subscriberBtn = $('#subscriberBtn'),
|
|
|
|
15
|
+ emailReg = /^[.\-_a-zA-Z0-9]+@[\-_a-zA-Z0-9]+\.[a-zA-Z0-9]/;
|
|
|
|
16
|
+ var subscribeParam = {
|
|
|
|
17
|
+ method: 'open.subscriber.subscriber',
|
|
|
|
18
|
+ v: 1,
|
|
|
|
19
|
+ return_type: 'jsonp',
|
|
|
|
20
|
+ open_key: '12345'
|
|
|
|
21
|
+ };
|
|
|
|
22
|
+ var email = $.trim($subscriberBox.val());
|
|
|
|
23
|
+ var params = {};
|
|
|
|
24
|
+ $subscriberBox.focus(function() {
|
|
|
|
25
|
+ $(this).val('').css('color', '');
|
|
|
|
26
|
+ $subscriberBtn.removeClass('done').text('m');
|
|
|
|
27
|
+ });
|
|
|
|
28
|
+ //订阅Start
|
|
|
|
29
|
+
|
|
|
|
30
|
+ $subscriberBtn.click(function() {
|
|
|
|
31
|
+ if (email !== '' && emailReg.test(email)) {
|
|
|
|
32
|
+ $.extend(params, subscribeParam, {
|
|
|
|
33
|
+ email: email,
|
|
|
|
34
|
+ tmp: Math.random(),
|
|
|
|
35
|
+ uid: $.uid('_UID')
|
|
|
|
36
|
+ });
|
|
|
|
37
|
+ try {
|
|
|
|
38
|
+ $.getJSON('http://test.open.yohobuy.com' + '/?callback=?', params, function(data) {
|
|
|
|
39
|
+ if (data.data.result === 1) {
|
|
|
|
40
|
+ $subscriberBox.val('已订阅到:' + email);
|
|
|
|
41
|
+ $subscriberBtn.addClass('done').text('=');
|
|
|
|
42
|
+ } else {
|
|
|
|
43
|
+ $subscriberBox.css('color', 'red');
|
|
|
|
44
|
+ }
|
|
|
|
45
|
+ });
|
|
|
|
46
|
+ } catch (e) {
|
|
|
|
47
|
+ console.log(e.message);
|
|
|
|
48
|
+ }
|
|
|
|
49
|
+ } else {
|
|
|
|
50
|
+ $subscriberBox.css('color', 'red');
|
|
|
|
51
|
+ }
|
|
|
|
52
|
+ });
|
|
|
|
53
|
+}
|
|
|
|
54
|
+
|
|
|
|
55
|
+function change(now, icon, box) {
|
|
|
|
56
|
+ var obj = now;
|
|
|
|
57
|
+ var index = icon.index(this);
|
|
|
|
58
|
+ var offset = index * 3;
|
|
|
|
59
|
+ box.each(function() {
|
|
|
|
60
|
+ $(this).hide();
|
|
|
|
61
|
+ });
|
|
|
|
62
|
+ for (var i = offset; i < offset + 3; i++) {
|
|
|
|
63
|
+ box.eq(i).show();
|
|
|
|
64
|
+ }
|
|
|
|
65
|
+ now.each(function() {
|
|
|
|
66
|
+ $(this).children().removeClass('cur').html('o');
|
|
|
|
67
|
+ });
|
|
|
|
68
|
+ obj.children().addClass('cur').html('O');
|
|
|
|
69
|
+}
|
|
|
|
70
|
+
|
|
|
|
71
|
+function actionhomeFootChange() {
|
|
|
|
72
|
+
|
|
|
|
73
|
+
|
|
|
|
74
|
+ //有货services
|
|
|
|
75
|
+ $('#button-services a').click(function() {
|
|
|
|
76
|
+ change($(this), $('#button-services a'), $('#foot-services ul li'));
|
|
|
|
77
|
+ });
|
|
|
|
78
|
+
|
|
|
|
79
|
+ //更多有货产品
|
|
|
|
80
|
+ $('#button-mobile a').click(function() {
|
|
|
|
81
|
+ change($(this), $('#button-mobile a'), $('#foot-mobile ul li'));
|
|
|
|
82
|
+ });
|
|
|
|
83
|
+
|
|
|
|
84
|
+ //在线调查
|
|
|
|
85
|
+ $('#feedbackPage a').click(function() {
|
|
|
|
86
|
+ $('#feedbackPage').find('a').children('span').removeClass('cur').html('o');
|
|
|
|
87
|
+ $(this).children('span').addClass('cur').html('O');
|
|
|
|
88
|
+ var indexNum = $('#feedbackPage a').index(this);
|
|
|
|
89
|
+ $('.vote li').hide();
|
|
|
|
90
|
+ $('.vote li').eq(indexNum).show();
|
|
|
|
91
|
+ });
|
|
|
|
92
|
+
|
|
|
|
93
|
+ $('.vote li').each(function() {
|
|
|
|
94
|
+ var obj = this;
|
|
|
|
95
|
+ var index = $(this).index();
|
|
|
|
96
|
+ $(this).find('#feedbackBtn').click(function() {
|
|
|
|
97
|
+ var params = {};
|
|
|
|
98
|
+ var _solution = [];
|
|
|
|
99
|
+ $(obj).find('input').each(function() {
|
|
|
|
100
|
+ if ($(this).attr('checked') == true || $(this).attr('checked') == 'checked') {
|
|
|
|
101
|
+ _solution.push($(this).val());
|
|
|
|
102
|
+ }
|
|
|
|
103
|
+ });
|
|
|
|
104
|
+ var _answer = $(obj).find('#feedback_answer').val();
|
|
|
|
105
|
+ var _feedback = $(obj).find('#feedback_id').val();
|
|
|
|
106
|
+ var _question = $(obj).find('#question_id').val();
|
|
|
|
107
|
+
|
|
|
|
108
|
+ params['method'] = 'open.feedback.submit';
|
|
|
|
109
|
+ params['feedback_id'] = _feedback || 0;
|
|
|
|
110
|
+ params['question_id'] = _question || 0;
|
|
|
|
111
|
+ params['answer'] = _answer || '';
|
|
|
|
112
|
+ params['solution'] = _solution.join(',');
|
|
|
|
113
|
+ $.getData(apiDomain, params, function(reData) {
|
|
|
|
114
|
+ if (reData.result == 1) {
|
|
|
|
115
|
+ var voteCount = $('.vote li').length - 1;
|
|
|
|
116
|
+ if (index == voteCount) {
|
|
|
|
117
|
+ alert('感谢您的参与!');
|
|
|
|
118
|
+ return false;
|
|
|
|
119
|
+ }
|
|
|
|
120
|
+ var Next = index + 1;
|
|
|
|
121
|
+ $('.vote li').eq(index).hide();
|
|
|
|
122
|
+ $('.vote li').eq(Next).show();
|
|
|
|
123
|
+ $('#feedbackPage').children('a').eq(index).children('span').removeClass('cur').html('o');
|
|
|
|
124
|
+ $('#feedbackPage').children('a').eq(Next).children('span').addClass('cur').html('O');
|
|
|
|
125
|
+ }
|
|
|
|
126
|
+ return false;
|
|
|
|
127
|
+ });
|
|
|
|
128
|
+ });
|
|
|
|
129
|
+ });
|
|
|
|
130
|
+}
|
|
|
|
131
|
+
|
|
|
|
132
|
+exports.init = function() {
|
|
|
|
133
|
+ actionSubscription();//执行订阅
|
|
|
|
134
|
+ actionhomeFootChange();//底部事件
|
|
|
|
135
|
+} |