Appcan后台數據庫表交互,注冊


<!DOCTYPE html>
<html class="um landscape min-width-240px min-width-320px min-width-480px min-width-768px min-width-1024px">
    <head>
        <title></title>
        <meta charset="utf-8">
        <meta name="viewport" content="target-densitydpi=device-dpi, width=device-width, initial-scale=1, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
        <link rel="stylesheet" href="css/fonts/font-awesome.min.css">
        <link rel="stylesheet" href="css/ui-box.css">
        <link rel="stylesheet" href="css/ui-base.css">
        <link rel="stylesheet" href="css/ui-color.css">
        <link rel="stylesheet" href="css/appcan.icon.css">
        <link rel="stylesheet" href="css/appcan.control.css">
        <link rel="stylesheet" href="zhuce_content/css/main.css">
    </head>
    <body class="um-vp bc-bg" ontouchstart>
        <div class="c-wh uinnh5">
            <div class="uba uc-a1 bc-border">
                <div class="ub uinn5 bc-border ubb">
                    <div class="ub ub-ac uw-reg ulev-app1">
                        登錄名稱
                    </div>
                    <div class="ub ub-ac ub-f1">
                        <div class="uinput ub ub-f1">
                            <input placeholder="請輸入您的登錄名" type="text" class="ub-f1" id="loginName">
                        </div>
                    </div>
                </div>
                <div class="ub uinn5 b-d8 ubb">
                    <div class="ub ub-ac uw-reg ulev-app1" >
                        設置密碼
                    </div>
                    <div class="ub ub-ac ub-f1">
                        <div class="uinput ub ub-f1" >
                            <input placeholder="輸入6~20位字符" type="password" class="ub-f1" id="password">
                        </div>
                    </div>
                </div>
                <div class="ub uinn5">
                    <div class="ub ub-ac uw-reg ulev-app1">
                        確認密碼
                    </div>
                    <div class="ub ub-ac  ub-f1">
                        <div class="uinput ub ub-f1">
                            <input placeholder="再次輸入設置的密碼" type="password" class="ub-f1" id="password_chack">
                        </div>
                    </div>
                </div>
            </div>
            <div class="ub ub-pe uinn-a6 ulev-4">
                    <div class="sc-text">
                        我同意
                    </div>
                    <div class="sc-text-active">
                        用戶服務協議
                    </div>
                </div>
            <div class="uinn-at1">
                <div class="btn ub ub-ac bc-text-head ub-pc bc-btn"  id="btn2" >
                    注冊
                </div>
            </div>
        </div>
    </body>
    <script src="js/appcan.js"></script>
    <script src="js/appcan.control.js"></script>
    <script src="js/appcan.listview.js"></script>
    <script src="js/main.js"></script>
    <script src="js/config.js"></script>
    </body>
    <script>
        appcan.ready(function() {
            appcan.initBounce();
        })
          appcan.button("#btn2","ani-act",function(){
            
            var loginName = $('#loginName').val();
            var password = $('#password').val();
            var password_chack=$('#password_chack').val();
            
            if(loginName==""){
                $toast("請輸入登錄名","3000")
                return;
            }
            if(password==""){
                $toast("請輸入登錄密碼","3000")
                return;
            }
            if(password!=""&password.length<6){
                $toast("密碼至少六位","3000")
                return;
            }
            if(password_chack==""){
                $toast("請再次輸入密碼","3000")
                return;
            }
            if(password!=password_chack){
                $toast("兩次密碼不一致","3000")
                return;
            }
              alert(serverURL);
                alert(loginName+"==="+password)
                ajax({
                url : "userAjax!add_model",
                data : {
                    name : loginName,
                    password : password
                },
                dataType : "json",
                successx : function(data) {
                  alert(111);
                },
                error : function(xhr, type) {
                    $toast("網絡連接超時", 3500); 
                }
     
  
                 });
             }
              
        );
    </script>
</html>
zhuce
//var ip = "192.168.1.102";

//分頁初始數據
var pageNo = 1;
var pageSize = 8;

var serverURL = "http://192.168.1.66:8080/HelloWorld/"
function log(info) {
    console.log(info);
    if (uexLog) {
        uexLog.sendLog(info);
    }
}

function alertX(content) {
    appcan.window.alert("提示", content);
}

function extend(target, source) {
    for (var p in source) {
        if (source.hasOwnProperty(p)) {
            target[p] = source[p];
        }
    }

    return target;
};

function openWin(opt) {
    var defaultOpt = {
        name : opt.name,
        dataType : 0,
        type : 0,
        aniId : 2,
        data : opt.name + ".html",
        extraInfo : {

        }
    };
    opt = extend(defaultOpt, opt);
    log(opt);
    appcan.window.open(opt);
}

function closeWin() {
    appcan.window.close(-1);
}

function openLoading(info) {
    var msg = '正在加載...';
    if (info) {
        msg = info;
    }
    appcan.window.openToast({
        msg : msg,
        duration : -1,
        position : 5,
        type : 1
    });
}

function closeToast() {
    appcan.window.closeToast();
}

function ajax(opt, loading) {
    var isload = true;
    if (loading == 1) {
        isload = false;
    }
    var defaultOpt = {
        url : "",
        type : "GET",
        data : {},
        dataType : 'json',
        timeout : 15000, //超時時間
        loading : isload,
        cache : false,
        error : function(xhr, type) {
            closeToast();
            alert('Ajax error!');
        }
    };
    opt.url = serverURL + opt.url;
    opt = extend(defaultOpt, opt);

    log("start request:" + opt.url + "--||--" + opt.type);
    log("request data:" + JSON.stringify(opt.data));
    if (opt.loading) {
        opt.beforeSend = function(xhr, settings) {
            openLoading();
        };
    }

    if (opt.successx) {
        opt.success = function(data, status) {
            closeToast();
            if (status != "success") {
                alert('Server error!');
                return;
            }
            log(JSON.stringify(data));
            opt.successx(data);
        }
    }
    appcan.request.ajax(opt);
}

function getFormField(selector) {
    var arr = $(selector).serializeArray();
    var param = {};
    for (var i = 0; i < arr.length; i++) {
        var p = arr[i];
        param[p.name] = p.value;
    }
    return param;
}

function setWinParam(param) {
    localStorage.winParam = null;
    localStorage.winParam = JSON.stringify(param);
}

function getWinParam() {
    var p = null;
    if (localStorage.winParam) {
        p = JSON.parse(localStorage.winParam);
        localStorage.winParam = null;
    }
    return p;
}

function setUserId(userId) {
    localStorage.currentUserId = userId;
}

function getUserId() {
    return localStorage.currentUserId;
}

function setZW(zw) {
    localStorage.currentZW = zw;
}

function getZW() {
    return localStorage.currentZW;
}

function setReportLvType(type) {
    localStorage.currentReportLvType = type;
}

function getReportLvType() {
    return localStorage.currentReportLvType;
}

function initBounce(funcTop, funcBottom) {
    uexWindow.setBounce("1");
    if (!funcTop && !funcBottom) {
        uexWindow.showBounceView("0", "rgba(255,255,255,0)", "0");
        uexWindow.showBounceView("1", "rgba(255,255,255,0)", "0");
        return;
    }
    var top = 0,
        btm = 1;
    uexWindow.onBounceStateChange = function(type, state) {

        if (type == top && state == 2) {//頂部彈動
            funcTop();
            uexWindow.resetBounceView("0");
        }
        if (type == btm && state == 2) {//底部彈動
            funcBottom();
            uexWindow.resetBounceView("1");
        }

    }
    if (funcTop) {
        uexWindow.setBounceParams('0', "{'pullToReloadText':'下拉刷新','releaseToReloadText':'釋放刷新','loadingText':'正在刷新,請稍候'}");
        uexWindow.showBounceView(top, "rgba(255,255,255,0)", 1);
        uexWindow.notifyBounceEvent(top, 1);
    }
    if (funcBottom) {
        uexWindow.setBounceParams('1', "{'pullToReloadText':'加載更多','releaseToReloadText':'加載更多','loadingText':'加載中,請稍候'}");
        uexWindow.showBounceView(btm, "rgba(255,255,255,0)", 1);
        //設置彈動位置及效果([1:顯示內容;0:不顯示])
        uexWindow.notifyBounceEvent(btm, 1);
        //注冊接收彈動事件([0:不接收onBounceStateChange方法回調;1:接收])
    }
}

/**
 * 獲取當前日期
 * 格式為:yyyy-MM-dd
 */
function getNowDate() {
    var now = new Date();
    y = now.getFullYear();
    m = now.getMonth() + 1;
    d = now.getDate();
    m = m < 10 ? "0" + m : m;
    d = d < 10 ? "0" + d : d;
    return y + "-" + m + "-" + d;
}

/**
 * 獲取明天日期
 * 格式為:yyyy-MM-dd
 */
function getTomorrowDate() {
    var nd = new Date(getNowDate());
    nd = nd.valueOf();
    // nd = nd + 1 * 24 * 60 * 60 * 1000;
    nd = new Date(nd);
    var y = nd.getFullYear();
    var m = nd.getMonth() + 1;
    var d = nd.getDate();
    if (m <= 9) {
        m = "0" + m;
    }

    if (d <= 9) {
        d = "0" + d;
    }

    return y + "-" + m + "-" + d;
}

/**
 * 獲取當前日期
 * 格式為:HH
 */
function getNowDateHH() {
    var now = new Date();
    var i = now.getHours();
    if (i < 10) {
        i = "0" + i;
    }
    return i;

}

//監聽安卓的返回功能

var closeflag = 0;
/**
 * 攔截物理返回鍵
 * 雙擊退出程序
 */
function doubleExit() {
    var plat = uexWidgetOne.getPlatform();
    if (plat) {
        uexWindow.onKeyPressed = function(keyCode) {
            if (keyCode == 0) {
                if (closeflag == 1) {
                    uexWidgetOne.exit(0);
                }
                uexWindow.toast(0, 5, "再次點擊退出程序", 2000);
                closeflag = 1;
                setTimeout(function() {
                    closeflag = 0;
                }, 2000);
            }
        }
        uexWindow.setReportKey(0, 1);
    }
}

/**
 * 為頁面添加覆蓋層
 * 防止誤操作或重復操作
 * @param headId:頁面head的id
 * @param pageId:頁面的id
 */

function open_cover(headId, pageId, popName, popHtml) {
    headId = '#' + headId;
    pageId = '#' + pageId;
    var titHeight = $(headId).offset().height;
    var page = window.getComputedStyle($(pageId)[0], null);
    var pagew = parseInt(page.width);
    var pageh = parseInt(page.height);
    uexWindow.openPopover(popName, "0", popHtml, "", "0", titHeight, pagew, pageh, "2", "0");
}

/**
 * 關閉pop窗口
 * @param  popName
 */
function close_cover(popName) {
    appcan.closePopover((popName) ? popName : 'coverpop');
}

/**
 *獲取上月日期
 */
function getLastMonth() {
    var now = new Date();
    y = now.getFullYear();
    m = now.getMonth();
    if (m == 0) {
        m = 12;
        y = y - 1;
    }
    m = m < 10 ? "0" + m : m;
    return y + "年" + m;
}

/**
 *解決后台mySql數據庫中傳來的datetime數據最后以.0結尾的問題
 */
function format(datetime) {
    return datetime.substring(0, datetime.lastIndexOf('.'))
}

function checkVersion(state) {
    var versionId = getLocVal('versionId');
    if (!versionId) {
        versionId = 0;
    }
    ajax({
        url : "appcanAjax/appversion_checkVersion",
        data : {
            id : versionId,
        },
        dataType : "json",
        successx : function(data) {
            var versionId = data.id;
            var versionNo = data.versionNo;
            if (data.state == 1) {
                uexWindow.cbConfirm = function(opId, dataType, data) {
                    if (data == 1)
                        updateVersion(versionId, versionNo);
                }
                uexWindow.confirm('提示', '發現有新的版本,是否立即更新?', ['下次再說', '立即更新']);
            } else {
                if (state == 1) {
                    //程序里手動檢測版本
                    $toast('當前為最新版本!', 2000);
                }else{
                    setLocVal('versionNo', versionNo);
                    setLocVal('versionId', versionId);
                }

            }
        },
        error : function(xhr, type) {
            //$toast("網絡連接超時", 3500);
        }
    }, 1);
}

function updateVersion(versionId, versionNo) {
    
    //下載地址
    var url = 'http://60.210.98.67:81/baoxiu.apk';
    //存儲路徑
    var path = 'wgt://data/down/baoxiu.apk';
    uexFileMgr.deleteFileByPath(path);
    uexDownloaderMgr.createDownloader(1);
    uexDownloaderMgr.cbCreateDownloader = function(opCode, dataType, data) {
        switch(dataType) {
        case 0:
            alert("uex.cText");
            break;
        case 1:
            alert("uex.cJson");
            break;
        case 2:
            if (data == 0) {
                uexDownloaderMgr.download(1, url, path, '1');
            } 
            break;
        default:
            alert("error");
        }
    }

    uexDownloaderMgr.onStatus = function(opCode, fileSize, percent, status) {
        switch (status) {
        case 0:
            $toast("下載進度:" + percent + "%");
            break;
        case 1:
            $toast("下載完成", 2000);
            uexDownloaderMgr.closeDownloader(1);
            setTimeout(function() {
                uexWidget.installApp(path);
                setLocVal('versionNo', versionNo);
                setLocVal('versionId', versionId);
            }, 2000)
            break;
        case 2:
            $toast("下載失敗", 2000);
            uexDownloaderMgr.closeDownloader(1);
            break;
        case 3:
            $toast("已取消下載", 2000);
            break;
        }
    }
}

// function findUsreLocation() {
    // uexLocation.openLocation();
// 
    // // uexLocation.cbOpenLocation = function(opId, dataType, data) {
        // // alert(opId + "," + dataType + "," + data);
    // // }
// 
    // uexLocation.onChange =  function(lat,log) {
//         
         // //   alert(log+","+lat);
    // }
// }
js

 //注意

要先關閉寫入的攔截器


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM