frame0.html 27 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019
  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. // console.log(JSON.stringify(ret.content));
  360. if (ret.content.indexOf("?store_id=") > -1|| ret.content.indexOf("?qs=") > -1) {
  361. if (ret.content.indexOf("?qs=") > -1) {
  362. var _goods_id = ret.content.split("?")[1];
  363. _goods_id = _goods_id.replace("qs=", "");
  364. var arr=_goods_id.split('--');
  365. // console.log(arr);
  366. api.openWin({
  367. name: 'showgoods',
  368. url: './home/showgoods.html',
  369. bounces: false,
  370. pageParam: {
  371. storeid: arr[0],
  372. keyid: arr[1]
  373. }
  374. });
  375. } else {
  376. var _store_id = ret.content.split("?")[1];
  377. _store_id = _store_id.split("&")[0];
  378. _store_id = _store_id.replace("store_id=", "");
  379. api.openWin({
  380. name: 'hoteldtl',
  381. url: './home/hoteldtl.html',
  382. bounces: false,
  383. pageParam: {
  384. keyid: _store_id
  385. }
  386. });
  387. }
  388. } else {
  389. $api.rmStorage("qr_data");
  390. $api.setStorage("qr_data", ret.content);
  391. $.ajax({
  392. url: siteurl + 'api/Payment/get_order_info',
  393. data: {
  394. member_id: $api.getStorage("memberid"),
  395. qr_data: ret.content
  396. },
  397. headers: {
  398. "X-TOKEN": $api.getStorage("accesstoken")
  399. },
  400. dataType: 'json',
  401. type: 'post',
  402. success: function(datas) {
  403. if (datas.code === 1) {
  404. api.openWin({
  405. name: 'venderdtl',
  406. url: './home/vender.html',
  407. bounces: false,
  408. pageParam: {
  409. keyid: datas.data.order_sn
  410. }
  411. });
  412. return false;
  413. } else {
  414. api.toast({
  415. msg: datas.msg,
  416. duration: 2000,
  417. location: 'bottom'
  418. });
  419. }
  420. },
  421. error: function() {
  422. api.toast({
  423. msg: '扫码失败'
  424. })
  425. }
  426. })
  427. }
  428. }
  429. } else {
  430. api.toast({
  431. msg: "扫码失败"
  432. })
  433. }
  434. toast_loding_hide();
  435. });
  436. return false;
  437. })
  438. function getRouteData() {
  439. $.ajax({
  440. url: siteurl + 'v1/entry/adv',
  441. data: {},
  442. headers: {
  443. "X-TOKEN": $api.getStorage("accesstoken")
  444. },
  445. dataType: 'json',
  446. type: 'post',
  447. success: function(datas) {
  448. if (datas.result) {
  449. $.each(datas.data, function(index, item) {
  450. if (item.adv_enabled == 1) {
  451. if (item.adv_target.type == 'store') {
  452. $(".swiper-wrapper").append('<div class="swiper-slide" type="store" keyid="' + item.adv_target.store_id +
  453. '"><img src="' + siteurl + "uploads/home/adv/" + item.adv_code + '"/></div>');
  454. } else if (item.adv_target.type == 'goods') {
  455. $(".swiper-wrapper").append('<div class="swiper-slide" type="goods" keyid="' + item.adv_target.goods_id +
  456. '" xkeyid="' + item.adv_target.store_id + '"><img src="' + siteurl + "uploads/home/adv/" + item.adv_code +
  457. '"/></div>');
  458. } else if (item.adv_target.type == 'article') {
  459. $(".swiper-wrapper").append('<div class="swiper-slide" type="article" keyid="' + item.adv_target.article_id +
  460. '"><img src="' + siteurl + "uploads/home/adv/" + item.adv_code + '"/></div>');
  461. } else {
  462. $(".swiper-wrapper").append('<div class="swiper-slide" type="0" keyid="0"><img src="' + siteurl +
  463. "uploads/home/adv/" + item.adv_code + '"/></div>');
  464. }
  465. } else {
  466. $(".swiper-wrapper").append('<div class="swiper-slide" type="0" keyid="0"><img src="' + siteurl +
  467. "uploads/home/adv/" + item.adv_code + '"/></div>');
  468. }
  469. });
  470. var swiper = new Swiper('.swiper-container', {
  471. allowSlidePrev: true,
  472. autoplay: {
  473. delay: 5000,
  474. disableOnInteraction: false
  475. },
  476. loop: true,
  477. speed:400,
  478. pagination: {
  479. el: '.swiper-pagination',
  480. },
  481. });
  482. } else {
  483. errcode(datas, datas.code);
  484. }
  485. }
  486. });
  487. function_name();
  488. }
  489. function set_height() {
  490. api.execScript({
  491. name: 'index',
  492. script: 'set_height();'
  493. })
  494. }
  495. function getmsgtotal() {
  496. $.ajax({
  497. url: siteurl + 'v2/shop/msg_count',
  498. data: {
  499. member_id: $api.getStorage("memberid")
  500. },
  501. headers: {
  502. "X-TOKEN": $api.getStorage("accesstoken")
  503. },
  504. dataType: 'json',
  505. type: 'post',
  506. success: function(datas) {
  507. if (datas.result) {
  508. if (datas.data.total > 0) {
  509. $(".msg-total").text(datas.data.total);
  510. $(".msg-total").removeClass('mask-hidden');
  511. } else {
  512. $(".msg-total").addClass('mask-hidden');
  513. }
  514. } else {
  515. if (datas.code == 2000) {} else {
  516. errcode(datas, datas.code);
  517. }
  518. }
  519. }
  520. });
  521. }
  522. function get_advx() {
  523. api.execScript({
  524. name: 'index',
  525. script: 'get_adv();'
  526. })
  527. }
  528. function goto_adv() {
  529. // body...
  530. switch (_adv_type) {
  531. case 'goods':
  532. to_goods_id(_adv_goods_id, _adv_store_id)
  533. break;
  534. case 'store':
  535. to_store_id(_adv_store_id);
  536. break;
  537. case 'article':
  538. to_article_id(_adv_article_id);
  539. break;
  540. }
  541. }
  542. function get_adv() {
  543. $.ajax({
  544. url: siteurl + 'v1/entry/poster',
  545. data: {},
  546. headers: {
  547. "X-TOKEN": $api.getStorage("accesstoken")
  548. },
  549. dataType: 'json',
  550. type: 'post',
  551. success: function(datas) {
  552. if (datas.result) {
  553. if (datas.data.enable == 1) {
  554. switch (datas.data.target.type) {
  555. case 'point':
  556. if ($api.getStorage("accesstoken")) {
  557. gallery_adv(siteurl + 'uploads/home/adv/' + datas.data.images, 'to_point');
  558. } else {
  559. gallery_adv(siteurl + 'uploads/home/adv/' + datas.data.images, 'to_login');
  560. }
  561. break;
  562. case 'goods':
  563. gallery_adv(siteurl + 'uploads/home/adv/' + datas.data.images, 'to_goods_id', datas.data.target.goods_id,
  564. datas.data.target.store_id);
  565. break;
  566. case 'store':
  567. gallery_adv(siteurl + 'uploads/home/adv/' + datas.data.images, 'to_store_id', datas.data.target.store_id);
  568. break;
  569. case 'article':
  570. gallery_adv(siteurl + 'uploads/home/adv/' + datas.data.images, 'to_article_id', datas.data.target.article_id);
  571. break;
  572. }
  573. }
  574. } else {
  575. errcode(datas, datas.code);
  576. }
  577. set_height();
  578. }
  579. })
  580. }
  581. //关闭弹窗
  582. function color(){
  583. $('.weui-gallery').remove()
  584. // getAddress(true);
  585. }
  586. //获取初始数据
  587. function getRouteHotelData(is) {
  588. $.ajax({
  589. url: siteurl + 'v2/entry/storeList',
  590. data: {
  591. page: _page,
  592. page_size: '10',
  593. minid: _minid,
  594. lon: _lon,
  595. lat: _lat
  596. },
  597. headers: {
  598. "X-TOKEN": $api.getStorage("accesstoken")
  599. },
  600. dataType: 'json',
  601. type: 'post',
  602. success: function(datas) {
  603. if (datas.result) {
  604. var i = 0;
  605. if (datas.data.store_list.length > 0) {
  606. var html = '<div class="h20"></div>';
  607. $.each(datas.data.store_list, function(index, item) {
  608. var _tags_0 = item.store_summary.split(' ');
  609. _tags_0 = jQuery.grep(_tags_0, function(a) {
  610. return a !== '';
  611. });
  612. html += '<div class="home-hotel-list" keyid="' + item.store_id +
  613. '"><div class="home-hotel-left"><img src="' + siteurl + 'uploads/home/store/' + item.store_id + '/' +
  614. item.store_banner + '"/></div>';
  615. html += '<div class="home-hotel-right"><div class="home-hotel-title">' + item.store_name + '</div>';
  616. html += '<div class="home-hotel-dtl"><ul><li style="width:40%"><div class="hotel_credit my-rating' + i +
  617. '">' + intToFloat(item.store_servicecredit) + '</div></li>';
  618. html += '<li style="text-align:center;"> 月访客' + item.store_visitor + '</li><li style="float:right;"> ' +
  619. item.distance + '</li>';
  620. html += '</ul></div>';
  621. html += '<div class="home-hotel-dsc">';
  622. $.each(_tags_0, function(index, tag) {
  623. if (index < 3) {
  624. html += '<span class="tag-item">' + tag + '</span>';
  625. }
  626. })
  627. html += '</div></div></div>';
  628. i++;
  629. });
  630. if (is) {
  631. $("#hotel-list").append(html);
  632. } else {
  633. $("#hotel-list").html(html);
  634. }
  635. } else {
  636. _isload = true;
  637. }
  638. } else {
  639. errcode(datas, datas.code);
  640. }
  641. function_name();
  642. },
  643. complete:function(){
  644. ofAjax=false;
  645. }
  646. });
  647. }
  648. //重新定位
  649. function openDw() {
  650. $(this).attr("src", "../image/home_local2.png");
  651. var _that = $(this);
  652. setTimeout(function() {
  653. _that.attr("src", "../image/home_local.png");
  654. }, 800);
  655. api.toast({
  656. msg: '正在获取当前位置...'
  657. });
  658. _page="1";
  659. _isload=false;
  660. isShowLoad=true;
  661. getAddress(true);
  662. }
  663. //获取定位
  664. function getAddress(is) {
  665. console.log(is);
  666. if(!is){
  667. getRouteHotelData();
  668. return false;
  669. }
  670. ofAjax=true;
  671. var resultList = api.hasPermission({
  672. list: ['location']
  673. });
  674. if (resultList[0].granted) {
  675. // 已授权,可以继续下一步操作
  676. getLocation();
  677. } else {
  678. // api.confirm({
  679. // msg: '应用需要您的授权才能访问定位',
  680. // buttons: ['取消', '去设置']
  681. // }, function(ret) {
  682. // if (ret.buttonIndex == 2) {
  683. api.requestPermission({
  684. list: ['location'],
  685. }, function(res) {
  686. if (res.list[0].granted) {
  687. // 已授权,可以继续下一步操作
  688. getLocation();
  689. }else{
  690. $("#hotel-list").hide();
  691. $(".border-none").show();
  692. }
  693. });
  694. // }
  695. // });
  696. }
  697. // if (!has || !has[0] || !has[0].granted) {
  698. // if(api.systemType == 'ios'){
  699. // if(isShowLoad){
  700. // api.confirm({
  701. // title: '提醒',
  702. // msg:'没有获得定位服务权限\n是否前往设置?',
  703. // buttons: ['去设置', '取消']
  704. // }, function(ret, err) {
  705. // isShowLoad=false;
  706. // if(1 == ret.buttonIndex){
  707. // api.requestPermission({list:['location']}, function(res, err){
  708. // if(res.list[0].granted){
  709. // }
  710. // });
  711. // }else{
  712. // $(".local-name").text('定位失败');
  713. // }
  714. // });
  715. // }
  716. // }else{
  717. // api.requestPermission({list:['location']}, function(res, err){
  718. // if(res.list[0].granted){
  719. // }
  720. // });
  721. // }
  722. // $("#hotel-list").hide();
  723. // $(".border-none").show();
  724. // return false;
  725. // }
  726. };
  727. function getLocation(){
  728. var aMap = api.require('aMap');
  729. if (api.systemType == 'ios') {
  730. aMap.hide();
  731. aMap.open({
  732. rect: {x: 0,y: 0,w: 0,h: 0},
  733. showUserLocation: true,
  734. zoomLevel: 11,
  735. center: {lon: 116.4021310000,lat: 39.9994480000},
  736. fixedOn: api.frameName,
  737. fixed: true
  738. }, function(ret, err) {})
  739. }
  740. aMap.getLocation(function(res, err) {//获取经纬度
  741. if (res.status) {
  742. _lon = res.lon;
  743. _lat = res.lat;
  744. if(res.lon==0||res.lat==0){
  745. $(".local-name").text('定位失败')
  746. $("#hotel-list").hide();
  747. $(".border-none").show();
  748. }else{
  749. aMap.getNameFromCoords({//获取地址
  750. lon: res.lon,
  751. lat: res.lat
  752. }, function(ret, err) {
  753. if (ret.status) {
  754. if(ret.city||ret.township||ret.street||ret.number){
  755. $(".local-name").text(ret.city + ret.township + ret.street + ret.number);
  756. }else{
  757. $(".local-name").text('定位失败');
  758. }
  759. aMap.close();
  760. $("#hotel-list").show();
  761. $(".border-none").hide();
  762. getRouteHotelData();
  763. }
  764. });
  765. }
  766. } else {
  767. $(".local-name").text(JSON.stringify(err));
  768. }
  769. });
  770. };
  771. $(".home-search").on("tap", function() {
  772. api.openWin({
  773. name: 'hotelsearch',
  774. url: './home/hotelsearch.html',
  775. bounces: false,
  776. pageParam: {
  777. lon: _lon,
  778. lat: _lat
  779. }
  780. });
  781. return false;
  782. })
  783. $(".swiper-wrapper").on("tap", ".swiper-slide", function() {
  784. var _type = $(this).attr("type");
  785. var _keyid = $(this).attr("keyid");
  786. if (_type == 'store') {
  787. to_store_id(_keyid);
  788. } else if (_type == 'goods') {
  789. var _sid = $(this).attr("xkeyid");
  790. to_goods_id(_keyid, _sid);
  791. } else if (_type == 'article') {
  792. to_article_id(_keyid);
  793. } else {
  794. api.toast({
  795. msg: '暂无活动'
  796. })
  797. }
  798. return false;
  799. })
  800. function intToFloat(val) {
  801. return new Number(val).toFixed(1);
  802. }
  803. function to_login() {
  804. // body...
  805. api.openWin({
  806. name: 'login',
  807. url: 'widget://login.html',
  808. bounces: false,
  809. pageParam: {
  810. keyid: true
  811. }
  812. })
  813. $('.weui-gallery').hide();
  814. return false;
  815. }
  816. function to_point() {
  817. // body...
  818. api.openWin({
  819. name: 'points',
  820. url: './my/points.html',
  821. bounces: false
  822. });
  823. $('.weui-gallery').hide();
  824. return false;
  825. }
  826. function to_article_id(_to_article_id) {
  827. // body...
  828. api.openWin({
  829. name: 'finddetails',
  830. url: './find/finddetails.html',
  831. bounces: false,
  832. pageParam: {
  833. keyid: _to_article_id
  834. }
  835. });
  836. $('.weui-gallery').hide();
  837. return false;
  838. }
  839. function to_goods_id(_to_goods_id, _to_storeid) {
  840. // body...
  841. api.openWin({
  842. name: 'showgoods',
  843. url: './home/showgoods.html',
  844. bounces: false,
  845. pageParam: {
  846. keyid: _to_goods_id,
  847. storeid: _to_storeid
  848. }
  849. });
  850. $('.weui-gallery').hide();
  851. return false;
  852. }
  853. function to_store_id(_to_storeid) {
  854. // body...
  855. api.openWin({
  856. name: 'hoteldtl',
  857. url: './home/hoteldtl.html',
  858. bounces: false,
  859. pageParam: {
  860. keyid: _to_storeid
  861. }
  862. });
  863. $('.weui-gallery').hide();
  864. return false;
  865. }
  866. function jpushInit() {
  867. jpush = api.require('ajpush');
  868. initJPush();
  869. api.addEventListener({
  870. name: 'noticeclicked'
  871. }, function(ret, err) { //ios noticeclicked
  872. // var _value = data.value.replace(/\\/g, "");
  873. // var obj = eval('(' + _value + ')');
  874. var data=JSON.stringify(ret.value);
  875. var obj=JSON.parse(data)
  876. if (obj.jump == "urge") {
  877. api.openWin({
  878. name: 'msglist',
  879. url: './home/msglist.html',
  880. bounces: false
  881. });
  882. }
  883. if (obj.jump == "article") {
  884. api.openWin({
  885. name: 'finddetails',
  886. url: './find/finddetails.html',
  887. bounces: false,
  888. pageParam: {
  889. keyid: obj.keyid
  890. }
  891. });
  892. }
  893. })
  894. api.addEventListener({
  895. name: 'pause'
  896. }, function(ret, err) {
  897. onPause(); //监听应用进入后台,通知jpush暂停事件
  898. })
  899. api.addEventListener({
  900. name: 'resume'
  901. }, function(ret, err) {
  902. onResume(); //监听应用恢复到前台,通知jpush恢复事件
  903. })
  904. jpush.setListener(function(ret, err) {
  905. if (ret) {
  906. notify(ret.content, ret.extra);
  907. }
  908. });
  909. }
  910. function initJPush() {
  911. jpush.init(function(ret, err) {
  912. if (ret && ret.status) {
  913. // console.log(JSON.stringify(ret))
  914. bindAliasAndTags();
  915. } else {
  916. api.toast({
  917. msg: '操作失败!'
  918. });
  919. }
  920. });
  921. }
  922. //统计-app恢复
  923. function onResume() {
  924. jpush.onResume();
  925. }
  926. //统计-app暂停
  927. function onPause() {
  928. jpush.onPause();
  929. }
  930. function bindAliasAndTags() {
  931. var param = {
  932. alias: _myalias,
  933. tags: ['tag1', 'qdduser']
  934. };
  935. jpush.bindAliasAndTags(param, function(ret) {
  936. // alert(JSON.stringify(ret));
  937. var statusCode = ret.statusCode;
  938. });
  939. }
  940. function notify(content, extras) {
  941. getmsgtotal();
  942. api.notification({
  943. vibrate: [100, 500, 200, 500, 300, 500],
  944. sound: 'widget://res/horse.ogg',
  945. notify: {
  946. title: '您有一条新的消息...',
  947. content: content,
  948. extra: extras,
  949. updateCurrent: false
  950. }
  951. }, function(ret, err) {});
  952. }
  953. function webtoappinit() {
  954. if (_webinkeyid) {
  955. to_goods_id(_webinkeyid, _webinstoreid);
  956. return false;
  957. }
  958. if (_webinstoreid) {
  959. to_store_id(_webinstoreid);
  960. return false;
  961. }
  962. }
  963. $(".back-top").on("tap", function() {
  964. $('html , body').animate({
  965. scrollTop: 0
  966. }, 'slow');
  967. return false;
  968. });
  969. $.fn.fixedDiv = function(actCls) {
  970. var that = $(this),
  971. offsetTop = that.offset().top,
  972. scrollTop;
  973. function fix() {
  974. scrollTop = $(document).scrollTop();
  975. if (scrollTop > offsetTop) {
  976. that.removeClass(actCls);
  977. } else {
  978. that.addClass(actCls);
  979. }
  980. }
  981. fix();
  982. $(window).scroll(fix);
  983. }
  984. $('#fix1').fixedDiv('mask-hidden')
  985. </script>
  986. </html>