-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch_friend_result.html
99 lines (82 loc) · 2.59 KB
/
search_friend_result.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<link href="css/mui.min.css" rel="stylesheet" />
</head>
<body>
<header class="mui-bar mui-bar-nav">
<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
<h1 class="mui-title">搜索结果</h1>
</header>
<div class="mui-content">
<br />
<ul class="mui-table-view">
<li class="mui-table-view-cell mui-media">
<a href="javascript:;">
<img id="photo" class="mui-media-object mui-pull-left" src="image/default_user_pic.png">
<div class="mui-media-body">
<span id="nickname">昵称名</span>
<p class="mui-ellipsis">HChat号:<span id="username">123123</span></p>
</div>
</a>
</li>
</ul>
<div style="margin:10px;">
<button id="add" type="button" class="mui-btn mui-btn-blue mui-btn-block">添加</button>
<button id="back" type="button" class="mui-btn mui-btn-block">返回</button>
</div>
</div>
<script src="js/mui.min.js"></script>
<script src="js/common.js"></script>
<script type="text/javascript">
mui.init();
mui.plusReady(function() {
var photo = document.getElementById("photo");
var nickname = document.getElementById("nickname");
var username = document.getElementById("username");
// 接收从上一个页面传递过来的数据
var friend = plus.webview.currentWebview().friend;
// 设置前端组件数据
photo.src = friend.picSmall;
nickname.innerHTML = friend.nickname;
username.innerHTML = friend.username;
var add = document.getElementById("add");
add.addEventListener("tap", function() {
var user = util.getUser();
mui.ajax(config.SERVER_URL + "/friend/sendRequest", {
data: {
fromUserid: user.id,
toUserid: friend.id
},
dataType: 'json', //服务器返回json格式数据
type: 'post', //HTTP请求类型
timeout: 10000, //超时时间设置为10秒;
headers: {
'Content-Type': 'application/json'
},
success: function(data) {
console.log("好友请求结果:" + JSON.stringify(data));
if(data.success) {
mui.toast(data.message);
mui.openWindow({
url: "index.html",
id: "index"
});
}
else {
mui.toast(data.message);
}
}
});
});
var back = document.getElementById("back");
back.addEventListener("tap", function() {
mui.back();
});
});
</script>
</body>
</html>