123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- var userimg = document.getElementById("userimg");
- var flag;
- mui.plusReady(function() {
- var ws = plus.webview.currentWebview();
- var resourceId = ws.resourceId;
- console.log(resourceId)
- var web = plus.webview.getWebviewById("html/proinforupdate.html");
- var web1 = plus.webview.getWebviewById("resinforupdate.html");
- if(ws == web) {
- flag = 0;
- }
- if(ws == web1) {
- flag = 1;
- }
- userimg.addEventListener("click", function() {
- if(mui.os.plus) {
- var a = [{
- title: "拍照"
- }, {
- title: "从手机相册选择"
- }];
- plus.nativeUI.actionSheet({
- title: "修改头像",
- cancel: "取消",
- buttons: a
- }, function(b) {
- switch(b.index) {
- case 0:
- break;
- case 1:
- getImage();
- break;
- case 2:
- galleryImg();
- break;
- default:
- break
- }
- })
- }
- })
-
- function getImage() {
- var c = plus.camera.getCamera();
- c.captureImage(function(e) {
- plus.io.resolveLocalFileSystemURL(e, function(entry) {
- var filPage = plus.webview.getWebviewById('../html/fillinfo.html');
- var dyPage = plus.webview.currentWebview();
- if(dyPage == filPage) {
- var imgvar = '<img src="' + entry.toLocalURL() + '" style="width:100%"/>';
-
- document.getElementById('imgshow').innerHTML = imgvar;
- }
- mui.openWindow({
- url: '../html/picture-upload.html',
- id: 'html/picture-upload.html',
- show: {
- aniShow: "slide-in-right"
- },
- extras: {
- imgurl: entry.toLocalURL(),
- flag: flag,
- resourceId: resourceId
- }
- });
- }, function(e) {
- plus.nativeUI.toast("读取拍照文件错误", toastStyle);
- });
- }, function(s) {
- console.log("error" + s);
- }, {
- filename: "_doc/head.jpg"
- })
- }
-
- function galleryImg() {
- plus.gallery.pick(function(file) {
- changeToLocalUrl(file);
- }, function(err) {
- console.log(JSON.stringify(err));
- }, {
- filter: 'image',
- multiple: false
- });
- }
- function changeToLocalUrl(path) {
- plus.io.resolveLocalFileSystemURL(path, function(entry) {
- var filPage = plus.webview.getWebviewById('../html/fillinfo.html');
- var dyPage = plus.webview.currentWebview();
- if(dyPage == filPage) {
- var imgvar = '<img src="' + entry.toLocalURL() + '" style="width:100%"/>';
-
- document.getElementById('imgshow').innerHTML = imgvar;
- }
- mui.openWindow({
- url: '../html/picture-upload.html',
- id: 'html/picture-upload.html',
- show: {
- aniShow: "slide-in-right"
- },
- extras: {
- imgurl: entry.toLocalURL(),
- flag: flag,
- resourceId: resourceId
- }
- });
- });
- }
- })
|