frame0.html 25 KB

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