|
|
@@ -0,0 +1,223 @@
|
|
|
+define([ 'toaster', 'services' ,'ui.router', 'file-upload', 'file-upload-shim'], function() {
|
|
|
+ 'use strict';
|
|
|
+ var app = angular.module('myApp', [ 'toaster', 'common.services', 'angularFileUpload', 'ui.router']);
|
|
|
+ app.init = function() {
|
|
|
+ angular.bootstrap(document, [ 'myApp' ]);
|
|
|
+ };
|
|
|
+ app.config(['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider){
|
|
|
+ $urlRouterProvider.otherwise("/step1");
|
|
|
+ $stateProvider.state('step1', {
|
|
|
+ url: '/step1',
|
|
|
+ templateUrl: 'static/tpl/saasRegister/step1.html'
|
|
|
+ }).state('step2', {
|
|
|
+ url: '/step2',
|
|
|
+ templateUrl: 'static/tpl/saasRegister/step2.html'
|
|
|
+ }).state('step3', {
|
|
|
+ url: '/step3/:uu/:checkcode',
|
|
|
+ templateUrl: 'static/tpl/saasRegister/step3.html'
|
|
|
+ });
|
|
|
+ }]);
|
|
|
+
|
|
|
+ app.controller('Step1Ctrl', ['$scope', '$http', '$location', '$upload', 'toaster', 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];
|
|
|
+ $upload.upload({
|
|
|
+ url: 'signup',
|
|
|
+ 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(){
|
|
|
+ var patt = new RegExp(/^[\d-]{6,}$/);
|
|
|
+ if(patt.test($scope.enterprise.enBussinessCode)) {
|
|
|
+ $http.get('signup/codeEnable', {
|
|
|
+ params: {
|
|
|
+ code: $scope.enterprise.enBussinessCode
|
|
|
+ }
|
|
|
+ }).success(function(data){
|
|
|
+ data = eval(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(){
|
|
|
+ var patt = new RegExp(/^[\d-]{8,}$/);
|
|
|
+ if(patt.test($scope.enterprise.enAdminTel)) {
|
|
|
+ $http.get('signup/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.telErrorInfo = '格式错误';
|
|
|
+ }
|
|
|
+ });
|
|
|
+ $scope.$watch('enterprise.enAdminEmail', function(){
|
|
|
+ if($scope.enterprise.enAdminEmail) {
|
|
|
+ $http.get('signup/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 ;
|
|
|
+ };
|
|
|
+ }]);
|
|
|
+
|
|
|
+ app.controller('Step3Ctrl', ['$scope', '$http', '$location', '$upload', 'toaster', '$stateParams', function($scope, $http, $location, $upload, toaster, $stateParams) {
|
|
|
+ $scope.uu = $stateParams.uu;
|
|
|
+ $scope.checkcode = $stateParams.checkcode;
|
|
|
+ $scope.activateResult = false;
|
|
|
+ $scope.activateSuccess = false;
|
|
|
+ $scope.activateSendAgain = false;
|
|
|
+
|
|
|
+ setTimeout(function() {//延迟5秒执行
|
|
|
+ $http.post('signup/activate?uu=' + $scope.uu + '&checkcode=' + $scope.checkcode)
|
|
|
+ .success(function(data){
|
|
|
+ if(data.result == "SUCCESS") {
|
|
|
+ $scope.checkResult = '成功';
|
|
|
+ $scope.activateResult = true;
|
|
|
+ $scope.activateSuccess = true;
|
|
|
+ } else {
|
|
|
+ $scope.activateSendAgain = true;
|
|
|
+ $scope.againInfo = "企业激活过程中断,需重新激活";
|
|
|
+ }
|
|
|
+
|
|
|
+ }).error(function(data){
|
|
|
+ $scope.checkResult = '失败,原因 - '+ data.result ;
|
|
|
+ $scope.activateResult = true;
|
|
|
+ if(data.result == '验证码错误,激活失败') {
|
|
|
+ $scope.activateSendAgain = true;
|
|
|
+ $scope.againInfo = "验证码错误";
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }, 5000);
|
|
|
+
|
|
|
+ $scope.setAdminPassword = function(enuu, psd) {
|
|
|
+ $scope.loadingShow = true;
|
|
|
+ $http.post('signup/setAdminPassword?enuu=' + enuu + '&password=' + psd).success(function(data){
|
|
|
+ $scope.loadingShow = false;
|
|
|
+ $scope.setSuccess = true;
|
|
|
+ $scope.buttonDisabled = true;
|
|
|
+ setTimeout(function() {//延迟3秒执行
|
|
|
+ window.location.href = window.location.href.replace('/signup', '');
|
|
|
+ }, 3000);
|
|
|
+ }).error(function(data) {
|
|
|
+ $scope.loadingShow = false;
|
|
|
+ $scope.setFaild = true;
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.sendEmailAgain = function(enuu){
|
|
|
+ $scope.loadingShow = true;
|
|
|
+ $http.get('signup/setEmailAgain?enuu=' + enuu).success(function(data){//发送失败
|
|
|
+ $scope.loadingShow = false;
|
|
|
+ $scope.emailDisabled = true;
|
|
|
+ $scope.sendSuccess = true;
|
|
|
+ }).error(function(data){//发送成功
|
|
|
+ $scope.loadingShow = false;
|
|
|
+ $scope.sendFaild = true;
|
|
|
+ });
|
|
|
+ };
|
|
|
+ }]);
|
|
|
+ return app;
|
|
|
+});
|