frame0.html 26 KB

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