|
|
var colorTpl = require('../../tpl/me/color-list.hbs');
|
|
|
var sizeTpl = require('../../tpl/me/size-list.hbs');
|
|
|
|
|
|
var dialog = require('../plugins/dialog');
|
|
|
var _alert = dialog.Alert;
|
|
|
|
|
|
var addrSelector = require('../plugins/cascading-address');
|
|
|
var addr;
|
|
|
|
|
|
var nameReg = /^[\u4e00-\u9fa5]{2,5}$/;
|
|
|
var addressReg = /^[\s\S]{2,100}$/;
|
|
|
var phoneReg = /^(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/;
|
|
|
|
|
|
var validate = require('./order/validation');
|
|
|
|
|
|
var validateMap = {
|
|
|
user: {
|
|
|
sl: '#user',
|
|
|
v: {
|
|
|
reg: nameReg,
|
|
|
errMsg: '真实姓名至少2个中文,最多5个中文'
|
|
|
}
|
|
|
},
|
|
|
addr: {
|
|
|
sl: '#addr',
|
|
|
v: {
|
|
|
reg: addressReg,
|
|
|
errMsg: '详细地址不能为空'
|
|
|
}
|
|
|
},
|
|
|
mob: {
|
|
|
sl: '#mob',
|
|
|
v: {
|
|
|
reg: phoneReg,
|
|
|
errMsg: '您输入的联系电话格式不正确'
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
|
|
|
// 添加.check方法
|
|
|
require('../plugins/check');
|
|
|
|
...
|
...
|
@@ -247,18 +280,52 @@ function submitChange(d) { |
|
|
url: '/me/return/submitExchange',
|
|
|
data: d
|
|
|
}).done(function(result) {
|
|
|
console.log(result);
|
|
|
if (result.code === 200) {
|
|
|
location.href = '/me/return';
|
|
|
} else {
|
|
|
new _alert('<h1>' + result.message + '</h1>').show();
|
|
|
}
|
|
|
}).fail(function(err) {
|
|
|
console.log(err);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
function validateData() {
|
|
|
var $inputs = $('.express-info-box .require input');
|
|
|
var pass = true;
|
|
|
|
|
|
$inputs.each(function(idx, input) {
|
|
|
var k = input.id;
|
|
|
|
|
|
if (k && validateMap[k]) {
|
|
|
if (!validate.do(validateMap[k].sl, validateMap[k].v)) {
|
|
|
pass = false;
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
// 检查地址
|
|
|
if (!validate.addr(addr.getAreaIds(), {
|
|
|
el: '#city',
|
|
|
errMsg: '请填写完整的省市区信息'
|
|
|
})) {
|
|
|
pass = false;
|
|
|
}
|
|
|
|
|
|
return pass;
|
|
|
}
|
|
|
|
|
|
function bindConfirmEvent() {
|
|
|
$('.confirm').on('click', function() {
|
|
|
var $changeGood = $('.change-info-box.will-change');
|
|
|
var changeGoodsList = [];
|
|
|
var changeData = {};
|
|
|
|
|
|
if (!validateData()) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
|
|
|
$changeGood.each(function(index, good) {
|
|
|
var goodObj = {};
|
|
|
var $good = $(good);
|
...
|
...
|
@@ -290,6 +357,17 @@ function bindConfirmEvent() { |
|
|
});
|
|
|
}
|
|
|
|
|
|
function bindBlurEvent() {
|
|
|
$('.express-info-box .require input').on('blur', function() {
|
|
|
var $this = $(this);
|
|
|
var v = validateMap[this.id];
|
|
|
|
|
|
if ($this.val().length > 0) {
|
|
|
validate.do(v.sl, v.v);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
|
|
|
function initAddr() {
|
|
|
addr = addrSelector({
|
...
|
...
|
@@ -304,4 +382,5 @@ $(document).on('ready', function() { |
|
|
bindCheckboxEvent();
|
|
|
bindConfirmEvent();
|
|
|
initAddr();
|
|
|
bindBlurEvent();
|
|
|
}); |
...
|
...
|
|