memberInfo.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>个人信息</title>
  6. <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
  7. <meta name="apple-mobile-web-app-capable" content="yes">
  8. <meta name="apple-mobile-web-app-status-bar-style" content="black">
  9. <!--标准mui.css-->
  10. <link rel="stylesheet" href="../../css/mui.min.css">
  11. <link href="../../css/OA-style.css" rel="stylesheet" />
  12. <!--App自定义的css-->
  13. <style type="text/css">
  14. .mui-content>.mui-table-view:first-child {
  15. margin-top: -1px;
  16. }
  17. .mui-bar-nav {
  18. box-shadow: none;
  19. }
  20. .mui-col-xs-2 {
  21. /*width: calc(100% - 50px);*/
  22. width: calc(100% - 10%);
  23. vertical-align: middle;
  24. padding: 11px 15px;
  25. }
  26. .mui-col-xs-10 {
  27. width: 24px;
  28. vertical-align: middle;
  29. }
  30. .mui-col-xs-10 img {
  31. width: 100%;
  32. }
  33. .mui-col-xs-2 h4 {
  34. color: #666;
  35. font-size: 14px;
  36. }
  37. .mui-col-xs-2 h5 {
  38. font-size: 14px;
  39. color: #468CF0;
  40. }
  41. .mui-table-view-cell:after {
  42. left: 0px;
  43. }
  44. .mui-input-row label {
  45. padding: 0;
  46. line-height: 21px;
  47. }
  48. input[type=color],
  49. input[type=date],
  50. input[type=datetime-local],
  51. input[type=datetime],
  52. input[type=email],
  53. input[type=month],
  54. input[type=number],
  55. input[type=password],
  56. input[type=search],
  57. input[type=tel],
  58. input[type=text],
  59. input[type=time],
  60. input[type=url],
  61. input[type=week],
  62. select,
  63. textarea {
  64. padding: 0;
  65. height: auto;
  66. }
  67. </style>
  68. </head>
  69. <body>
  70. <header class="mui-bar mui-bar-nav" id="login">
  71. <a href="" class="mui-action-back back mui-pull-left"><img src="../../images/back.png"></a>
  72. </header>
  73. <div class="mui-content">
  74. <div class="geren">
  75. <div class="geren_touxiang"><img id="changeimg" src="../../images/user-photo.png"></div>
  76. </div>
  77. <div class="geren_ziliao">
  78. <h1><span id="username">&nbsp;</span></h1>
  79. <h2><span id="departname">&nbsp;</span>- <span id="positionname">&nbsp;</span></h2>
  80. <!--<a id="telhref" href="javaScript:void(0);"><button>拨打电话</button></a>-->
  81. </div>
  82. <div class="lianxi">
  83. <div class="lianxi_item">
  84. <div class=" mui-table">
  85. <div class="mui-table-cell mui-col-xs-10"><img src="../../images/me_telephone.png"></div>
  86. <div class="mui-table-cell mui-col-xs-2 mui-text-left">
  87. <h4 class="mui-ellipsis">手机</h4>
  88. <h5><span id="tel">&nbsp;</span></h5>
  89. </div>
  90. </div>
  91. </div>
  92. <div class="lianxi_item">
  93. <div class=" mui-table">
  94. <div class="mui-table-cell mui-col-xs-10"><img src="../../images/me_E_mail.png"></div>
  95. <div class="mui-table-cell mui-col-xs-2 mui-text-left">
  96. <h4 class="mui-ellipsis">邮箱</h4>
  97. <h5><span id="email">&nbsp;</span></h5>
  98. </div>
  99. </div>
  100. </div>
  101. </div>
  102. <ul class="mui-table-view " style="margin-top: 15px;">
  103. <li class="mui-table-view-cell mui-input-row">
  104. <label>性别</label>
  105. <span id="sex">女</span>
  106. </li>
  107. <li class="mui-table-view-cell mui-input-row">
  108. <label>生日</label>
  109. <span id="birthday"></span>
  110. </li>
  111. </ul>
  112. </div>
  113. <script src="../../js/mui.min.js"></script>
  114. <script src="../../js/app.js"></script>
  115. <script src="../../js/config.js"></script>
  116. <script src="../../js/dj/person/person.js"></script>
  117. <script>
  118. mui.init({
  119. beforeback: function() {
  120. //获得列表界面的webview
  121. var list = plus.webview.currentWebview().opener();
  122. //触发列表界面的自定义事件(refresh),从而进行数据刷新
  123. mui.fire(list, 'refresh');
  124. //返回true,继续页面关闭逻辑
  125. return true;
  126. }
  127. });
  128. mui.plusReady(function() {
  129. getMemberInfo(function(data) {
  130. var memeber = data.returnParams;
  131. memeber = memeber[0];
  132. console.log(JSON.stringify(memeber))
  133. if(memeber) {
  134. document.getElementById("username").innerHTML = memeber.name;
  135. document.getElementById("departname").innerHTML = memeber.deptName;
  136. document.getElementById("positionname").innerHTML = memeber.positionName;
  137. var email = "暂无";
  138. if(memeber.email) {
  139. email = memeber.email;
  140. }
  141. document.getElementById("email").innerHTML = email;
  142. var tel = "暂无";
  143. if(memeber.contact_tel1) {
  144. tel = memeber.contact_tel1;
  145. // document.getElementById("telhref").href = "tel:" + tel;
  146. }
  147. if(memeber.photo) {
  148. document.getElementById("changeimg").src = API.API_IP_PORT + memeber.photo;
  149. }
  150. document.getElementById("tel").innerHTML = tel;
  151. document.getElementById("birthday").innerHTML = memeber.birthday;
  152. var sex = memeber.sex;
  153. if('M' == sex) {
  154. document.getElementById("sex").innerHTML = '男';
  155. } else {
  156. document.getElementById("sex").innerHTML = '女';
  157. }
  158. //document.getElementById("integral").innerHTML = memeber.integral;
  159. }
  160. });
  161. /*document.getElementById('changeimg').addEventListener('tap', function() {
  162. var src = document.getElementById('changeimg').src;
  163. openFile(src);
  164. }, false);*/
  165. })
  166. //拍照触发监听
  167. document.getElementById("changeimg").addEventListener("tap", function() {
  168. if(mui.os.plus) {
  169. var a = [{
  170. title: "拍照"
  171. },
  172. {
  173. title: "从手机相册选择"
  174. }
  175. ]
  176. plus.nativeUI.actionSheet({
  177. title: "修改用户头像",
  178. cancel: "取消",
  179. buttons: a
  180. }, function(b) { //actionsheet 点击之后出现的东西
  181. switch(b.index) {
  182. case 0:
  183. break;
  184. case 1:
  185. getImage();
  186. break;
  187. case 2:
  188. getimg();
  189. break;
  190. default:
  191. break;
  192. }
  193. })
  194. }
  195. });
  196. //获取相册
  197. function getimg() {
  198. plus.gallery.pick(function(a) {
  199. plus.io.resolveLocalFileSystemURL(a, function(entry) {
  200. plus.io.resolveLocalFileSystemURL("_doc/", function(root) {
  201. root.getFile("head.png", {}, function(file) {
  202. //文件已存在
  203. file.remove(function() {
  204. console.log("删除成功");
  205. entry.copyTo(root, "head.png", function(e) {
  206. var e = e.fullPath + "?version=" + new Date().getTime();
  207. //显示头像图片
  208. var mainImage = document.getElementById("changeimg");
  209. mainImage.src = e; //显示头像图片
  210. //getImageSize(e); /*上判断图片的大小*/
  211. uploadHead(e);
  212. //变更大的图预览的src
  213. //目前只有一张图暂且这样处理,后续需要用标准组件实现
  214. }, function(e) {
  215. console.log("copy img file:" + e.message);
  216. });
  217. }, function() {
  218. console.log("删除" + e.message)
  219. });
  220. }, function() {
  221. //文件不存在
  222. entry.copyTo(root, "head.png", function(e) {
  223. var path = e.fullPath + "?version=" + new Date().getTime();
  224. //显示头像图片
  225. var mainImage = document.getElementById("changeimg");
  226. mainImage.src = e; //显示头像图片
  227. //getImageSize(e); /*上判断图片的大小*/
  228. uploadHead(e);
  229. }, function(e) {
  230. console.log("copy img file:" + e.message);
  231. });
  232. });
  233. }, function(e) {
  234. console.log("get _www folder fail");
  235. })
  236. }, function(e) {
  237. console.log("读取拍照文件错误" + e.message);
  238. })
  239. }, function(a) {}, {
  240. filter: "image"
  241. })
  242. }
  243. // 拍照
  244. function getImage() {
  245. var cmr = plus.camera.getCamera();
  246. cmr.captureImage(function(p) {
  247. plus.io.resolveLocalFileSystemURL(p, function(entry) {
  248. var s = entry.toLocalURL() + "?version=" + new Date().getTime();
  249. //uploadHead(s); //上传图片
  250. var mainImage = document.getElementById("changeimg");
  251. mainImage.src = s; //显示头像图片
  252. getImageSize(s); /*上判断图片的大小*/
  253. }, function(e) {
  254. plus.nativeUI.toast("读取拍照文件错误:" + e.message);
  255. });
  256. }, function(e) {}, {
  257. filename: "_doc/camera/",
  258. index: 1
  259. });
  260. }
  261. //判断图片/*上判断图片的大小*/
  262. function getImageSize(imagePath) {
  263. //alert("=========>getImageSize==begin");
  264. //nwaiting = plus.nativeUI.showWaiting("上传中..");
  265. var image = new Image();
  266. image.src = imagePath;
  267. image.onload = function() {
  268. var imgData = getBase64(image);
  269. var width = image.width;
  270. var height = image.height;
  271. var fileSize = image.fileSize;
  272. //alert(width + '======' + height + "=====" + fileSize);
  273. imgData = imgData.substring(22);
  274. var equalIndex = imgData.indexOf("=");
  275. if(imgData.indexOf("=") > 0) {
  276. imgData = imgData.substring(0, equalIndex);
  277. }
  278. var imgDataLength = imgData.length; // base64字符流
  279. var fileLength = parseInt(imgDataLength - (imgDataLength / 8) * 2); //字节流大小
  280. //alert(fileLength / 1024);
  281. //imgArray.push(imagePath);
  282. //sizeArray.push(fileLength / 1024);
  283. var imageSize = fileLength / 1024;
  284. imgSize = imageSize;
  285. if(imageSize > 500) {
  286. fnImageZip(imagePath);
  287. } else {
  288. uploadHead(imagePath); /*上传图片*/
  289. }
  290. }
  291. //alert("=========>getImageSize==end");
  292. }
  293. var imgSize = 0;
  294. //转换64
  295. function getBase64(img) {
  296. var canvas = document.createElement("canvas");
  297. var width = img.width;
  298. var height = img.height;
  299. canvas.width = width;
  300. canvas.height = height;
  301. var ctx = canvas.getContext("2d");
  302. ctx.drawImage(img, 0, 0, width, height); /*绘图*/
  303. var dataURL = canvas.toDataURL("image/png");
  304. return dataURL.replace("data:image/png;base64,", "");
  305. }
  306. /**
  307. * 压缩图片
  308. * @param {Object} imagePath
  309. */
  310. function fnImageZip(imagePath) {
  311. //alert("====>fnImageZip==begin");
  312. alert("====>" + imagePath);
  313. plus.zip.compressImage({
  314. src: imagePath,
  315. dst: '_doc/zip_' + RndNum(11) + imagePath.substr(imagePath.lastIndexOf('/') + 1),
  316. quality: 20, //质量1-100
  317. overwrite: false //overwrite: (Boolean 类型 )覆盖生成新文件
  318. },
  319. function(zip) {
  320. //alert("success");
  321. alert(zip.target);
  322. var target = zip.target; // 压缩转换后的图片url路径,以"file://"开头
  323. uploadHead(target); /*上传图片*/
  324. },
  325. function(error) {
  326. //alert("end");
  327. uploadHead(imagePath); /*上传图片*/
  328. });
  329. //alert("=========>fnImageZip==end");
  330. }
  331. function submitData(data) {
  332. var serviceId = "eu_2018V01_head_phone_upload";
  333. var state = app.getState(); //获取登陆信息
  334. var obj = {
  335. userId: state.user.useId,
  336. phone_upload: data
  337. }
  338. //alert("po");
  339. app.ajax(serviceId, obj, function(data) {
  340. console.log(data);
  341. if(data) {
  342. mui.toast("上传成功");
  343. //nwaiting.close();
  344. }
  345. });
  346. }
  347. //转换64
  348. function getBase64Image(img) {
  349. var canvas = document.createElement("canvas");
  350. var width = img.width;
  351. var height = img.height;
  352. if(width > height) {
  353. if(width > 100) {
  354. height = Math.round(height *= 100 / width);
  355. width = 100;
  356. }
  357. } else {
  358. if(height > 100) {
  359. width = Math.round(width *= 100 / height);
  360. height = 100;
  361. }
  362. }
  363. canvas.width = width;
  364. canvas.height = height;
  365. var ctx = canvas.getContext("2d");
  366. ctx.drawImage(img, 0, 0, width, height); /*绘图*/
  367. var dataURL = canvas.toDataURL("image/png", 0.8);
  368. return dataURL.replace("data:image/png;base64,", "");
  369. }
  370. //转换64
  371. function getBase64Image2(img) {
  372. var canvas = document.createElement("canvas");
  373. var width = img.width;
  374. var height = img.height;
  375. if(imgSize > 500) {
  376. alert("getBase64Image压缩" + imgSize)
  377. var num;
  378. if(width > height) {
  379. num = width / 1.5;
  380. } else {
  381. num = height / 1.5;
  382. }
  383. if(width > height) {
  384. if(width > num) {
  385. height = Math.round(height *= num / width);
  386. width = num;
  387. }
  388. } else {
  389. if(height > num) {
  390. width = Math.round(width *= num / height);
  391. height = num;
  392. }
  393. }
  394. }
  395. canvas.width = width;
  396. canvas.height = height;
  397. var ctx = canvas.getContext("2d");
  398. ctx.drawImage(img, 0, 0, width, height); /*绘图*/
  399. var dataURL = canvas.toDataURL("image/png", 0.8);
  400. return dataURL.replace("data:image/png;base64,", "");
  401. }
  402. //上传头像图片
  403. function uploadHead(imgPath) {
  404. //alert("=========>uploadHead==begin");
  405. var nwaiting = plus.nativeUI.showWaiting("加载中,请等待...", {
  406. loading: {
  407. display: "inline"
  408. }
  409. });
  410. var image = new Image();
  411. image.src = imgPath;
  412. image.onload = function() {
  413. var imgData = getBase64Image(image);
  414. var serviceId = "eu_2018V01_head_phone_upload";
  415. var state = app.getState(); //获取登陆信息
  416. var obj = {
  417. userId: state.user.useId,
  418. phone_upload: imgData
  419. }
  420. //alert("po");
  421. app.ajax(serviceId, obj, function(data) {
  422. console.log(data);
  423. if(data) {
  424. mui.toast("上传成功");
  425. nwaiting.close();
  426. }
  427. });
  428. }
  429. }
  430. function RndNum(n) {
  431. var rnd = "";
  432. for(var i = 0; i < n; i++)
  433. rnd += Math.floor(Math.random() * 10);
  434. return rnd;
  435. }
  436. </script>
  437. </body>
  438. </html>