|
|
@@ -1,6 +1,6 @@
|
|
|
-define([ 'toaster', 'services' ,'ui.router'], function() {
|
|
|
+define([ 'toaster', 'services' ,'ui.router', 'file-upload', 'file-upload-shim'], function() {
|
|
|
'use strict';
|
|
|
- var app = angular.module('myApp', [ 'toaster', 'common.services' ,'ui.router']);
|
|
|
+ var app = angular.module('myApp', [ 'toaster', 'common.services', 'angularFileUpload', 'ui.router']);
|
|
|
app.init = function() {
|
|
|
angular.bootstrap(document, [ 'myApp' ]);
|
|
|
};
|
|
|
@@ -18,8 +18,147 @@ define([ 'toaster', 'services' ,'ui.router'], function() {
|
|
|
});
|
|
|
});
|
|
|
|
|
|
- app.controller('Step1Ctrl', function() {
|
|
|
+ app.controller('Step1Ctrl', function($scope, $http, $location, $upload, toaster) {
|
|
|
+ $scope.loadingShow = false;//加载小图标,设为true即可显示
|
|
|
+ $scope.title = '注册表单';
|
|
|
+ $scope.enterprise = {};//企业实体
|
|
|
+ $scope.agree = true;//默认同意服务协议
|
|
|
|
|
|
+ /**
|
|
|
+ * 处理企业信息注册提交
|
|
|
+ */
|
|
|
+ $scope.register = function(){
|
|
|
+ $scope.loadingShow = true;
|
|
|
+ var file = $scope.myFiles[0];
|
|
|
+ console.log($scope.enterprise);
|
|
|
+ $upload.upload({
|
|
|
+ url: 'signin/register.action',
|
|
|
+ file: file,
|
|
|
+ method: 'POST',
|
|
|
+ data: {
|
|
|
+ enterprise: $scope.enterprise
|
|
|
+ }
|
|
|
+ }).success(function(data){
|
|
|
+ $scope.loadingShow = false;
|
|
|
+ $location.path('step2');
|
|
|
+ }).error(function(data){
|
|
|
+ $scope.loadingShow = false;
|
|
|
+ toaster.pop('error', '操作失败', data.error);
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.$watch('enterprise.enBussinessCode', function(){
|
|
|
+ if($scope.enterprise.enBussinessCode && $scope.enterprise.enBussinessCode.length==15) {
|
|
|
+ $http.get('signin/codeEnable', {
|
|
|
+ params: {
|
|
|
+ code: $scope.enterprise.enBussinessCode
|
|
|
+ }
|
|
|
+ }).success(function(data){
|
|
|
+ console.log(data);
|
|
|
+ if(data == 'ENABLE') {
|
|
|
+ $scope.myForm.enBussinessCode.$setValidity('available', true);
|
|
|
+ } else if(data == 'USED') {
|
|
|
+ $scope.myForm.enBussinessCode.$setValidity('available', false);
|
|
|
+ $scope.codeErrorInfo = '执照号已注册';
|
|
|
+ } else {
|
|
|
+ $scope.myForm.enBussinessCode.$setValidity('available', false);
|
|
|
+ $scope.codeErrorInfo = '执照号已申请';
|
|
|
+ }
|
|
|
+ }).error(function() {
|
|
|
+ $scope.myForm.enBussinessCode.$setValidity('available', false);
|
|
|
+ $scope.codeErrorInfo = '验证出错';
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ $scope.myForm.enBussinessCode.$setValidity('available', false);
|
|
|
+ if($scope.enterprise.enBussinessCode) $scope.codeErrorInfo = '格式错误';
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ $scope.$watch('enterprise.enAdminTel', function(){
|
|
|
+ if($scope.enterprise.enAdminTel) {
|
|
|
+ $http.get('signin/telEnable', {
|
|
|
+ params: {
|
|
|
+ tel: $scope.enterprise.enAdminTel
|
|
|
+ }
|
|
|
+ }).success(function(data){
|
|
|
+ console.log(data);
|
|
|
+ if(data && data == 'true') {
|
|
|
+ $scope.myForm.enAdminTel.$setValidity('available', true);
|
|
|
+ } else {
|
|
|
+ $scope.myForm.enAdminTel.$setValidity('available', false);
|
|
|
+ $scope.telErrorInfo = '手机号已被使用';
|
|
|
+ }
|
|
|
+ }).error(function() {
|
|
|
+ $scope.myForm.enAdminTel.$setValidity('available', false);
|
|
|
+ $scope.telErrorInfo = '验证出错';
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ $scope.myForm.enAdminTel.$setValidity('available', false);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ $scope.$watch('enterprise.enAdminEmail', function(){
|
|
|
+ if($scope.enterprise.enAdminEmail) {
|
|
|
+ $http.get('signin/emailEnable', {
|
|
|
+ params: {
|
|
|
+ email: $scope.enterprise.enAdminEmail
|
|
|
+ }
|
|
|
+ }).success(function(data){
|
|
|
+ if(data && data == 'true') {
|
|
|
+ $scope.myForm.enAdminEmail.$setValidity('available', true);
|
|
|
+ } else {
|
|
|
+ $scope.myForm.enAdminEmail.$setValidity('available', false);
|
|
|
+ $scope.emailErrorInfo = '邮箱已被使用';
|
|
|
+ }
|
|
|
+ }).error(function(){
|
|
|
+ $scope.myForm.enAdminEmail.$setValidity('available', false);
|
|
|
+ $scope.emailErrorInfo = '验证出错';
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ $scope.myForm.enAdminEmail.$setValidity('available', false);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ $scope.previewShow = false;
|
|
|
+ $scope.pdfShow = false;
|
|
|
+ $scope.noneFileShow = true;
|
|
|
+ $scope.$watch('myFiles', function(){
|
|
|
+ if($scope.myFiles) {
|
|
|
+ $scope.noneFileShow = false;
|
|
|
+ var file = $scope.myFiles[0];
|
|
|
+ if(file.name.indexOf('.pdf') != -1 || file.name.indexOf('.PDF') != -1) {//pdf文件
|
|
|
+ $scope.pdfShow = true;
|
|
|
+ $scope.previewShow = false;
|
|
|
+ $scope.imgPreviewName = file.name;
|
|
|
+ } else{
|
|
|
+ if (typeof(Worker) !== "undefined") {//支持HTML5
|
|
|
+ $scope.imgPreview = getObjectURL(file);
|
|
|
+ $scope.imgPreviewName = file.name;
|
|
|
+ } else{//不支持HTML5
|
|
|
+ $scope.imgPreview = 'static/img/all/preview-error.jpg';
|
|
|
+ $scope.imgPreviewName = file.name;
|
|
|
+ }
|
|
|
+ $scope.previewShow = true;
|
|
|
+ $scope.pdfShow = false;
|
|
|
+ }
|
|
|
+ console.log($scope.myFiles[0]);
|
|
|
+ console.log(getObjectURL($scope.myFiles[0]));
|
|
|
+ } else {
|
|
|
+ $scope.noneFileShow = true;
|
|
|
+ $scope.previewShow = false;
|
|
|
+ $scope.pdfShow = false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ //建立一个可存取到该file的url
|
|
|
+ var getObjectURL = function(file) {
|
|
|
+ var url = null ;
|
|
|
+ if (window.createObjectURL!=undefined) { // basic
|
|
|
+ url = window.createObjectURL(file) ;
|
|
|
+ } else if (window.URL!=undefined) { // mozilla(firefox)
|
|
|
+ url = window.URL.createObjectURL(file) ;
|
|
|
+ } else if (window.webkitURL!=undefined) { // webkit or chrome
|
|
|
+ url = window.webkitURL.createObjectURL(file) ;
|
|
|
+ }
|
|
|
+ return url ;
|
|
|
+ };
|
|
|
});
|
|
|
return app;
|
|
|
});
|