import
Ember
from
'ember';
import
ajax
from
'ic-ajax';
export
default
Ember.
Component.
extend({
city:[],
application_type_person:
false,
application_type_corp:
true,
reAuthentication:
false,
idauth_type:
2,
idauth_status:
'',
actions: {
setActive(
selected){
if(
selected.
active){
return;
}
this.
get(
'auth.user').
toArray().
forEach(
it
=>{
if(
it.
name===
selected.
name){
Ember.
set(
it,
'active',
true);
}
else
if(
it.
active){
Ember.
set(
it,
'active',
false);
}
});
},
//选项切换
switchType(
it){
if(
it ==
'corp'){
this.
set(
'application_type_person',
false);
this.
set(
'application_type_corp',
true);
// this.set('idauth_type',2);//企业
// this.set('idauth_status',0);
}
else
if(
it ==
'person'){
this.
set(
'application_type_person',
true);
this.
set(
'application_type_corp',
false);
}
},
applicationHouse(){
if (
$(
'#application-house').
validate() !==
true) {
$.
toastr.
error(
"请填写必填项!")
return;
}
if(
this.
get(
'application_type_person')){
if(!
/
(
^
\d
{15}
$
)
|
(
^
\d
{18}
$
)
|
(
^
\d
{17}
(
\d
|
X
|
x
)
$
)
/.
test(
$(
"#id_card").
val()))
{
$.
toastr.
error(
"身份证输入不合法!");
return
false;
}
}
if(
this.
get(
'application_type_corp')){
if(
$(
"#yy_pictures").
val()===
""){
$.
toastr.
error(
"必须上传营业执照照片!");
return;
}
}
this.
get(
'auth').
registerTokenToAjaxHeader();
let
url =
this.
get(
"config").
apiUrl1 +
"account/idauth_apply";
//水滴认证
let
_params = {};
// "idauth_type": 1, //身份认证类型, 1为个人 2为企业
// "iduath_status": 1, //认证状态: 0未认证, 1认证中, 2认证成功, 3认证失败
_params.
idauth_type =
this.
get(
'idauth_type')||
$(
"input[name=application_type]").
val();
_params.
name =
$(
"#apply_name").
val();
_params.
phone =
$(
"#apply_phone").
val()||
$(
"#apply_name").
val();
_params.
province =
$(
"#apply_province").
val();
_params.
city =
$(
"#apply_city").
val();
_params.
operate_mode=
$(
"#select_module_cla").
find(
":checked").
val();
_params.
legal =
$(
"#apply_legalPerson").
val();
_params.
company_name =
$(
"#apply_companyName").
val();
_params.
company_id_card =
$(
"#apply_businessNumber").
val();
_params.
brand_name =
$(
"#apply_apartmentBrand").
val();
_params.
id_card =
$(
"#id_card").
val();
//身份证
_params.
person_picture=
$(
"#per_pictures").
val();
//个人头像
_params.
pictures=
$(
"#yy_pictures").
val();
_params.
room_count=
$(
"#apartment_mess").
val();
ajax(
url, {
method:
'post',
data:
_params
}).
then((
res)
=> {
$.
toastr.
success(
"申请成功!");
this.
set(
"app_status",
1);
//
this.
set(
"idauth_type",
res.
data.
idauth_type);
this.
set(
"idauth_status",
res.
data.
idauth_status);
$(
"#application-house .xsd-modal-close").
trigger(
'click');
this.
sendAction(
"roomReload");
}).
catch((
err)
=> {
$.
toastr.
error(
err.
jqXHR.
responseJSON.
msg);
});
},
provinceSelected(
e)
{
let
selectedPro =
e.
target.
value;
//隐藏选项框
$(
e.
target).
parent().
hide();
$(
'#apply_province').
val(
selectedPro);
$(
'#apply_city').
val(
"");
//改变城市选项
this.
set(
'city',
this.
get(
"auth").
cityArr[
selectedPro]);
},
isCardNo(
id_card) {
// 身份证号码为15位或者18位,15位时全为数字,18位前17位为数字,最后一位是校验位,可能为数字或字符X
var
reg =
/
(
^
\d
{15}
$
)
|
(
^
\d
{18}
$
)
|
(
^
\d
{17}
(
\d
|
X
|
x
)
$
)
/;
if(!
reg.
test(
id_card))
{
alert(
"身份证输入不合法");
return
false;
}
}
}
});