File size: 4,794 Bytes
597ee18 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | function presentacion(){
var self = Ti.UI.createWindow({
backgroundImage:"/assets/fondo.jpg",
zIndex:1,
fullscreen:false,
orientationModes: [Ti.UI.PORTRAIT],
exitOnClose:true,
navBarHidden:true
});
var scroll = Ti.UI.createScrollView({
top:1,
width:"98%",
height:"100%",
scrollType:'vertical'
});
var monstrito1 = Ti.UI.createImageView({
image:"/assets/mons4.png",
width:80,
height:88,
top:20,
left:20,
zIndex:2
});
var monstrito2 = Ti.UI.createImageView({
image:"/assets/mos3.png",
width:130,
height:129,
top:20,
right:10,
zIndex:3
});
var logosa = Ti.UI.createImageView({
image:"/assets/alphaLOGO.png",
width:300,
heigh:143,
top:90,
left:30,
zIndex:21
});
var contenedor = Ti.UI.createView({
backgroundColor:"#ffffff",
zIndex:2,
width:"70%",
height:130,
top:230
});
var texto = Ti.UI.createLabel({
textAlign:Ti.UI.TEXT_ALIGNMENT_CENTER,
html:"El desafío Alpha es un reto para valientes, responde de manera correcta las preguntas que te haremos y ¡gana puntos para canjear grandes premios!",
top:10,
left:10,
width:"90%",
color:"#000000"
});
contenedor.add(texto);
var style;
if (Ti.Platform.name === 'android'){
style = Ti.UI.ActivityIndicatorStyle.DARK;
}
else {
style = Ti.UI.iPhone.ActivityIndicatorStyle.DARK;
}
var activityIndicator = Ti.UI.createActivityIndicator({
color: 'black',
font: {fontFamily:'Helvetica Neue', fontSize:20, fontWeight:'bold'},
message: 'Abriendo...',
style:style,
backgroundColor : '#000000',
height:"100%",
width:"100%",
color : 'white',
padding : 10,
opacity : 0.87,
top : 0,
borderRadius : 0,
borderColor : 'black',
borderWidth : 1
});
var nboton = Ti.UI.createButton({
top: 380,
width:200,
height:40,
backgroundColor:'#37ade2',
zIndex:22,
title:'INGRESAR',
color:'#ffffff',
font:{fontFamily:'Minecrafter_3',fontSize:14},
textAlign:Ti.UI.TEXT_ALIGNMENT_CENTER,
});
nboton.addEventListener('touchend',function(){
this.animate({
top:380,
duration:150
});
});
nboton.addEventListener('touchstart',function(){
this.animate({
top:385,
duration:150
});
});
nboton.addEventListener('click',function(){
///////// existe registro
if(Titanium.Network.online){
////verficamos existencia de registro de UUID
var url='http://productosalpha.com.pe/webservice/verificacion.php';
param=({
'idmobile':Ti.Platform.id
});
var client = Ti.Network.createHTTPClient({
onload : function(e) {
var getdata = JSON.parse(this.responseText);
Titanium.API.nivel = getdata.level;
niveles = Titanium.API.nivel;
if(getdata.registro=="registra"){
//var firstView = new FirstView();
//self.add(firstView);
var Selector = require("/ui/common/selector");
selector = new Selector();
selector.open();
}else{
Titanium.API.nivel = getdata.level;
var Bienvenida = require('/ui/common/bienvenido');
var bienvenida = new Bienvenida();
bienvenida.open();
}
},
// function called when an error occurs, including a timeout
onerror : function(e) {
Ti.API.debug(e.error);
alert('No tienes conexion a internet');
},
onreadystatechange: function(e){
if(e.readyState==4){
activityIndicator.hide();
}else{
activityIndicator.show();
}
}
});
// Prepare the connection.
client.open("POST", url);
// Send the request.
client.send(param);
}else {
var vista = Ti.UI.createView({
width:'100%',
height:'100%',
top:0,
zIndex:10
});
var toast = Ti.UI.createNotification({
message:"Su dispositivo no tiene conexión a internet Intentelo mas tarde."
});
toast.show();
vista.addEventListener('click',function(){
var activity = Titanium.Android.currentActivity;
activity.finish();
});
self.add(vista);
}
//////// fin de codigo
});
scroll.add(logosa);
scroll.add(nboton);
scroll.add(contenedor);
scroll.add(monstrito1);
scroll.add(monstrito2);
self.add(scroll);
contenedor.getOpacity(0);
monstrito1.getOpacity(0);
monstrito2.getOpacity(0);
logosa.getOpacity(0);
contenedor.animate({
delay:600,
opacity:1,
duration:350
});
monstrito1.animate({
delay:600,
opacity:1,
duration:350
});
monstrito2.animate({
delay:600,
opacity:1,
duration:350
});
logosa.animate({
delay:350,
opacity:1,
duration:350
});
return self;
}
module.exports = presentacion; |