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 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233
| <!doctype html> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/> <meta name="format-detection" content="telephone=no,email=no,date=no,address=no"> <title></title> <link rel="stylesheet" type="text/css" href="../../css/api.css"/> <link rel="stylesheet" type="text/css" href="../../css/aui.css"/> <style> #userHeader { text-align: center; padding: 10px 0; background-color: #FFFFFF; margin-bottom: 10px; } #userHeader img { border-radius: 100%; width: 120px; height: 120px; } #userHeader h1 { font-size: 20px; } #userButton { display: -webkit-box; padding-bottom: 10px; } #userButton .aui-col-xs-6 { padding: 0 6px; } #userButton .aui-col-xs-6 .aui-btn { width: 100%; line-height: 26px; } #userInfo { background-color: #FFFFFF; padding: 0 12px; margin-bottom: 10px; } #userInfo li { border-bottom: 1px solid #e3e3e3; line-height: 56px; } #userInfo li:last-child { border-bottom: 0; } #userInfo li div { display: inline-block; margin-right: 15px; color: #8f8f94; } </style> </head> <body> <div class="aui-content"> <div id="userHeader"> <img id="info-head" src="../../image/default_head.jpg"/>
<h1 id="info-name"> </h1> </div> <ul id="userInfo"> <li> <div>性别</div> <span id="info-sex"> </span> </li> <li> <div>学校</div> <span id="info-school"> </span> </li> <li> <div>身份</div> <span id="info-role"> </span> </li> <li> <div>简介</div> <span id="info-intro"> </span> </li> </ul> <div id="userButton"> <div class="aui-col-xs-6"> <div class="aui-btn aui-btn-default" onclick="AddFriend();">关注</div> </div> <div class="aui-col-xs-6"> <div class="aui-btn aui-btn-danger" onclick="SendMessage();">发消息</div> </div> </div> </div> </body> <script type="text/javascript" src="../../script/api.js"></script> <script type="text/javascript"> var userId; var userName, headImgUrl; var defaultHeadImg = '../../image/default_head.jpg'; apiready = function () { $api.fixStatusBar($api.dom('header')); var pageParam = api.pageParam; userId = pageParam.userId; UpdateUserInfo(userId); }; function UpdateUserInfo(userId) { if(!!userId){ var model = api.require('model'); var query = api.require('query'); query.createQuery(function (ret, err) { if (ret && ret.qid) { var queryId = ret.qid; query.whereEqual({qid: ret.qid, column: 'id', value: userId}); query.include({qid: ret.qid, column: 'profile'}); model.findAll({ class: "user", qid: queryId }, function (ret, err) { if (ret) { var userInfo = ret[0]; var nickname = userName = userInfo.nickname; var url = headImgUrl = userInfo.avatar ? userInfo.avatar.url : defaultHeadImg; var profile = userInfo.profile || { role: '未知', school: '未知', intro: '这家伙很懒什么都没写', sex: '未知' }; $api.attr($api.byId('info-head'), 'src', url); $api.html($api.byId('info-name'), nickname); $api.html($api.byId('info-sex'), profile.sex); $api.html($api.byId('info-school'), profile.school); $api.html($api.byId('info-role'), profile.school); $api.html($api.byId('info-intro'), profile.intro); } }); } }); } } function AddFriend() { var myUserInfo = $api.getStorage('userInfo'); if (!!myUserInfo && !!myUserInfo.userId && !!userId) { api.showProgress({ style: 'default', animationType: 'fade', title: '努力加载中...', text: '先喝杯茶...' }); var myUserId = myUserInfo.userId; var model = api.require('model'); var query = api.require('query'); query.createQuery(function (ret, err) { if (ret && ret.qid) { var queryId = ret.qid; query.whereEqual({qid: queryId, column: 'userId', value: myUserId}); model.findAll({ class: "Friends", qid: queryId }, function (ret, err) { if (!!ret && ret.length > 0) { var data = ret[0]; var id = data.id; var friends = data.friends; if (!!friends.default) { if (friends.default.indexOf(userId) >= 0) { api.toast({msg: '已经添加过该好友了'}); return; } else { friends.default.push(userId); } } else { friends.default = [userId]; } model.updateById({ class: 'Friends', id: id, value: { friends: friends } }, function (ret, err) { api.hideProgress(); if (!!ret) { api.toast({msg: '添加好友成功'}); } else { api.toast({msg: '网络异常'}); } }) } else if (!!ret && ret.length == 0) { api.hideProgress(); model.insert({ class: 'Friends', value: { userId: userId, friends: { default: [userId] } } }); api.toast({msg: '添加好友成功'}); } }); } }); } else { api.toast({msg: '您尚未登录'}); } } function SendMessage() { if (!!userId && !!userName && !!headImgUrl) { api.openWin({ name: 'chattingFrame', url: '../message/chattingFrame.html', pageParam: { targetId: userId, targetName: userName, headImgUrl: headImgUrl, conversationType: 'PRIVATE' } }); } } </script> </html>
|