You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

329 lines
12 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

angular.module('applyPartnerApp', ['ngMessages']).controller('applyPartnerCtrl', ['$scope', '$http','$interval', function ($scope, $http,$interval) {
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"
}
];
$scope.name_exist = false;
$scope.states = angular.copy(stateMap);
$scope.countries = angular.copy(countryMap);
$scope.cleanDays = angular.copy(cleanDays);
$scope.canClick=false;
$scope.description = "Send Code";
$scope.partner = {nation_code:"+61"};
$scope.bankaccount = {};
$scope.rate = {};
$scope.phone_code_timer=$interval(function () {}, 1000);
$scope.loadRoyalpayindustry = function () {
$http.get('/static/data/rp_industry_apply.json').then(function (resp) {
$scope.royalpayindustry = resp.data;
})
};
$scope.loadRoyalpayindustry();
$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.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.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.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.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.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.showCleanDay = true;
break;
}
}
}else {
$scope.showCleanDay = false;
}
};
$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;
}
$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 = ' ';
}
}
$scope.initErrorMsg = function () {
$scope.resError = '';
}
}]);