...
|
...
|
@@ -5,27 +5,38 @@ |
|
|
*/
|
|
|
|
|
|
var $ = require('yoho.jquery');
|
|
|
|
|
|
var apiDomain;
|
|
|
|
|
|
/**
|
|
|
* 订阅
|
|
|
* @return {[type]} [description]
|
|
|
*/
|
|
|
function actionSubscription() {
|
|
|
var $subscriberBox = $('#subscriberBox'),
|
|
|
$subscriberBtn = $('#subscriberBtn'),
|
|
|
var $subscriberBox = $('#subscriber-box'),
|
|
|
$subscriberBtn = $('#subscriber-btn'),
|
|
|
emailReg = /^[.\-_a-zA-Z0-9]+@[\-_a-zA-Z0-9]+\.[a-zA-Z0-9]/;
|
|
|
|
|
|
var subscribeParam = {
|
|
|
method: 'open.subscriber.subscriber',
|
|
|
v: 1,
|
|
|
return_type: 'jsonp',
|
|
|
open_key: '12345'
|
|
|
};
|
|
|
|
|
|
var iconCode = {
|
|
|
mail: '',
|
|
|
tick: ''
|
|
|
};
|
|
|
|
|
|
var email = $.trim($subscriberBox.val());
|
|
|
|
|
|
var params = {};
|
|
|
|
|
|
$subscriberBox.focus(function() {
|
|
|
$(this).val('').css('color', '');
|
|
|
$subscriberBtn.removeClass('done').text('m');
|
|
|
$subscriberBtn.removeClass('done').html(iconCode.mail);
|
|
|
});
|
|
|
//订阅Start
|
|
|
|
|
|
$subscriberBtn.click(function() {
|
|
|
if (email !== '' && emailReg.test(email)) {
|
...
|
...
|
@@ -38,7 +49,7 @@ function actionSubscription() { |
|
|
$.getJSON('http://test.open.yohobuy.com' + '/?callback=?', params, function(data) {
|
|
|
if (data.data.result === 1) {
|
|
|
$subscriberBox.val('已订阅到:' + email);
|
|
|
$subscriberBtn.addClass('done').text('=');
|
|
|
$subscriberBtn.addClass('done').html(iconCode.tick);
|
|
|
} else {
|
|
|
$subscriberBox.css('color', 'red');
|
|
|
}
|
...
|
...
|
@@ -52,84 +63,69 @@ function actionSubscription() { |
|
|
});
|
|
|
}
|
|
|
|
|
|
function change(now, icon, box) {
|
|
|
var obj = now;
|
|
|
var index = icon.index(this);
|
|
|
var offset = index * 3;
|
|
|
box.each(function() {
|
|
|
$(this).hide();
|
|
|
});
|
|
|
for (var i = offset; i < offset + 3; i++) {
|
|
|
box.eq(i).show();
|
|
|
}
|
|
|
now.each(function() {
|
|
|
$(this).children().removeClass('cur').html('o');
|
|
|
});
|
|
|
obj.children().addClass('cur').html('O');
|
|
|
}
|
|
|
|
|
|
function actionhomeFootChange() {
|
|
|
var $vote = $('.vote'),
|
|
|
$feedBackPage = $('#feed-back-page'),
|
|
|
count = $vote.children('li').length;
|
|
|
|
|
|
//意见反馈
|
|
|
$feedBackPage.on('click', 'span', function() {
|
|
|
var $this = $(this);
|
|
|
|
|
|
//有货services
|
|
|
$('#button-services a').click(function() {
|
|
|
change($(this), $('#button-services a'), $('#foot-services ul li'));
|
|
|
});
|
|
|
if ($this.hasClass('cur')) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
//更多有货产品
|
|
|
$('#button-mobile a').click(function() {
|
|
|
change($(this), $('#button-mobile a'), $('#foot-mobile ul li'));
|
|
|
});
|
|
|
$this.siblings('.cur').removeClass('cur');
|
|
|
$this.addClass('cur');
|
|
|
|
|
|
//在线调查
|
|
|
$('#feedbackPage a').click(function() {
|
|
|
$('#feedbackPage').find('a').children('span').removeClass('cur').html('o');
|
|
|
$(this).children('span').addClass('cur').html('O');
|
|
|
var indexNum = $('#feedbackPage a').index(this);
|
|
|
$('.vote li').hide();
|
|
|
$('.vote li').eq(indexNum).show();
|
|
|
$vote.children().not('.hide').addClass('hide')
|
|
|
.end()
|
|
|
.eq($this.index()).removeClass('hide');
|
|
|
});
|
|
|
|
|
|
$('.vote li').each(function() {
|
|
|
var obj = this;
|
|
|
var index = $(this).index();
|
|
|
$(this).find('#feedbackBtn').click(function() {
|
|
|
var params = {};
|
|
|
var _solution = [];
|
|
|
$(obj).find('input').each(function() {
|
|
|
if ($(this).attr('checked') == true || $(this).attr('checked') == 'checked') {
|
|
|
_solution.push($(this).val());
|
|
|
}
|
|
|
});
|
|
|
var _answer = $(obj).find('#feedback_answer').val();
|
|
|
var _feedback = $(obj).find('#feedback_id').val();
|
|
|
var _question = $(obj).find('#question_id').val();
|
|
|
|
|
|
params['method'] = 'open.feedback.submit';
|
|
|
params['feedback_id'] = _feedback || 0;
|
|
|
params['question_id'] = _question || 0;
|
|
|
params['answer'] = _answer || '';
|
|
|
params['solution'] = _solution.join(',');
|
|
|
$.getData(apiDomain, params, function(reData) {
|
|
|
if (reData.result == 1) {
|
|
|
var voteCount = $('.vote li').length - 1;
|
|
|
if (index == voteCount) {
|
|
|
alert('感谢您的参与!');
|
|
|
return false;
|
|
|
}
|
|
|
var Next = index + 1;
|
|
|
$('.vote li').eq(index).hide();
|
|
|
$('.vote li').eq(Next).show();
|
|
|
$('#feedbackPage').children('a').eq(index).children('span').removeClass('cur').html('o');
|
|
|
$('#feedbackPage').children('a').eq(Next).children('span').addClass('cur').html('O');
|
|
|
$vote.on('click', '.feed-back-btn', function() {
|
|
|
var $this = $(this),
|
|
|
$li = $this.closest('li'),
|
|
|
index = $li.index(),
|
|
|
params = {},
|
|
|
_solution = [];
|
|
|
|
|
|
var _answer = $li.find('.feedback-answer').val(),
|
|
|
_feedback = $li.find('.feedback-id').val(),
|
|
|
_question = $li.find('.question-id').val();
|
|
|
|
|
|
$li.find(':checked').each(function() {
|
|
|
_solution.push($(this).val());
|
|
|
});
|
|
|
|
|
|
params = {
|
|
|
method: 'open.feedback.submit',
|
|
|
feedback: _feedback || 0,
|
|
|
question: _question || 0,
|
|
|
answer: _answer || '',
|
|
|
solution: _solution.join(',')
|
|
|
};
|
|
|
|
|
|
$.getData(apiDomain, params, function(data) {
|
|
|
var next = index + 1;
|
|
|
|
|
|
if (data.result === 1) {
|
|
|
if (index === count - 1) {
|
|
|
alert('感谢您的参与!');
|
|
|
return;
|
|
|
}
|
|
|
return false;
|
|
|
});
|
|
|
|
|
|
$li.addClass('hide');
|
|
|
|
|
|
$vote.eq(index + 1).removeClass('hide');
|
|
|
$feedBackPage.children('.cur').removeClass('cur');
|
|
|
$feedBackPage.eq(next).addClass('cur');
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
|
|
|
exports.init = function() {
|
|
|
actionSubscription();//执行订阅
|
|
|
actionhomeFootChange();//底部事件
|
|
|
} |
|
|
\ No newline at end of file |
|
|
//初始化
|
|
|
actionSubscription();
|
|
|
actionhomeFootChange(); |
|
|
\ No newline at end of file |
...
|
...
|
|