github.com/jincm/wesharechain@v0.0.0-20210122032815-1537409ce26a/app/html/near/near_goodman.html (about) 1 <!doctype html> 2 <html> 3 <head> 4 <meta charset="UTF-8"> 5 <meta name="copyright" content="www.apicloud.com" /> 6 <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/> 7 <title>附近好人</title> 8 <link rel="stylesheet" type="text/css" href="../../css/api.css" /> 9 <link rel="stylesheet" type="text/css" href="../../css/idangerous.swiper.css"> 10 <style> 11 html,body {min-height: 100%;} 12 .fr {float: right;} 13 .fl {float: left;} 14 .mt5 {margin-top: 5px;} 15 .mt10 {margin-top: 10px;} 16 .mt15 {margin-top: 15px;} 17 .mt20 {margin-top: 20px;} 18 .ml5 {margin-left: 0.5em;} 19 .mr5 {margin-right: 0.5em;} 20 .hdivider {width: 100%; height: 1px;background-color: #e0e0e0;} 21 22 .row {display: -webkit-box;display: -webkit-flex;} 23 .col {-webkit-box-flex:1; -webkit-flex:1; flex:1;margin: 0 5px; position: relative;} 24 25 .swiper-container img {width: 100%;} 26 27 /* 标题 */ 28 .sectionTitle {height: 2em; line-height: 2em; font-size: 1.12em;} 29 .sectionTitle .titleDivider {display: inline-block; height: 1.12em; width: 3px; vertical-align: top; background-color: #D43C33; margin-top: 0.44em; margin-left: 0.7em; margin-right: 0.3em;} 30 /* */ 31 .col .listcoverbar {position: absolute; top: 0; background-color: rgba(0,0,0,0.4); width: 100%;height: 1.2em;} 32 .col .listcoverbar span {color: #fff;} 33 .col .listcoverbar .earphone {width: 1em; margin-top: 0.2em; margin-right: 0.3em;} 34 .col .listcover {width: 100%;} 35 .col .listtitle {height: 2.4em; font-size: 1em; line-height: 1.2em; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;} 36 37 /* item样式 */ 38 .egret-item {height: 4em;} 39 .egret-item .egret-item-box-cover-center {display: table; height: inherit;} 40 .egret-item .egret-item-box-cover-center .egret-item-box-abtc {display: table-cell; vertical-align: middle;} 41 .egret-item .egret-item-box-cover-center .egret-item-box-abtc img {width: 3em; vertical-align: top;} 42 /* 右侧箭头样式 */ 43 .egret-item .egret-item-arrow {display: table; height: inherit;} 44 .egret-item .egret-item-arrow .egret-item-box-abtc {display: table-cell; vertical-align: middle;} 45 .egret-item .egret-item-arrow .egret-item-box-abtc img {width: 0.8em; vertical-align: top;} 46 /* 中间shelf 两个条目*/ 47 .egret-item .egret-item-shelf {height: inherit; } 48 .egret-item .egret-item-shelf .egret-item-shelf-title {font-size: 1.1em; margin-top: 0.6em;} 49 .egret-item .egret-item-shelf .egret-item-shelf-subtitle {font-size: 0.6em; color: #666; margin-top: 0.6em;} 50 /* 中间shelf 一个条目 */ 51 .egret-item .egret-item-shelf-single {height: inherit; line-height: 4em;font-size: 1.1em;} 52 .egret-item .egret-item-shelf-redclassify {color: #E03F40; border:1px solid #E03F40; font-size: inherit;padding: 0.1em;border-radius: 1px;margin-right: 5px;} 53 54 55 /* 用flex重写框架 */ 56 .egret-flex-item {display: -webkit-box;-webkit-box-align:center;height: 4em;} 57 /* 左部logo */ 58 .egret-flex-item-logo {max-width: 50px; min-width: 50px; margin-left: 0.5em; margin-right: 0.2em;-webkit-box-flex: 1; -webkit-box-align: center;} 59 .egret-flex-item-logo img {height: 3em; width: 3em; -webkit-box-align: center;vertical-align: top;/*否则图片不会居中,底部仍然是会有空白*/} 60 /* 中间文本信息 */ 61 .egret-flex-item-shelf {overflow: hidden; -webkit-box-flex:2; -webkit-box-align: center;} 62 .egret-flex-item-shelf div {text-overflow: ellipsis; white-space: nowrap; overflow: hidden;} 63 .egret-flex-item-shelf .egret-flex-item-shelf01 {font-size: 1.1em;} 64 .egret-flex-item-shelf .egret-flex-item-shelf02 {font-size: 0.6em; color: #666; margin-top: 0.6em;} 65 .egret-flex-item-shelf .egret-flex-item-redclassify {color: #E03F40; border: 1px solid #E03F40; font-size: inherit; padding: 0 0.1em; border-radius: 1px; margin-right: 5px;box-sizing: border-box;} 66 67 /* 右部箭头 */ 68 .egret-flex-item-arrow {-webkit-box-flex: 1;max-width: 10px; min-width: 10px; margin-right: 5px;} 69 .egret-flex-item-arrow img {width: 100%; max-width: 10px;} 70 71 72 /* 关注card */ 73 .sharecard {display: -webkit-box;margin-left: 10px;margin-right: 10px;margin-top: 10px;padding: 10px 10px 15px 10px;border: 1px solid #e0e0e0;background-color: #fff;} 74 .sharecard .userlogo {margin-right: 10px;} 75 .sharecard .userlogo img {width: 40px;vertical-align: top;border-radius: 20px;} 76 .sharecard .rightcol {-webkit-box-flex: 1;} 77 .sharecard .rightcol .usertitle {font-size: 0.9em; color: #666;} 78 .sharecard .rightcol .usertitle .username{font-size: 1em; color: #507DAF; margin-right: 5px;} 79 .sharecard .rightcol .usertitle .sharetime{float: right; font-size: 0.6em; color: #999;} 80 .sharecard .rightcol .sharecontent {font-size: 1em; line-height: 1.3em;padding-top: 5px;} 81 .sharecard .rightcol .sharemusic{display: -webkit-box;margin-top: 15px;border: 1px solid #e0e0e0;-webkit-box-align: center;} 82 .sharecard .rightcol .sharemusic .musiclogo {padding: 5px;} 83 .sharecard .rightcol .sharemusic .musiclogo img {vertical-align: top;width: 60px;} 84 .sharecard .rightcol .sharemusic .musictitle {} 85 .sharecard .rightcol .sharemusic .musictitle .title02 {font-size: 0.8em;color: #666;margin-top: 10px;} 86 .sharetool {display: -webkit-box; height: 30px; line-height: 30px; margin: 0 10px 10px 10px;border: 1px solid #e0e0e0; border-top: 0;background-color: #fff;} 87 .sharetool .tool {-webkit-box-flex:1;text-align: center;} 88 .sharetool .tool span {font-size: 0.8em; color: #666;} 89 .sharetool .tool img {width: 16px;vertical-align: top;padding: 7px;} 90 91 /* 悬浮 */ 92 .fmbtnhover {background: #D8D9DA ;} 93 .fmbtnhoverinside {background: #D8D9DA ;} 94 95 </style> 96 </head> 97 98 <body> 99 100 101 <!--D:\srccode\zuohaoshi\client\demo\wangyimusic20141207\html\third_frame\frame0301.html--> 102 103 <div class="sectionTitle mt20" id="data_div"></div> 104 105 <script id="mytmpl" type="text/x-dot-template"> 106 {{ if(it && it.length > 0){ }} 107 {{ for(var i=0;i<it.length;i++){ }} 108 109 <div class="egret-flex-item" tapmode="fmbtnhover" onclick="openUserDetail('{{=it[i].id}}','{{=it[i].name}}')"> 110 <div class="egret-flex-item-logo"> 111 <img src="../../image/test/frame0103cover09.jpg" alt="" class=""> 112 </div> 113 <div class="egret-flex-item-shelf"> 114 {{ if(it[i].id){ }} 115 <div class="egret-flex-item-shelf01">{{=it[i].id}} phone:{{=it[i].name}}</div> 116 {{ }else{ }} 117 <div class="egret-flex-item-shelf01">无名</div> 118 {{ } }} 119 120 121 {{ if(it[i].content){ }} 122 <div class="egret-flex-item-shelf02"><span class="egret-flex-item-redclassify">好人</span>抬头看天,低头看地,平头看人!</div> 123 {{ }else{ }} 124 <div class="egret-flex-item-shelf02"><span class="egret-flex-item-redclassify">好人</span>抬头看天,低头看地,平头看人!</div> 125 {{ } }} 126 </div> 127 </div> 128 129 {{ } }} 130 131 {{ }else{ }} 132 <li>没有数据</li> 133 {{ } }} 134 </script> 135 136 <script type="text/javascript" src="../../script/api.js"></script> 137 <script type="text/javascript" src="../../script/idangerous.swiper.js"></script> 138 <script type="text/javascript" src="../../script/doT.min.js" charset="utf-8"></script> 139 <script type="text/javascript" src="../../script/app.js"></script> 140 141 <script type="text/javascript" charset="utf-8"> 142 143 144 </script> 145 146 <script type="text/javascript"> 147 148 function openUserDetail(user_id,user_name) { 149 150 alert("应该跳转到user页面 id " + user_id + ":" + user_name); 151 152 /*winName = grouptype + "_" + type + "_detail" 153 winUrl = winName + "_win.html" 154 api.openWin({ 155 name: winName, 156 url: winUrl, 157 pageParam: {dataId: did} 158 });*/ 159 } 160 161 var headerPos; 162 163 window.onload = function() { 164 } 165 166 apiready = function () { 167 console.log("come setFrameGroupIndex:win name:" + api.winName + " framename:" + api.frameName); 168 169 var pageSize=10; // 页容量 170 var totalData=0; // 定义一个变量存储第一次加载返回来的总记录数 171 var totalPages=0; // 定义一个变量存储第一次加载返回来的总页数 172 var tmp_html = ""; 173 $api.setStorage("currentPage", 1); // 默认设置为第一页 174 175 // 加载数据 176 // @currentPage:当前页码 177 // @isReload:是否为刷新操作 178 function loadData(currentPage,isReload){ 179 currentPage=isReload?1:currentPage; 180 181 user_id = $api.getStorage("user_id"); 182 //token = $api.getStorage("token"); 183 184 url = "/u/" + "/users/search?loc_x=116&loc_y=40&_id=-1" ;//+ "&limit=" + pageSize + "&offset=" + currentPage; 185 //url = "/u/" + "/users/search" ; //tmp for loc is null 186 myajax(url,'GET','', function(ret,err){ 187 if (ret) { 188 console.log("ret body = " + JSON.stringify(ret.body)); 189 //totalData=ret.totalCount; 190 //totalPages=ret.totalPages; 191 //var data=ret.data; 192 /* 193 { 194 pageSize:10, // 页码 195 currentPage:1, // 当前页 196 totalCount:100, // 总记录数 197 totalPages:10, // 总页数 198 data:[ // 当前页查询的记录 199 {id:1,name:'新生帝',age:22}, 200 {id:2,name:'流浪男',age:28} 201 ] 202 } 203 */ 204 totalData = 10; 205 totalPages = 8; 206 if(isReload){ 207 $api.setStorage("currentPage", 1); // 重新设置为1 208 tmp_html = ""; 209 } 210 211 // 渲染HTML 212 //get data from server 213 var obj = new Array(); 214 215 for(var i = 0; i < ret.body.users.length; i++) { 216 console.log(ret.body.users[i]._id); 217 console.log(ret.body.users[i].account); 218 obj.push({"id":ret.body.users[i]._id,"name":ret.body.users[i].account,"content":ret.body.users[i].account}); 219 } 220 /*obj = [ {"id":"123451","name":"user1","content":"user1 is a good man"}, 221 {"id":"123452","name":"user2","content":"user2 is a good man"}, 222 {"id":"123453","name":"user3","content":"user3 is a good man"}, 223 {"id":"123454","name":"user4","content":"user4 is a good man"}, 224 {"id":"123455","name":"user5","content":"user5 is a good man"}, 225 {"id":"123456","name":"user6","content":"user6 is a good man"}, 226 {"id":"123457","name":"user7","content":"user7 is a good man"}, 227 {"id":"123458","name":"user8","content":"user8 is a good man"}, 228 {"id":"123459","name":"user9","content":"user9 is a good man"}, 229 {"id":"123460","name":"user10","content":"user10 is a good man"}, 230 {"id":"123461","name":"user11","content":"user11 is a good man"}, 231 {"id":"123462","name":"user12","content":"user12 is a good man"} ];*/ 232 233 var data_div = $api.byId('data_div'); 234 var tpl = $api.byId('mytmpl').text; 235 var tempFn = doT.template(tpl); 236 data_div.innerHTML = tempFn(obj); 237 238 }else { 239 api.alert({ 240 msg:('错误码:'+err.code+';错误信息:'+err.msg+';网络状态码:'+err.statusCode) 241 }); 242 } 243 }); 244 } 245 246 // 结合下拉刷新 247 api.setRefreshHeaderInfo({ 248 visible: true, 249 loadingImg: 'widget://image/near/refresh.png', 250 bgColor: '#ccc', 251 textColor: '#fff', 252 textDown: '下拉刷新...', 253 textUp: '松开刷新...', 254 showTime: true 255 }, function(ret, err){ 256 257 loadData(1,true); // 第一次加载 258 api.refreshHeaderLoadDone(); 259 }); 260 261 // 默认第一次打开页面就下拉加载数据 262 api.refreshHeaderLoading(); 263 264 265 // 结合上拉刷新: 266 api.addEventListener({ 267 name:'scrolltobottom', 268 extra:{ 269 threshold:0 //设置距离底部多少距离时触发,默认值为0,数字类型 270 } 271 },function(ret,err){ 272 var _page=parseInt($api.getStorage("currentPage")); 273 if(_page+1<=totalPages){ 274 loadData(_page+1,false); 275 $api.setStorage("currentPage", _page+1); // 页码+1 276 } 277 else{ 278 alert("没有更多数据了!"); 279 } 280 }); 281 282 } 283 </script> 284 </html>