mirror of
https://gitee.com/farsunset/cim.git
synced 2025-07-22 15:56:42 +08:00
2.android sdk优化升级,去除mina或netty相关包的依赖 3.java sdk优化升级,去除mina或netty相关包的依赖 4.新增web sdk,可以由index.html快速启动demo 5.修正文档中一些疏漏
161 lines
5.2 KiB
HTML
161 lines
5.2 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8"/>
|
|
<title>CIM Webclient </title>
|
|
<link charset="utf-8" rel="stylesheet" href="./css/bootstrap.min.css" />
|
|
<link charset="utf-8" rel="stylesheet" href="./css/common.css" />
|
|
<script type="text/javascript" src="./js/jquery-3.3.1.min.js"></script>
|
|
<script type="text/javascript" src="./js/bootstrap.min.js"></script>
|
|
<script type="text/javascript" src="./js/common.js"></script>
|
|
<script type="text/javascript" src="./js/cim/message.js"></script>
|
|
<script type="text/javascript" src="./js/cim/replybody.js"></script>
|
|
<script type="text/javascript" src="./js/cim/sentbody.js"></script>
|
|
<script type="text/javascript" src="./js/cim/cim.web.sdk.js"></script>
|
|
</head>
|
|
|
|
|
|
<script>
|
|
|
|
/***********************************推送配置开始**************************/
|
|
|
|
/** 当socket连接成功回调 **/
|
|
function onConnectionSuccessed(){
|
|
CIMPushManager.bindAccount($('#account').val());
|
|
}
|
|
|
|
/** 当收到请求回复时候回调 **/
|
|
function onReplyReceived(reply)
|
|
{
|
|
console.log(reply);
|
|
if(reply.key=='client_bind' && reply.code==200)
|
|
{
|
|
hideProcess();
|
|
|
|
$('#LoginDialog').fadeOut();
|
|
|
|
|
|
$('#MessageDialog').fadeIn();
|
|
$('#MessageDialog').addClass("in");
|
|
$("#current_account").text($('#account').val());
|
|
|
|
}
|
|
}
|
|
|
|
/** 当收到消息时候回调 **/
|
|
|
|
function onMessageReceived(message)
|
|
{
|
|
console.log(message);
|
|
if(message.action == ACTION_999){
|
|
$('#MessageDialog').fadeOut();
|
|
$('#LoginDialog').fadeIn();
|
|
$('#LoginDialog').addClass("in");
|
|
return ;
|
|
}
|
|
|
|
showNotification(message.content);
|
|
|
|
$("#messageList").append("<h6 style='text-align: center;'>时间:"+new Date(message.timestamp).toLocaleString()+"</h6>");
|
|
$("#messageList").append("<div class='alert alert-info' >"+message.content+"</div>");
|
|
}
|
|
|
|
|
|
/***********************************推送配置结束**************************/
|
|
|
|
|
|
|
|
/***********************************业务配置开始**************************/
|
|
|
|
function doLogin(){
|
|
|
|
if($.trim($('#account').val()) =='' ){
|
|
return;
|
|
}
|
|
showProcess('正在接入请稍后......');
|
|
/**登录成功后创建连接****/
|
|
CIMPushManager.connection();
|
|
}
|
|
|
|
|
|
|
|
$(document).ready(function(){
|
|
$('#LoginDialog').fadeIn();
|
|
$('#LoginDialog').addClass("in");
|
|
|
|
initNotification();
|
|
});
|
|
|
|
|
|
function initNotification(){
|
|
//判断浏览器是否支持桌面通知
|
|
if (window.Notification) {
|
|
var notification = window.Notification;
|
|
if (notification.permission == "default") {
|
|
notification.requestPermission(function(permission) {
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
function showNotification(msg){
|
|
var notify = new Notification("系统消息", {
|
|
body: msg,
|
|
icon: './image/icon.png',
|
|
tag: 1
|
|
});
|
|
|
|
notify.onshow = function() {
|
|
setTimeout(function() {
|
|
notify.close();
|
|
}, 3000);
|
|
}
|
|
}
|
|
|
|
/***********************************业务配置结束**************************/
|
|
</script>
|
|
|
|
|
|
<body style="width: 600px;">
|
|
|
|
|
|
<div class="modal fade" id="LoginDialog" tabindex="-1" role="dialog" data-backdrop="static">
|
|
<div class="modal-dialog" style="width: 400px;margin: 64px auto;">
|
|
<div class="modal-content" >
|
|
<div class="modal-body" style="padding:0px;" >
|
|
<div style="height:200px;text-align: center; background: #5FA0D3; color: #ffffff; border: 0px; border-top-left-radius: 4px; border-top-right-radius: 4px;">
|
|
<img src="./image/icon.png" style="height: 72px;width: 72px;margin-top:40px;"/>
|
|
<div style="margin-top: 20px; color: #ffffff;font-size: 16px;">请输入一个帐号用于登录,随后接收推送消息</div>
|
|
</div>
|
|
|
|
<div class="input-group" style="margin-top: 30px;margin-left:10px;margin-right:10px;margin-bottom:30px;">
|
|
<span class="input-group-addon"><span class="glyphicon glyphicon-user" aria-hidden="true"></span></span>
|
|
<input type="text" class="form-control" id="account" maxlength="32" placeholder="帐号(数字或者英文字母)"
|
|
style="display: inline; width: 100%; height: 50px;" />
|
|
</div>
|
|
|
|
</div>
|
|
<div class="modal-footer" style="text-align: center;">
|
|
<a type="button" class="btn btn-success btn-lg" onclick="doLogin()"
|
|
style="width: 300px;">登录</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 消息提示页面 -->
|
|
<div class="modal fade" data-backdrop="static" id="MessageDialog" tabindex="-1" role="dialog" >
|
|
<div class="modal-dialog" style="width: 600px;margin: 30px auto;">
|
|
<div class="modal-content" >
|
|
<div class="modal-header" style="text-align: center;">
|
|
<span style="float: left;">请在管理页面推送一条消息</span>
|
|
<span style="float: right;color: #4caf50;">当前帐号:<span id="current_account"></span></span>
|
|
</div>
|
|
<div class="modal-body" id="messageList" style="min-height: 600px;" >
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</body>
|
|
</html> |