|
- <!DOCTYPE html>
- <html>
-
- <head>
- <meta charset="utf-8">
- <title>Hello MUI</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">
-
- <link rel="stylesheet" href="css/mui.min.css">
- <style>
- html,
- body {
- background-color: #efeff4;
- }
-
- .mui-content>.mui-table-view:first-child {
- margin-top: 0px;
- }
-
- .title {
- margin: 20px 15px 10px;
- color: #6d6d72;
- font-size: 15px;
- }
-
- .oa-contact-cell.mui-table .mui-table-cell {
- padding: 11px 0;
- vertical-align: middle;
- }
-
- .oa-contact-cell {
- position: relative;
- margin: -11px 0;
- }
-
- .oa-contact-avatar {
- width: 75px;
- }
-
- .oa-contact-avatar img {
- border-radius: 50%;
- }
-
- .oa-contact-content {
- width: 100%;
- }
-
- .oa-contact-name {
- margin-right: 20px;
- }
-
- .oa-contact-name,
- oa-contact-position {
- float: left;
- }
-
- .tit {
- padding: 10px 8px;
- font-size: 16px;
- font-family: "微软雅黑";
- }
- </style>
- </head>
-
- <body>
- <div class="mui-content">
-
- <div class="tit">咨询老师</div>
- <ul class="mui-table-view mui-table-view-striped mui-table-view-condensed" id="table">
-
- </ul>
- <div class="tit">关联老师</div>
- <ul class="mui-table-view mui-table-view-striped mui-table-view-condensed" id="tableguanlian">
- </ul>
- </div>
- </body>
- <script src="js/mui.min.js"></script>
- <script src="js/serverurl.js"></script>
- <script src="js/tools.js"></script>
- <script src="js/userinfos.js"></script>
- <script type="text/javascript" charset="utf-8">
- function RefreshContactTeacher() {
- CheckLogin();
- if(users.teaID != undefined && users.teaID != null && users.teaID != '' && users.teaID != 0 && users.teaID != '0') {
- //关联老师
- var table = document.getElementById("tableguanlian");
- var li = document.createElement("li");
- li.innerHTML = '<li class="mui-table-view-cell" onclick="OpenChat(\'' + users.teaID + '\');" id="' + users.teaID + '">' +
- '<div class="mui-slider-cell">' +
- '<div class="oa-contact-cell mui-table">' +
- '<div class="oa-contact-avatar mui-table-cell">' +
- '<img src="images/geren.png" />' +
- '</div>' +
- '<div class="oa-contact-content mui-table-cell">' +
- '<div class="mui-clearfix">' +
- '<h4 class="oa-contact-name">' + (users.teaName != undefined && users.teaName != null ? users.teaName : users.teaID) + '</h4>' +
- '<span class="oa-contact-position mui-h6" style="float: right;"></span>' +
- '</div>' +
- '<p class="oa-contact-email mui-h6">' +
- '聊天记录' +
- '</p>' +
- '</div>' +
- '</div>' +
- '</div>' +
- '</li>';
- table.appendChild(li, table.firstChild);
- }
- }
- (function($, doc) {
- mui.plusReady(function() {
- if(CheckLogin()) {
- var B = window.plus.bridge;
- var Yuntx = {
- ReadOffLineMessage: function(uln, unickname, successCallback, errorCallback) {
- var success = typeof successCallback !== 'function' ? null : function(args) {
- successCallback(args);
- },
- fail = typeof errorCallback !== 'function' ? null : function(code) {
- errorCallback(code);
- },
- callbackID = B.callbackId(success, fail);
- return B.exec("Yuntx", "ReadOffLineMessage", [callbackID, uln, unickname]);
- },
- OpenChat: function(uln, tln, successCallback, errorCallback) {
- var success = typeof successCallback !== 'function' ? null : function(args) {
- successCallback(args);
- },
- fail = typeof errorCallback !== 'function' ? null : function(code) {
- errorCallback(code);
- },
- callbackID = B.callbackId(success, fail);
- return B.exec("Yuntx", "OpenChat", [callbackID, uln, tln]);
- }
- };
- window.plus.Yuntx = Yuntx;
- var list = JSON.parse(localStorage.getItem('taigangteacherMsgList') || '[]');
- LoadList(list);
- GetMessage();
- RefreshContactTeacher();
- }
- });
- }(mui, document));
-
- function GetMessage() {
- plus.Yuntx.ReadOffLineMessage(users.ID, users.username,
- function(contact) { //成功
- },
- function(status) { //失败
- plus.nativeUI.toast("获取消息失败!");
- }
- );
- }
-
- function OpenChat(id) {
- plus.Yuntx.OpenChat(users.ID, id,
- function(contact) { //成功
- plus.nativeUI.closeWaiting();
- },
- function(status) { //失败
- plus.nativeUI.closeWaiting();
- });
- }
-
- function LoadList() {
- var table = document.getElementById("table");
- table.innerHTML = "";
- var xhr = new plus.net.XMLHttpRequest();
- xhr.responseType = "json";
- xhr.onreadystatechange = function() {
- switch(xhr.readyState) {
- case 4:
- if(xhr.status == 200) {
- if(xhr.response.result == "ok") {
- if(xhr.response.msg != null && xhr.response.msg.length > 0) {
- for(var i in xhr.response.msg) {
- var dataobject = xhr.response.msg[i];
- var li = document.createElement("li");
- li.setAttribute("userid", "" + dataobject.userID + "");
- li.innerHTML = '<li class="mui-table-view-cell" onclick="OpenChat(\'' + dataobject.userID + '\');" id="' + dataobject.userID + '">' +
- '<div class="mui-slider-cell">' +
- '<div class="oa-contact-cell mui-table">' +
- '<div class="oa-contact-avatar mui-table-cell">' +
- '<img src="images/geren.png" />' +
- '</div>' +
- '<div class="oa-contact-content mui-table-cell">' +
- '<div class="mui-clearfix">' +
- '<h4 class="oa-contact-name">' + dataobject.schoolName + '-' + dataobject.teacherName + '</h4>' +
- '<span class="oa-contact-position mui-h6" style="float: right;"></span>' +
- '</div>' +
- '<p class="oa-contact-email mui-h6">' +
- '咨询老师' +
- '</p>' +
- '</div>' +
- '</div>' +
- '</div>' +
- '</li>';
- table.appendChild(li, table.firstChild);
- }
-
- }
- } else {}
- } else {
- plus.nativeUI.toast('世界上最遥远的距离就是没有网络。');
- }
- break;
- default:
- break;
- }
- }
- xhr.open("GET", encodeURI(serverdomain + "/WebService/UserService.ashx?Action=getTeacherInfo"));
- xhr.send();
- }
- </script>
-
- </html>
|