mirror of
https://github.com/arnaucube/commonroutesApp.git
synced 2026-02-07 19:46:44 +01:00
actualitzant...
This commit is contained in:
91
www/js/signup.js
Normal file
91
www/js/signup.js
Normal file
@@ -0,0 +1,91 @@
|
||||
angular.module('app.signup', ['pascalprecht.translate'])
|
||||
|
||||
.controller('SignupCtrl', function($scope, $ionicModal, $timeout, $http, $window, $ionicLoading) {
|
||||
$scope.signupData = {};
|
||||
$scope.doSignup = function() {
|
||||
console.log('Doing signup', $scope.signupData);
|
||||
if ($scope.emptyParams($scope.signupData)) {
|
||||
$http({
|
||||
url: urlapi + 'users',
|
||||
method: "POST",
|
||||
data: $scope.signupData
|
||||
})
|
||||
.then(function(response) {
|
||||
// success
|
||||
console.log("response: ");
|
||||
console.log(response.data);
|
||||
|
||||
if (response.data.success == true)
|
||||
{
|
||||
localStorage.setItem("cim_app_token", response.data.token);
|
||||
localStorage.setItem("cim_app_userdata", JSON.stringify(response.data.user));
|
||||
window.location.reload();
|
||||
}else{
|
||||
console.log("signup failed");
|
||||
$ionicLoading.show({ template: 'signup failed, user or password error.', noBackdrop: true, duration: 2000 });
|
||||
}
|
||||
},
|
||||
function(response) { // optional
|
||||
// failed
|
||||
$ionicLoading.show({
|
||||
template: 'Error on signup',
|
||||
noBackdrop: true,
|
||||
duration: 2000
|
||||
});
|
||||
});
|
||||
} else {
|
||||
$ionicLoading.show({
|
||||
template: 'First complete all parameters',
|
||||
noBackdrop: true,
|
||||
duration: 2000
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
$scope.emptyParams = function(obj) {
|
||||
if (obj.username == undefined) {
|
||||
return (false);
|
||||
}
|
||||
if (obj.password == undefined) {
|
||||
return (false);
|
||||
}
|
||||
if (obj.mail == undefined) {
|
||||
return (false);
|
||||
}
|
||||
/*if(obj.avatar==undefined)
|
||||
{
|
||||
return(false);
|
||||
}*/
|
||||
return (true);
|
||||
};
|
||||
$scope.avatars = [
|
||||
"turtle",
|
||||
"cat",
|
||||
"toucan",
|
||||
"racoon",
|
||||
"tiger",
|
||||
"squirrel",
|
||||
"sheep",
|
||||
"penguin",
|
||||
"panda",
|
||||
"owl",
|
||||
"pelican",
|
||||
"whale",
|
||||
"snake",
|
||||
"mouse",
|
||||
"giraffe",
|
||||
"macaw",
|
||||
"lion",
|
||||
"llama",
|
||||
"kangaroo",
|
||||
"hen",
|
||||
"frog",
|
||||
"clown-fish",
|
||||
"chameleon",
|
||||
"octopus"
|
||||
];
|
||||
$scope.avatarSelect = function(avat) {
|
||||
$scope.signupData.avatar = avat;
|
||||
//alert($scope.signupData.avatar);
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user