news_win.html 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
  6. <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
  7. <meta name="format-detection"content="telephone=no">
  8. <title>index</title>
  9. <link rel="stylesheet" type="text/css" href="../../css/api.css"/>
  10. <link rel="stylesheet" href="../../css/style.css">
  11. <link rel="stylesheet" href="../../css/projeck.css">
  12. <style media="screen">
  13. body,html{
  14. margin: 0;
  15. background: #fff;
  16. }
  17. .api_layout{
  18. height: 100%;
  19. }
  20. .aui-searchbar{
  21. width: 100%;
  22. height: 50px;
  23. background-color: #efeff4;
  24. position: relative;
  25. }
  26. .aui-searchbar:after{
  27. content: "";
  28. position: absolute;
  29. bottom: 0;
  30. left: 0;
  31. width: 100%;
  32. height: 1px;
  33. background: #e7e8eb;
  34. }
  35. .aui-searchbar .aui-searchbar-btn{
  36. color: #fff;
  37. }
  38. .aui-searchbar-input{
  39. background: #fff;
  40. }
  41. .aui-searchbar-input input{
  42. color: #000;
  43. }
  44. #search-input::placeholder{
  45. color: #ccc;
  46. font-size: 14px;
  47. }
  48. .search_ico{
  49. width: 16px;
  50. height: 16px;
  51. display: block;
  52. position: absolute;
  53. background: url("../../image/search.png") no-repeat;
  54. background-size: cover;
  55. top: 8px;
  56. left: 17px;
  57. }
  58. .backBtn{
  59. margin-left: 5px;
  60. }
  61. #search-input{
  62. font-size: 14px;
  63. height: 28px;
  64. }
  65. .aui-searchbar-input{
  66. margin-right: 80px;
  67. }
  68. .search_btn{
  69. position: absolute;
  70. bottom: 9px;
  71. right: 10px;
  72. width: 54px;
  73. height: 31px;
  74. line-height: 31px;
  75. -webkit-border-radius: 50px;
  76. -moz-border-radius: 50px;
  77. border-radius: 50px;
  78. color: #000;
  79. background: #fff;
  80. font-size: 13px;
  81. text-align: center;
  82. }
  83. .footer_ul{
  84. text-align: center;
  85. padding: 15px 0;
  86. font-size: 16px;
  87. font-weight: bold;
  88. }
  89. .footer{
  90. width: 100%;
  91. }
  92. .footer:after{
  93. top: 0;
  94. }
  95. .footer_ul li:after{
  96. content: '';
  97. position: absolute;
  98. top: 0;
  99. right: 0;
  100. height: 100%;
  101. width: 1px;
  102. background: #ebeef3;
  103. }
  104. .footer_ul li:last-child:after{
  105. width:0;
  106. }
  107. .news_num{
  108. width: 20px;
  109. height: 20px;
  110. line-height: 20px;
  111. background-color: #e74e42;
  112. color: #fff;
  113. position: absolute;
  114. top: -8px;
  115. left: 7px;
  116. text-align: center;
  117. -webkit-border-radius: 50%;
  118. border-radius: 50%;
  119. font-size: 11px;
  120. font-style: normal;
  121. z-index: 10;
  122. }
  123. </style>
  124. </head>
  125. <body>
  126. <div class="api_layout flex-wrap flex-vertical">
  127. <header class="header-login">
  128. <img class="backBtn" src="../../image/btn_back.png" alt="" tapmode onclick="backIndex()">
  129. <p class="api_text">消息</p>
  130. </header>
  131. <div class="aui-searchbar" id="search">
  132. <div class="aui-searchbar-input aui-border-radius">
  133. <i class="search_ico"></i>
  134. <form>
  135. <input type="search" placeholder="" id="search-input">
  136. </form>
  137. </div>
  138. <span class="search_btn" onclick="searchNews(inputValue)">搜索</span>
  139. </div>
  140. <div class="main flex-con">
  141. </div>
  142. <footer class="after-border relative footer">
  143. <ul class="flex-wrap footer_ul">
  144. <li class="flex-con relative" onclick="clickNews('')">
  145. 所有消息
  146. </li>
  147. <li class="flex-con relative" onclick="clickNews('unread')">
  148. <i class="news_num" style="display:none"></i>
  149. 未读消息
  150. </li>
  151. <li class="flex-con relative" onclick="clickNews('read')">
  152. 全部标已读
  153. </li>
  154. </ul>
  155. </footer>
  156. </div>
  157. </body>
  158. </html>
  159. <script type="text/javascript" src="../../script/api.js"></script>
  160. <!-- <script src="../../script/fastclick.min.js" charset="utf-8"></script> -->
  161. <script type="text/javascript" src="../../script/config.js"></script>
  162. <script type="text/javascript">
  163. var inputValue = '',headers;
  164. apiready = function () {
  165. $api.fixStatusBar($api.dom('header') );
  166. var info = $api.getStorage('data'),
  167. token = JSON.parse(info).data.access_token;
  168. headers = {
  169. "Authorization": "Bearer " + token
  170. };
  171. newsNum();
  172. fnInitUIInput();
  173. openFrameNewsList();
  174. keybackFun()
  175. };
  176. function openFrameNewsList(){
  177. api.openFrame({
  178. name: 'news_frm',
  179. url: 'news_frm.html',
  180. rect: {
  181. x: 0,
  182. y: $api.dom('header').offsetHeight+$api.dom('.aui-searchbar').offsetHeight,
  183. w: api.winWidth,
  184. h: $api.dom('.main').offsetHeight
  185. },
  186. pageParam: {
  187. name: 'test'
  188. },
  189. bounces: true,
  190. bgColor: '#f1f1f1',
  191. vScrollBarEnabled: true,
  192. hScrollBarEnabled: true
  193. });
  194. }
  195. function backIndex() {
  196. api.closeWin();
  197. api.sendEvent({
  198. name: 'myNews',
  199. extra: {
  200. key1: 'value1',
  201. key2: 'value2'
  202. }
  203. });
  204. }
  205. // 监听物理返回键
  206. function keybackFun() {
  207. api.addEventListener({
  208. name: 'keyback'
  209. }, function(ret, err){
  210. api.sendEvent({
  211. name: 'myNews',
  212. extra: {
  213. key1: 'value1',
  214. key2: 'value2'
  215. }
  216. });
  217. api.closeWin();
  218. });
  219. }
  220. // input
  221. function fnInitUIInput() {
  222. var searchText = $api.byId('search-input');
  223. var rect = $api.offset(searchText);
  224. var UIInput = api.require('UIInput');
  225. UIInput.open({
  226. rect: {
  227. x: rect.l,
  228. y: rect.t+1,
  229. w: rect.w,
  230. h: rect.h+1
  231. },
  232. styles: {
  233. bgColor: '#fff',
  234. size: 14,
  235. color: '#000',
  236. placeholder: {
  237. color: '#ccc'
  238. }
  239. },
  240. autoFocus: false,
  241. maxRows: 1,
  242. placeholder: '搜索',
  243. keyboardType: 'default',
  244. fixedOn: api.frameName
  245. }, function(ret, err) {
  246. if (ret) {
  247. var uiInputId = ret.id;
  248. if (ret.eventType == "change") {
  249. UIInput.value({
  250. id: uiInputId
  251. }, function(ret, err) {
  252. if (ret) {
  253. if (ret.status) {
  254. inputValue = ret.msg;
  255. searchNews(ret.msg);
  256. }
  257. }
  258. });
  259. }
  260. }
  261. });
  262. }
  263. // 所有消息
  264. // 未读消息
  265. // 全部标记已读
  266. function clickNews(type) {
  267. api.execScript({
  268. name: 'newsList',
  269. frameName: 'news_frm',
  270. script: 'getNewsListFun("'+type+'","'+true+'");'
  271. });
  272. newsNum();
  273. }
  274. // 搜索
  275. function searchNews(name) {
  276. // $api.setStorage('flatSeacrh', true);
  277. api.execScript({
  278. name: 'newsList',
  279. frameName: 'news_frm',
  280. script: 'getSearchData("'+name+'");'
  281. });
  282. }
  283. // 消息总数
  284. function newsNum() {
  285. $http.fnReuestDataNologing(UrlRouter.getNewsNum,headers,'get','',function (ret,err) {
  286. if (ret.code === 0) {
  287. if (ret.data.unread_num === 0) {
  288. $api.css($api.dom('.news_num'), 'display:none');
  289. $api.html($api.dom('.news_num'), '');
  290. }else if(ret.data.unread_num > 99 || ret.data.unread_num == 99){
  291. $api.css($api.dom('.news_num'), 'display:block');
  292. $api.html($api.dom('.news_num'), 99);
  293. }else {
  294. $api.css($api.dom('.news_num'), 'display:block');
  295. $api.html($api.dom('.news_num'), ret.data.unread_num);
  296. }
  297. }
  298. })
  299. }
  300. </script>