<script type="text/javascript">
$(function() {
$("#draggableT").draggable();
});
$(document).ready(function() {
//定时查询业务员信息
window.setTimeout(timeUsers, 1000);
function timeUsers() {
$.ajax({
type: "POST",
url: "http://localhost:19424/ServiceUser.asmx/GetUsers",
data: "{font:'S'}", //可变参数
contentType: "application/json",
dataType: 'json',
success: function(result) { //回调函数,result,返回值
$('#draggableT').html(result.d);
}
});
window.setTimeout(timeUsers, 1000);
};
});
//单击客服人员名称时触发事件
function open(id, name) {
//打开消息窗口
$('#dialogU').dialog('open');
//消息窗口的宽
$('#dialogU').dialog({ width: 460 });
//消息窗口的高
$('#dialogU').dialog({ height: 580 });
//消息窗口的标题
$('#dialogU').dialog({ title: name });
//隐藏客服人员层
document.getElementById("draggableT").style.display = 'none';
//将当前消息窗口的客服人员ID 存储在隐藏表单中
document.getElementById("hdnId").value = id;
};
$(function() {
$('#dialogU').dialog({
autoOpen: false //隐藏消息对话框
// show: 'blind', //这个属性是设置对话框以什么样式弹出
//hide: 'explode'//设置对话框关闭时的样式
});
$("#dialogU").dialog({
close: function(event, ui) {
document.getElementById("draggableT").style.display = 'block';
}
});
});
$(document).ready(function() {
//客户发送消息按钮
$("#btnMessage").click(function() {
//获取消息内容
var message = $("#message").val();
if (message == "") {
alert("一定要输入您发送的消息内容!");
return;
}
//清空发送消息窗口
$('#message').val('');
//获取编号
var id = document.getElementById("hdnId").value;
//客户唯一编号
var customer = '<%= Session["id"] %>'; //??????
if (customer == "") {
alert("您好!网站需要自动刷新!");
document.URL = "../Default.aspx";
return;
}
$.ajax({
type: "POST",
contentType: "application/json",
url: "http://localhost:19424/ServiceManager.asmx/AddMessage",
data: "{messages:'" + message + "',fromUser:'" + customer + "',toUser:'" + id + "'}",
dataType: 'json',
success: function(result) { //回调函数,result,返回值
GetMessage(customer, id, 1);
}
});
});
});
//fromUser/发送者, toUser/接收者,from/1-查询客户发送的消息. 2-查询业务员发送的消息
function GetMessage(fromUser, toUser, from) {
$.ajax({
type: "POST",
contentType: "application/json",
url: "http://localhost:19424/ServiceManager.asmx/GetMessageWeb",
data: "{fromUser:'" + fromUser + "',toUser:'" + toUser + "',from:" + from + "}",
dataType: 'json',
success: function(result) { //回调函数,result,返回值
$('#showMessage').append(result.d);
//使消息窗口滚动条始终在右下方(显示当前发送的信息)
var messageDIV = document.getElementById('showMessage');
messageDIV.scrollTop = messageDIV.scrollHeight;
}
});
};
</script>
<!-- 显示客服人员名称 --->
<!--- 查詢客服人員數據 --->
<div id="draggableT" style="position: absolute; width: 100px; height: 150px; left: 340px;
top: 40px; padding: 10px;" class="ui-widget ui-widget-content ui-corner-all">
<br />
</div>
<div id="dialogU" title="name" style="background-color: White; display: none;">
<!-- 显示聊天记录 -->
<div id="showMessage" style="width: 98%; height: 73%; border: 1px Black solid; padding: 3px;
margin: 0px; overflow: scroll;">
</div>
<!--- 发送 -->
<div style="width: 99%; height: 25%; padding: 0px; margin: 0px; text-align: right;
float: left;">
<textarea id="message" style="width: 98%;" cols="10" rows="7"></textarea>
<input id="btnMessage" type="button" value="Send" title="发送按钮" />
</div>
</div>
<!--将当前消息窗口的客服人员ID 存储在隐藏表单中 -->
<input id="hdnId" type="hidden" />