jquery ошибка входа при компиляции как apk на phonegap - PullRequest
0 голосов
/ 21 марта 2020

Я занимаюсь разработкой мобильных приложений с jquery и php с использованием phonegap, но мой логин не работает, когда я скомпилировал его и установил на свой android телефон.

вот мой логин. html

<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, viewport-fit=cover" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="apple-mobile-web-app-capable" content="yes">
<title>app </title>

<link rel="manifest" href="_manifest.json" data-pwa-version="set_by_pwa.js">
<link rel="stylesheet" type="text/css" href="fonts/css/all.min.css">
<link rel="stylesheet" type="text/css" href="styles/framework.css">
<script src="scripts/jquery.min.js"></script>
<script src="cordova.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<link href="https://fonts.googleapis.com/css?family=Poppins:400,500,600,700|Roboto:100,100i,300,300i,400,400i,500,500i,700,700i,900,900i&display=swap" rel="stylesheet">

<script type="text/javascript">
$(document).ready(
    function() {
      console.log(localStorage.getItem("id"));
      var id = localStorage.getItem("id");
      if(id!=null){
         window.location.href="main.html";
      }
    }
);

$(document).ready(function(){
 $("#login").click(function(){
    var username=$("#username").val();
    var password=$("#password").val();
   $.ajax({
   url:'website.com/data/login.php',
   type:'POST',
       data:{
          username:username,
         password:password
       },
       success:function(data){
           console.log(data);
           if(data ==0){
             alert("invalid username or password");

           }else{
             localStorage.setItem("id", data);
             window.location.href="main.html";
           }
       }
   });
 });
});
function sessionCall() {
   if(typeof(Storage) != "undefined"){
     localStorage.setItem("id", )
   }
};
</script>
</head>
<body class="theme-light is-not-ios" data-highlight="green">
  <div id="notification">
  </div>
<div id="page-transitions" style="min-height: 740px;" class="back-button-clicked"><div class="page-hider" style="display: none;"></div>
<div class="header header-logo-center header-round">
<a href="index.html" class="header-title">Login</a>
<div class="page-content header-clear-larger" style="min-height: 740px;">
<div class="page-login">
<img class="preload-image login-bg responsive-image bottom-0" src="include/logo.png" data-src="include/logo.png" alt="img">
<h3 class="ultrabold top-30 bottom-0">Login</h3>
<div class="page-login-field top-15">
<i class="fa fa-user"></i>
<input type="text" id="username" placeholder="Username">
<em>(required)</em>
</div>
<div class="page-login-field bottom-20">
<i class="fa fa-lock"></i>
<input type="password" id="password" placeholder="Password">
<em>(required)</em>
</div>
<center>
<a id="login" class="btn button-large uppercase ultrabold btn-success button-center-large">Login</a>
<div class="decoration decoration-margins"></div>

<script type="text/javascript" src="scripts/jquery.js"></script>
<script type="text/javascript" src="scripts/plugins.js"></script>
<!-- <script type="text/javascript" src="scripts/custom.js"></script> -->
</body>
</html>

вот мой

логин. php

<?php
include_once "connect.php";
include_once "MODEL/account.php";
$database = new Database();
$db = $database->getConnection();
$acct = new Account($db);
header('Access-Control-Allow-Origin: *');

$id=null;
            $acct->username= $_POST['username'];
            $acct->password = md5($_POST['password']);
            if($acct->Login()){
                    $id = $acct->id;
            }else{

              $id = "0";
            }
           echo $id;

           ?>

и вот мой Модель / аккаунты. php

<?php

/**
 *
 */
class Account
{

  public function __construct($db)
  {
    $this->conn = $db;
  }
  private $conn;
  public $id;
  public $username;
  public $password;
  public $accode;
  public $status;
  public $stype;

  function login(){
    $query ="select * from accounts where username=:username and password=:password limit 1";
    $stmt = $this->conn->prepare($query);
    $this->username=htmlspecialchars(strip_tags($this->username));
    $this->password=htmlspecialchars(strip_tags($this->password));
    $stmt->bindParam(":username", $this->username);
    $stmt->bindParam(":password", $this->password);
    $stmt->execute();
    $c = $stmt->rowCount();
           $row = $stmt->fetch();
           if($c > 0){
           extract($row);
    $this->status = $status;
    $this->id= $id;
    return true;
   }else{
    return false;

    }
    }
}
?>

приведенный выше код работает с браузером на моем p c, но когда он становится apk и набран в android, он больше не работает,

спасибо за все помогите :)

...