frame0.html 24 KB

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