frame0.html 26 KB

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