UNPKG

unserver-unify

Version:

104 lines (103 loc) 3.58 kB
angular.module('bamboo.setting').controller('ShopSignupCtrl', function($scope, ApiService, CommonService, loginService, $state, $timeout, formService) { this.userCredentials = {}; this.company = {}; var self = this; $scope.submitted = false; this.wizardstep = 0; this.maxstep = 0; this.backtostep = function(step) { self.wizardstep = step; if (self.wizardstep > self.maxstep) { self.maxstep = self.wizardstep; } } this.nextfrombasic = function(form) { $scope.submitted = true; console.log(form); if (form.$invalid) { $scope.shaking = true; $timeout(function() { $scope.shaking = false; }, 500); console.log(form.$invalid); return; } $scope.submitted = false; self.wizardstep = 1; if (self.wizardstep > self.maxstep) { self.maxstep = self.wizardstep; } console.log(self.userCredentials); console.log(self.company); } this.nextform2 = function(form) { $scope.submitted = true; console.log(form); if (form.$invalid) { $scope.shaking = true; $timeout(function() { $scope.shaking = false; }, 500); console.log(form.$invalid); return; } $scope.submitted = false; self.wizardstep = 2; if (self.wizardstep > self.maxstep) { self.maxstep = self.wizardstep; } console.log(self.userCredentials); console.log(self.company); } this.registerWithCompany = function() { $scope.submitted = true; var info = self.userCredentials; info.companyUser = true; info.company = self.company; info.url = ApiService.HOST + "/#/active_account"; info.ownername = loginService.school.name || "tianhang"; console.log(info); ApiService.post('/signup', info).then(function(result) { console.log(result); if (result.data.success) { CommonService.showInfo(" " + result.data.success); $state.go('index.home'); } else { CommonService.showError(result.data.error); return; } }); }; this.register = function(flag) { $scope.submitted = true; this.userCredentials.user_profiles = formService.getFormData(); if (!flag) { if ($scope.form.$invalid) { $scope.shaking = true; $timeout(function() { $scope.shaking = false; }, 500); return; } } var info = self.userCredentials; //console.log(info); if (info.pass != info.re_pass) { CommonService.showError("Password not matched"); return; } info.url = ApiService.HOST + "#/active_account"; info.ownername = loginService.school.name; console.log(info); ApiService.post('/signup', info).then(function(result) { //console.log(result); if (result.data.success) { CommonService.showInfo(" " + result.data.success); $state.go('index.home'); } else { CommonService.showError(result.data.error); return; } }); }; });