index.html 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469
  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" type="text/css" href="./css/style.css"/>
  11. <style>
  12. header ul li { height: 50px; line-height: 50px; text-align: center; display: none; color: #fff; position: relative;font-size: 18px; position: relative;}
  13. header ul li.active{ display: block; }
  14. .flex-con{
  15. overflow: auto
  16. }
  17. #main{
  18. -webkit-overflow-scrolling:touch;
  19. }
  20. .search_warp{
  21. padding: 0 60px 0 13px;
  22. box-sizing: border-box;
  23. -webkit-box-sizing: border-box;
  24. position: relative;
  25. }
  26. .search_warp .search_input{
  27. box-sizing: border-box;
  28. -webkit-box-sizing: border-box;
  29. height: 29px;
  30. line-height: 29px;
  31. background-color: rgba(255,255,255,.3);
  32. -webkit-border-radius: 50px;
  33. -moz-border-radius: 50px;
  34. border-radius: 50px;
  35. padding-left: 43px;
  36. font-size: 13px;
  37. color: #fff;
  38. width: 100%;
  39. }
  40. .search_warp .search_input::placeholder{
  41. color: #fff;
  42. }
  43. .search_icon{
  44. width: 19px;
  45. height: 19px;
  46. display: block;
  47. position: absolute;
  48. top: 18px;
  49. left: 28px;
  50. background: url("image/seacrh001.png") no-repeat;
  51. background-size: cover;
  52. }
  53. .topheader_img{
  54. background: url("image/topheader.png") no-repeat;
  55. background-size: contain;
  56. }
  57. .qrcode_{
  58. width: 29px;
  59. height:37px;
  60. display: block;
  61. position: absolute;
  62. top: 9px;
  63. right: 13px;
  64. background: url("image/qrcode.png") no-repeat;
  65. background-size: contain;
  66. }
  67. </style>
  68. </head>
  69. <body class="topheader_img">
  70. <div id="wrap" class="flex-wrap flex-vertical">
  71. <header id="headers">
  72. <ul>
  73. <li class="border-b active">
  74. <div class="search_warp">
  75. <input type="text" class="search_input" placeholder="搜索" onclick="searchInfo()" readonly>
  76. <i class="search_icon"></i>
  77. <i class="qrcode_" onclick="scanFun()"></i>
  78. </div>
  79. </li>
  80. <li class="border-b "></li>
  81. <li class="border-b">
  82. <!-- <div class="search_warp">
  83. <input type="text" class="search_input" placeholder="搜索" onclick="searchInfo()" readonly>
  84. <i class="search_icon"></i>
  85. <i class="qrcode_" onclick="scanFun()"></i>
  86. </div> -->
  87. </li>
  88. <li class="border-b "></li>
  89. <li class="border-b "></li>
  90. </ul>
  91. </header>
  92. <div id="main" class="flex-con">
  93. </div>
  94. </div>
  95. </body>
  96. </html>
  97. <script type="text/javascript" src="script/api.js"></script>
  98. <!-- <script src="script/aui-toast.js" charset="utf-8"></script> -->
  99. <!-- <script src="script/fastclick.min.js" charset="utf-8"></script> -->
  100. <script src="script/config.js" charset="utf-8"></script>
  101. <script type="text/javascript">
  102. var uuid = ''
  103. apiready = function () {
  104. $api.fixStatusBar( $api.dom('header'));
  105. // 从sesstion获取工号var info = $api.getStorage('data'),
  106. var info = $api.getStorage('data'),
  107. user = JSON.parse(info).data.user;
  108. uuid = JSON.parse(info).data.user.staff_num;
  109. // 手机类别
  110. var systemType = api.systemType;
  111. api.setStatusBarStyle({
  112. style:'light',
  113. color:'transparent'
  114. });
  115. api.addEventListener({
  116. name: 'keyback'
  117. }, function(ret, err) {
  118. api.confirm({
  119. title: '提示',
  120. msg: '是否退出应用',
  121. buttons: ['确定', '取消']
  122. }, function(ret, err) {
  123. if (ret.buttonIndex == 1) {
  124. // 关闭当前的主Widget,就可以实现推出APP的效果
  125. api.closeWidget({
  126. silent: true //直接退出,无需提示
  127. });
  128. }
  129. });
  130. })
  131. frameFun()//第一次进入首页
  132. sendEventFun()//广播,消息页面监听刷新
  133. // 关闭tabnar
  134. var NVTabBar = api.require('NVTabBar');
  135. NVTabBar.close();
  136. if (systemType == 'ios') {
  137. NVTabBarFun(33,26,2);
  138. } else if (systemType == 'android') {
  139. NVTabBarFun(14,45,1);
  140. }
  141. // 消息徽章
  142. newsBadge(uuid);
  143. api.addEventListener({
  144. name: 'newsBroadcast'
  145. }, function(ret, err) {
  146. newsBadge(uuid)
  147. });
  148. // 让NVTabBar在所有页面的上面
  149. var NVTabBar = api.require('NVTabBar');
  150. NVTabBar.bringToFront();
  151. // 极光推送
  152. initPush(uuid);
  153. }
  154. // 二维码
  155. function scanFun(){
  156. var FNScanner = api.require('FNScanner');
  157. FNScanner.open({
  158. autorotation: true
  159. }, function(ret, err) {
  160. if(ret.eventType == "success" && ret.content.length>0){
  161. QRcodeDetaile(ret.content)
  162. };
  163. });
  164. }
  165. // 详情
  166. function QRcodeDetaile(url) {
  167. $event.openWin('SweepcodeDetaile','./html/Qrcode/Sweepcode',{pageUrl:url},'');
  168. }
  169. // 极光推送
  170. function initPush(ids) {
  171. var ajpush = api.require('ajpush');
  172. ajpush.init(function(ret) {
  173. if (ret && ret.status) {
  174. bindId(ids);
  175. // 监听状态栏消息,获取数据
  176. appintent();
  177. }
  178. });
  179. }
  180. // 绑定工号
  181. function bindId (ids){
  182. var ajpush = api.require('ajpush');
  183. var param = {alias:ids};
  184. ajpush.bindAliasAndTags(param,function(ret) {
  185. var statusCode = ret.statusCode;
  186. });
  187. }
  188. // 点击状态栏 消息推送的回调
  189. function appintent() {
  190. api.addEventListener({
  191. name: 'appintent'
  192. }, function(ret, err) {
  193. if (ret && ret.appParam.ajpush) {
  194. $event.openWin('newsList','./html/news/news_win','','');
  195. var ajpush = ret.appParam.ajpush;
  196. var id = ajpush.id;
  197. var title = ajpush.title;
  198. var content = ajpush.content;
  199. var extra = ajpush.extra;
  200. }
  201. })
  202. }
  203. // 发送广播消息 监听消息提醒
  204. function sendEventFun() {
  205. api.sendEvent({
  206. name: 'myEvent'
  207. });
  208. api.sendEvent({
  209. name: 'myNews',
  210. });
  211. }
  212. // tabnar
  213. function NVTabBarFun(marginB,centerX,centerY) {
  214. var NVTabBar = api.require('NVTabBar');
  215. NVTabBar.open({
  216. styles: {
  217. bg: '#fff',
  218. h: 60,
  219. dividingLine: {
  220. width:0.5,
  221. color: '#ecf0f1'
  222. },
  223. badge: {
  224. bgColor: '#ff0000',
  225. numColor: '#fff',
  226. size: 7.0,
  227. centerX: centerX,
  228. centerY: centerY
  229. }
  230. },
  231. items: [{
  232. w: api.winWidth / 5.0,
  233. bg: {
  234. marginB: -1,
  235. },
  236. iconRect: {
  237. w: 25.0,
  238. h: 25.0,
  239. },
  240. icon: {
  241. normal: 'widget://image/NVTabBar/s01.png',
  242. highlight: 'widget://image/NVTabBar/s011.png',
  243. selected: 'widget://image/NVTabBar/s011.png'
  244. },
  245. title: {
  246. text : '首页',
  247. size: 13.0,
  248. normal: '#929292',
  249. selected: '#3498db',
  250. marginB: 6.0
  251. }
  252. },{
  253. w: api.winWidth / 5.0,
  254. bg: {
  255. marginB: -1
  256. },
  257. iconRect: {
  258. w: 25.0,
  259. h: 25.0,
  260. },
  261. icon: {
  262. normal: 'widget://image/NVTabBar/x02.png',
  263. highlight: 'widget://image/NVTabBar/x021.png',
  264. selected: 'widget://image/NVTabBar/x021.png'
  265. },
  266. title: {
  267. text: '消息',
  268. size: 13.0,
  269. normal: '#929292',
  270. selected: '#3498db',
  271. marginB: 6.0
  272. }
  273. }, {
  274. w: api.winWidth / 5.0,
  275. bg: {
  276. marginB: -1
  277. },
  278. iconRect: {
  279. w: 25.0,
  280. h: 25.0,
  281. },
  282. icon: {
  283. normal: 'widget://image/NVTabBar/k1.png',
  284. highlight: 'widget://image/NVTabBar/k1.png',
  285. selected: 'widget://image/NVTabBar/k2.png'
  286. },
  287. title: {
  288. text: '任务',
  289. size: 13.0,
  290. normal: '#929292',
  291. selected: '#3498db',
  292. marginB: 6.0
  293. }
  294. },{
  295. w: api.winWidth / 5.0,
  296. bg: {
  297. marginB: -1
  298. },
  299. iconRect: {
  300. w: 25.0,
  301. h: 25.0,
  302. },
  303. icon: {
  304. normal: 'widget://image/NVTabBar/s03.png',
  305. highlight: 'widget://image/NVTabBar/s031.png',
  306. selected: 'widget://image/NVTabBar/s031.png'
  307. },
  308. title: {
  309. text: '生产数据',
  310. size: 13.0,
  311. normal: '#929292',
  312. selected: '#3498db',
  313. marginB: 6.0
  314. }
  315. }, {
  316. w: api.winWidth / 5.0,
  317. bg: {
  318. marginB: -1
  319. },
  320. iconRect: {
  321. w: 25.0,
  322. h: 25.0,
  323. },
  324. icon: {
  325. normal: 'widget://image/NVTabBar/g04.png',
  326. highlight: 'widget://image/NVTabBar/g041.png',
  327. selected: 'widget://image/NVTabBar/g041.png'
  328. },
  329. title: {
  330. text: '我的',
  331. size: 13.0,
  332. normal: '#929292',
  333. selected: '#3498db',
  334. marginB: 6.0
  335. }
  336. }],
  337. selectedIndex: 0
  338. }, function(ret, err) {
  339. if (ret.eventType == "click" && ret.index == 0) {
  340. api.setFrameGroupIndex({
  341. name: 'group',
  342. index: 0
  343. });
  344. $api.html($api.dom('.border-b'), `<div class="search_warp">
  345. <input type="text" class="search_input" placeholder="搜索" onclick="searchInfo()" readonly>
  346. <i class="search_icon"></i>
  347. <i class="qrcode_" onclick="scanFun()"></i>
  348. </div>`);
  349. $api.css($api.byId('headers'), 'background-color: transparent');
  350. api.sendEvent({
  351. name: 'newsBroadcast'
  352. });
  353. }
  354. if (ret.eventType == "click" && ret.index == 1) {
  355. api.setFrameGroupIndex({
  356. name: 'group',
  357. index: 1
  358. });
  359. $api.css($api.byId('headers'), 'background-color: transparent');
  360. $api.css($api.byId('headers'), 'background-color: #009fe8');
  361. $api.html($api.dom('.border-b'), '消息');
  362. api.sendEvent({
  363. name: 'myEvent'
  364. });
  365. api.sendEvent({
  366. name: 'newsBroadcast'
  367. });
  368. }
  369. if (ret.eventType == "click" && ret.index == 2) {
  370. api.setFrameGroupIndex({
  371. name: 'group',
  372. index: 2
  373. });
  374. $api.css($api.byId('headers'), 'background-color: #009fe8');
  375. $api.html($api.dom('.border-b'), '任务');
  376. api.sendEvent({
  377. name: 'newsBroadcast'
  378. });
  379. }
  380. if (ret.eventType == "click" && ret.index == 3) {
  381. api.setFrameGroupIndex({
  382. name: 'group',
  383. index: 3
  384. });
  385. api.sendEvent({
  386. name: 'refreshProduction'
  387. });
  388. $api.css($api.byId('headers'), 'background-color: #009fe8');
  389. $api.html($api.dom('.border-b'), '生产数据');
  390. api.sendEvent({
  391. name: 'newsBroadcast'
  392. });
  393. }
  394. if (ret.eventType == "click" && ret.index == 4) {
  395. api.setFrameGroupIndex({
  396. name: 'group',
  397. index: 4
  398. });
  399. $api.css($api.byId('headers'), 'background-color: #009fe8');
  400. $api.html($api.dom('.border-b'), '个人中心');
  401. api.sendEvent({
  402. name: 'myNews'
  403. });
  404. api.sendEvent({
  405. name: 'newsBroadcast'
  406. });
  407. }
  408. });
  409. }
  410. function frameFun() {
  411. var eHeaderLis = $api.domAll('header li'),
  412. frames = [];
  413. for (var i = 0,len = eHeaderLis.length; i < len; i++) {
  414. frames.push( {
  415. name: 'frame'+i,
  416. url: './html/page/frame'+i+'.html',
  417. bgColor : '#f2f2f2',
  418. bounces:true,
  419. overScrollMode:'always'
  420. } )
  421. }
  422. api.openFrameGroup({
  423. name: 'group',
  424. scrollEnabled: false,
  425. rect: {
  426. x: 0,
  427. y: $api.dom('header').offsetHeight,
  428. w: api.winWidth,
  429. h: $api.dom('#main').offsetHeight - 60
  430. },
  431. preload:0,
  432. index: 0,
  433. frames: frames
  434. }, function (ret, err) {
  435. });
  436. var NVTabBar = api.require('NVTabBar');
  437. NVTabBar.bringToFront();
  438. }
  439. // 消息徽章
  440. function newsBadge(id) {
  441. var NVTabBar = api.require('NVTabBar');
  442. $http.fnReuestDataNologing(UrlRouter.findMessageCount+id,'','get','',function (ret,err) {
  443. if (ret.data && ret.data>99) {
  444. NVTabBar.setBadge({
  445. index: 1,
  446. badge: ret.data > 99?'99':ret.data
  447. });
  448. }
  449. if (ret.data && ret.data<99 && ret.data != 0) {
  450. NVTabBar.setBadge({
  451. index: 1,
  452. badge: ' '+ret.data+' '
  453. });
  454. }
  455. if (ret.data === 0) {
  456. NVTabBar.setBadge({
  457. index: 1
  458. });
  459. }
  460. })
  461. }
  462. // 搜索
  463. function searchInfo() {
  464. $event.openWin('search_win','./html/page/search_win','','')
  465. }
  466. </script>