| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405 |
- <!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" />
- <link href="../css/mui.min.css" rel="stylesheet" />
- <link rel="stylesheet" type="text/css" href="../css/iconfont.css" />
- <link rel="stylesheet" type="text/css" href="../css/common.css" />
- <style type="text/css">
- #account {
- height: 200px;
- background: #82c0fa;
- position: relative;
- }
-
- .userMsg {
- text-align: center;
- }
-
- .userMsg img {
- border-radius: 50%;
- margin: 30px 0 0;
- }
-
- #username {
- color: #fff;
- line-height: 32px;
- font-size: 18px;
- }
- .waveWrapper{
- background: url(../images/shadow.png);
- height: 52px;
- background-color: #82c0fa;
- position: absolute;
- left: 0;
- right: 0;
- bottom: 0;
- background-size: cover;
- }
-
- .option{
- margin-bottom:17px;
- }
-
- .option .iconfont {
- font-size: 16px;
- color: #666;
- }
-
- .option span {
- color: #666;
- font-size: 16px;
- margin-left: 10px;
- }
- #userImg{
- width: 70px;
- height: 70px;
- }
- .failed{
- display: none;
- position: absolute;
- left: 0;
- right: 0;
- top: 0;
- bottom: 0;
- z-index: 10;
- }
- .failed img{
- width: 70%;
- position: absolute;
- top: 21%;
- left: 50%;
- margin-left: -35%;
- }
- .failed p{
- width: 100%;
- font-size: 16px;
- text-align: center;
- position: absolute;
- top: 54%;
- left: 0;
- right: 0;
- }
- .failed button{
- width: 34%;
- position: absolute;
- top: 61%;
- left: 50%;
- margin-left: -15%;
- }
- .header{
- display: none;
- }
- .mui-bar-nav~.mui-content {
- padding-top: 0;
- }
- </style>
- </head>
- <body>
- <header class="mui-bar mui-bar-nav header">
- <h1 class="mui-title">我的</h1>
- </header>
- <div class="mui-content">
- <div id="account">
- <div class="userMsg">
- <a class="" id="" href="#">
- <img id="userImg" src="" />
- </a>
- <p id="username"></p>
- </div>
- <div class="waveWrapper"></div>
- </div>
- <ul class="mui-table-view option">
- <li class="mui-table-view-cell">
- <a class="mui-navigate-right" href="../personalinfo/userinfo.html">
- <i class="iconfont"></i>
- <span>个人信息</span>
- </a>
- </li>
- <li class="mui-table-view-cell">
- <a class="mui-navigate-right" href="../personalinfo/feedback.html">
- <i class="iconfont"></i>
- <span>反馈</span>
- </a>
- </li>
- <!--<li class="mui-table-view-cell">
- <a class="mui-navigate-right" href="../personalinfo/about.html">
- <i class="iconfont"></i>
- <span>关于</span>
- </a>
- </li>-->
- <li class="mui-table-view-cell">
- <a class="mui-navigate-right" href="../personalinfo/refresh.html">
- <i class="iconfont"></i>
- <span>系统</span>
- </a>
- </li>
- <!--<li class="mui-table-view-cell">
- <a class="mui-navigate-right" id="refresh">
- <i class="iconfont"></i>
- <span>更新</span>
- </a>
- </li>-->
- </ul>
- <ul class="mui-table-view option" style="margin-bottom: 0;">
- <li class="mui-table-view-cell">
- <a class="mui-navigate-right" href="../personalinfo/setting.html">
- <i class="iconfont"></i>
- <span>设置</span>
- </a>
- </li>
- </ul>
- </div>
- <div class="failed">
- <img src="../images/againLoad.png"/>
- <p>数据加载失败</p>
- <button id="loadBtn">重新加载</button>
- </div>
- <script src="../js/jquery-2.1.0.js"></script>
- <script src="../js/mui.min.js"></script>
- <script type="text/javascript">
- mui.init();
- $('.mui-content').hide();
- var userinfoData;
- mui.plusReady(function() {
- var username = plus.storage.getItem('username');
- console.log(username);
- getuserinfo();
- $('#loadBtn').on('tap',getuserinfo);
- function getuserinfo(){
- mui.ajax('http://192.168.1.11:8000/app_user_info', {
- data: {
- req:'info'
- },
- dataType: 'json', //服务器返回json格式数据
- type: 'post', //HTTP请求类型
- timeout: 10000, //超时时间设置为10秒;
- beforeSend: function() {
- plus.nativeUI.showWaiting('请求中...');
- },
- complete: function() {
- plus.nativeUI.closeWaiting();
- },
- success: function(data) {
- userinfoData = data;
- $('#userImg').attr('src','http://192.168.1.11:8000/'+data.user_picture);
- $('#username').html(data.username);
- $('.failed').hide();
- $('.header').hide();
- $('.mui-content').show();
- },
- error: function(xhr, type, errorThrown) {
- console.log(type)
- console.log(errorThrown)
- mui.toast('个人信息获取失败');
- $('.mui-content').hide();
- $('.failed').show();
- $('.header').show();
- }
- });
- }
-
- mui('.option').on('tap', 'a', function() {
- var src = this.getAttribute('href');
- var id = (this.href.substr(this.href.lastIndexOf('/') + 1)).split('.')[0];
- console.log(id)
- if(id){
- if(id == 'userinfo'){
- mui.openWindow({
- url:src,
- id:id,
- extras: {
- data: userinfoData //扩展参数
- }
- })
- }else{
- mui.openWindow({
- url:src,
- id:id
- })
- }
- }else{
- mui.openWindow({
- url:src,
- id:id
- })
- }
-
- })
- //刷新
- // document.getElementById('refresh').addEventListener('tap', function() {
- // var btnArray = ['确定', '取消'];
- // mui.confirm('确定更新到最新版本?', '版本更新', btnArray, function(e) {
- // if(e.index == 0) {
- // console.log('是');
- // } else {
- // console.log('否');
- // }
- // })
- //获取当前版本号
- // plus.runtime.getProperty(plus.runtime.appid, function(inf) {
- // wgtVer = inf.version;//获取版本号
- // console.log(wgtVer)
- // var wait = plus.nativeUI.showWaiting('下载更新中,请勿关闭');
- // //创建一个下载任务
- // var dtask = plus.downloader.createDownload( "", {method:"GET"}, function ( d, status ) {
- // if ( status == 200 ) {
- // console.log( "Download success: " + d.filename );
- // plus.runtime.install(d.filename); // 安装下载的apk文件
- // }else{
- // mui.alert('更新失败')
- //// plus.runtime.install('../H5B2852C7_0925104810.apk'); // 安装下载的apk文件
- // }
- // wait.close();
- // });
- // //开始下载
- // dtask.start();
- // });
- // })
- //更换头像
- document.getElementById('userImg').addEventListener('tap', function() {
- if(mui.os.plus) {
- var a = [{
- title: '查看大图'
- },{
- title: '拍照'
- }, {
- title: '从手机相册选择'
- }];
- plus.nativeUI.actionSheet({
- title: '修改头像',
- cancel: '取消',
- buttons: a
- }, function(b) {
- console.log(b.index)
- switch(b.index) {
- case 0:
- break;
- case 1:
- lookBigImg();
- break;
- case 2:
- //拍照
- getImages();
- break;
- case 3:
- //打开相册
- galleryImages();
- break;
- default:
- break;
- }
- }, false);
- }
- });
-
- //查看大图
- function lookBigImg(){
- var imgsrc = document.getElementById('userImg').getAttribute('src');
- console.log(imgsrc)
- plus.nativeUI.previewImage([
- imgsrc
- ]);
- }
- //拍照
- function getImages() {
- var mobileCamera = plus.camera.getCamera();
- mobileCamera.captureImage(function(e) {
- plus.io.resolveLocalFileSystemURL(e, function(entry) {
- var path = entry.toLocalURL() + '?version=' + new Date().getTime();
- uploadHeadImg(path);
- }, function(e) {
- console.log("读取拍照文件错误");
- });
- }, function(e) {
- console.log("er", e.message);
- }, function() {
- filename: '_doc/head.png';
- });
- }
-
- //从本地相册选择
- function galleryImages() {
- console.log("你选择了从相册选择");
- 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 path = e.fullPath + '?version=' + new Date().getTime();
- uploadHeadImg(path);
- }, function(err) {
- console.log("copy image fail: ", err);
- });
- }, function(err) {
- console.log("删除图片失败:(" + JSON.stringify(err) + ")");
- });
- }, function(err) {
- //打开文件失败
- entry.copyTo(root, 'head.png', function(e) {
- var path = e.fullPath + '?version=' + new Date().getTime();
- uploadHeadImg(path);
- }, function(err) {
- console.log("上传图片失败:(" + JSON.stringify(err) + ")");
- });
- });
- }, function(e) {
- console.log("读取文件夹失败:(" + JSON.stringify(e) + ")");
- });
- });
- }, function(err) {
- console.log("读取拍照文件失败: ", err);
- }, {
- filter: 'image'
- });
- };
- //上传图片
- function uploadHeadImg(imgPath) {
- //服务端接口路径
- var server = "http://192.168.1.11:8000/app_user_info";
- //获取图片元素
- var files = document.getElementById('userImg');
- console.log(files.src);
- var wt = plus.nativeUI.showWaiting('上传中...');
- var task = plus.uploader.createUpload(server, {
- method: "POST",
- // timeout:10
- },
- function(t, status) { //上传完成
- if(status == 200) {
- alert("上传成功:" + t.responseText);
- wt.close(); //关闭等待提示按钮
- document.getElementById('userImg').src = imgPath;
- } else {
- alert("上传失败:" + status);
- wt.close(); //关闭等待提示按钮
- }
- }
- );
- //添加其他参数
- // task.addData("name", "test");
- task.addData("req", "change_photo");
- task.addFile(imgPath, {
- key: "file"
- });
- task.start();
- }
- });
- </script>
- </body>
- </html>
|