frame0.html 30 KB

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