| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>Hello MUI</title>
- <meta name="viewport" content="width=device-width, initial-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">
- <link href="css/mui.min.css" rel="stylesheet" />
- <link href="css/mui.indexedlist.css" rel="stylesheet" />
- <link href="css/OA-style.css" rel="stylesheet" />
- <style>
- .mui-content>.mui-table-view:first-child {
- margin-top: -1px;
- }
- </style>
- </head>
- <body>
- <div id="pullrefresh" class="mui-content mui-scroll-wrapper">
- <div class="mui-scroll">
-
- </div>
- </div>
- <script src="js/mui.min.js "></script>
- <script src="js/app.js"></script>
- <script src="js/config.js "></script>
- <script type="text/javascript " src="js/jquery.min.js "></script>
- <script src="js/dj/article/list.js "></script>
-
- <script>
- mui.init();
-
- window.addEventListener('refresh', function(e){//当子页面有查看数据时,此页面执行刷新
- var flag = e.detail.flagBatchRead;
- //console.log(flag);
- if(flag){
- location.reload();
- }
- });
- function addData() {
- //开启等待框
- var w = plus.nativeUI.showWaiting("加载中,请等待...", {
- loading: {
- display: "inline"
- }
- });
- var url = API.API_URL();
- var state = app.getState(); //获取登陆信息
- var staffId = state.user.useId;
- //var staffId = 118978536110432;
- var obj = {
- 'serviceId': 'oa_phone_messageIndex',
- 'params': '{staffId:' + staffId + '}'
- };
- mui.ajax(url, {
- dataType: 'json', //服务器返回json格式数据
- type: 'post', //HTTP请求类型
- data: obj,
- timeout: 30000, //超时时间设置为10秒;
- headers: {
- 'Accept': 'application/json'
- },
- success: function(data) {
- //服务器返回响应
- console.log(JSON.stringify(data))
- //var obj = eval(response);
- var params = data.returnParams;
- var list = params.list;
- var table = document.body.querySelector('.mui-scroll');
- var ul = document.createElement('ul');
- ul.setAttribute("id", "listDetail");
- ul.className = 'mui-table-view mui-clearfix';
- table.innerHTML = "";
- for(var i = 0, len = list.length; i < len; i++) {
- var id = list[i].UNIVERSALID;
- var title = list[i].title;
- var type = list[i].jump_type;
- var count = list[i].count_num;
- var dateVal = getymd(list[i].sendTime,'md');
- var name = "";
- var imgUrl = "";
- if(type == 1){//消息
- name = "我的消息";
- imgUrl = 'images/xiaoxi_messages.png';
- }else if(type == 2){//通知公告
- name = "通知公告";
- imgUrl = 'images/xiaoxi_tongzhi.png';
- }else if(type == 3){//流程办理
- name = "流程办理";
- imgUrl = 'images/xiaoxi_shenpi.png';
- // }else if(type == 4){//用餐管理
- // name = "用餐管理";
- // imgUrl = 'images/xiaoxi_yongcang.png';
- // }else if(type == 5){//物品管理
- // name = "物品管理";
- // imgUrl = 'images/xiaoxi_wuping.png';
- }
- /*else if(type == 6){//效率管理
- name = "效率管理";
- imgUrl = 'images/xiaoxi_xiaolv.png';
- }else if(type == 7){//效率管理
- name = "出差审批";
- imgUrl = 'images/xiaoxi_chuchai.png';
- }*/
-
-
- var li = document.createElement('li');
- li.setAttribute("jump_type", type);
- li.setAttribute("name", name);
- li.className = 'mui-table-view-cell';
-
-
- var html = '<div class="mui-pull-left head "><img src="'+imgUrl+'"></div>';
- html += '<div class="mui-pull-right text ">';
- html += '<div class="mui-clearfix ">';
- html += '<h1 class="mui-pull-left " style="height:24px;line-height:24px;">'+name+'</h1>';
- html += '<h3 class="mui-pull-right ">'+dateVal+'</h3>';
- html += '</div>';
- html += '<div class="mui-clearfix ">';
- html += '<h2 class="mui-pull-left " style="height:16px;line-height:16px;">'+title+' </h2>';
- if(count > 0){
- html += '<div class="angle mui-pull-right ">'+count+'</div>';
- }
- html += '</div>';
- html += '</div>';
- li.innerHTML = html;
- ul.appendChild(li);
- table.appendChild(ul);
- }
- if(list.length > 0){
- mui('#listDetail').on('tap', 'li', function() {
- var jump_type = this.getAttribute('jump_type');
- var name = this.getAttribute('name');
- mui.openWindow({
- url: 'page/message/messageList.html',
- id: 'messageList.html',
- extras:{'jump_type':jump_type,'name':name}
- })
- })
- }else{
- var html = '<center>';
- html += '<img src="images/noxiaoxi.png" style="margin-top: 80px;width: 200px;">';
- html += '<p style="margin-top: 50px;">亲 暂时没有消息哟~</p>';
- html += '</center>';
- table.innerHTML = html;
- }
-
-
-
- //关闭等待框
- var t = setInterval(function() {
- w.close();
- clearInterval(t);
- }, 1000);
- },
- error: function(xhr, type, errorThrown) {
- //异常处理;
- console.log(type);
- }
- });
- };
- mui.plusReady(function() {
- var state = app.getState().user;
- if(state){
- addData();
- }
-
- //自定义事件,模拟点击“首页选项卡”
- document.addEventListener('messageEvent', function() {
- addData();
- });
- });
-
- /**
- * js将字符串转成日期格式,返回年月日
- * @param dateStr 日期字符串
- * @param type 转换类型 d返回日、md返回月日、ymd返回年月日
- * 想了解更多,请搜索微信wu7zhi,在线帮你解答难题
- */
- function getymd(dateStr, type) {
- var date = new Date(Date.parse(dateStr.replace(/-/g, "/")));
- var mm = date.getMonth() + 1;
- //月
- var dd = date.getDate();
- //日
- var yy = date.getFullYear();
- //年
- if (type == "d") {
- return dd;
- }else if (type == "md") {
- return mm + "月" + dd + "日";
- }else if(type == "ymd") {
- return yy + "-" + mm + "-" + dd;
- }
- }
-
- </script>
- </body>
- </html>
|