frame0.html 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931
  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. reqPermission('storage');
  244. setIosTopBar();
  245. getAddress();
  246. get_adv();
  247. // goto_adv();
  248. // get_advx();
  249. getRouteData();
  250. webtoappinit();
  251. // getRouteHotelData();
  252. _myalias = "member" + $api.getStorage("memberid");
  253. jpushInit();
  254. api.addEventListener({
  255. name: 'scrolltobottom'
  256. }, function(ret, err) {
  257. getRouteHotelData();
  258. getmsgtotal();
  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. setTimeout(function(){
  270. goto_adv();
  271. }, 800);
  272. };
  273. $(".msg-list").on("tap", function() {
  274. api.openWin({
  275. name: 'msglist',
  276. url: './home/msglist.html',
  277. bounces: false,
  278. pageParam: {
  279. xx: ''
  280. }
  281. });
  282. return false;
  283. })
  284. $("#hotel-list").on("tap", ".home-hotel-list", function() {
  285. var _keyid = $(this).attr("keyid");
  286. api.openWin({
  287. name: 'hoteldtl',
  288. url: './home/hoteldtl.html',
  289. bounces: false,
  290. pageParam: {
  291. keyid: _keyid
  292. }
  293. });
  294. return false;
  295. })
  296. $(".scan-barcode").on("tap", function() {
  297. var has = hasPermission('camera');
  298. if(!has || !has[0] || !has[0].granted){
  299. api.confirm({
  300. title: '提醒',
  301. msg: "没有获得 相机 权限\n是否前往设置?",
  302. buttons: ['去设置', '取消']
  303. }, function (ret, err) {
  304. var index = ret.buttonIndex;
  305. if (index == 1) {
  306. reqPermission('camera');
  307. } else {
  308. api.toast({ msg: '获取相机权限失败...' });
  309. }
  310. });
  311. // $(".border-none").removeClass("mask-hidden");
  312. return false;
  313. }
  314. var FNScanner = api.require('FNScanner');
  315. FNScanner.open({
  316. autorotation: true
  317. }, function(ret, err) {
  318. toast_loding_show();
  319. if (ret) {
  320. // alert(JSON.stringify(ret));
  321. if (ret.eventType == "success") {
  322. if (ret.content.indexOf("?store_id=") > -1) {
  323. var _store_id = ret.content.split("?")[1];
  324. _store_id = _store_id.split("&")[0];
  325. _store_id = _store_id.replace("store_id=", "");
  326. // alert(_store_id);
  327. if (ret.content.indexOf("goods_id=") > -1) {
  328. var _goods_id = ret.content.split("?")[1];
  329. _goods_id = _goods_id.split("&")[1];
  330. _goods_id = _goods_id.replace("goods_id=", "");
  331. // alert(_goods_id);
  332. api.openWin({
  333. name: 'showgoods',
  334. url: './home/showgoods.html',
  335. bounces: false,
  336. pageParam: {
  337. storeid: _store_id,
  338. keyid: _goods_id
  339. }
  340. });
  341. } else {
  342. //
  343. api.openWin({
  344. name: 'hoteldtl',
  345. url: './home/hoteldtl.html',
  346. bounces: false,
  347. pageParam: {
  348. keyid: _store_id
  349. }
  350. });
  351. }
  352. } else {
  353. $api.rmStorage("qr_data");
  354. $api.setStorage("qr_data", ret.content);
  355. $.ajax({
  356. url: siteurl + 'api/Payment/get_order_info',
  357. data: {
  358. member_id: $api.getStorage("memberid"),
  359. qr_data: ret.content
  360. },
  361. headers: { "X-TOKEN": $api.getStorage("accesstoken") },
  362. dataType: 'json',
  363. type: 'post',
  364. success: function(datas) {
  365. if (datas.code === 1) {
  366. api.openWin({
  367. name: 'venderdtl',
  368. url: './home/vender.html',
  369. bounces: false,
  370. pageParam: {
  371. keyid: datas.data.order_sn
  372. }
  373. });
  374. return false;
  375. } else {
  376. api.toast({
  377. msg: datas.msg,
  378. duration: 2000,
  379. location: 'bottom'
  380. });
  381. }
  382. },
  383. error: function() {
  384. api.toast({
  385. msg: '扫码失败'
  386. })
  387. }
  388. })
  389. }
  390. }
  391. } else {
  392. api.toast({
  393. msg: "扫码失败"
  394. })
  395. }
  396. toast_loding_hide();
  397. });
  398. return false;
  399. })
  400. function getRouteData() {
  401. $.ajax({
  402. url: siteurl + 'v1/entry/adv',
  403. data: {},
  404. headers: { "X-TOKEN": $api.getStorage("accesstoken") },
  405. dataType: 'json',
  406. type: 'post',
  407. success: function(datas) {
  408. if (datas.result) {
  409. $.each(datas.data, function(index, item) {
  410. if (item.adv_enabled == 1) {
  411. if (item.adv_target.type == 'store') {
  412. $(".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>');
  413. } else if (item.adv_target.type == 'goods') {
  414. $(".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>');
  415. } else if (item.adv_target.type == 'article') {
  416. $(".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>');
  417. } else {
  418. $(".swiper-wrapper").append('<div class="swiper-slide" type="0" keyid="0"><img src="' + siteurl + "uploads/home/adv/" + item.adv_code + '"/></div>');
  419. }
  420. } else {
  421. $(".swiper-wrapper").append('<div class="swiper-slide" type="0" keyid="0"><img src="' + siteurl + "uploads/home/adv/" + item.adv_code + '"/></div>');
  422. }
  423. });
  424. var swiper = new Swiper('.swiper-container', {
  425. allowSlidePrev: true,
  426. autoplay: {
  427. delay: 5000,
  428. disableOnInteraction: false
  429. },
  430. loop : true,
  431. pagination: {
  432. el: '.swiper-pagination',
  433. },
  434. on: {
  435. transitionEnd: function(){
  436. var tempSlideWidth = $(".swiper-slide").width();
  437. $(".swiper-slide").css("width", tempSlideWidth);
  438. $(".swiper-slide-active").css("width", (tempSlideWidth+1));
  439. }
  440. }
  441. });
  442. } else {
  443. errcode(datas, datas.code);
  444. }
  445. }
  446. });
  447. getmsgtotal();
  448. function_name();
  449. }
  450. function set_height() {
  451. api.execScript({
  452. name: 'index',
  453. script: 'set_height();'
  454. })
  455. }
  456. function getmsgtotal() {
  457. // body...
  458. $.ajax({
  459. url: siteurl + 'v2/shop/msg_count',//'?do=getmsgtotal',
  460. data: {
  461. member_id: $api.getStorage("memberid")
  462. },
  463. headers: { "X-TOKEN": $api.getStorage("accesstoken") },
  464. dataType: 'json',
  465. type: 'post',
  466. success: function(datas) {
  467. if (datas.result) {
  468. if (datas.data.total > 0) {
  469. $(".msg-total").text(datas.data.total);
  470. $(".msg-total").removeClass('mask-hidden');
  471. } else {
  472. $(".msg-total").addClass('mask-hidden');
  473. }
  474. } else {
  475. if (datas.code == 2000) {
  476. console.log(datas)
  477. } else {
  478. errcode(datas, datas.code);
  479. }
  480. }
  481. }
  482. });
  483. }
  484. function get_advx() {
  485. // body...
  486. api.execScript({
  487. name: 'index',
  488. script: 'get_adv();'
  489. })
  490. }
  491. function goto_adv() {
  492. // body...
  493. switch (_adv_type) {
  494. case 'goods':
  495. console.log(_adv_goods_id, _adv_store_id)
  496. to_goods_id(_adv_goods_id, _adv_store_id)
  497. break;
  498. case 'store':
  499. console.log(_adv_store_id);
  500. to_store_id(_adv_store_id);
  501. break;
  502. case 'article':
  503. console.log(_adv_article_id);
  504. to_article_id(_adv_article_id);
  505. break;
  506. }
  507. }
  508. function get_adv() {
  509. //
  510. $.ajax({
  511. url: siteurl + 'v1/entry/poster',
  512. data: {},
  513. headers: { "X-TOKEN": $api.getStorage("accesstoken") },
  514. dataType: 'json',
  515. type: 'post',
  516. success: function(datas) {
  517. if (datas.result) {
  518. if (datas.data.enable == 1) {
  519. switch (datas.data.target.type) {
  520. case 'point':
  521. if ($api.getStorage("accesstoken")) {
  522. gallery_adv(siteurl + 'uploads/home/adv/' + datas.data.images, 'to_point');
  523. } else {
  524. gallery_adv(siteurl + 'uploads/home/adv/' + datas.data.images, 'to_login');
  525. }
  526. break;
  527. case 'goods':
  528. gallery_adv(siteurl + 'uploads/home/adv/' + datas.data.images, 'to_goods_id', datas.data.target.goods_id, datas.data.target.store_id);
  529. break;
  530. case 'store':
  531. gallery_adv(siteurl + 'uploads/home/adv/' + datas.data.images, 'to_store_id', datas.data.target.store_id);
  532. break;
  533. case 'article':
  534. gallery_adv(siteurl + 'uploads/home/adv/' + datas.data.images, 'to_article_id', datas.data.target.article_id);
  535. break;
  536. }
  537. }
  538. } else {
  539. errcode(datas, datas.code);
  540. }
  541. set_height();
  542. }
  543. })
  544. }
  545. function getRouteHotelData() {
  546. // toast_loding_show();
  547. if (_lon=='0') {
  548. $(".border-none").removeClass("mask-hidden");
  549. // toast_loding_hide();
  550. getAddress();
  551. return false;
  552. } else {
  553. $(".border-none").addClass("mask-hidden");
  554. }
  555. if (_isload) {
  556. // toast_loding_hide();
  557. return false;
  558. }
  559. $.ajax({
  560. url: siteurl + 'v2/entry/storeList',//'?do=gethomehotel',
  561. data: {
  562. page: _page,
  563. minid: _minid,
  564. lon: _lon,
  565. lat: _lat
  566. },
  567. headers: { "X-TOKEN": $api.getStorage("accesstoken") },
  568. dataType: 'json',
  569. type: 'post',
  570. success: function(datas) {
  571. // toast_loding_hide();
  572. if (datas.result) {
  573. var i = 0;
  574. if ( datas.data.store_list.length > 0 ) {
  575. var html = '<div class="h20"></div>';
  576. $.each(datas.data.store_list, function(index, item) {
  577. var _tags_0 = item.store_summary.split(' ');
  578. _tags_0 = jQuery.grep(_tags_0, function( a ) { return a !== ''; });
  579. 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>';
  580. html += '<div class="home-hotel-right"><div class="home-hotel-title">' + item.store_name + '</div>';
  581. html += '<div class="home-hotel-dtl"><ul><li style="width:40%"><div class="hotel_credit my-rating' + i + '">'+intToFloat(item.store_servicecredit)+'</div></li>';
  582. html += '<li style="text-align:center;"> 月访客' + item.store_visitor + '</li><li style="float:right;"> ' + item.distance + '</li>';
  583. html += '</ul></div>';
  584. html += '<div class="home-hotel-dsc">';
  585. $.each(_tags_0, function(index, tag) {
  586. if (index < 3) {
  587. html += '<span class="tag-item">'+tag+'</span>';
  588. }
  589. })
  590. html += '</div></div></div>';
  591. i++;
  592. });
  593. if ( _page == 1 ) {
  594. $("#hotel-list").html(html);
  595. $(".border-none").addClass("mask-hidden");
  596. $("#hotel-list").removeClass("mask-hidden");
  597. } else {
  598. $("#hotel-list").append(html);
  599. }
  600. _page++;
  601. } else {
  602. if ( _page == 1 ) {
  603. $(".border-none").removeClass("mask-hidden");
  604. $("#hotel-list").addClass("mask-hidden");
  605. }
  606. _isload = true;
  607. }
  608. } else {
  609. errcode(datas, datas.code);
  610. }
  611. function_name();
  612. }
  613. });
  614. }
  615. /////
  616. $(".home-search").on("tap", function() {
  617. api.openWin({
  618. name: 'hotelsearch',
  619. url: './home/hotelsearch.html',
  620. bounces: false,
  621. pageParam: {
  622. lon: _lon,
  623. lat: _lat
  624. }
  625. });
  626. return false;
  627. })
  628. $(".swiper-wrapper").on("tap", ".swiper-slide", function() {
  629. var _type = $(this).attr("type");
  630. var _keyid = $(this).attr("keyid");
  631. if (_type == 'store') {
  632. to_store_id(_keyid);
  633. } else if (_type == 'goods') {
  634. var _sid = $(this).attr("xkeyid");
  635. to_goods_id(_keyid, _sid);
  636. } else if (_type == 'article') {
  637. to_article_id(_keyid);
  638. } else {
  639. api.toast({ msg: '暂无活动' })
  640. }
  641. return false;
  642. })
  643. function intToFloat(val) {
  644. // body...
  645. return new Number(val).toFixed(1);
  646. }
  647. function to_login() {
  648. // body...
  649. api.openWin({
  650. name: 'login',
  651. url: 'widget://login.html',
  652. bounces: false,
  653. pageParam: {
  654. keyid: true
  655. }
  656. })
  657. $('.weui-gallery').hide();
  658. return false;
  659. }
  660. function to_point() {
  661. // body...
  662. api.openWin({
  663. name: 'points',
  664. url: './my/points.html',
  665. bounces: false
  666. });
  667. $('.weui-gallery').hide();
  668. return false;
  669. }
  670. function to_article_id(_to_article_id) {
  671. // body...
  672. api.openWin({
  673. name: 'finddetails',
  674. url: './find/finddetails.html',
  675. bounces: false,
  676. pageParam: {
  677. keyid: _to_article_id
  678. }
  679. });
  680. $('.weui-gallery').hide();
  681. return false;
  682. }
  683. function to_goods_id(_to_goods_id, _to_storeid) {
  684. // body...
  685. api.openWin({
  686. name: 'showgoods',
  687. url: './home/showgoods.html',
  688. bounces: false,
  689. pageParam: {
  690. keyid: _to_goods_id,
  691. storeid: _to_storeid
  692. }
  693. });
  694. $('.weui-gallery').hide();
  695. return false;
  696. }
  697. function to_store_id(_to_storeid) {
  698. // body...
  699. api.openWin({
  700. name: 'hoteldtl',
  701. url: './home/hoteldtl.html',
  702. bounces: false,
  703. pageParam: {
  704. keyid: _to_storeid
  705. }
  706. });
  707. $('.weui-gallery').hide();
  708. return false;
  709. }
  710. $("#set-local").on("tap", function() {
  711. $(this).attr("src", "../image/home_local2.png");
  712. var _that = $(this);
  713. setTimeout(function() { _that.attr("src", "../image/home_local.png"); }, 800);
  714. api.toast({
  715. msg: '正在获取当前位置...'
  716. });
  717. getAddress();
  718. })
  719. function getAddress() {
  720. var has = hasPermission('location');
  721. if(!has || !has[0] || !has[0].granted){
  722. api.confirm({
  723. title: '提醒',
  724. msg: "没有获得 定位 权限\n是否前往设置?",
  725. buttons: ['去设置', '取消']
  726. }, function (ret, err) {
  727. var index = ret.buttonIndex;
  728. if (index == 1) {
  729. reqPermission('location');
  730. // getAddress();
  731. } else {
  732. api.toast({ msg: '获取定位权限失败...' });
  733. }
  734. });
  735. $(".border-none").removeClass("mask-hidden");
  736. return false;
  737. }
  738. // toast_loding_show();
  739. var aMap = api.require('aMap');
  740. if(api.systemType == 'ios'){
  741. aMap.hide();
  742. aMap.open({
  743. rect: {
  744. x: 0,
  745. y: 0,
  746. w: 0,
  747. h: 0
  748. },
  749. showUserLocation: true,
  750. zoomLevel: 11,
  751. center: {
  752. lon: 116.4021310000,
  753. lat: 39.9994480000
  754. },
  755. fixedOn: api.frameName,
  756. fixed: true
  757. }, function(ret, err) {
  758. if (ret.status) {
  759. // $(".local-name").text(JSON.stringify(ret));
  760. } else {
  761. // $(".local-name").text(JSON.stringify(err));
  762. }
  763. })
  764. }
  765. aMap.getLocation(function(ret, err) {
  766. // toast_loding_hide();
  767. if (ret.status) {
  768. // alert(JSON.stringify(ret));
  769. _lon = ret.lon;
  770. _lat = ret.lat;
  771. getRouteHotelData();
  772. aMap.getNameFromCoords({
  773. lon: ret.lon,
  774. lat: ret.lat
  775. }, function(ret, err) {
  776. if (ret.status) {
  777. aMap.close();
  778. $(".local-name").text(ret.city + ret.township + ret.street + ret.number);
  779. }
  780. });
  781. } else {
  782. $(".local-name").text(JSON.stringify(err));
  783. }
  784. });
  785. // toast_loding_hide();
  786. }
  787. function jpushInit() {
  788. jpush = api.require('ajpush');
  789. initJPush();
  790. api.addEventListener({ name: 'noticeclicked' }, function(ret, err) { //ios noticeclicked
  791. var _value = ret.value.replace(/\\/g, "");
  792. // $(".home-search").text(JSON.stringify(ret));
  793. // $(".local-name").text(JSON.stringify(err));
  794. var obj = eval('(' + _value + ')');
  795. if (obj.jump == "urge") {
  796. api.openWin({
  797. name: 'msglist',
  798. url: './home/msglist.html',
  799. bounces: false
  800. });
  801. }
  802. if (obj.jump == "article") {
  803. api.openWin({
  804. name: 'finddetails',
  805. url: './find/finddetails.html',
  806. bounces: false,
  807. pageParam: {
  808. keyid: obj.keyid
  809. }
  810. });
  811. }
  812. })
  813. api.addEventListener({ name: 'pause' }, function(ret, err) {
  814. onPause(); //监听应用进入后台,通知jpush暂停事件
  815. })
  816. api.addEventListener({ name: 'resume' }, function(ret, err) {
  817. onResume(); //监听应用恢复到前台,通知jpush恢复事件
  818. })
  819. jpush.setListener(function(ret, err) {
  820. if (ret) {
  821. notify(ret.content, ret.extra);
  822. }
  823. });
  824. }
  825. /////
  826. function initJPush() {
  827. jpush.init(function(ret, err) {
  828. if (ret && ret.status) {
  829. bindAliasAndTags();
  830. } else {
  831. api.toast({ msg: '操作失败!' });
  832. }
  833. });
  834. }
  835. //统计-app恢复
  836. function onResume() {
  837. jpush.onResume();
  838. }
  839. //统计-app暂停
  840. function onPause() {
  841. jpush.onPause();
  842. }
  843. function bindAliasAndTags() {
  844. var param = { alias: _myalias, tags: ['tag1', 'qdduser'] };
  845. jpush.bindAliasAndTags(param, function(ret) {
  846. var statusCode = ret.statusCode;
  847. // alert(JSON.stringify(ret));
  848. });
  849. }
  850. function notify(content, extras) {
  851. getmsgtotal();
  852. api.notification({
  853. vibrate: [100, 500, 200, 500, 300, 500],
  854. sound: 'widget://res/horse.ogg',
  855. notify: {
  856. title: '您有一条新的消息...',
  857. content: content,
  858. extra: extras,
  859. updateCurrent: false
  860. }
  861. }, function(ret, err) {
  862. //alert(JSON.stringify(extras));
  863. });
  864. }
  865. function webtoappinit() {
  866. // body...
  867. if (_webinkeyid) {
  868. to_goods_id(_webinkeyid, _webinstoreid);
  869. return false;
  870. }
  871. if (_webinstoreid) {
  872. to_store_id(_webinstoreid);
  873. return false;
  874. }
  875. }
  876. $(".back-top").on("tap", function() {
  877. $('html , body').animate({ scrollTop: 0 }, 'slow');
  878. return false;
  879. });
  880. $.fn.fixedDiv = function(actCls) {
  881. var that = $(this),
  882. offsetTop = that.offset().top,
  883. scrollTop;
  884. function fix() {
  885. scrollTop = $(document).scrollTop();
  886. if (scrollTop > offsetTop) {
  887. that.removeClass(actCls);
  888. } else {
  889. that.addClass(actCls);
  890. }
  891. }
  892. fix();
  893. $(window).scroll(fix);
  894. }
  895. $('#fix1').fixedDiv('mask-hidden')
  896. </script>
  897. </html>