index.html 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502
  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. initPush(uuid);
  111. // 手机类别
  112. var systemType = api.systemType;
  113. api.setStatusBarStyle({
  114. style:'light',
  115. color:'transparent'
  116. });
  117. api.addEventListener({
  118. name: 'keyback'
  119. }, function(ret, err) {
  120. api.confirm({
  121. title: '提示',
  122. msg: '是否退出应用',
  123. buttons: ['确定', '取消']
  124. }, function(ret, err) {
  125. if (ret.buttonIndex == 1) {
  126. // 关闭当前的主Widget,就可以实现推出APP的效果
  127. api.closeWidget({
  128. silent: true //直接退出,无需提示
  129. });
  130. }
  131. });
  132. })
  133. frameFun()//第一次进入首页
  134. sendEventFun()//广播,消息页面监听刷新
  135. // 关闭tabnar
  136. var NVTabBar = api.require('NVTabBar');
  137. NVTabBar.close();
  138. if (systemType == 'ios') {
  139. NVTabBarFun(33,26,2);
  140. } else if (systemType == 'android') {
  141. NVTabBarFun(14,45,1);
  142. }
  143. // 消息徽章
  144. newsBadge(uuid);
  145. api.addEventListener({
  146. name: 'newsBroadcast'
  147. }, function(ret, err) {
  148. newsBadge(uuid)
  149. });
  150. // 让NVTabBar在所有页面的上面
  151. var NVTabBar = api.require('NVTabBar');
  152. NVTabBar.bringToFront();
  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(urls) {
  167. var name,value,info =[],Qrurl= urls;
  168. var str = Qrurl;
  169. var num=str.indexOf("?");
  170. str=str.substr(num+1);
  171. var arr=str.split("&");
  172. for(var i=0;i < arr.length;i++){
  173. num=arr[i].indexOf("=");
  174. if(num>0){
  175. name=arr[i].substring(0,num);
  176. value=arr[i].substr(num+1);
  177. this[name]=value;
  178. info.push(value)
  179. }
  180. }
  181. if (info[2] != "" && info[2]) {
  182. $event.openWin('browseQrcode_win','./html/browseQrcode/browseQrcode_win',{pageId:info[2],title:'二维码详情'},'');
  183. }else {
  184. $event.openWin('SweepcodeDetaile','./html/Qrcode/Sweepcode',{pageUrl:urls},'');
  185. }
  186. }
  187. // 极光推送
  188. function initPush(ids) {
  189. var ajpush = api.require('ajpush');
  190. ajpush.init(function(ret) {
  191. if (ret && ret.status) {
  192. bindId(ids);
  193. // 监听状态栏消息,获取数据
  194. appintent();
  195. }
  196. });
  197. }
  198. // 绑定工号
  199. function bindId (ids){
  200. var ajpush = api.require('ajpush');
  201. var param = {alias:ids};
  202. ajpush.bindAliasAndTags(param,function(ret) {
  203. var statusCode = ret.statusCode;
  204. });
  205. }
  206. // 点击状态栏 消息推送的回调
  207. function appintent() {
  208. api.addEventListener({
  209. name: 'appintent'
  210. }, function(ret, err) {
  211. if (ret && ret.appParam.ajpush) {
  212. $event.openWin('newsList','./html/news/news_win','','');
  213. var ajpush = ret.appParam.ajpush;
  214. var id = ajpush.id;
  215. var title = ajpush.title;
  216. var content = ajpush.content;
  217. var extra = ajpush.extra;
  218. }
  219. })
  220. }
  221. // 发送广播消息 监听消息提醒
  222. function sendEventFun() {
  223. api.sendEvent({
  224. name: 'myEvent'
  225. });
  226. api.sendEvent({
  227. name: 'myNews',
  228. });
  229. }
  230. // tabnar
  231. function NVTabBarFun(marginB,centerX,centerY) {
  232. var NVTabBar = api.require('NVTabBar');
  233. NVTabBar.open({
  234. styles: {
  235. bg: '#fff',
  236. h: 60,
  237. dividingLine: {
  238. width:0.5,
  239. color: '#ecf0f1'
  240. },
  241. badge: {
  242. bgColor: '#ff0000',
  243. numColor: '#fff',
  244. size: 7.0,
  245. centerX: centerX,
  246. centerY: centerY
  247. }
  248. },
  249. items: [{
  250. w: api.winWidth / 5.0,
  251. bg: {
  252. marginB: -1,
  253. },
  254. iconRect: {
  255. w: 25.0,
  256. h: 25.0,
  257. },
  258. icon: {
  259. normal: 'widget://image/NVTabBar/s01.png',
  260. highlight: 'widget://image/NVTabBar/s011.png',
  261. selected: 'widget://image/NVTabBar/s011.png'
  262. },
  263. title: {
  264. text : '首页',
  265. size: 13.0,
  266. normal: '#929292',
  267. selected: '#3498db',
  268. marginB: 6.0
  269. }
  270. },{
  271. w: api.winWidth / 5.0,
  272. bg: {
  273. marginB: -1
  274. },
  275. iconRect: {
  276. w: 25.0,
  277. h: 25.0,
  278. },
  279. icon: {
  280. normal: 'widget://image/NVTabBar/x02.png',
  281. highlight: 'widget://image/NVTabBar/x021.png',
  282. selected: 'widget://image/NVTabBar/x021.png'
  283. },
  284. title: {
  285. text: '消息',
  286. size: 13.0,
  287. normal: '#929292',
  288. selected: '#3498db',
  289. marginB: 6.0
  290. }
  291. }, {
  292. w: api.winWidth / 5.0,
  293. bg: {
  294. marginB: -1
  295. },
  296. iconRect: {
  297. w: 25.0,
  298. h: 25.0,
  299. },
  300. icon: {
  301. normal: 'widget://image/NVTabBar/k1.png',
  302. highlight: 'widget://image/NVTabBar/k1.png',
  303. selected: 'widget://image/NVTabBar/k2.png'
  304. },
  305. title: {
  306. text: '工作台',
  307. size: 13.0,
  308. normal: '#929292',
  309. selected: '#3498db',
  310. marginB: 6.0
  311. }
  312. },{
  313. w: api.winWidth / 5.0,
  314. bg: {
  315. marginB: -1
  316. },
  317. iconRect: {
  318. w: 25.0,
  319. h: 25.0,
  320. },
  321. icon: {
  322. normal: 'widget://image/NVTabBar/s03.png',
  323. highlight: 'widget://image/NVTabBar/s031.png',
  324. selected: 'widget://image/NVTabBar/s031.png'
  325. },
  326. title: {
  327. text: '生产数据',
  328. size: 13.0,
  329. normal: '#929292',
  330. selected: '#3498db',
  331. marginB: 6.0
  332. }
  333. }, {
  334. w: api.winWidth / 5.0,
  335. bg: {
  336. marginB: -1
  337. },
  338. iconRect: {
  339. w: 25.0,
  340. h: 25.0,
  341. },
  342. icon: {
  343. normal: 'widget://image/NVTabBar/g04.png',
  344. highlight: 'widget://image/NVTabBar/g041.png',
  345. selected: 'widget://image/NVTabBar/g041.png'
  346. },
  347. title: {
  348. text: '我的',
  349. size: 13.0,
  350. normal: '#929292',
  351. selected: '#3498db',
  352. marginB: 6.0
  353. }
  354. }],
  355. selectedIndex: 0
  356. }, function(ret, err) {
  357. if (ret.eventType == "click" && ret.index == 0) {
  358. api.setFrameGroupIndex({
  359. name: 'group',
  360. index: 0
  361. });
  362. $api.html($api.dom('.border-b'), `<div class="search_warp">
  363. <input type="text" class="search_input" placeholder="搜索" onclick="searchInfo()" readonly>
  364. <i class="search_icon"></i>
  365. <i class="qrcode_" onclick="scanFun()"></i>
  366. </div>`);
  367. $api.css($api.byId('headers'), 'background-color: transparent');
  368. api.sendEvent({
  369. name: 'newsBroadcast'
  370. });
  371. }
  372. if (ret.eventType == "click" && ret.index == 1) {
  373. api.setFrameGroupIndex({
  374. name: 'group',
  375. index: 1
  376. });
  377. $api.css($api.byId('headers'), 'background-color: transparent');
  378. $api.css($api.byId('headers'), 'background-color: #009fe8');
  379. $api.html($api.dom('.border-b'), '消息');
  380. api.sendEvent({
  381. name: 'myEvent'
  382. });
  383. api.sendEvent({
  384. name: 'newsBroadcast'
  385. });
  386. }
  387. if (ret.eventType == "click" && ret.index == 2) {
  388. api.setFrameGroupIndex({
  389. name: 'group',
  390. index: 2
  391. });
  392. $api.css($api.byId('headers'), 'background-color: #009fe8');
  393. $api.html($api.dom('.border-b'), '工作台');
  394. api.sendEvent({
  395. name: 'newsBroadcast'
  396. });
  397. }
  398. if (ret.eventType == "click" && ret.index == 3) {
  399. api.setFrameGroupIndex({
  400. name: 'group',
  401. index: 3
  402. });
  403. // api.sendEvent({
  404. // name: 'eventCanvas'
  405. // });
  406. api.sendEvent({
  407. name: 'refreshProduction'
  408. });
  409. $api.css($api.byId('headers'), 'background-color: #009fe8');
  410. $api.html($api.dom('.border-b'), '生产数据');
  411. api.sendEvent({
  412. name: 'newsBroadcast'
  413. });
  414. } else {
  415. api.sendEvent({
  416. name: 'clearCanvas'
  417. });
  418. }
  419. if (ret.eventType == "click" && ret.index == 4) {
  420. api.setFrameGroupIndex({
  421. name: 'group',
  422. index: 4
  423. });
  424. $api.css($api.byId('headers'), 'background-color: #009fe8');
  425. $api.html($api.dom('.border-b'), '个人中心');
  426. api.sendEvent({
  427. name: 'myNews'
  428. });
  429. api.sendEvent({
  430. name: 'newsBroadcast'
  431. });
  432. }
  433. });
  434. }
  435. function frameFun() {
  436. var eHeaderLis = $api.domAll('header li'),
  437. frames = [];
  438. for (var i = 0,len = eHeaderLis.length; i < len; i++) {
  439. frames.push( {
  440. name: 'frame'+i,
  441. url: './html/page/frame'+i+'.html',
  442. bgColor : '#f2f2f2',
  443. bounces:true,
  444. overScrollMode:'always'
  445. } )
  446. }
  447. api.openFrameGroup({
  448. name: 'group',
  449. scrollEnabled: false,
  450. rect: {
  451. x: 0,
  452. y: $api.dom('header').offsetHeight,
  453. w: api.winWidth,
  454. h: $api.dom('#main').offsetHeight - 60
  455. },
  456. preload:0,
  457. index: 0,
  458. frames: frames
  459. }, function (ret, err) {
  460. if (ret.index == 3) {
  461. api.sendEvent({
  462. name: 'eventCanvas'
  463. });
  464. }else {
  465. api.sendEvent({
  466. name: 'clearCanvas'
  467. });
  468. }
  469. });
  470. var NVTabBar = api.require('NVTabBar');
  471. NVTabBar.bringToFront();
  472. }
  473. // 消息徽章
  474. function newsBadge(id) {
  475. var NVTabBar = api.require('NVTabBar');
  476. $http.fnReuestDataNologing(UrlRouter.findMessageCount+id,'','get','',function (ret,err) {
  477. if (ret.data && ret.data>99) {
  478. NVTabBar.setBadge({
  479. index: 1,
  480. badge: ret.data > 99?'99':ret.data
  481. });
  482. }
  483. if (ret.data && ret.data<99 && ret.data != 0) {
  484. NVTabBar.setBadge({
  485. index: 1,
  486. badge: ' '+ret.data+' '
  487. });
  488. }
  489. if (ret.data === 0) {
  490. NVTabBar.setBadge({
  491. index: 1
  492. });
  493. }
  494. })
  495. }
  496. // 搜索
  497. function searchInfo() {
  498. $event.openWin('search_win','./html/page/search_win','','')
  499. }
  500. </script>