frame0.html 24 KB

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