Authored by wenjiekong

添加JS

... ... @@ -4,9 +4,11 @@
* @date: 2016/02/24
*/
var $ = require('yoho-jquery'),
dialog = require('./dialog'),
Alert = dialog.Alert;
var $ = require('yoho-jquery');
var dialog = require('./dialog');
var Alert = dialog.Alert;
var address = {
... ... @@ -22,13 +24,13 @@ var address = {
initDomIds: function(domOptions) {
var the = this;
if (domOptions.provinceDomId !== undefined) {
if (domOptions.provinceDomId) {
the.provinceDomId = domOptions.provinceDomId;
}
if (domOptions.cityDomId !== undefined) {
if (domOptions.cityDomId) {
the.cityDomId = domOptions.cityDomId;
}
if (domOptions.areaDomId !== undefined) {
if (domOptions.areaDomId) {
the.areaDomId = domOptions.areaDomId;
}
},
... ... @@ -87,7 +89,7 @@ var address = {
bindAreaChange: function(domOptions) {
var the = this;
if ($('#' + the.provinceDomId).data('events') !== undefined) {
if ($('#' + the.provinceDomId).data('events')) {
return;
}
... ... @@ -133,7 +135,7 @@ var address = {
strCity = $('#' + the.cityDomId).find('option:selected').text(),
strArea = $('#' + the.areaDomId).find('option:selected').text();
if (dispDomId !== undefined && dispDomId !== '') {
if (dispDomId && dispDomId !== '') {
if (strProvince.indexOf('选择') < 0) {
strAddr = strProvince;
}
... ...
... ... @@ -9,8 +9,11 @@ var $allEditForms = $('.userinfo-edit form');
var address = require('../common/common-address');
var $brands = $('#brand-box li'),
$province = $('#province').val();
var date = {
init: function(year, month, day) {
init: function() {
var $year = $('#year'),
$month = $('#month'),
$day = $('#day');
... ... @@ -32,14 +35,14 @@ var date = {
},
createDay: function(year, month, day) {
var html = '<select name="day" id="day">',
monthArray = new Array(4, 6, 9, 11),
monthArray = [4, 6, 9, 11],
dayNum = 31;
var select,
i;
year = parseInt(year);
month = parseInt(month);
year = parseInt(year, 10);
month = parseInt(month, 10);
if (year === 0) {
year = 0;
... ... @@ -59,7 +62,7 @@ var date = {
dayNum = 30;
} else if (month === 2) {
dayNum = 28;
if (0 === year % 4 && (year % 100 !== 0 || year % 400 === 0)) {
if (0 === (year % 4) && (year % 100 !== 0 || year % 400 === 0)) {
dayNum = 29;
}
}
... ... @@ -67,7 +70,7 @@ var date = {
for (i = 1; i <= dayNum; i++) {
select = '';
if (parseInt(day) === i) {
if (parseInt(day, 10) === i) {
select = 'selected';
}
html += '<option value="' + i + '" ' + select + '>' + i + '</option>';
... ... @@ -176,7 +179,7 @@ function checkFavoriteForm() {
function delBrand(brandId) {
var brand = $('#likebrand').val();
if (parseInt(brandId) === 0) {
if (parseInt(brandId, 10) === 0) {
return false;
}
... ... @@ -196,7 +199,7 @@ function addBrand(domObj, brandId, brandName) {
var $brandBox = $('#brand-box');
if (parseInt(brandId) === 0) {
if (parseInt(brandId, 10) === 0) {
return false;
}
... ... @@ -220,8 +223,8 @@ function addBrand(domObj, brandId, brandName) {
function checkBrand() {
var postData = {
brandName: $('#keywords').val()
};
brandName: $('#keywords').val()
};
$.post('/home/user/isbrandname', postData, function(data) {
if (data.code === 200) {
... ... @@ -291,7 +294,7 @@ $('#favorite-brand').on('click', function() {
alert(data.message);
return false;
},
error: function(err) {
error: function() {
alert('网络异常');
}
});
... ... @@ -309,19 +312,13 @@ $('.user-favorite-info input[type="checkbox"]').on('click', function() {
});
(function() {
var $brands = $('#brand-box li');
if ($brands.length > 0) {
$brands.find('a').on('click', function() {
delBrand($(this).closest('li').attr('id').substr(6));
});
}
})();
date.init();
(function() {
if (!$('#province').val()) {
if (!$province) {
address.loadAllData(0, {
provinceDomId: 'province',
cityDomId: 'city',
... ... @@ -334,4 +331,7 @@ date.init();
areaDomId: 'areaCode'
});
}
})();
}());
date.init();
... ...