huangbo 9 gadi atpakaļ
vecāks
revīzija
4a27dfae47

+ 14 - 15
display-server/etc/lua/tag/WmDropmenu.lua

@ -4,7 +4,7 @@ local WmDropmenu = Class(Tag)
4 4

5 5
--htmlbuff
6 6
function WmDropmenu:createNew(obj,htmlbuff)
7
  self.htmlbuff=htmlbuff
7
  self.htmlbuff = htmlbuff
8 8
  self.clicks = {}
9 9
end
10 10

@ -59,14 +59,11 @@ function WmDropmenu:doEndTag()
59 59
 for k,v in pairs(self.clicks) do
60 60
    --print(k,v,type(v))
61 61
    if v~=-1 then
62
      self.htmlbuff:append([[
63
      items[]])
62
      self.htmlbuff:append('items[')
64 63
      self.htmlbuff:append(k-1)
65
      self.htmlbuff:append([[].click(function(){
66
          ]])
64
      self.htmlbuff:append('].setAction(function(){')
67 65
      self.htmlbuff:append(v)
68 66
      self.htmlbuff:append([[
69
      
70 67
        });
71 68
      ]])
72 69
    end
@ -80,6 +77,13 @@ function WmDropmenu:doEndTag()
80 77
  ]])
81 78
end
82 79

80
function WmDropmenu:addClicks(click)
81
  table.insert(self.clicks, click)
82
end
83

84

85
return WmDropmenu
86

83 87
--[[
84 88
require(["wmDropmenu","util"],function(WmDropmenu) {
85 89
  var wmDropmenu=new WmDropmenu(dropmenu01);
@ -96,7 +100,7 @@ require(["wmDropmenu","util"],function(WmDropmenu) {
96 100
  for(var i=0;i<items.length;i++){
97 101
    console.log("index:"+items[i].getIndex());
98 102
    console.log("parent:"+items[i].getParent());
99
    items[i].click(function(obj){
103
    items[i].setAction(function(obj){
100 104
      alert(obj.html());
101 105
    });
102 106
  }
@ -108,16 +112,16 @@ require(["wmDropmenu","util"],function(WmDropmenu) {
108 112
  }
109 113
  //wmDropmenu.removeAll();
110 114
  var item1=wmDropmenu.push("111");
111
  item1.click(function(obj){
115
  item1.setAction(function(obj){
112 116
    alert("我是新来的1");
113 117
  });
114 118
  var item2=wmDropmenu.push("22222");
115
  item2.click(function(obj){
119
  item2.setAction(function(obj){
116 120
    alert("我是新来的2");
117 121
  });
118 122
  item1.remove();
119 123
  //wmDropmenu.getItems()[0].remove();
120
  $("#testbtn").click(function(){
124
  $("#testbtn").setAction(function(){
121 125
    if(wmDropmenu.Invisible()){
122 126
      wmDropmenu.show();
123 127
    }else{
@ -127,9 +131,4 @@ require(["wmDropmenu","util"],function(WmDropmenu) {
127 131
});
128 132

129 133
]]
130
function WmDropmenu:addClicks(click)
131
  table.insert(self.clicks, click)
132
end
133

134 134

135
return WmDropmenu

+ 4 - 2
display-server/etc/server-data.xml

@ -1,6 +1,8 @@
1 1
<?xml version="1.0" encoding="UTF-8"?>
2 2
<datas>
3
    <action name="Login" class="com.ai.server.bean.LoginBean" method="login" verify="false" encrypt="true"></action>
4
	<action name="GetLoginInfo" class="com.ai.server.bean.LoginBean" method="getLoginInfo"></action>
3
    <action name="LoginBean.login" class="com.ai.server.bean.LoginBean" method="login" verify="false"></action>
4
	<action name="LoginBean.getLoginInfo" class="com.ai.server.bean.LoginBean" method="getLoginInfo"></action>
5
	<action name="LoginBean.setLoginInfo" class="com.ai.server.bean.LoginBean" method="setLoginInfo"></action>
6
	
5 7
	<action name="receiveData" class="com.ai.server.bean.TestBean" method="receive" verify="false"></action>
6 8
</datas>

+ 4 - 0
display-server/etc/server-page.xml

@ -81,4 +81,8 @@
81 81
    
82 82
    <action name="WmRefreshSrc" template="template/webapp/tag/WmRefreshSrc.html"></action>
83 83
    <action name="WmRefresh" template="template/webapp/tag/WmRefresh.html"></action>
84
    
85
    <!-- Scene Demo -->
86
	<action name="Scene" template="template/webapp/scene/Scene.html"></action>
87
	<action name="Login" template="template/webapp/scene/Login.html"></action>
84 88
</pages>

+ 5 - 1
display-server/src/com/ai/server/bean/LoginBean.java

@ -16,7 +16,11 @@ public class LoginBean extends DisplayBean{
16 16
	}
17 17
	
18 18
	public IData getLoginInfo(IData param) throws Exception{
19
		getContextData().setAccount("更新工号");
19
		return getContextData().getData();
20
	}
21
	
22
	public IData setLoginInfo(IData param) throws Exception{
23
		getContextData().setAccount(param.getString("NEW_ACCOUNT"));
20 24
		return getContextData().getData();
21 25
	}
22 26
}

+ 7 - 7
display-server/web/biz/js/scene/Login.js

@ -1,15 +1,15 @@
1 1
require(["wmTabbar","common","mobile"], function(WmTabbar,Common,Mobile) {
2 2
	var loginData = new Wade.DataMap();
3
	
4 3
	loginData.put("ACCOUNT","测试工号");
5
	Common.callSvc("Login",loginData,function(data){
6
		alert("登陆成功:"+data);
4
	Common.callSvc("LoginBean.login",loginData,function(data){
5
		console.log("登陆成功:" + data);
7 6
		Common.put("SESSION_ID",data.get("SESSION_ID"));
8 7
		setTimeout(function(){
9
			Common.callSvc("GetLoginInfo",data,function(info){
10
				alert(info)
11
				Common.callSvc("GetLoginInfo",info,function(info1){
12
					alert(info1)
8
			data.put("NEW_ACCOUNT","更新工号");
9
			Common.callSvc("LoginBean.setLoginInfo",data,function(result){
10
				console.log("更新信息:" + result);
11
				Common.callSvc("LoginBean.getLoginInfo",null,function(result){
12
					console.log("获取信息:" + result);
13 13
				});
14 14
			});
15 15
		},200);

+ 2 - 2
display-server/web/biz/js/tag/WmDropmenu.js

@ -57,12 +57,12 @@ require(["domReady!","wmWebUI","jcl","mobile"],function(doc,WmWebUI,$,Mobile){
57 57
		dropmenu.removeAll();
58 58
		alert("清除成功。");
59 59
	});
60
/*	$("#push").on("tap",function(){
60
	$("#push").on("tap",function(){
61 61
		var dropmenu=WmWebUI.select("dropmenu01");
62 62
		var str=prompt("请输入菜单显示条目。示例:中国");
63 63
		dropmenu.push(str);
64 64
		alert("添加成功。")
65
	});*/
65
	});
66 66
	$("#remove").on("tap",function(){
67 67
		var dropmenu=WmWebUI.select("dropmenu01");
68 68
		var items=dropmenu.getItems();

+ 4 - 1
display-server/web/res/js/mobile/mobile-browser.js

@ -18,7 +18,7 @@ define(["browserTool","jcl"],function(browserTool,Wade) {
18 18
		/******************数据请求**********************/
19 19
		/*调用服务*/
20 20
		this.dataRequest = function(action, param, callback, isEscape, err) {
21
			browserTool.ajax.post(action, param, function(resultData){
21
			/*browserTool.ajax.post(action, param, function(resultData){
22 22
				resultData = Wade.DataMap(resultData);
23 23
				var x_resultcode = resultData.get("X_RESULTCODE");
24 24
				if(x_resultcode < 0){
@ -26,6 +26,9 @@ define(["browserTool","jcl"],function(browserTool,Wade) {
26 26
				}else{
27 27
					callback(resultData);
28 28
				};
29
			}, isEscape, err);*/
30
			browserTool.ajax.post(action, param, function(resultData){
31
				callback(resultData);
29 32
			}, isEscape, err);
30 33
		};
31 34
		/******************页面跳转**********************/

+ 83 - 85
display-server/web/res/js/ui/wm-dropmenu.js

@ -4,65 +4,52 @@
4 4
 * example:
5 5
 * 		new IScroll("#content",{tap:true,scrollbars: true,useTransform:false});  
6 6
 */
7
define(["jcl","iScroll","wmWebUI"],function($,iScrol,WmWebUI){
8
	function DropmenuItem(obj,parent){
9
		this.entity=obj;
10
		this.parent=parent;
7
define(["jcl","wmWebUI"],function($,WmWebUI){
8
	/*下拉菜单构造方法*/
9
	function WmDropmenu(id) {
10
		this.items = new Array();
11
		var dropmenu = WmWebUI.getElement(id);
12
		/* 使用children方法代替子元素选择器,是为了防止有子元素误判 */
13
		this.labelButton = dropmenu.children("div").eq(0).children("span").eq(0);
14
		this.menu = dropmenu.children("div").eq(1);
15
		this.closeAction;// 关闭事件
16
		this.openAction;// //打开事件
11 17
	}
12
	DropmenuItem.prototype.remove=function(){
13
		this.entity.parentNode.removeChild(this.entity);
14
		this.parent.initMenu();
15
		this.parent.items.splice(this.getIndex(),1)
18
	/*下拉菜单项构造方法*/
19
	function WmDropmenuItem(dropmenu, index, dropmenuItem) {
20
		this.dropmenu = dropmenu;
21
		this.index = index;
22
		this.dropmenuItem = dropmenuItem;
16 23
	}
17
	DropmenuItem.prototype.html=function(html){
18
		if(html==undefined){
19
			return this.entity.innerHTML;
20
		}else{
21
			this.entity.innerHTML=html;
24
	/*移除下拉选项*/
25
	WmDropmenuItem.prototype.remove = function() {
26
		this.dropmenuItem.parentNode.removeChild(this.dropmenuItem);
27
		this.dropmenu.items.splice(this.index, 1);//删除第index个元素
28
		for ( var i = this.index; i < this.dropmenu.items.length; i++) {
29
			this.dropmenu.items[i].index = i;
22 30
		}
31
		this.dropmenu.initMenu();
23 32
	}
24
	DropmenuItem.prototype.click=function(callback){
25
		var that=this;
26
		this.entity.onclick=function(){
27
			callback(that);
33
	/*设置下拉选项的文本内容*/
34
	WmDropmenuItem.prototype.html = function(html) {
35
		if (html == undefined) {
36
			return this.dropmenuItem.innerHTML;
37
		} else {
38
			this.dropmenuItem.innerHTML = html;
28 39
		}
29 40
	}
30
	DropmenuItem.prototype.getIndex=function(){
31
		for(var i=0;i<this.parent.items.length;i++){
32
			if(this.parent.items[i]==this){
33
				return i;
34
			}
41
	/*设置下拉选项的事件*/
42
	WmDropmenuItem.prototype.setAction = function(callback) {
43
		var that = this;
44
		this.dropmenuItem.onclick = function() {
45
			callback(that);
35 46
		}
36
		return -1;
37
	}
38
	DropmenuItem.prototype.getParent=function(){
39
		return this.parent;
40 47
	}
41
	function WmDropmenu(id){
42
		this.entity=(function(obj){
43
			if(typeof(obj)=="object"){
44
				obj=$(obj);
45
			}else if(typeof(obj)=="string"){
46
				obj=$("#"+obj);
47
			}else{
48
				alert("没有匹配的类型");
49
				return null;
50
			}
51
			return obj;
52
		})(id);
53
		this.btn=this.entity.children("div").eq(0).children("span").eq(0);
54
		this.menu=this.entity.children("div").eq(1);
55
		this.closeAction=function(){};
56
		this.openAction=function(){};
57
		this.items=new Array();
58
		this.lis=this.menu.children("ul").children("li");
59
		this.temp=false;
60
		var that=this;
61
		$.each(this.lis,function(index,obj){
62
			var item=new DropmenuItem(obj,that);
63
			that.items.push(item);
64
		});
48
	/*获取下拉选项的序号*/
49
	WmDropmenuItem.prototype.getIndex=function(){
50
		return this.index;
65 51
	}
52
	/*初始化下拉菜单*/
66 53
	WmDropmenu.prototype.initMenu=function(){
67 54
		this.menu.css("display","");
68 55
		//设置 dropmenu
@ -70,72 +57,83 @@ define(["jcl","iScroll","wmWebUI"],function($,iScrol,WmWebUI){
70 57
		this.menu.children("ul").css("top",(this.menu.height())*(-1) + "px");
71 58
		this.menu.children("ul").css("transition","-webkit-transform 0.2s ease-out");
72 59
		this.menu.children("ul").css("-webkit-transition","transform 0.2s ease-out");
73
		this.btn.children(".e_ico-unfold").css("transition","transform 0.2s ease-out");
74
		this.btn.children(".e_ico-unfold").css("-webkit-transition","-webkit-transform 0.2s ease-out");
60
		this.labelButton.children(".e_ico-unfold").css("transition","transform 0.2s ease-out");
61
		this.labelButton.children(".e_ico-unfold").css("-webkit-transition","-webkit-transform 0.2s ease-out");
75 62
		this.menu.css("visibility","hidden");
76 63
		//位置
77
		this.menu.css("left",this.btn.offset().left + this.btn.width() - this.menu.width());//靠右要减去这两个 width(),靠左则不需要
78
		this.menu.css("top",this.btn.offset().top + 1.1 * this.btn.height());/*modified*/
64
		this.menu.css("left",this.labelButton.offset().left + this.labelButton.width() - this.menu.width());//靠右要减去这两个 width(),靠左则不需要
65
		this.menu.css("top",this.labelButton.offset().top + 1.1 * this.labelButton.height());/*modified*/
79 66
		this.menu.css("display","none");
80 67
		this.menu.css("visibility","visible");
81 68
	}
82
	WmDropmenu.prototype.create=function(){
69
	WmDropmenu.prototype.create = function() {
70
		var that = this;
71
		var lis = this.menu.children("ul").children("li");
72
		lis.each(function(index) {
73
			that.items.push(new WmDropmenuItem(that, index, this));
74
		});
75

83 76
		this.initMenu();
84
		var that=this;
85
		//显隐
86
		this.btn.tap(function(){
87
			if(that.invisible()){
77
		// 显隐
78
		this.labelButton.tap(function() {
79
			if (that.invisible()) {
88 80
				that.show();
89
			}else{
81
			} else {
90 82
				that.hidden();
91 83
			}
92 84
		});
93 85
	};
94
	WmDropmenu.prototype.invisible=function(){
86
	/*判断下拉菜单是否可见*/
87
	WmDropmenu.prototype.invisible = function() {
95 88
		return this.menu.css("display") == "none";
96 89
	};
97
	WmDropmenu.prototype.show=function(){
90
	/*显示下拉菜单*/
91
	WmDropmenu.prototype.show = function() {
98 92
		this.openAction();
99
		this.menu.css("display","block");
93
		this.menu.css("display", "block");
100 94
		this.menu.children("ul").css("transform","translateY(" + this.menu.height() + "px)");
101 95
		this.menu.children("ul").css("-webkit-transform","translateY(" + this.menu.height() + "px)");
102
		this.btn.find(".e_ico-unfold").css("transform","rotate(180deg)");
103
		this.btn.find(".e_ico-unfold").css("-webkit-transform","rotate(180deg)");
96
		this.labelButton.find(".e_ico-unfold").css("transform","rotate(180deg)");
97
		this.labelButton.find(".e_ico-unfold").css("-webkit-transform","rotate(180deg)");
104 98
	};
105
	WmDropmenu.prototype.hidden=function(){
99
	/*隐藏下拉菜单*/
100
	WmDropmenu.prototype.hidden = function(){
106 101
		this.closeAction();
107 102
		this.menu.children("ul").css("transform","translateY(0)");
108 103
		this.menu.children("ul").css("-webkit-transform","translateY(0)");
109
		this.btn.find(".e_ico-unfold").css("transform","rotate(0)");
110
		this.btn.find(".e_ico-unfold").css("-webkit-transform","rotate(0)");
104
		this.labelButton.find(".e_ico-unfold").css("transform","rotate(0)");
105
		this.labelButton.find(".e_ico-unfold").css("-webkit-transform","rotate(0)");
111 106
		this.menu.css("display","none");
112 107
	};
113
	WmDropmenu.prototype.removeAll=function(){
114
		this.menu.children("ul")[0].innerHTML="";
115
		this.items=new Array();
108
	/*删除所有下拉菜单选项*/
109
	WmDropmenu.prototype.removeAll = function() {
110
		this.menu.children("ul")[0].innerHTML = "";
111
		this.items = new Array();
116 112
	};
117
	WmDropmenu.prototype.push=function(obj){
113
	/*添加下拉菜单选项*/
114
	WmDropmenu.prototype.push = function(obj){
118 115
		this.menu.children("ul").append("<li>"+obj+"</li>");
119 116
		this.initMenu();
120
		var li=this.menu.children("ul").children("li").last()[0];
121
		var item=new DropmenuItem(li,this);
117
		var lis = this.menu.children("ul").children("li");
118
		var item = new WmDropmenuItem(this,lis.length-1,lis.last()[0]);
122 119
		this.items.push(item);
123 120
		return item;
124 121
	};
125
	WmDropmenu.prototype.setLabel=function(label){
126
		this.btn.children("span")[0].innerHTML=label;
127
	};
128
	WmDropmenu.prototype.getLabel=function(){
129
		return this.btn.children("span")[0].innerHTML;
122
	/* 设置下拉菜单文本 */
123
	WmDropmenu.prototype.setLabel = function(label) {
124
		this.labelButton.children("span")[0].innerHTML = label;
130 125
	};
131
	WmDropmenu.prototype.setCloseAction=function(callback){
132
		this.closeAction=callback;
126
	/* 获取下拉菜单文本 */
127
	WmDropmenu.prototype.getLabel = function() {
128
		return this.labelButton.children("span")[0].innerHTML;
133 129
	};
134
	WmDropmenu.prototype.setOpenAction=function(callback){
135
		this.openAction=callback;
130
	/* 设置关闭下拉菜单事件 */
131
	WmDropmenu.prototype.setCloseAction = function(callback) {
132
		this.closeAction = callback;
136 133
	};
137
	WmDropmenu.prototype.getItems=function(){
138
		return this.items;
134
	/* 设置打开下拉菜单事件 */
135
	WmDropmenu.prototype.setOpenAction = function(callback) {
136
		this.openAction = callback;
139 137
	};
140 138
	return WmDropmenu;
141 139
});

+ 4 - 1
display-server/web/template/lua/tag/WmDropmenu.lua

@ -63,7 +63,9 @@ function WmDropmenu:doEndTag()
63 63
      self.htmlbuff:append(k-1)
64 64
      self.htmlbuff:append('].setAction(function(){')
65 65
      self.htmlbuff:append(v)
66
      self.htmlbuff:append('});')
66
      self.htmlbuff:append([[
67
        });
68
      ]])
67 69
    end
68 70
  end
69 71
  self.htmlbuff:append([[
@ -79,6 +81,7 @@ function WmDropmenu:addClicks(click)
79 81
  table.insert(self.clicks, click)
80 82
end
81 83

84

82 85
return WmDropmenu
83 86

84 87
--[[

+ 6 - 4
display-server/web/template/lua/tag/WmDropmenuItem.lua

@ -2,17 +2,19 @@ local Class = require("util.Class")
2 2
local Tag = require("engine.Tag")
3 3
local WmDropmenuItem = Class(Tag)
4 4

5
function WmDropmenuItem:createNew(obj, htmlbuff)
6
  self.htmlbuff = htmlbuff
5
function WmDropmenuItem:createNew(obj,htmlbuff)
6
  self.htmlbuff=htmlbuff
7 7
end
8 8

9 9
function WmDropmenuItem:doStartTag(attr)
10 10
  self.parent:addClicks(attr.click or -1);
11
  self.htmlbuff:append('<li>')
11
  self.htmlbuff:append([[
12
    <li>]])
13
 
12 14
end
13 15

14 16
function WmDropmenuItem:doEndTag()
15
 self.htmlbuff:append('</li>');
17
 self.htmlbuff:append([[</li> ]]);
16 18
end
17 19

18 20
return WmDropmenuItem

+ 1 - 1
display-server/web/template/webapp/More.html

@ -7,7 +7,7 @@
7 7
		<div class="pic"><span class="e_ico-chat"></span></div>
8 8
		<div class="text">推送展示</div>
9 9
	</li>
10
	<li action="Push">
10
	<li action="Scene">
11 11
		<div class="pic"><span class="e_ico-scene"></span></div>
12 12
		<div class="text">场景展示</div>
13 13
	</li>

+ 22 - 0
display-server/web/template/webapp/scene/Login.html

@ -0,0 +1,22 @@
1
<!DOCTYPE HTML>
2
<html class="s_bs">
3
<head>
4
	<meta charset="utf-8" />
5
	<meta name="viewport" content="target-densitydpi=device-dpi, width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1" />
6
	<title>登陆</title>
7
	{%>template/common/Head.html%}
8
	<link href="biz/css/project.css" rel="stylesheet" type="text/css" />
9
	<script type="text/javascript" src="biz/js/scene/Login.js"></script>
10
</head>
11
<body>
12
<div class="c_navBar">
13
	<div class="left">
14
		<div class="back">
15
			<span class="e_ico-back"></span>
16
			<span class="text">登陆</span>
17
		</div>
18
	</div>
19
</div>
20

21
</body>
22
</html>

+ 67 - 0
display-server/web/template/webapp/scene/Scene.html

@ -0,0 +1,67 @@
1
<!DOCTYPE HTML>
2
<html class="s_bs">
3
<head>
4
	<meta charset="utf-8" />
5
	<meta name="viewport" content="target-densitydpi=device-dpi, width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1" />
6
	<title>场景演示</title>
7
	{%>template/common/Head.html%}
8
	<link href="biz/css/project.css" rel="stylesheet" type="text/css" />
9
</head>
10
<body>
11
<div class="c_navBar">
12
	<div class="left">
13
		<div class="back">
14
			<span class="e_ico-back"></span>
15
			<span class="text">场景演示</span>
16
		</div>
17
	</div>
18
</div>
19

20
<div class="m_content m_content-nofooter">
21
<div>
22
	<div class="c_list">
23
		<ul id="scene-menu">
24
			<li action="Login">
25
				<div class="content">
26
					<div class="main">
27
						<div class="title">登陆</div>
28
						<div class="info">登陆场景</div>
29
						<div class="info">登陆场景详细描述</div>
30
					</div>
31
				</div>
32
			</li>
33
			<li action="PageRedirect">
34
				<div class="content">
35
					<div class="main">
36
						<div class="title">页面跳转</div>
37
					</div>
38
				</div>
39
			</li>
40
			<li action="DataRequest">
41
				<div class="content">
42
					<div class="main">
43
						<div class="title">数据请求</div>
44
					</div>
45
				</div>
46
			</li>
47
		</ul>
48
	</div>
49
</div>
50
</div>
51
</body>
52
<script type="text/javascript">
53
require(["mobile"], function(Mobile) {
54
	$("#scene-menu > li").each(function(index, item) {
55
		if (item.getAttribute("action") != "null") {
56
			$(item).tap(function() {
57
				Mobile.openPage(item.getAttribute("action"));
58
			});
59
		} else {
60
			item.onclick = function() {
61
				alert("敬请期待……");
62
			};
63
		}
64
	});
65
});
66
</script>
67
</html>