frame0.html 24 KB

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