frame0.html 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909
  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. <title></title>
  8. <link rel="stylesheet" type="text/css" href="../css/api.css" />
  9. <link rel="stylesheet" type="text/css" href="../css/star-rating-svg.css?v=1.2" />
  10. <link rel="stylesheet" type="text/css" href="../css/weui.min.css" />
  11. <link rel="stylesheet" type="text/css" href="../css/style.css" />
  12. <link rel="stylesheet" type="text/css" href="../css/swiper.min.css" />
  13. <style>
  14. .swiper-container {
  15. width: 100%;
  16. height: 100%;
  17. }
  18. .swiper-slide img{
  19. width:100%;
  20. height:100%;
  21. }
  22. .home-hotel-title {
  23. font-size: 0.27rem;
  24. overflow: hidden;
  25. white-space: nowrap;
  26. text-overflow: ellipsis;
  27. color: #000;
  28. font-weight: 700;
  29. }
  30. .home-hotel-list {
  31. margin-bottom: 0.2rem;
  32. }
  33. .msg-list,.scan-barcode{
  34. position:absolute;
  35. /*width: 1rem;*/
  36. text-align:center;
  37. }
  38. .home-top-left {
  39. padding-top: 0.1rem;
  40. float: left;
  41. line-height: 0;
  42. }
  43. .home-hotel-right { /*width: 4.2rem;*/ }
  44. .home-hotel-dsc {
  45. font-size: 0.24rem;
  46. line-height: 0.34rem;
  47. }
  48. .swiper-container-horizontal>.swiper-pagination-bullets, .swiper-pagination-custom, .swiper-pagination-fraction {
  49. bottom: 0;
  50. }
  51. .swiper-pagination-bullet {
  52. background: #fff;
  53. opacity: .8;
  54. }
  55. .swiper-pagination-bullet-active {
  56. background: #d9251c;
  57. }
  58. .home-nearby:before {
  59. content: ' ';
  60. position: absolute;
  61. pointer-events: none;
  62. box-sizing: border-box;
  63. /*top: -50%;*/
  64. left: -50%;
  65. right: -50%;
  66. bottom: 0;
  67. -webkit-transform: scale(0.5);
  68. transform: scale(0.5);
  69. border-bottom: 1px solid #ddd;
  70. }
  71. .border-none{
  72. text-align: center;
  73. font-size: 0.28rem;
  74. height: 8rem;
  75. }
  76. .border-none p{
  77. color:#999999;
  78. }
  79. .border-none-img{
  80. margin-top: 1.5rem;
  81. width: 1.73rem;
  82. height: auto;
  83. }
  84. .home-nearby .weui-cell {
  85. padding: 16px 3px;
  86. }
  87. .home-nearby weui-cell__bd p {
  88. font-size: 0.35rem;
  89. }
  90. .home-top-left {
  91. width: 4.9rem;
  92. }
  93. .local-name {
  94. width: 4.2rem;
  95. }
  96. .weui-cell__ft {
  97. font-size: 0.25rem;
  98. }
  99. .home-hotel-left img {
  100. height: auto;
  101. }
  102. .home-hotel-dsc {
  103. -webkit-line-clamp: 1;
  104. }
  105. .hotel_credit {
  106. font-size: 0.47rem;
  107. position: absolute;
  108. margin-top: -0.2rem;
  109. color: #000000;
  110. font-family: Medium;
  111. font-weight: 500;
  112. }
  113. .hotel_credit:after {
  114. position: absolute;
  115. top: 0.45rem;
  116. width: 100%;
  117. height: 0.13rem;
  118. content: "";
  119. /*background: #ffdb26;*/
  120. margin-left: -100%;
  121. z-index: -1;
  122. }
  123. .tag-item {
  124. position: relative;
  125. margin: 1px 0.08rem;
  126. padding: 0rem 0.1rem;
  127. display: inline-block;
  128. line-height: 1.5;
  129. /* margin-left: 0; */
  130. margin-right: 0;
  131. font-size: 0.2rem;
  132. }
  133. .tag-item:first-child {
  134. margin-left: 0;
  135. }
  136. .tag-item:after {
  137. position: absolute;
  138. box-sizing: border-box;
  139. content: ' ';
  140. pointer-events: none;
  141. top: -50%;
  142. right: -50%;
  143. bottom: -50%;
  144. left: -50%;
  145. border: 1px solid #222;
  146. -webkit-transform: scale(0.5);
  147. transform: scale(0.5);
  148. border-radius: 0.08rem;
  149. }
  150. </style>
  151. <script>
  152. (function(window) {
  153. var winW = document.documentElement.clientWidth || document.body.clientWidth;
  154. if (winW > 750) {
  155. winW = 750;
  156. }
  157. document.documentElement.style.fontSize = winW / 7.5 + "px";
  158. window.onresize = function() {
  159. var winW = document.documentElement.clientWidth || document.body.clientWidth;
  160. document.body.clientWidth;
  161. if (winW > 750) {
  162. winW = 750;
  163. }
  164. document.documentElement.style.fontSize = winW / 7.5 + "px";
  165. }
  166. }(window));
  167. </script>
  168. </head>
  169. <body>
  170. <div class="topbar"></div>
  171. <section>
  172. <div style="position: fixed;width: 6.9rem;margin-left: -1px;z-index: 2;background: #fff;">
  173. <div class="home-top" style="padding: 0.1rem 0;">
  174. <div class="home-top-left"><img id="set-local" class="home-top-local" src="../image/home_local.png" /> <span class="local-name">&nbsp;正在搜索您附近的酒店</span></div>
  175. <div class="home-top-right" style="margin-top: -0.05rem;">
  176. <div class="scan-barcode" style="right: 1rem;"><img class="home-top-local" src="../image/home_scan.png" />
  177. <p>扫一扫</p>
  178. </div>
  179. <div class="msg-list" style="right: 0.2rem;"><img class="home-top-local" src="../image/home_msg.png" />
  180. <p>消息</p><span class="msg-total mask-hidden" style="position: absolute;top: 0;">0</span>
  181. </div>
  182. </div>
  183. </div>
  184. <div class="home-search" style="margin-bottom: 0.2rem;"><img src="../image/search.png"> 搜索您入住的酒店</div>
  185. </div>
  186. <div class="h10" style="height: 1.6rem;"></div>
  187. <div class="home-ads" style="border-radius: 0.1rem;">
  188. <div class="swiper-container" style="border-radius: 0.1rem;">
  189. <div class="swiper-wrapper">
  190. </div>
  191. <div class="swiper-pagination"></div>
  192. </div>
  193. </div>
  194. <div class="home-nearby">
  195. <div class="weui-cell" style="padding-bottom: 0;">
  196. <div class="weui-cell__bd">
  197. <p style="color: #000;font-weight: 700;font-size: 0.33rem;">附近酒店</p>
  198. </div>
  199. <div class="weui-cell__ft">在此找到您入住的酒店</div>
  200. </div>
  201. </div>
  202. </section>
  203. <section>
  204. <div id="hotel-list">
  205. <div class="home-hotel-list">
  206. </div>
  207. </div>
  208. </section>
  209. <section class="border-none mask-hidden">
  210. <img src="../image/no_lon.png" class="border-none-img" />
  211. <p>定位失败<br>请在手机上打开位置信息<br>或直接搜索当前入住的酒店</p>
  212. </section>
  213. <div class="h50"></div>
  214. <div class="back-top mask-hidden" id="fix1"></div>
  215. </body>
  216. <script type="text/javascript" src="../script/api.js"></script>
  217. <script type="text/javascript" src="../script/swiper.min.js"></script>
  218. <script type="text/javascript" src="../script/jquery.min.js"></script>
  219. <script type="text/javascript" src="../script/jquery.tap.js"></script>
  220. <script type="text/javascript" src="../script/imagesloaded.pkgd.min.js"></script>
  221. <script type="text/javascript" src="../script/jquery.star-rating-svg.js"></script>
  222. <script type="text/javascript">
  223. var _myalias = '';
  224. var _minid = '';
  225. var _lon = '0';
  226. var _lat = '0';
  227. var _page = '1';
  228. var _isload = false;
  229. var _isrefurbish = false;
  230. var _adv_type = '0';
  231. var _adv_goods_id = '0';
  232. var _adv_store_id = '0';
  233. var _adv_article_id = '0';
  234. var _webinkeyid = '0';
  235. var _webinstoreid = '0';
  236. apiready = function() {
  237. _webinkeyid = api.pageParam.keyid;
  238. _webinstoreid = api.pageParam.storeid;
  239. _adv_type = api.pageParam.advtype;
  240. _adv_goods_id = api.pageParam.advgoodsid;
  241. _adv_store_id = api.pageParam.advstoreid;
  242. _adv_article_id = api.pageParam.advarticleid;
  243. setIosTopBar();
  244. get_adv();
  245. getRouteData();
  246. webtoappinit();
  247. _myalias = "member" + $api.getStorage("memberid");
  248. jpushInit();
  249. var storage = hasPermission('storage');
  250. if(!storage || !storage[0] || !storage[0].granted){
  251. reqPermission('storage')
  252. }
  253. //滑动到底部
  254. api.addEventListener({
  255. name: 'scrolltobottom'
  256. }, function(ret, err) {
  257. getmsgtotal();
  258. });
  259. //应用从后台回到前台事件
  260. api.addEventListener({
  261. name: 'resume'
  262. }, function(ret, err) {
  263. _isload = false;
  264. _minid = '';
  265. _isrefurbish = true;
  266. getAddress();
  267. getmsgtotal();
  268. });
  269. //应用每次显示
  270. api.addEventListener({
  271. name: 'viewappear'
  272. }, function(ret, err) {
  273. getAddress();
  274. getmsgtotal();
  275. });
  276. setTimeout(function(){
  277. goto_adv();
  278. }, 800);
  279. };
  280. $(".msg-list").on("tap", function() {
  281. api.openWin({
  282. name: 'msglist',
  283. url: './home/msglist.html',
  284. bounces: false,
  285. pageParam: {
  286. xx: ''
  287. }
  288. });
  289. return false;
  290. })
  291. $("#hotel-list").on("tap", ".home-hotel-list", function() {
  292. var _keyid = $(this).attr("keyid");
  293. api.openWin({
  294. name: 'hoteldtl',
  295. url: './home/hoteldtl.html',
  296. bounces: false,
  297. pageParam: {
  298. keyid: _keyid
  299. }
  300. });
  301. return false;
  302. })
  303. $(".scan-barcode").on("tap", function() {
  304. var has = hasPermission('camera');
  305. if(!has || !has[0] || !has[0].granted){
  306. api.confirm({
  307. title: '提醒',
  308. msg: "没有获得 相机 权限\n是否前往设置?",
  309. buttons: ['去设置', '取消']
  310. }, function (ret, err) {
  311. var index = ret.buttonIndex;
  312. if (index == 1) {
  313. reqPermission('camera');
  314. } else {
  315. api.toast({ msg: '获取相机权限失败...' });
  316. }
  317. });
  318. return false;
  319. }
  320. var FNScanner = api.require('FNScanner');
  321. FNScanner.open({
  322. autorotation: true
  323. }, function(ret, err) {
  324. toast_loding_show();
  325. if (ret) {
  326. // alert(JSON.stringify(ret));
  327. if (ret.eventType == "success") {
  328. if (ret.content.indexOf("?store_id=") > -1) {
  329. var _store_id = ret.content.split("?")[1];
  330. _store_id = _store_id.split("&")[0];
  331. _store_id = _store_id.replace("store_id=", "");
  332. // alert(_store_id);
  333. if (ret.content.indexOf("goods_id=") > -1) {
  334. var _goods_id = ret.content.split("?")[1];
  335. _goods_id = _goods_id.split("&")[1];
  336. _goods_id = _goods_id.replace("goods_id=", "");
  337. // alert(_goods_id);
  338. api.openWin({
  339. name: 'showgoods',
  340. url: './home/showgoods.html',
  341. bounces: false,
  342. pageParam: {
  343. storeid: _store_id,
  344. keyid: _goods_id
  345. }
  346. });
  347. } else {
  348. //
  349. api.openWin({
  350. name: 'hoteldtl',
  351. url: './home/hoteldtl.html',
  352. bounces: false,
  353. pageParam: {
  354. keyid: _store_id
  355. }
  356. });
  357. }
  358. } else {
  359. $api.rmStorage("qr_data");
  360. $api.setStorage("qr_data", ret.content);
  361. $.ajax({
  362. url: siteurl + 'api/Payment/get_order_info',
  363. data: {
  364. member_id: $api.getStorage("memberid"),
  365. qr_data: ret.content
  366. },
  367. headers: { "X-TOKEN": $api.getStorage("accesstoken") },
  368. dataType: 'json',
  369. type: 'post',
  370. success: function(datas) {
  371. if (datas.code === 1) {
  372. api.openWin({
  373. name: 'venderdtl',
  374. url: './home/vender.html',
  375. bounces: false,
  376. pageParam: {
  377. keyid: datas.data.order_sn
  378. }
  379. });
  380. return false;
  381. } else {
  382. api.toast({
  383. msg: datas.msg,
  384. duration: 2000,
  385. location: 'bottom'
  386. });
  387. }
  388. },
  389. error: function() {
  390. api.toast({
  391. msg: '扫码失败'
  392. })
  393. }
  394. })
  395. }
  396. }
  397. } else {
  398. api.toast({
  399. msg: "扫码失败"
  400. })
  401. }
  402. toast_loding_hide();
  403. });
  404. return false;
  405. })
  406. function getRouteData() {
  407. $.ajax({
  408. url: siteurl + 'v1/entry/adv',
  409. data: {},
  410. headers: { "X-TOKEN": $api.getStorage("accesstoken") },
  411. dataType: 'json',
  412. type: 'post',
  413. success: function(datas) {
  414. if (datas.result) {
  415. $.each(datas.data, function(index, item) {
  416. if (item.adv_enabled == 1) {
  417. if (item.adv_target.type == 'store') {
  418. $(".swiper-wrapper").append('<div class="swiper-slide" type="store" keyid="' + item.adv_target.store_id + '"><img src="' + siteurl + "uploads/home/adv/" + item.adv_code + '"/></div>');
  419. } else if (item.adv_target.type == 'goods') {
  420. $(".swiper-wrapper").append('<div class="swiper-slide" type="goods" keyid="' + item.adv_target.goods_id + '" xkeyid="' + item.adv_target.store_id + '"><img src="' + siteurl + "uploads/home/adv/" + item.adv_code + '"/></div>');
  421. } else if (item.adv_target.type == 'article') {
  422. $(".swiper-wrapper").append('<div class="swiper-slide" type="article" keyid="' + item.adv_target.article_id + '"><img src="' + siteurl + "uploads/home/adv/" + item.adv_code + '"/></div>');
  423. } else {
  424. $(".swiper-wrapper").append('<div class="swiper-slide" type="0" keyid="0"><img src="' + siteurl + "uploads/home/adv/" + item.adv_code + '"/></div>');
  425. }
  426. } else {
  427. $(".swiper-wrapper").append('<div class="swiper-slide" type="0" keyid="0"><img src="' + siteurl + "uploads/home/adv/" + item.adv_code + '"/></div>');
  428. }
  429. });
  430. var swiper = new Swiper('.swiper-container', {
  431. allowSlidePrev: true,
  432. autoplay: {
  433. delay: 5000,
  434. disableOnInteraction: false
  435. },
  436. loop : true,
  437. pagination: {
  438. el: '.swiper-pagination',
  439. },
  440. on: {
  441. transitionEnd: function(){
  442. var tempSlideWidth = $(".swiper-slide").width();
  443. $(".swiper-slide").css("width", tempSlideWidth);
  444. $(".swiper-slide-active").css("width", (tempSlideWidth+1));
  445. }
  446. }
  447. });
  448. } else {
  449. errcode(datas, datas.code);
  450. }
  451. }
  452. });
  453. function_name();
  454. }
  455. function set_height() {
  456. api.execScript({
  457. name: 'index',
  458. script: 'set_height();'
  459. })
  460. }
  461. function getmsgtotal() {
  462. $.ajax({
  463. url: siteurl + 'v2/shop/msg_count',
  464. data: {
  465. member_id: $api.getStorage("memberid")
  466. },
  467. headers: { "X-TOKEN": $api.getStorage("accesstoken") },
  468. dataType: 'json',
  469. type: 'post',
  470. success: function(datas) {
  471. if (datas.result) {
  472. if (datas.data.total > 0) {
  473. $(".msg-total").text(datas.data.total);
  474. $(".msg-total").removeClass('mask-hidden');
  475. } else {
  476. $(".msg-total").addClass('mask-hidden');
  477. }
  478. } else {
  479. if (datas.code == 2000) {
  480. console.log(datas)
  481. } else {
  482. errcode(datas, datas.code);
  483. }
  484. }
  485. }
  486. });
  487. }
  488. function get_advx() {
  489. api.execScript({
  490. name: 'index',
  491. script: 'get_adv();'
  492. })
  493. }
  494. function goto_adv() {
  495. // body...
  496. switch (_adv_type) {
  497. case 'goods':
  498. console.log(_adv_goods_id, _adv_store_id)
  499. to_goods_id(_adv_goods_id, _adv_store_id)
  500. break;
  501. case 'store':
  502. console.log(_adv_store_id);
  503. to_store_id(_adv_store_id);
  504. break;
  505. case 'article':
  506. console.log(_adv_article_id);
  507. to_article_id(_adv_article_id);
  508. break;
  509. }
  510. }
  511. function get_adv() {
  512. $.ajax({
  513. url: siteurl + 'v1/entry/poster',
  514. data: {},
  515. headers: { "X-TOKEN": $api.getStorage("accesstoken") },
  516. dataType: 'json',
  517. type: 'post',
  518. success: function(datas) {
  519. if (datas.result) {
  520. if (datas.data.enable == 1) {
  521. switch (datas.data.target.type) {
  522. case 'point':
  523. if ($api.getStorage("accesstoken")) {
  524. gallery_adv(siteurl + 'uploads/home/adv/' + datas.data.images, 'to_point');
  525. } else {
  526. gallery_adv(siteurl + 'uploads/home/adv/' + datas.data.images, 'to_login');
  527. }
  528. break;
  529. case 'goods':
  530. gallery_adv(siteurl + 'uploads/home/adv/' + datas.data.images, 'to_goods_id', datas.data.target.goods_id, datas.data.target.store_id);
  531. break;
  532. case 'store':
  533. gallery_adv(siteurl + 'uploads/home/adv/' + datas.data.images, 'to_store_id', datas.data.target.store_id);
  534. break;
  535. case 'article':
  536. gallery_adv(siteurl + 'uploads/home/adv/' + datas.data.images, 'to_article_id', datas.data.target.article_id);
  537. break;
  538. }
  539. }
  540. } else {
  541. errcode(datas, datas.code);
  542. }
  543. set_height();
  544. }
  545. })
  546. }
  547. function getRouteHotelData() {
  548. if (_lon=='0') {
  549. $(".border-none").removeClass("mask-hidden");
  550. return false;
  551. } else {
  552. $(".border-none").addClass("mask-hidden");
  553. }
  554. if (_isload) {
  555. return false;
  556. }
  557. $.ajax({
  558. url: siteurl + 'v2/entry/storeList',
  559. data: {
  560. page: _page,
  561. minid: _minid,
  562. lon: _lon,
  563. lat: _lat
  564. },
  565. headers: { "X-TOKEN": $api.getStorage("accesstoken") },
  566. dataType: 'json',
  567. type: 'post',
  568. success: function(datas) {
  569. if (datas.result) {
  570. var i = 0;
  571. if ( datas.data.store_list.length > 0 ) {
  572. var html = '<div class="h20"></div>';
  573. $.each(datas.data.store_list, function(index, item) {
  574. var _tags_0 = item.store_summary.split(' ');
  575. _tags_0 = jQuery.grep(_tags_0, function( a ) { return a !== ''; });
  576. html += '<div class="home-hotel-list" keyid="' + item.store_id + '"><div class="home-hotel-left"><img src="' + siteurl + 'uploads/home/store/' + item.store_id + '/' + item.store_banner + '"/></div>';
  577. html += '<div class="home-hotel-right"><div class="home-hotel-title">' + item.store_name + '</div>';
  578. html += '<div class="home-hotel-dtl"><ul><li style="width:40%"><div class="hotel_credit my-rating' + i + '">'+intToFloat(item.store_servicecredit)+'</div></li>';
  579. html += '<li style="text-align:center;"> 月访客' + item.store_visitor + '</li><li style="float:right;"> ' + item.distance + '</li>';
  580. html += '</ul></div>';
  581. html += '<div class="home-hotel-dsc">';
  582. $.each(_tags_0, function(index, tag) {
  583. if (index < 3) {
  584. html += '<span class="tag-item">'+tag+'</span>';
  585. }
  586. })
  587. html += '</div></div></div>';
  588. i++;
  589. });
  590. if ( _page == 1 ) {
  591. $("#hotel-list").html(html);
  592. $(".border-none").addClass("mask-hidden");
  593. $("#hotel-list").removeClass("mask-hidden");
  594. } else {
  595. $("#hotel-list").append(html);
  596. }
  597. _page++;
  598. } else {
  599. if ( _page == 1 ) {
  600. $(".border-none").removeClass("mask-hidden");
  601. $("#hotel-list").addClass("mask-hidden");
  602. }
  603. _isload = true;
  604. }
  605. } else {
  606. errcode(datas, datas.code);
  607. }
  608. function_name();
  609. }
  610. });
  611. }
  612. $(".home-search").on("tap", function() {
  613. api.openWin({
  614. name: 'hotelsearch',
  615. url: './home/hotelsearch.html',
  616. bounces: false,
  617. pageParam: {
  618. lon: _lon,
  619. lat: _lat
  620. }
  621. });
  622. return false;
  623. })
  624. $(".swiper-wrapper").on("tap", ".swiper-slide", function() {
  625. var _type = $(this).attr("type");
  626. var _keyid = $(this).attr("keyid");
  627. if (_type == 'store') {
  628. to_store_id(_keyid);
  629. } else if (_type == 'goods') {
  630. var _sid = $(this).attr("xkeyid");
  631. to_goods_id(_keyid, _sid);
  632. } else if (_type == 'article') {
  633. to_article_id(_keyid);
  634. } else {
  635. api.toast({ msg: '暂无活动' })
  636. }
  637. return false;
  638. })
  639. function intToFloat(val) {
  640. return new Number(val).toFixed(1);
  641. }
  642. function to_login() {
  643. // body...
  644. api.openWin({
  645. name: 'login',
  646. url: 'widget://login.html',
  647. bounces: false,
  648. pageParam: {
  649. keyid: true
  650. }
  651. })
  652. $('.weui-gallery').hide();
  653. return false;
  654. }
  655. function to_point() {
  656. // body...
  657. api.openWin({
  658. name: 'points',
  659. url: './my/points.html',
  660. bounces: false
  661. });
  662. $('.weui-gallery').hide();
  663. return false;
  664. }
  665. function to_article_id(_to_article_id) {
  666. // body...
  667. api.openWin({
  668. name: 'finddetails',
  669. url: './find/finddetails.html',
  670. bounces: false,
  671. pageParam: {
  672. keyid: _to_article_id
  673. }
  674. });
  675. $('.weui-gallery').hide();
  676. return false;
  677. }
  678. function to_goods_id(_to_goods_id, _to_storeid) {
  679. // body...
  680. api.openWin({
  681. name: 'showgoods',
  682. url: './home/showgoods.html',
  683. bounces: false,
  684. pageParam: {
  685. keyid: _to_goods_id,
  686. storeid: _to_storeid
  687. }
  688. });
  689. $('.weui-gallery').hide();
  690. return false;
  691. }
  692. function to_store_id(_to_storeid) {
  693. // body...
  694. api.openWin({
  695. name: 'hoteldtl',
  696. url: './home/hoteldtl.html',
  697. bounces: false,
  698. pageParam: {
  699. keyid: _to_storeid
  700. }
  701. });
  702. $('.weui-gallery').hide();
  703. return false;
  704. }
  705. $("#set-local").on("tap", function() {
  706. $(this).attr("src", "../image/home_local2.png");
  707. var _that = $(this);
  708. setTimeout(function() { _that.attr("src", "../image/home_local.png"); }, 800);
  709. api.toast({
  710. msg: '正在获取当前位置...'
  711. });
  712. getAddress();
  713. })
  714. function getAddress() {
  715. var has = hasPermission('location');
  716. if(!has || !has[0] || !has[0].granted){
  717. api.confirm({
  718. title: '提醒',
  719. msg: "没有获得 定位 权限\n是否前往设置?",
  720. buttons: ['去设置', '取消']
  721. }, function (ret, err) {
  722. var index = ret.buttonIndex;
  723. if (index == 1) {
  724. reqPermission('location');
  725. } else {
  726. api.toast({ msg: '获取定位权限失败...' });
  727. }
  728. });
  729. $(".border-none").removeClass("mask-hidden");
  730. return false;
  731. }
  732. var aMap = api.require('aMap');
  733. if(api.systemType == 'ios'){
  734. aMap.hide();
  735. aMap.open({
  736. rect: {x:0,y: 0,w: 0,h: 0},
  737. showUserLocation: true,
  738. zoomLevel: 11,
  739. center: {
  740. lon: 116.4021310000,
  741. lat: 39.9994480000
  742. },
  743. fixedOn: api.frameName,
  744. fixed: true
  745. }, function(ret, err) {
  746. })
  747. }
  748. aMap.getLocation(function(ret, err) {
  749. if (ret.status) {
  750. _lon = ret.lon;
  751. _lat = ret.lat;
  752. getRouteHotelData();
  753. aMap.getNameFromCoords({
  754. lon: ret.lon,
  755. lat: ret.lat
  756. }, function(ret, err) {
  757. if (ret.status) {
  758. aMap.close();
  759. $(".local-name").text(ret.city + ret.township + ret.street + ret.number);
  760. }
  761. });
  762. } else {
  763. $(".local-name").text(JSON.stringify(err));
  764. }
  765. });
  766. }
  767. function jpushInit() {
  768. jpush = api.require('ajpush');
  769. initJPush();
  770. api.addEventListener({ name: 'noticeclicked' }, function(ret, err) { //ios noticeclicked
  771. var _value = ret.value.replace(/\\/g, "");
  772. // $(".home-search").text(JSON.stringify(ret));
  773. // $(".local-name").text(JSON.stringify(err));
  774. var obj = eval('(' + _value + ')');
  775. if (obj.jump == "urge") {
  776. api.openWin({
  777. name: 'msglist',
  778. url: './home/msglist.html',
  779. bounces: false
  780. });
  781. }
  782. if (obj.jump == "article") {
  783. api.openWin({
  784. name: 'finddetails',
  785. url: './find/finddetails.html',
  786. bounces: false,
  787. pageParam: {
  788. keyid: obj.keyid
  789. }
  790. });
  791. }
  792. })
  793. api.addEventListener({ name: 'pause' }, function(ret, err) {
  794. onPause(); //监听应用进入后台,通知jpush暂停事件
  795. })
  796. api.addEventListener({ name: 'resume' }, function(ret, err) {
  797. onResume(); //监听应用恢复到前台,通知jpush恢复事件
  798. })
  799. jpush.setListener(function(ret, err) {
  800. if (ret) {
  801. notify(ret.content, ret.extra);
  802. }
  803. });
  804. }
  805. /////
  806. function initJPush() {
  807. jpush.init(function(ret, err) {
  808. if (ret && ret.status) {
  809. bindAliasAndTags();
  810. } else {
  811. api.toast({ msg: '操作失败!' });
  812. }
  813. });
  814. }
  815. //统计-app恢复
  816. function onResume() {
  817. jpush.onResume();
  818. }
  819. //统计-app暂停
  820. function onPause() {
  821. jpush.onPause();
  822. }
  823. function bindAliasAndTags() {
  824. var param = { alias: _myalias, tags: ['tag1', 'qdduser'] };
  825. jpush.bindAliasAndTags(param, function(ret) {
  826. var statusCode = ret.statusCode;
  827. // alert(JSON.stringify(ret));
  828. });
  829. }
  830. function notify(content, extras) {
  831. getmsgtotal();
  832. api.notification({
  833. vibrate: [100, 500, 200, 500, 300, 500],
  834. sound: 'widget://res/horse.ogg',
  835. notify: {
  836. title: '您有一条新的消息...',
  837. content: content,
  838. extra: extras,
  839. updateCurrent: false
  840. }
  841. }, function(ret, err) {
  842. });
  843. }
  844. function webtoappinit() {
  845. // body...
  846. if (_webinkeyid) {
  847. to_goods_id(_webinkeyid, _webinstoreid);
  848. return false;
  849. }
  850. if (_webinstoreid) {
  851. to_store_id(_webinstoreid);
  852. return false;
  853. }
  854. }
  855. $(".back-top").on("tap", function() {
  856. $('html , body').animate({ scrollTop: 0 }, 'slow');
  857. return false;
  858. });
  859. $.fn.fixedDiv = function(actCls) {
  860. var that = $(this),
  861. offsetTop = that.offset().top,
  862. scrollTop;
  863. function fix() {
  864. scrollTop = $(document).scrollTop();
  865. if (scrollTop > offsetTop) {
  866. that.removeClass(actCls);
  867. } else {
  868. that.addClass(actCls);
  869. }
  870. }
  871. fix();
  872. $(window).scroll(fix);
  873. }
  874. $('#fix1').fixedDiv('mask-hidden')
  875. </script>
  876. </html>