| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>个人信息</title>
- <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
- <meta name="apple-mobile-web-app-capable" content="yes">
- <meta name="apple-mobile-web-app-status-bar-style" content="black">
- <!--标准mui.css-->
- <link rel="stylesheet" href="../../css/mui.min.css">
- <link href="../../css/OA-style.css" rel="stylesheet" />
- <!--App自定义的css-->
- <style type="text/css">
- .mui-content>.mui-table-view:first-child {
- margin-top: -1px;
- }
-
- .mui-bar-nav {
- box-shadow: none;
- }
-
- .mui-col-xs-2 {
- /*width: calc(100% - 50px);*/
- width: calc(100% - 10%);
- vertical-align: middle;
- padding: 11px 15px;
- }
-
- .mui-col-xs-10 {
- width: 24px;
- vertical-align: middle;
- }
-
- .mui-col-xs-10 img {
- width: 100%;
- }
-
- .mui-col-xs-2 h4 {
- color: #666;
- font-size: 14px;
- }
-
- .mui-col-xs-2 h5 {
- font-size: 14px;
- color: #468CF0;
- }
-
- .mui-table-view-cell:after {
- left: 0px;
- }
-
- .mui-input-row label {
- padding: 0;
- line-height: 21px;
- }
-
- input[type=color],
- input[type=date],
- input[type=datetime-local],
- input[type=datetime],
- input[type=email],
- input[type=month],
- input[type=number],
- input[type=password],
- input[type=search],
- input[type=tel],
- input[type=text],
- input[type=time],
- input[type=url],
- input[type=week],
- select,
- textarea {
- padding: 0;
- height: auto;
- }
- </style>
- </head>
- <body>
- <header class="mui-bar mui-bar-nav" id="login">
- <a href="" class="mui-action-back back mui-pull-left"><img src="../../images/back.png"></a>
- </header>
- <div class="mui-content">
- <div class="geren">
- <div class="geren_touxiang"><img id="changeimg" src="../../images/user-photo.png"></div>
- </div>
- <div class="geren_ziliao">
- <h1><span id="username"> </span></h1>
- <h2><span id="departname"> </span>- <span id="positionname"> </span></h2>
- <!--<a id="telhref" href="javaScript:void(0);"><button>拨打电话</button></a>-->
- </div>
- <div class="lianxi">
- <div class="lianxi_item">
- <div class=" mui-table">
- <div class="mui-table-cell mui-col-xs-10"><img src="../../images/me_telephone.png"></div>
- <div class="mui-table-cell mui-col-xs-2 mui-text-left">
- <h4 class="mui-ellipsis">手机</h4>
- <h5><span id="tel"> </span></h5>
- </div>
- </div>
- </div>
- <div class="lianxi_item">
- <div class=" mui-table">
- <div class="mui-table-cell mui-col-xs-10"><img src="../../images/me_E_mail.png"></div>
- <div class="mui-table-cell mui-col-xs-2 mui-text-left">
- <h4 class="mui-ellipsis">邮箱</h4>
- <h5><span id="email"> </span></h5>
- </div>
- </div>
- </div>
- </div>
- <ul class="mui-table-view " style="margin-top: 15px;">
- <li class="mui-table-view-cell mui-input-row">
- <label>性别</label>
- <span id="sex">女</span>
- </li>
- <li class="mui-table-view-cell mui-input-row">
- <label>生日</label>
- <span id="birthday"></span>
- </li>
- </ul>
- </div>
- <script src="../../js/mui.min.js"></script>
- <script src="../../js/app.js"></script>
- <script src="../../js/config.js"></script>
- <script src="../../js/dj/person/person.js"></script>
- <script>
- mui.init({
- beforeback: function() {
- //获得列表界面的webview
- var list = plus.webview.currentWebview().opener();
- //触发列表界面的自定义事件(refresh),从而进行数据刷新
- mui.fire(list, 'refresh');
- //返回true,继续页面关闭逻辑
- return true;
- }
- });
- mui.plusReady(function() {
- getMemberInfo(function(data) {
- var memeber = data.returnParams;
- memeber = memeber[0];
- console.log(JSON.stringify(memeber))
- if(memeber) {
- document.getElementById("username").innerHTML = memeber.name;
- document.getElementById("departname").innerHTML = memeber.deptName;
- document.getElementById("positionname").innerHTML = memeber.positionName;
- var email = "暂无";
- if(memeber.email) {
- email = memeber.email;
- }
- document.getElementById("email").innerHTML = email;
- var tel = "暂无";
- if(memeber.contact_tel1) {
- tel = memeber.contact_tel1;
- // document.getElementById("telhref").href = "tel:" + tel;
- }
- if(memeber.photo) {
- document.getElementById("changeimg").src = API.API_IP_PORT + memeber.photo;
- }
- document.getElementById("tel").innerHTML = tel;
- document.getElementById("birthday").innerHTML = memeber.birthday;
- var sex = memeber.sex;
- if('M' == sex) {
- document.getElementById("sex").innerHTML = '男';
- } else {
- document.getElementById("sex").innerHTML = '女';
- }
- //document.getElementById("integral").innerHTML = memeber.integral;
- }
- });
- /*document.getElementById('changeimg').addEventListener('tap', function() {
- var src = document.getElementById('changeimg').src;
- openFile(src);
- }, false);*/
- })
- //拍照触发监听
- document.getElementById("changeimg").addEventListener("tap", function() {
- if(mui.os.plus) {
- var a = [{
- title: "拍照"
- },
- {
- title: "从手机相册选择"
- }
- ]
- plus.nativeUI.actionSheet({
- title: "修改用户头像",
- cancel: "取消",
- buttons: a
- }, function(b) { //actionsheet 点击之后出现的东西
- switch(b.index) {
- case 0:
- break;
- case 1:
- getImage();
- break;
- case 2:
- getimg();
- break;
- default:
- break;
- }
- })
- }
- });
- //获取相册
- function getimg() {
- plus.gallery.pick(function(a) {
- plus.io.resolveLocalFileSystemURL(a, function(entry) {
- plus.io.resolveLocalFileSystemURL("_doc/", function(root) {
- root.getFile("head.png", {}, function(file) {
- //文件已存在
- file.remove(function() {
- console.log("删除成功");
- entry.copyTo(root, "head.png", function(e) {
- var e = e.fullPath + "?version=" + new Date().getTime();
- //显示头像图片
- var mainImage = document.getElementById("changeimg");
- mainImage.src = e; //显示头像图片
- //getImageSize(e); /*上判断图片的大小*/
- uploadHead(e);
- //变更大的图预览的src
- //目前只有一张图暂且这样处理,后续需要用标准组件实现
- }, function(e) {
- console.log("copy img file:" + e.message);
- });
- }, function() {
- console.log("删除" + e.message)
- });
- }, function() {
- //文件不存在
- entry.copyTo(root, "head.png", function(e) {
- var path = e.fullPath + "?version=" + new Date().getTime();
- //显示头像图片
- var mainImage = document.getElementById("changeimg");
- mainImage.src = e; //显示头像图片
- //getImageSize(e); /*上判断图片的大小*/
- uploadHead(e);
- }, function(e) {
- console.log("copy img file:" + e.message);
- });
- });
- }, function(e) {
- console.log("get _www folder fail");
- })
- }, function(e) {
- console.log("读取拍照文件错误" + e.message);
- })
- }, function(a) {}, {
- filter: "image"
- })
- }
- // 拍照
- function getImage() {
- var cmr = plus.camera.getCamera();
- cmr.captureImage(function(p) {
- plus.io.resolveLocalFileSystemURL(p, function(entry) {
- var s = entry.toLocalURL() + "?version=" + new Date().getTime();
- //uploadHead(s); //上传图片
- var mainImage = document.getElementById("changeimg");
- mainImage.src = s; //显示头像图片
- getImageSize(s); /*上判断图片的大小*/
- }, function(e) {
- plus.nativeUI.toast("读取拍照文件错误:" + e.message);
- });
- }, function(e) {}, {
- filename: "_doc/camera/",
- index: 1
- });
- }
- //判断图片/*上判断图片的大小*/
- function getImageSize(imagePath) {
- //alert("=========>getImageSize==begin");
- //nwaiting = plus.nativeUI.showWaiting("上传中..");
- var image = new Image();
- image.src = imagePath;
- image.onload = function() {
- var imgData = getBase64(image);
- var width = image.width;
- var height = image.height;
- var fileSize = image.fileSize;
- //alert(width + '======' + height + "=====" + fileSize);
- imgData = imgData.substring(22);
- var equalIndex = imgData.indexOf("=");
- if(imgData.indexOf("=") > 0) {
- imgData = imgData.substring(0, equalIndex);
- }
- var imgDataLength = imgData.length; // base64字符流
- var fileLength = parseInt(imgDataLength - (imgDataLength / 8) * 2); //字节流大小
- //alert(fileLength / 1024);
- //imgArray.push(imagePath);
- //sizeArray.push(fileLength / 1024);
- var imageSize = fileLength / 1024;
- imgSize = imageSize;
- if(imageSize > 500) {
- fnImageZip(imagePath);
- } else {
- uploadHead(imagePath); /*上传图片*/
- }
- }
- //alert("=========>getImageSize==end");
- }
- var imgSize = 0;
- //转换64
- function getBase64(img) {
- var canvas = document.createElement("canvas");
- var width = img.width;
- var height = img.height;
- canvas.width = width;
- canvas.height = height;
- var ctx = canvas.getContext("2d");
- ctx.drawImage(img, 0, 0, width, height); /*绘图*/
- var dataURL = canvas.toDataURL("image/png");
- return dataURL.replace("data:image/png;base64,", "");
- }
- /**
- * 压缩图片
- * @param {Object} imagePath
- */
- function fnImageZip(imagePath) {
- //alert("====>fnImageZip==begin");
- alert("====>" + imagePath);
- plus.zip.compressImage({
- src: imagePath,
- dst: '_doc/zip_' + RndNum(11) + imagePath.substr(imagePath.lastIndexOf('/') + 1),
- quality: 20, //质量1-100
- overwrite: false //overwrite: (Boolean 类型 )覆盖生成新文件
- },
- function(zip) {
- //alert("success");
- alert(zip.target);
- var target = zip.target; // 压缩转换后的图片url路径,以"file://"开头
- uploadHead(target); /*上传图片*/
- },
- function(error) {
- //alert("end");
- uploadHead(imagePath); /*上传图片*/
- });
- //alert("=========>fnImageZip==end");
- }
- function submitData(data) {
- var serviceId = "eu_2018V01_head_phone_upload";
- var state = app.getState(); //获取登陆信息
- var obj = {
- userId: state.user.useId,
- phone_upload: data
- }
- //alert("po");
- app.ajax(serviceId, obj, function(data) {
- console.log(data);
- if(data) {
- mui.toast("上传成功");
- //nwaiting.close();
- }
- });
- }
- //转换64
- function getBase64Image(img) {
- var canvas = document.createElement("canvas");
- var width = img.width;
- var height = img.height;
- if(width > height) {
- if(width > 100) {
- height = Math.round(height *= 100 / width);
- width = 100;
- }
- } else {
- if(height > 100) {
- width = Math.round(width *= 100 / height);
- height = 100;
- }
- }
- canvas.width = width;
- canvas.height = height;
- var ctx = canvas.getContext("2d");
- ctx.drawImage(img, 0, 0, width, height); /*绘图*/
- var dataURL = canvas.toDataURL("image/png", 0.8);
- return dataURL.replace("data:image/png;base64,", "");
- }
- //转换64
- function getBase64Image2(img) {
- var canvas = document.createElement("canvas");
- var width = img.width;
- var height = img.height;
- if(imgSize > 500) {
- alert("getBase64Image压缩" + imgSize)
- var num;
- if(width > height) {
- num = width / 1.5;
- } else {
- num = height / 1.5;
- }
- if(width > height) {
- if(width > num) {
- height = Math.round(height *= num / width);
- width = num;
- }
- } else {
- if(height > num) {
- width = Math.round(width *= num / height);
- height = num;
- }
- }
- }
- canvas.width = width;
- canvas.height = height;
- var ctx = canvas.getContext("2d");
- ctx.drawImage(img, 0, 0, width, height); /*绘图*/
- var dataURL = canvas.toDataURL("image/png", 0.8);
- return dataURL.replace("data:image/png;base64,", "");
- }
- //上传头像图片
- function uploadHead(imgPath) {
- //alert("=========>uploadHead==begin");
- var nwaiting = plus.nativeUI.showWaiting("加载中,请等待...", {
- loading: {
- display: "inline"
- }
- });
- var image = new Image();
- image.src = imgPath;
- image.onload = function() {
- var imgData = getBase64Image(image);
- var serviceId = "eu_2018V01_head_phone_upload";
- var state = app.getState(); //获取登陆信息
- var obj = {
- userId: state.user.useId,
- phone_upload: imgData
- }
- //alert("po");
- app.ajax(serviceId, obj, function(data) {
- console.log(data);
- if(data) {
- mui.toast("上传成功");
- nwaiting.close();
- }
- });
- }
- }
- function RndNum(n) {
- var rnd = "";
- for(var i = 0; i < n; i++)
- rnd += Math.floor(Math.random() * 10);
- return rnd;
- }
- </script>
- </body>
- </html>
|