ddxiami

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 3437|回复: 0

[其它] APP封装和安装插件

[复制链接]
发表于 2017-8-18 16:48:43 | 显示全部楼层 |阅读模式
##Andriod封装

#建立目录
cordova create cfjrAndroid

#添加platform
cd cfjrAndroid
cordova platform add android

#添加插件
cordova plugin add cordova-plugin-crosswalk-webview
cordova plugin rm cordova-plugin-crosswalk-webview
cordova plugin add cordova-plugin-inappbrowser

cordova plugin add cordova-plugin-device-orientation
cordova plugin add cordova-plugin-screen-orientation

cordova plugin add cordova-plugin-x-socialsharing
cordova prepare

cordova plugin add cordova-plugin-device
cordova plugin add cordova-plugin-app-version


cordova plugin add cordova-plugin-file-transfer
cordova plugin add cordova-plugin-camera
cordova plugin add cordova-plugin-splashscreen


#待测试
cordova plugin add cordova-plugin-whitelist


#编译
cordova build android

#文件index.html
======================================================================
<!DOCTYPE html>

<html>
<head>
    <meta charset="utf-8">
    <meta content="telephone=no" name="format-detection">
    <!-- WARNING: for iOS 7, remove the width=device-width and height=device-height attributes. See https://issues.apache.org/jira/browse/CB-4323 -->
    <meta content=
                  "user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi"
          name="viewport">
    <script src="cordova.js" type="text/javascript"></script>
    <script src="js/index.js" type="text/javascript"></script>
    <title>Camera Cordova Plugin</title>
</head>

<body>
<button>Capture Photo</button><br>
<button>From Photo
    Library</button><br>
<img id="image" src="" style="display:none;width:100%;">
<button>Upload</button>
</body>
</html>
======================================================================

#文件index.js
======================================================================
var pictureSource; // picture source
var destinationType; // sets the format of returned value
// Wait for device API libraries to load
//
document.addEventListener("deviceready", onDeviceReady, false);
// device APIs are available
//

function onDeviceReady() {
    pictureSource = navigator.camera.PictureSourceType;
    destinationType = navigator.camera.DestinationType;
}
// Called when a photo is successfully retrieved
//

function onPhotoDataSuccess(imageURI) {
        alert("fire");
    // Uncomment to view the base64-encoded image data
    console.log(imageURI);
    // Get image handle
    //
    var cameraImage = document.getElementById('image');
    // Unhide image elements
    //
    cameraImage.style.display = 'block';
    // Show the captured photo
    // The inline CSS rules are used to resize the image
    //
    cameraImage.src = imageURI;
}
// Called when a photo is successfully retrieved
//

function onPhotoURISuccess(imageURI) {
        alert("fire");
    // Uncomment to view the image file URI
    console.log(imageURI);
    // Get image handle
    //
    var galleryImage = document.getElementById('image');
    // Unhide image elements
    //
    galleryImage.style.display = 'block';
    // Show the captured photo
    // The inline CSS rules are used to resize the image
    //
    galleryImage.src = imageURI;
}
// A button will call this function
//

function capturePhoto() {
    // Take picture using device camera and retrieve image as base64-encoded string
    navigator.camera.getPicture(onPhotoDataSuccess, onFail, {
        quality: 30,
        targetWidth: 600,
        targetHeight: 600,
        destinationType: destinationType.FILE_URI,
        saveToPhotoAlbum: true
    });
}
// A button will call this function
//

function getPhoto(source) {
    // Retrieve image file location from specified source
    navigator.camera.getPicture(onPhotoURISuccess, onFail, {
        quality: 30,
        targetWidth: 600,
        targetHeight: 600,
        destinationType: destinationType.FILE_URI,
        sourceType: source
    });
}
// Called if something bad happens.
//

function onFail(message) {
    //alert('Failed because: ' + message);
}

function upload() {
    var img = document.getElementById('image');
    var imageURI = img.src;
    var options = new FileUploadOptions();
    options.fileKey = "file";
    options.fileName = imageURI.substr(imageURI.lastIndexOf('/') + 1);
    options.mimeType = "image/jpeg";
    var params = new Object();
    options.params = params;
    options.chunkedMode = false;
    var ft = new FileTransfer();
    ft.upload(imageURI, "http://cfjr.ddxiami.com/upload.php", win, fail,
        options);
}

function win(r) {
    console.log("Code = " + r.responseCode);
    console.log("Response = " + r.response);
    console.log("Sent = " + r.bytesSent);
}

function fail(error) {
    alert("An error has occurred: Code = " + error.code);
    console.log("upload error source " + error.source);
    console.log("upload error target " + error.target);
}
======================================================================

#APP图标
#启动画面
http://www.cnblogs.com/a420120206/p/5856371.html
http://blog.csdn.net/bobo8945510/article/details/52883751

#IOS顶部覆盖问题
http://blog.csdn.net/alex8046/article/details/43835851
======================================================================
#pragma mark View lifecycle

- (void)viewWillAppear:(BOOL)animated
{
    // View defaults to full size.  If you want to customize the view's size, or its subviews (e.g. webView),
    // you can do so here.

    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
        CGRect viewBounds = [self.webView bounds];
        viewBounds.origin.y = 20;
        viewBounds.size.height = viewBounds.size.height - 20;
        self.webView.frame = viewBounds;
    }

    [super viewWillAppear:animated];
}
======================================================================

#IOS打包过程
http://www.jianshu.com/p/6e228ce32ccd
https://www.pgyer.com/cfjrtestios
pre.im和蒲公英









回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|技术文档库 ( 闽ICP备15017263号-2 )|网站地图

GMT+8, 2025-5-18 17:29 , Processed in 0.035306 second(s), 16 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表