|
|
var app = angular.module('applyPartnerApp', ['ngMessages','ngFileUpload','ui.bootstrap']);
|
|
|
app.controller('applyPartnerCtrl', ['$scope', '$http','$interval','Upload','$uibModal', 'commonDialog', function ($scope, $http,$interval,Upload,$uibModal,commonDialog) {
|
|
|
var countryMap = [{
|
|
|
"label": "AUS",
|
|
|
"value": "AUS"
|
|
|
}, {
|
|
|
"label": "CHN",
|
|
|
"value": "CHN"
|
|
|
}];
|
|
|
var cleanDays = [{
|
|
|
"label": "T+1",
|
|
|
"value": "1"
|
|
|
}, {
|
|
|
"label": "T+2",
|
|
|
"value": "2"
|
|
|
}, {
|
|
|
"label": "T+3",
|
|
|
"value": "3"
|
|
|
}];
|
|
|
|
|
|
var stateMap = [
|
|
|
{
|
|
|
"label": "ACT",
|
|
|
"value": "ACT"
|
|
|
},
|
|
|
{
|
|
|
"label": "NSW",
|
|
|
"value": "NSW"
|
|
|
},
|
|
|
{
|
|
|
"label": "NT",
|
|
|
"value": "NT"
|
|
|
},
|
|
|
{
|
|
|
"label": "QLD",
|
|
|
"value": "QLD"
|
|
|
},
|
|
|
{
|
|
|
"label": "SA",
|
|
|
"value": "SA"
|
|
|
},
|
|
|
{
|
|
|
"label": "TAS",
|
|
|
"value": "TAS"
|
|
|
},
|
|
|
{
|
|
|
"label": "VIC",
|
|
|
"value": "VIC"
|
|
|
},
|
|
|
{
|
|
|
"label": "WA",
|
|
|
"value": "WA"
|
|
|
}
|
|
|
];
|
|
|
|
|
|
var industryMap = [
|
|
|
{
|
|
|
"label": "鞋包服饰",
|
|
|
"value": "327"
|
|
|
},
|
|
|
{
|
|
|
"label": "机票行业",
|
|
|
"value": "339"
|
|
|
},
|
|
|
{
|
|
|
"label": "软件服务",
|
|
|
"value": "356"
|
|
|
},
|
|
|
{
|
|
|
"label": "旅游票务",
|
|
|
"value": "357"
|
|
|
},
|
|
|
{
|
|
|
"label": "国际租车",
|
|
|
"value": "358"
|
|
|
},
|
|
|
{
|
|
|
"label": "医疗服务(出国)",
|
|
|
"value": "359"
|
|
|
},
|
|
|
{
|
|
|
"label": "医疗服务(不出国)",
|
|
|
"value": "360"
|
|
|
},
|
|
|
{
|
|
|
"label": "留学教育(网络教育)",
|
|
|
"value": "361"
|
|
|
},
|
|
|
{
|
|
|
"label": "留学教育(一年及以下)",
|
|
|
"value": "362"
|
|
|
},
|
|
|
{
|
|
|
"label": "其它货物贸易行业",
|
|
|
"value": "338"
|
|
|
},
|
|
|
{
|
|
|
"label": "文具/办公用品",
|
|
|
"value": "337"
|
|
|
},
|
|
|
{
|
|
|
"label": "综合商城",
|
|
|
"value": "336"
|
|
|
},
|
|
|
{
|
|
|
"label": "酒店行业",
|
|
|
"value": "328"
|
|
|
},
|
|
|
{
|
|
|
"label": "教育行业",
|
|
|
"value": "329"
|
|
|
},
|
|
|
{
|
|
|
"label": "国际物流",
|
|
|
"value": "330"
|
|
|
},
|
|
|
{
|
|
|
"label": "数码电器",
|
|
|
"value": "332"
|
|
|
},
|
|
|
{
|
|
|
"label": "母婴",
|
|
|
"value": "333"
|
|
|
},
|
|
|
{
|
|
|
"label": "化妆品",
|
|
|
"value": "334"
|
|
|
},
|
|
|
{
|
|
|
"label": "食品",
|
|
|
"value": "335"
|
|
|
},
|
|
|
{
|
|
|
"label": "留学教育(一年以上)",
|
|
|
"value": "363"
|
|
|
},
|
|
|
{
|
|
|
"label": "其它服务行业",
|
|
|
"value": "331"
|
|
|
}
|
|
|
];
|
|
|
var removeClientPayDesc = function (items, key) {
|
|
|
for (var i = 0; i < items.length; i++) {
|
|
|
var item = items[i];
|
|
|
if (item.indexOf(key)>=0) {
|
|
|
items.splice(items.indexOf(item), 1);
|
|
|
i = i - 1;
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
$scope.name_exist = false;
|
|
|
$scope.states = angular.copy(stateMap);
|
|
|
$scope.countries = angular.copy(countryMap);
|
|
|
$scope.cleanDays = angular.copy(cleanDays);
|
|
|
$scope.industries = angular.copy(industryMap);
|
|
|
$scope.canClick=false;
|
|
|
$scope.description = "Send Code";
|
|
|
$scope.partner = {nation_code:"+61"};
|
|
|
$scope.bankaccount = {};
|
|
|
$scope.rate = {};
|
|
|
$scope.partner.client_pay_type = [];
|
|
|
$scope.partner.client_pay_desc = [];
|
|
|
$scope.phone_code_timer=$interval(function () {}, 1000);
|
|
|
$scope.signInfo = {};
|
|
|
|
|
|
$scope.loadRoyalpayindustry = function () {
|
|
|
$http.get('/static/data/rp_industry_apply.json').then(function (resp) {
|
|
|
$scope.royalpayindustry = resp.data;
|
|
|
})
|
|
|
};
|
|
|
$scope.loadRoyalpayindustry();
|
|
|
|
|
|
$scope.loadAlipayCategory = function () {
|
|
|
$http.get('/static/data/alipayMcc.json').then(function (resp) {
|
|
|
$scope.alipayMccCategory = resp.data;
|
|
|
})
|
|
|
};
|
|
|
$scope.loadAlipayCategory();
|
|
|
|
|
|
$scope.onAlipayMccSelect = function (selectedItem) {
|
|
|
$scope.partner.alipay_category = selectedItem.label;
|
|
|
$scope.partner.alipayindustry = selectedItem.mccCode;
|
|
|
};
|
|
|
|
|
|
$scope.loadCustomerChannel = function () {
|
|
|
$http.get('/static/data/rp_customer_channel.json').then(function (resp) {
|
|
|
$scope.customerchannel = resp.data;
|
|
|
})
|
|
|
};
|
|
|
$scope.loadCustomerChannel();
|
|
|
|
|
|
|
|
|
$scope.checkParams = function () {
|
|
|
if($scope.partner.contact_phone && $scope.partner.nation_code){
|
|
|
$http.get('/register/account/check?phone='+$scope.partner.contact_phone+'&nation_code='+$scope.partner.nation_code).then(function (resp) {
|
|
|
$scope.name_exist = false;
|
|
|
}, function (resp) {
|
|
|
if (resp.data.status == 403){
|
|
|
$scope.name_exist = true;
|
|
|
}
|
|
|
})
|
|
|
};
|
|
|
if($scope.partner.contact_email){
|
|
|
var reg = new RegExp("^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$");
|
|
|
if(!reg.test($scope.partner.contact_email)){
|
|
|
$scope.trueEmail = true;
|
|
|
}else {
|
|
|
$scope.trueEmail = false;
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
$scope.checkUserName = function (phone,nation_code) {
|
|
|
if(phone && nation_code){
|
|
|
$http.get('/register/account/check?phone='+phone+'&nation_code='+nation_code).then(function (resp) {
|
|
|
$scope.name_exist = false;
|
|
|
}, function (resp) {
|
|
|
if (resp.data.status == 403){
|
|
|
$scope.name_exist = true;
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
};
|
|
|
$scope.chooseArray = new Array(true, false, false, false, false);
|
|
|
$scope.changeChoose = function (index) {
|
|
|
$scope.repartner = {};
|
|
|
angular.forEach($scope.partner, function(value, key) {
|
|
|
if((value+'').trim()!=''){
|
|
|
$scope.repartner[key] = value;
|
|
|
}
|
|
|
});
|
|
|
$scope.partner = $scope.repartner;
|
|
|
$scope.chooseArray = new Array(false, false, false, false, false);
|
|
|
$scope.chooseArray[index] = true;
|
|
|
};
|
|
|
$scope.getRateConfig = function () {
|
|
|
$http.get('/register/config/sys_rates').then(function (resp) {
|
|
|
$scope.sysRateConfig = resp.data;
|
|
|
}, function (resp) {
|
|
|
})
|
|
|
};
|
|
|
$scope.sendPhoneCodeTime = function(){
|
|
|
var second=59;
|
|
|
$scope.phone_code_timer = $interval(function () {
|
|
|
if(second<=0){
|
|
|
$interval.cancel($scope.phone_code_timer);
|
|
|
second=59;
|
|
|
$scope.description="Send Code";
|
|
|
$scope.canClick=false;
|
|
|
}else{
|
|
|
$scope.description=second+"s后重发";
|
|
|
second--;
|
|
|
$scope.canClick=true;
|
|
|
}
|
|
|
}, 1000);
|
|
|
};
|
|
|
|
|
|
/* $scope.goToLogin = function () {
|
|
|
var timer = $interval(function(){
|
|
|
$scope.seconds = $scope.seconds -1;
|
|
|
if ($scope.seconds == 0) {
|
|
|
location.href = '/login.html';
|
|
|
}
|
|
|
},1000)
|
|
|
};*/
|
|
|
|
|
|
$scope.partner.sameAsAddress=false;
|
|
|
$scope.sameAddress = function (){
|
|
|
$scope.partner.sameAsAddress = !($scope.partner.sameAsAddress);
|
|
|
if($scope.partner.sameAsAddress) {
|
|
|
$scope.partner.registered_address = $scope.partner.address;
|
|
|
$scope.partner.registered_suburb = $scope.partner.suburb;
|
|
|
$scope.partner.registered_postcode = $scope.partner.postcode;
|
|
|
$scope.partner.registered_state = $scope.partner.state;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
$scope.partner.sameAsContactPerson = false;
|
|
|
$scope.samePerson = function (){
|
|
|
$scope.partner.sameAsContactPerson = !($scope.partner.sameAsContactPerson);
|
|
|
if($scope.partner.sameAsContactPerson) {
|
|
|
$scope.partner.representative_person = $scope.partner.contact_person;
|
|
|
$scope.partner.representative_phone = $scope.partner.contact_phone;
|
|
|
$scope.partner.representative_email = $scope.partner.contact_email;
|
|
|
$scope.partner.representative_job_title = $scope.partner.contact_job;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
$scope.checkEmail = function () {
|
|
|
$scope.trueEmail = false;
|
|
|
if($scope.partner.contact_email){
|
|
|
var reg = new RegExp("^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$");
|
|
|
if(!reg.test($scope.partner.contact_email)){
|
|
|
$scope.trueEmail = true;
|
|
|
}else {
|
|
|
$scope.trueEmail = false;
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
|
|
|
$scope.signContract = function(username,clean_days)
|
|
|
{
|
|
|
var url='/contract/source?username='+username+'&clean_days='+clean_days;
|
|
|
return url;
|
|
|
}
|
|
|
|
|
|
$scope.sendVerificationCode = function () {
|
|
|
$scope.initErrorMsg();
|
|
|
$scope.sendPhoneCodeTime();
|
|
|
$http.post('/register/info/phone/'+ $scope.partner.contact_phone +'/verify?nation_code='+$scope.partner.nation_code).then(function (resp) {
|
|
|
}, function (resp) {
|
|
|
if(resp.data.status+0 ==500) {
|
|
|
$interval.cancel($scope.phone_code_timer);
|
|
|
$scope.description="Send Code";
|
|
|
$scope.canClick=false;
|
|
|
}
|
|
|
$scope.resError = resp.data.message;
|
|
|
});
|
|
|
};
|
|
|
$scope.chooseIndustry = function (industry) {
|
|
|
$scope.partner.industry = industry.mccCode;
|
|
|
$scope.industryLable = industry.label;
|
|
|
};
|
|
|
|
|
|
$scope.chooseChannel = function (channel) {
|
|
|
$scope.partner.channel = channel.mccCode;
|
|
|
$scope.channelLable = channel.label;
|
|
|
};
|
|
|
|
|
|
$scope.searchBankInfo = function (bsb_no) {
|
|
|
$scope.initErrorMsg();
|
|
|
if (bsb_no != null && bsb_no != "") {
|
|
|
$scope.showBankInfo = false;
|
|
|
$http.get('/register/info/bank/' + bsb_no+"?username="+$scope.partner.username+'&'+'codeKey='+$scope.partner.codeKey).then(function (resp) {
|
|
|
$scope.bankInfo = resp.data;
|
|
|
$scope.bankaccount.bank = $scope.bankInfo.bank;
|
|
|
$scope.bankaccount.city = $scope.bankInfo.city;
|
|
|
$scope.bankaccount.address = $scope.bankInfo.address;
|
|
|
$scope.bankaccount.system = $scope.bankInfo.system;
|
|
|
$scope.bankaccount.postcode = $scope.bankInfo.postcode;
|
|
|
$scope.bankaccount.state = $scope.bankInfo.state;
|
|
|
$scope.bankaccount.branch = $scope.bankInfo.branch;
|
|
|
$scope.showBankInfo = true;
|
|
|
}, function (resp) {
|
|
|
$scope.showBankInfo = false;
|
|
|
});
|
|
|
} else {
|
|
|
$scope.resError = "请先填写BSB No";
|
|
|
}
|
|
|
};
|
|
|
$scope.changeDays = function (clean_days) {
|
|
|
if (clean_days) {
|
|
|
$scope.showCleanDay = false;
|
|
|
switch (clean_days) {
|
|
|
case '1': {
|
|
|
$scope.rate.wechat_rate_value = parseFloat($scope.sysRateConfig.t1.Wechat);
|
|
|
$scope.rate.alipay_rate_value = parseFloat($scope.sysRateConfig.t1.Alipay);
|
|
|
$scope.rate.alipayonline_rate_value = parseFloat($scope.sysRateConfig.t1.AlipayOnline);
|
|
|
$scope.rate.bestpay_rate_value = parseFloat($scope.sysRateConfig.t1.Bestpay);
|
|
|
$scope.rate.jd_rate_value = parseFloat($scope.sysRateConfig.t1.JDpay);
|
|
|
$scope.rate.cb_bankpay_rate_value = parseFloat($scope.sysRateConfig.t1.CB_Bankpay);
|
|
|
$scope.showCleanDay = true;
|
|
|
break;
|
|
|
}
|
|
|
case '2': {
|
|
|
$scope.rate.wechat_rate_value = parseFloat($scope.sysRateConfig.t2.Wechat);
|
|
|
$scope.rate.alipay_rate_value = parseFloat($scope.sysRateConfig.t2.Alipay);
|
|
|
$scope.rate.bestpay_rate_value = parseFloat($scope.sysRateConfig.t2.Bestpay);
|
|
|
$scope.rate.alipayonline_rate_value = parseFloat($scope.sysRateConfig.t2.AlipayOnline);
|
|
|
$scope.rate.jd_rate_value = parseFloat($scope.sysRateConfig.t2.JDpay);
|
|
|
$scope.rate.cb_bankpay_rate_value = parseFloat($scope.sysRateConfig.t2.CB_Bankpay);
|
|
|
$scope.showCleanDay = true;
|
|
|
break;
|
|
|
}
|
|
|
case '3': {
|
|
|
$scope.rate.wechat_rate_value = parseFloat($scope.sysRateConfig.t3.Wechat);
|
|
|
$scope.rate.alipay_rate_value = parseFloat($scope.sysRateConfig.t3.Alipay);
|
|
|
$scope.rate.bestpay_rate_value = parseFloat($scope.sysRateConfig.t3.Bestpay);
|
|
|
$scope.rate.alipayonline_rate_value = parseFloat($scope.sysRateConfig.t3.AlipayOnline);
|
|
|
$scope.rate.jd_rate_value = parseFloat($scope.sysRateConfig.t3.JDpay);
|
|
|
$scope.rate.cb_bankpay_rate_value = parseFloat($scope.sysRateConfig.t3.CB_Bankpay);
|
|
|
$scope.showCleanDay = true;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}else {
|
|
|
$scope.showCleanDay = false;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
var resetClientPayDescByTpey = function (type) {
|
|
|
type = parseInt(type);
|
|
|
if (type == 1) {
|
|
|
removeClientPayDesc($scope.partner.client_pay_desc, '10');
|
|
|
}
|
|
|
if (type == 2) {
|
|
|
removeClientPayDesc($scope.partner.client_pay_desc, '20');
|
|
|
}
|
|
|
};
|
|
|
|
|
|
var compare = function (x, y) {
|
|
|
x = parseInt(x);
|
|
|
y = parseInt(y);
|
|
|
if (x < y) {
|
|
|
return -1;
|
|
|
} else if (x > y) {
|
|
|
return 1;
|
|
|
} else {
|
|
|
return 0;
|
|
|
}
|
|
|
}
|
|
|
$scope.toggleClientPayType = function (type) {
|
|
|
if ($scope.partner.client_pay_type == null) {
|
|
|
$scope.partner.client_pay_type = [];
|
|
|
$scope.partner.client_pay_desc = [];
|
|
|
}
|
|
|
var $idx = $scope.partner.client_pay_type.indexOf(type);
|
|
|
if ($idx >= 0) {
|
|
|
$scope.partner.client_pay_type.splice($idx, 1);
|
|
|
resetClientPayDescByTpey(type);
|
|
|
} else {
|
|
|
$scope.partner.client_pay_type.push(type);
|
|
|
$scope.partner.client_pay_type.sort(compare);
|
|
|
}
|
|
|
};
|
|
|
$scope.toggleClientPayDesc = function (type) {
|
|
|
var $idx = $scope.partner.client_pay_desc.indexOf(type);
|
|
|
if ($idx >= 0) {
|
|
|
if (type == '203') {
|
|
|
removeClientPayDesc($scope.partner.client_pay_desc,'2030')
|
|
|
}
|
|
|
$scope.partner.client_pay_desc.splice($idx, 1);
|
|
|
} else {
|
|
|
$scope.partner.client_pay_desc.push(type);
|
|
|
$scope.partner.client_pay_desc.sort(compare);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
$scope.saveStep1 = function (form,index) {
|
|
|
alert('Do not forget your login id ('+$scope.partner.contact_phone+') and password');
|
|
|
$scope.initErrorMsg();
|
|
|
if (form.$invalid) {
|
|
|
angular.forEach(form, function (item, key) {
|
|
|
if (key.indexOf('$') < 0) {
|
|
|
item.$dirty = true;
|
|
|
}
|
|
|
});
|
|
|
return;
|
|
|
}
|
|
|
$scope.initParam();
|
|
|
$scope.partner.username = $scope.partner.contact_phone;
|
|
|
$scope.partner.apply_source = 'pc';
|
|
|
$http.post('/register/info/update/' + $scope.partner.username +'/step1', $scope.partner).then(function (resp) {
|
|
|
$scope.changeChoose(index);
|
|
|
$scope.partner.codeKey = resp.data.codeKey;
|
|
|
}, function (resp) {
|
|
|
$scope.resError = resp.data.message;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
$scope.saveApplyInfo = function (form,index) {
|
|
|
$scope.initErrorMsg();
|
|
|
if (form.$invalid) {
|
|
|
angular.forEach(form, function (item, key) {
|
|
|
if (key.indexOf('$') < 0) {
|
|
|
item.$dirty = true;
|
|
|
}
|
|
|
});
|
|
|
return;
|
|
|
}
|
|
|
if(index == 4){
|
|
|
$scope.submit = true;
|
|
|
}
|
|
|
$scope.initParam();
|
|
|
if ($scope.partner.company_name.indexOf("Migration") != -1) {
|
|
|
alert("Company Name包含敏感词汇,请检查后重新提交!");
|
|
|
return;
|
|
|
}
|
|
|
if ($scope.partner.client_pay_type.length==0) {
|
|
|
alert('请选择商户支付场景')
|
|
|
return;
|
|
|
}
|
|
|
if ($scope.partner.client_pay_desc.length==0) {
|
|
|
alert('请选择商户支付方式')
|
|
|
return;
|
|
|
}
|
|
|
if ($scope.partner.client_pay_type.indexOf('1') >= 0) {
|
|
|
if ($scope.partner.client_pay_desc instanceof Array) {
|
|
|
if ($scope.partner.client_pay_desc.join(',').indexOf('10') < 0) {
|
|
|
alert("请检查线上支付场景是否已选择支付方式");
|
|
|
return;
|
|
|
}
|
|
|
}else {
|
|
|
if ($scope.partner.client_pay_desc.indexOf('10') < 0) {
|
|
|
alert("请检查线上支付场景是否已选择支付方式");
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if ( $scope.partner.client_pay_type.indexOf('2') >= 0) {
|
|
|
if ($scope.partner.client_pay_desc instanceof Array) {
|
|
|
if ($scope.partner.client_pay_desc.join(',').indexOf('20') < 0) {
|
|
|
alert("请检查线下支付场景是否已选择支付方式");
|
|
|
return;
|
|
|
}
|
|
|
if ($scope.partner.client_pay_desc.join(',').indexOf('203') >= 0) {
|
|
|
if ($scope.partner.client_pay_desc.join(',').indexOf('2030') < 0 && $scope.partner.client_pay_desc.join(',').indexOf('20399') < 0) {
|
|
|
alert("请检查线下支付是否已选择收银系统类型");
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
}else {
|
|
|
if ($scope.partner.client_pay_desc.indexOf('20') < 0) {
|
|
|
alert("请检查线下支付场景是否已选择支付方式");
|
|
|
return;
|
|
|
}
|
|
|
if ($scope.partner.client_pay_desc.indexOf('203') >= 0) {
|
|
|
if ($scope.partner.client_pay_desc.indexOf('2030') < 0 && $scope.partner.client_pay_desc.join(',').indexOf('20399') < 0) {
|
|
|
alert("请检查线下支付是否已选择收银系统类型");
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if ($scope.partner.client_pay_type instanceof Array) {
|
|
|
$scope.partner.client_pay_type = $scope.partner.client_pay_type.join(',');
|
|
|
}
|
|
|
if ($scope.partner.client_pay_desc instanceof Array) {
|
|
|
$scope.partner.client_pay_desc = $scope.partner.client_pay_desc.join(',');
|
|
|
}
|
|
|
$http.post('/register/info/update/' + $scope.partner.username, $scope.partner).then(function (resp) {
|
|
|
if (index == 3) {
|
|
|
$scope.getRateConfig();
|
|
|
}
|
|
|
$scope.changeChoose(index);
|
|
|
}, function (resp) {
|
|
|
$scope.resError = resp.data.message;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
$scope.initParam = function () {
|
|
|
if(!$scope.partner.company_name){
|
|
|
$scope.partner.company_name = ' ';
|
|
|
}
|
|
|
if(!$scope.partner.short_name){
|
|
|
$scope.partner.short_name = ' ';
|
|
|
}
|
|
|
if(!$scope.partner.company_phone){
|
|
|
$scope.partner.company_phone = ' ';
|
|
|
}
|
|
|
if(!$scope.partner.address){
|
|
|
$scope.partner.address = ' ';
|
|
|
}
|
|
|
if(!$scope.partner.suburb){
|
|
|
$scope.partner.suburb = ' ';
|
|
|
}
|
|
|
if(!$scope.partner.state){
|
|
|
$scope.partner.state = ' ';
|
|
|
}
|
|
|
if(!$scope.partner.postcode){
|
|
|
$scope.partner.postcode = ' ';
|
|
|
}
|
|
|
if(!$scope.partner.industry){
|
|
|
$scope.partner.industry = ' ';
|
|
|
}
|
|
|
if(!$scope.partner.bank_no){
|
|
|
$scope.partner.bank_no = ' ';
|
|
|
}
|
|
|
if(!$scope.partner.bank_name){
|
|
|
$scope.partner.bank_name = ' ';
|
|
|
}
|
|
|
if(!$scope.partner.bsb_no){
|
|
|
$scope.partner.bsb_no = ' ';
|
|
|
}
|
|
|
if(!$scope.partner.clean_days){
|
|
|
$scope.partner.clean_days = ' ';
|
|
|
}
|
|
|
if(!$scope.partner.abn){
|
|
|
$scope.partner.abn = ' ';
|
|
|
}
|
|
|
if(!$scope.partner.contact_job){
|
|
|
$scope.partner.contact_job = ' ';
|
|
|
}
|
|
|
if(!$scope.partner.representative_person){
|
|
|
$scope.partner.representative_person = ' ';
|
|
|
}
|
|
|
if(!$scope.partner.representative_phone){
|
|
|
$scope.partner.representative_phone = ' ';
|
|
|
}
|
|
|
if(!$scope.partner.representative_email){
|
|
|
$scope.partner.representative_email = ' ';
|
|
|
}
|
|
|
if(!$scope.partner.representative_job_title){
|
|
|
$scope.partner.representative_job_title = ' ';
|
|
|
}
|
|
|
if(!$scope.partner.registered_address){
|
|
|
$scope.partner.registered_address = ' ';
|
|
|
}
|
|
|
if(!$scope.partner.registered_suburb){
|
|
|
$scope.partner.registered_suburb = ' ';
|
|
|
}
|
|
|
if(!$scope.partner.registered_state){
|
|
|
$scope.partner.registered_state = ' ';
|
|
|
}
|
|
|
if(!$scope.partner.registered_postcode){
|
|
|
$scope.partner.registered_postcode = ' ';
|
|
|
}
|
|
|
if(!$scope.partner.logo_url){
|
|
|
$scope.partner.logo_url = ' ';
|
|
|
}
|
|
|
if(!$scope.partner.company_website){
|
|
|
$scope.partner.company_website = ' ';
|
|
|
}
|
|
|
if(!$scope.partner.company_photo){
|
|
|
$scope.partner.company_photo = ' ';
|
|
|
}
|
|
|
}
|
|
|
|
|
|
$scope.initErrorMsg = function () {
|
|
|
$scope.resError = '';
|
|
|
}
|
|
|
|
|
|
$scope.uploadLogo = function (file) {
|
|
|
if (file != null) {
|
|
|
if (file.size > 1 * 1024 * 1024) {
|
|
|
commonDialog.alert({title: 'Error', content: '文件大小不能超过1MB,请压缩后重试', type: 'error'})
|
|
|
} else {
|
|
|
$scope.logoProgress = {value: 0};
|
|
|
Upload.upload({
|
|
|
url: '/register/upload/files',
|
|
|
data: {file: file}
|
|
|
}).then(function (resp) {
|
|
|
delete $scope.logoProgress;
|
|
|
$scope.partner.logo_id = resp.data.fileid;
|
|
|
$scope.partner.logo_url = resp.data.url;
|
|
|
}, function (resp) {
|
|
|
delete $scope.logoProgress;
|
|
|
/*commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'})*/
|
|
|
alert(resp.data.message);
|
|
|
}, function (evt) {
|
|
|
$scope.logoProgress.value = parseInt(100 * evt.loaded / evt.total);
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
|
|
|
$scope.uploadShopPhoto = function (file) {
|
|
|
if (file != null) {
|
|
|
if (file.size > 2 * 1024 * 1024) {
|
|
|
commonDialog.alert({title: 'Error', content: '文件大小不能超过2MB,请压缩后重试', type: 'error'})
|
|
|
} else {
|
|
|
$scope.shopPhotoProgress = {value: 0};
|
|
|
Upload.upload({
|
|
|
url: '/register/upload/files',
|
|
|
data: {file: file}
|
|
|
}).then(function (resp) {
|
|
|
delete $scope.shopPhotoProgress;
|
|
|
$scope.partner.company_photo = resp.data.url;
|
|
|
}, function (resp) {
|
|
|
delete $scope.shopPhotoProgress;
|
|
|
/*commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'})*/
|
|
|
alert(resp.data.message);
|
|
|
}, function (evt) {
|
|
|
$scope.shopPhotoProgress.value = parseInt(100 * evt.loaded / evt.total);
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
|
|
|
$scope.uploadStorePhoto = function (file) {
|
|
|
if (file != null) {
|
|
|
if (file.size > 2 * 1024 * 1024) {
|
|
|
commonDialog.alert({title: 'Error', content: '文件大小不能超过2MB,请压缩后重试', type: 'error'})
|
|
|
} else {
|
|
|
$scope.storePhotoProgress = {value: 0};
|
|
|
Upload.upload({
|
|
|
url: '/register/upload/files',
|
|
|
data: {file: file}
|
|
|
}).then(function (resp) {
|
|
|
delete $scope.storePhotoProgress;
|
|
|
$scope.partner.store_photo = resp.data.url;
|
|
|
}, function (resp) {
|
|
|
delete $scope.storePhotoProgress;
|
|
|
/*commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'})*/
|
|
|
alert(resp.data.message);
|
|
|
}, function (evt) {
|
|
|
$scope.storePhotoProgress.value = parseInt(100 * evt.loaded / evt.total);
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
|
|
|
$scope.submitSign = function (fullName) {
|
|
|
var sign = $("#signature").jSignature('getData', 'image');
|
|
|
var signInfo = {};
|
|
|
signInfo.src = 'data:' + sign[0] + ',' + sign[1];
|
|
|
signInfo.fullName = fullName;
|
|
|
$scope.$close(signInfo);
|
|
|
};
|
|
|
|
|
|
|
|
|
$scope.submitApply = function () {
|
|
|
$uibModal.open({
|
|
|
backdrop: false,
|
|
|
templateUrl: '/static/payment/partner/templates/agreement_signature_dialog.html',
|
|
|
controller: 'agreementSignDialogCtrl',
|
|
|
size: 'md'
|
|
|
}).result.then(function (result) {
|
|
|
$scope.confirmBtn = true;
|
|
|
$scope.signItBtn = false;
|
|
|
$scope.signInfo.fullName = result.fullName;
|
|
|
$scope.signInfo.src = result.src;
|
|
|
$scope.uploadSign();
|
|
|
})
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
$scope.uploadSign = function () {
|
|
|
if ($scope.signInfo.fullName == null || $scope.signInfo.fullName == "") {
|
|
|
commonDialog.alert({title: 'Submit Fail', content: 'Please confirm full name entered', type: 'error'});
|
|
|
return;
|
|
|
}
|
|
|
if ($scope.signInfo.src == null || $scope.signInfo.src == "") {
|
|
|
commonDialog.alert({title: 'Submit Fail', content: 'Please confirm signature', type: 'error'});
|
|
|
return;
|
|
|
}
|
|
|
document.getElementById("loading_logo").style ="";
|
|
|
$scope.white();
|
|
|
var signFile = dataURLtoFile($scope.signInfo.src, $scope.signInfo.fullName);
|
|
|
$scope.logoProgress = {value: 0};
|
|
|
Upload.upload({
|
|
|
url: '/register/clientCompliance/commit_aggregate_file'+'?username='+$scope.partner.contact_phone+'&clean_days='+$scope.partner.clean_days,
|
|
|
data: {file: signFile}
|
|
|
}).then(function (resp) {
|
|
|
$scope.contract_url= resp.data.contract_url;
|
|
|
document.getElementById('loading').style.display = "none";
|
|
|
document.getElementById('loading_logo').style.display = "none";
|
|
|
delete $scope.logoProgress;
|
|
|
$scope.changeChoose(4);
|
|
|
}, function (resp) {
|
|
|
debugger;
|
|
|
document.getElementById('loading').style.display = "none";
|
|
|
document.getElementById('loading_logo').style.display = "none";
|
|
|
delete $scope.logoProgress;
|
|
|
commonDialog.alert({title: 'Commit Aggregate File Fail', content: resp.data.message, type: 'error'})
|
|
|
}, function (evt) {
|
|
|
$scope.logoProgress.value = parseInt(100 * evt.loaded / evt.total);
|
|
|
});
|
|
|
|
|
|
};
|
|
|
|
|
|
$scope.white=function(){
|
|
|
$("#loading").css({
|
|
|
"position":"absolute", //绝对位置
|
|
|
"display":"block", //让对象成为块级元素
|
|
|
"background-color":"white", //背景白色
|
|
|
"z-index":"9999", //最上层显示
|
|
|
"opacity":"0.7" //背景透明度
|
|
|
});
|
|
|
}
|
|
|
|
|
|
function dataURLtoFile(dataurl, filename) {//将base64转换为文件
|
|
|
var arr = dataurl.split(','), mime = arr[0].match(/:(.*?);/)[1],
|
|
|
bstr = atob(arr[1]), n = bstr.length, u8arr = new Uint8Array(n);
|
|
|
while (n--) {
|
|
|
u8arr[n] = bstr.charCodeAt(n);
|
|
|
}
|
|
|
return new File([u8arr], filename, {type: mime});
|
|
|
}
|
|
|
|
|
|
|
|
|
}]);
|
|
|
|
|
|
app.controller('agreementSignDialogCtrl', ['$scope', '$http', 'commonDialog', function ($scope, $http, commonDialog) {
|
|
|
$scope.submitSign = function (fullName) {
|
|
|
var sign = $("#signature").jSignature('getData', 'image');
|
|
|
var signInfo = {};
|
|
|
signInfo.src = 'data:' + sign[0] + ',' + sign[1];
|
|
|
signInfo.fullName = fullName;
|
|
|
$scope.$close(signInfo);
|
|
|
};
|
|
|
}]);
|
|
|
app.factory('commonDialog', ['$q', '$uibModal', function ($q, $uibModal) {
|
|
|
return {
|
|
|
alert: function (cfg) {
|
|
|
var choises = [{label: 'OK', className: 'btn-default', key: '1'}];
|
|
|
var config = {
|
|
|
title: cfg.title,
|
|
|
content: cfg.content,
|
|
|
contentHtml: cfg.contentHtml,
|
|
|
backdrop: cfg.backdrop,
|
|
|
size: cfg.size,
|
|
|
choises: choises,
|
|
|
type: cfg.type
|
|
|
};
|
|
|
var defer = $q.defer();
|
|
|
showModalDialog(config).then(function () {
|
|
|
defer.resolve();
|
|
|
}, function () {
|
|
|
defer.resolve()
|
|
|
});
|
|
|
return defer.promise;
|
|
|
},
|
|
|
confirm: function (cfg) {
|
|
|
var choises = [{label: 'OK', className: 'btn-success', key: '1'},
|
|
|
{label: 'Cancel', className: 'btn-danger', key: '2', dismiss: true}];
|
|
|
var config = {
|
|
|
title: cfg.title,
|
|
|
content: cfg.content,
|
|
|
contentHtml: cfg.contentHtml,
|
|
|
json:cfg.json,
|
|
|
backdrop: cfg.backdrop,
|
|
|
size: cfg.size,
|
|
|
choises: cfg.choises || choises
|
|
|
};
|
|
|
var deferred = $q.defer();
|
|
|
showModalDialog(config).then(function (choice) {
|
|
|
if (choice.dismiss) {
|
|
|
deferred.reject();
|
|
|
} else {
|
|
|
deferred.resolve(choice.key);
|
|
|
}
|
|
|
}, function () {
|
|
|
deferred.reject();
|
|
|
});
|
|
|
return deferred.promise;
|
|
|
},
|
|
|
inputNum: function (cfg) {
|
|
|
return $uibModal.open({
|
|
|
templateUrl: '/static/commons/templates/num_input.html',
|
|
|
size: 'sm',
|
|
|
resolve: {
|
|
|
cfg: function () {
|
|
|
return cfg;
|
|
|
}
|
|
|
},
|
|
|
controller: ['$scope', 'cfg', function ($scope, cfg) {
|
|
|
$scope.title = cfg.title || 'Input Amount';
|
|
|
$scope.data = {};
|
|
|
$scope.submit = function () {
|
|
|
$scope.$close($scope.data.num);
|
|
|
};
|
|
|
}]
|
|
|
}).result;
|
|
|
},
|
|
|
inputText:function (cfg) {
|
|
|
return $uibModal.open({
|
|
|
backdrop: 'static', keyboard: false,
|
|
|
templateUrl:'/static/commons/templates/text_input.html',
|
|
|
size: cfg.size || 'sm',
|
|
|
resolve:{
|
|
|
cfg:function () {
|
|
|
return cfg;
|
|
|
}
|
|
|
},
|
|
|
controller:['$scope','cfg',function ($scope, cfg) {
|
|
|
$scope.title = cfg.title || 'Input Amount';
|
|
|
$scope.data = {};
|
|
|
$scope.submit = function () {
|
|
|
$scope.$close($scope.data.text);
|
|
|
};
|
|
|
}]
|
|
|
}).result;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
function showModalDialog(cfg) {
|
|
|
cfg = angular.extend({}, defaultCfg, cfg);
|
|
|
return $uibModal.open({
|
|
|
templateUrl: 'static/commons/templates/dialog.html',
|
|
|
controller: 'commonModalCtrl',
|
|
|
size: cfg.size,
|
|
|
backdrop: cfg.backdrop,
|
|
|
resolve: {
|
|
|
cfg: function () {
|
|
|
return cfg;
|
|
|
}
|
|
|
}
|
|
|
}).result;
|
|
|
}
|
|
|
}]);
|
|
|
app.controller('commonModalCtrl', ['$scope', '$timeout', 'cfg', function ($scope, $timeout, cfg) {
|
|
|
var bgClasses = {
|
|
|
success: 'bg-success',
|
|
|
error: 'bg-warning',
|
|
|
info: 'bg-info'
|
|
|
};
|
|
|
var glyIcons = {
|
|
|
success: 'glyphicon-ok-circle',
|
|
|
error: 'glyphicon-remove-circle',
|
|
|
info: 'glyphicon-info-sign'
|
|
|
};
|
|
|
$scope.title = cfg.title;
|
|
|
$scope.content = cfg.content;
|
|
|
$scope.contentHtml = cfg.contentHtml;
|
|
|
$scope.jsonData = cfg.json;
|
|
|
$scope.bgClass = bgClasses[cfg.type];
|
|
|
$scope.glyIcon = glyIcons[cfg.type];
|
|
|
$scope.choises = cfg.choises;
|
|
|
if(cfg.type=='success'){
|
|
|
$timeout(function () {
|
|
|
$scope.$dismiss();
|
|
|
},2000)
|
|
|
}
|
|
|
|
|
|
$scope.btnClick = function (choice) {
|
|
|
$scope.$close(choice);
|
|
|
}
|
|
|
}]);
|
|
|
app.directive('multiLevelSelectPopup', [function () {
|
|
|
return {
|
|
|
restrict: 'A',
|
|
|
scope: {
|
|
|
multiLevelSelectPopup: '=',
|
|
|
childrenKey: '@',
|
|
|
labelKey: '@',
|
|
|
onSelect: '&'
|
|
|
},
|
|
|
link: function (scope, element, attr) {
|
|
|
var selectBox,bg;
|
|
|
var selectGroups = [];
|
|
|
scope.labelKey = scope.labelKey || 'label';
|
|
|
scope.childrenKey = scope.childrenKey || 'children';
|
|
|
$(element).focus(function () {
|
|
|
if (selectBox) {
|
|
|
selectBox.remove();
|
|
|
}
|
|
|
selectBox = $('<div></div>').addClass('ml-select-box');
|
|
|
var offset = $(this).offset();
|
|
|
selectBox.css({
|
|
|
top: (offset.top + $(this).outerHeight() + 3) + 'px',
|
|
|
left: offset.left + 'px'
|
|
|
});
|
|
|
var container = $('<div></div>').appendTo(selectBox);
|
|
|
initSelectLevel(container, scope.multiLevelSelectPopup, 0);
|
|
|
var $body = $('body');
|
|
|
selectBox.appendTo($body);
|
|
|
bg = $('<div></div>').css({position:'fixed',top:0,left:0,right:0,bottom:0,zIndex:9998}).appendTo($body);
|
|
|
bg.click(function () {
|
|
|
selectBox.remove();
|
|
|
bg.remove();
|
|
|
selectBox = null;
|
|
|
})
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
function initSelectLevel(container, list, groupIndex) {
|
|
|
if (selectGroups[groupIndex]) {
|
|
|
var groups = selectGroups.splice(groupIndex, 999);
|
|
|
angular.forEach(groups, function (group) {
|
|
|
group.remove();
|
|
|
})
|
|
|
}
|
|
|
var levelBox = $('<ul></ul>').addClass('select-group').appendTo(container);
|
|
|
selectGroups[groupIndex] = levelBox;
|
|
|
angular.forEach(list, function (item) {
|
|
|
var label = item[scope.labelKey];
|
|
|
var li = $('<li></li>').text(label).attr('title', label).appendTo(levelBox);
|
|
|
if (!item[scope.childrenKey] || !item[scope.childrenKey].length) {
|
|
|
if (angular.isFunction(scope.onSelect)) {
|
|
|
li.click(function () {
|
|
|
try {
|
|
|
scope.$apply(function () {
|
|
|
scope.onSelect({$selected: item});
|
|
|
|
|
|
})
|
|
|
}catch(err){}
|
|
|
selectBox.remove();
|
|
|
bg.remove();
|
|
|
selectBox = null;
|
|
|
|
|
|
})
|
|
|
}
|
|
|
} else {
|
|
|
li.hover(function () {
|
|
|
levelBox.find('.active').removeClass('active');
|
|
|
li.addClass('active');
|
|
|
initSelectLevel(container, item.children, groupIndex + 1);
|
|
|
});
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}]);
|