浏览代码

云巴推送调整

Lu 9 年之前
父节点
当前提交
e130c24692

+ 7 - 0
display-server/.project

@ -14,4 +14,11 @@
14 14
	<natures>
15 15
		<nature>org.eclipse.jdt.core.javanature</nature>
16 16
	</natures>
17
	<linkedResources>
18
		<link>
19
			<name>wade-mobile-server-src</name>
20
			<type>2</type>
21
			<location>/Users/kevin/Work/WorkSpace/javaCore/wade-mobile-server/src</location>
22
		</link>
23
	</linkedResources>
17 24
</projectDescription>

+ 73 - 0
display-server/web/biz/js/push/Push.js

@ -0,0 +1,73 @@
1
require(["domReady!","wadeMobile","mobile","util"],function(doc,WadeMobile,Mobile){
2
	var isConnected = false; //是否连接
3
	/*刷新在线联系人*/
4
	var refreshOnlineList = function(){
5
		var loading = '<div class="c_loading"><div class="pic"></div><div class="text">正在加载中,请稍候</div></div>';
6
		$("#content").html(loading);
7
		WadeMobile.httpGet(function(data){
8
			var onlineStaffs = new Wade.DataMap(data).get("SESSION_LRU");
9
			onlineStaffs = onlineStaffs.split("|");
10
			
11
			var params = new Wade.DatasetList();
12
			var param;
13
			for(var i=0;i<onlineStaffs.length;i++){
14
				param = new Wade.DataMap();
15
				if(onlineStaffs[i]!=""){
16
					param.put("ACCOUNT",onlineStaffs[i]);
17
					params.add(param);
18
				}
19
			}
20
			param = new Wade.DataMap();
21
			param.put("ONLINE_STAFFS",params);
22
			Mobile.getTemplate("OnlineList",param.toString(),function(html){
23
				$("#content").html(html);
24
				new iScroll("content");
25
				$("#refresh").tap(function(){
26
					refreshOnlineList();
27
				});
28
			});
29
		},"http://114.215.100.48:8080/push/mobiledata?action=getLRUSession",true);
30
//		},"http://192.168.51.155:8080/push/mobiledata?action=getLRUSession",true);
31
	}
32
	/*进入界面先销毁链接,防止离开此界面时没有断开*/
33
	WadeMobile.unregisterForPush(function(){
34
		refreshOnlineList();//刷新在线人员列表
35
	});
36
	
37
	$("#register").tap(function(){
38
		if($("#register").html()=="连接"){
39
			if(!$("#account").val()){
40
				WadeMobile.tip("请输入一个昵称,让小伙伴认识你~");
41
				return;
42
			}
43
			WadeMobile.registerForPush($("#account").val(),function(msg){
44
				WadeMobile.tip($("#account").val() + msg);
45
				$("#register").html("注销");
46
				
47
				refreshOnlineList();//刷新在线人员列表
48
				isConnected = true;
49
			},function(msg){
50
				WadeMobile.tip(msg);
51
			});
52
		}else{
53
			WadeMobile.unregisterForPush(function(){
54
				WadeMobile.tip("注销成功");
55
				refreshOnlineList();//刷新在线人员列表
56
			});
57
			$("#register").html("连接");
58
			$("#account").val("");
59
			isConnected = false;
60
		}
61
	});
62
	
63
	window.chatByAccount = function(account){
64
		if(!isConnected){
65
			WadeMobile.tip("请先输入昵称让小伙伴找到你!然后【连接】");
66
			return;
67
		}
68
		var param = new Wade.DataMap();
69
		param.put("OWN_ACCOUNT",$("#account").val());
70
		param.put("OTHER_ACCOUNT",account);
71
		Mobile.openTemplate("Chat",param);
72
	}
73
});

+ 34 - 11
display-server/web/biz/js/push/YunbaPush.js

@ -1,16 +1,20 @@
1
require(["common","wadeMobile"], function(Common, WadeMobile) {
2
	
3
	$('#channel').val("IPU");//设置频道名称
4
	$('#alias').val("Dave");//设置默认用户别名
5
	$('#msgForSend').val("今天天气真不错!");//设置内容
1
require(["common","wadeMobile","jcl","util"], function(Common, WadeMobile,$) {
6 2
	
3
//	$('#alias').val("Dave");//设置默认用户别名
4
//	$('#msgForSend').val("今天天气真不错!");//设置内容
7 5
	
8 6
	$("#register").tap(function() {
9 7
		//按钮
10 8
		var registerBtn = $('#register');
9
		
11 10
		if(registerBtn.attr('connected') != 'true'){
11
			var alias = $('#alias').val();
12
			if (escape(alias).indexOf( "%u" ) >= 0){
13
				alert("昵称不能含有中文,请重新输入!");
14
				return;
15
			}
12 16
			//订阅主题/频道
13
			WadeMobile.registerForPush($('#channel').val(), function(obj){
17
			WadeMobile.registerForPushWithYunba(alias, function(obj){
14 18
				if(obj != 'SUC'){
15 19
					alert('频道订阅失败!');
16 20
				}
@ -19,7 +23,7 @@ require(["common","wadeMobile"], function(Common, WadeMobile) {
19 23
			});
20 24
		}else{
21 25
			//退订主题/频道
22
			WadeMobile.unregisterForPush(function(obj){
26
			WadeMobile.unregisterForPushWithYunba(function(obj){
23 27
				if(obj != 'SUC'){
24 28
					alert('频道退订失败!')
25 29
				}
@ -31,12 +35,31 @@ require(["common","wadeMobile"], function(Common, WadeMobile) {
31 35
	
32 36
	
33 37
	$("#send").tap(function() {
38
		//获取参数
39
		var array = function(info){
40
			var index = info.lastIndexOf("@");
41
			var alias = "ALL", msg = info;
42
			if(index != -1){
43
				index += info.substr(index).indexOf(' ');
44
				msg = info.substr(index).trim();
45
				
46
				var aliasInfo = info.substring(0, index).trim();
47
				var aliasList = alias.split(/\s+/);
48
				alias = aliasInfo.replace(new RegExp(/(@)/g), '').split(/\s+/)[0];
49
			}
50
			
51
			var result = new Array();
52
			result.push(alias);//发送用户
53
			result.push(msg);//发送内容
54
			return result;
55
			
56
		}($('#msgForSend').val());
57
		
34 58
		//发送消息
35
		WadeMobile.sendText($('#alias').val(), $('#msgForSend').val(), function(obj){
59
		WadeMobile.sendTextWithYunba(array[0], array[1], function(obj){
36 60
			alert((obj != 'SUC') + '发送结果:' + obj);
37 61
			if(obj != 'SUC'){
38
				alert('消息发送失败!')
39
				return ;
62
				alert('消息发送失败!');
40 63
			}
41 64
		});
42 65
	});
@ -57,5 +80,5 @@ require(["common","wadeMobile"], function(Common, WadeMobile) {
57 80
		$('#msgForReceive').prepend($(content)); 
58 81
	}
59 82
	//设置回调函数
60
	WadeMobile.setCallbackForPush("receiveMessage");
83
	WadeMobile.setCallbackForPushWithYunba("receiveMessage");
61 84
});

+ 7 - 7
display-server/web/res/js/mobile/expand-mobile.js

@ -229,16 +229,16 @@ define(["require"],function(require) {
229 229
			},setCallbackForPush:function(callback){
230 230
				execute("setCallbackForPush", [callback]);
231 231
			},registerForPushWithYunba:function(account,callback,err){
232
				storageCallback("registerForPush",callback);
233
				execute("registerForPush",[account],err);
232
				storageCallback("registerForPushWithYunba",callback);
233
				execute("registerForPushWithYunba",[account],err);
234 234
			},unregisterForPushWithYunba:function(callback){
235
				storageCallback("unregisterForPush",callback);
236
				execute("unregisterForPush", []);
235
				storageCallback("unregisterForPushWithYunba",callback);
236
				execute("unregisterForPushWithYunba", []);
237 237
			},sendTextWithYunba:function(account,content,callback,err){
238
				storageCallback("sendText",callback);
239
				execute("sendText", [account,content],err);
238
				storageCallback("sendTextWithYunba",callback);
239
				execute("sendTextWithYunba", [account,content],err);
240 240
			},setCallbackForPushWithYunba:function(callback){
241
				execute("setCallbackForPush", [callback]);
241
				execute("setCallbackForPushWithYunba", [callback]);
242 242
			},aliPay:function(tradeNo,subject,body,price,callback,err){
243 243
				storageCallback("aliPay",callback);
244 244
				execute("aliPay",[tradeNo,subject,body,price],err);	

+ 40 - 0
display-server/web/template/webapp/plugin/YunbaPush.html

@ -6,6 +6,7 @@
6 6
	<title>云巴推送</title>
7 7
	{%>template/common/Head.html%}
8 8
	<link href="biz/css/project.css" rel="stylesheet" type="text/css" />
9
	<script type="text/javascript" src="biz/js/push/YunbaPush.js"></script>
9 10
</head>
10 11
<body>
11 12
<div class="c_navBar">
@ -16,5 +17,44 @@
16 17
		</div>
17 18
	</div>
18 19
</div>
20

21
<div class="c_list">
22
	<ul>
23
		<li ontap=";">
24
			<div class="content">
25
				
26
			</div>
27
		</li>
28
	</ul>
29
</div>
30
<div class="c_list">
31
	<ul>
32
		<li>
33
			<div class="content">
34
				<div class="value"><input type="text" class="e_left" id="alias" placeholder="昵称[字母/数字/下划线]" /></div>
35
				<div class="fn fn-2" id="register">连接</div>
36
			</div>
37
		</li>
38
	</ul>
39
</div>
40
<div class="c_list">
41
	<ul>
42
		<li>
43
			<div class="content">
44
				<div class="value"><input type="text" class="e_left" id="msgForSend" placeholder="发送信息" /></div>
45
				<div class="fn fn-2" id="send">发送</div>
46
			</div>
47
		</li>
48
		<li>
49
			<div class="content">
50
				<div id="msgForReceive" style="background-color:gray;color:white;height:190px;overflow-x:auto;overflow-y:auto;" class="panel panel-default col-sm-7 col-sm-offset-2">
51
					
52
				</div>
53
			</div>
54
		</li>
55
	</ul>
56
</div>
57
<div class="c_scroll c_scroll-mix c_scroll-fixed l_padding" style="top:2.22rem; bottom:0;" id="content">
58
</div>
19 59
</body>
20 60
</html>

+ 6 - 38
display-server/web/template/webapp/push/Push.html

@ -12,58 +12,26 @@
12 12

13 13
<div class="c_navBar">
14 14
	<div class="left">
15
	<div class="left">
16
	<div class="left">
15 17
		<div class="back">
16 18
			<span class="e_ico-back"></span>
17 19
			<span class="text">推送</span>
18 20
		</div>
19 21
	</div>
20 22
</div>
21
<div class="c_list">
22
	<ul>
23
		<li ontap=";">
24
			<div class="content">
25
				
26
			</div>
27
		</li>
28
	</ul>
29
</div>
23

30 24
<div class="c_list">
31 25
	<ul>
32 26
		<li>
33 27
			<div class="content">
34
				<div class="value"><input type="text" class="e_left" id="channel" placeholder="频道" /></div>
28
				<div class="value"><input type="text" class="e_left" id="account" placeholder="昵称" /></div>
35 29
				<div class="fn fn-2" id="register">连接</div>
36 30
			</div>
37 31
		</li>
38 32
	</ul>
39 33
</div>
40
<div class="c_list">
41
	<ul>
42
		<li>
43
			<div class="content">
44
				<div class="value"><input type="text" class="e_left" id="alias" placeholder="昵称[字母/数字/下划线]" /></div>
45
			</div>
46
		</li>
47
	</ul>
48
</div>
49
<div class="c_list">
50
	<ul>
51
		<li>
52
			<div class="content">
53
				<div class="value"><input type="text" class="e_left" id="msgForSend" placeholder="发送信息" /></div>
54
				<div class="fn fn-2" id="send">发送</div>
55
			</div>
56
		</li>
57
		<li>
58
			<div class="content">
59
				<div id="msgForReceive" style="background-color:gray;color:white;height:190px;overflow-x:auto;overflow-y:auto;" class="panel panel-default col-sm-7 col-sm-offset-2">
60
					
61
				</div>
62
			</div>
63
		</li>
64
	</ul>
65
</div>
66
<div class="c_scroll c_scroll-mix c_scroll-fixed l_padding" style="top:2.22rem; bottom:0;" id="content">
34
<div class="c_scroll c_scroll-mix c_scroll-fixed l_padding" style="top:1.22rem; bottom:0;" id="content">
67 35
</div>
68 36
</body>
69
</html>
37
</html>