index.html 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta http-equiv="pragma" content="no-cache">
  6. <meta http-equiv="cache-control" content="no-cache">
  7. <meta http-equiv="expires" content="0">
  8. <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
  9. <meta name="apple-mobile-web-app-capable" content="yes">
  10. <meta name="apple-mobile-web-app-status-bar-style" content="black">
  11. <title>Aiberle官方商城</title>
  12. <link rel="stylesheet" type="text/css" href="css/mui.min.css" />
  13. <link rel="stylesheet" type="text/css" href="css/iconfont.css" />
  14. <link rel="stylesheet" type="text/css" href="css/main.css" />
  15. <style>
  16. .year-dalog{background:url(images/year-dalog.png) center center no-repeat rgba(0,0,0,.7);background-size: 80% auto; position: fixed;left: 0;top: 0;right: 0;bottom: 0;width: 100%; height: 100%;z-index: 99;display: none;-webkit-transform: translateY(-100%);transform: translateY(-100%); -webkit-transition: .5s;transition: .5s;}
  17. .year-dalog.active{-webkit-transform: translateY(0%);transform: translateY(0%);}
  18. .year-dalog img{width: 100%;}
  19. div{color: #000000;}
  20. </style>
  21. <script>
  22. var start = new Date(2019,9,24,8,00,00);
  23. var end = new Date(2019,10,11,23,59,59);
  24. var d = new Date().getTime(); //当前时间戳
  25. if (d > start && d <= end) {
  26. location.href = "20191023.html?dates="+new Date().getTime();
  27. }
  28. </script>
  29. </head>
  30. <body>
  31. <header class="mui-bar mui-bar-nav" style="display: none;">
  32. <div class="search-cotainer">
  33. <div class="mui-input-row mui-search">
  34. <input id="search" name="search" class="my-search-ipt" type="text" placeholder='大家都在搜"净水机"'>
  35. </div>
  36. <span class="iconfont icon-caidan"></span>
  37. <span class="my-btn-cancel">取消</span>
  38. </div>
  39. <div id="search-hot" style="display: none;">
  40. <div class="search-cotainer line-25" id="history">
  41. <p>历史搜索</p>
  42. </div>
  43. </div>
  44. </header>
  45. <footer class="mui-bar mui-bar-tab" id="footer-bar-tab">
  46. <a class="mui-tab-item mui-active">
  47. <span class="iconfont icon-shouye"></span>
  48. <span class="mui-tab-label">首页</span>
  49. </a>
  50. <a class="mui-tab-item">
  51. <span class="iconfont icon-gouwuche"></span>
  52. <span class="mui-tab-label">购物车</span>
  53. </a>
  54. <a class="mui-tab-item">
  55. <span class="iconfont icon-dingdan"></span>
  56. <span class="mui-tab-label">订单</span>
  57. </a>
  58. <a class="mui-tab-item">
  59. <span class="iconfont icon-wode"></span>
  60. <span class="mui-tab-label">我的</span>
  61. </a>
  62. </footer>
  63. <div class="mui-content" style="padding-top: 10px;">
  64. <div class="banner-box">
  65. <div class="index-banner" style="display: none;"></div>
  66. </div>
  67. <!-- <div id="" style="display: block;margin-top: 25px;;">
  68. <img style="width: 100%;" src="https://s.iamberry.com/common/image/product/xpsd.png"/>
  69. </div>
  70. <ul class="mui-table-view mui-grid-view my-view-no" id="index-pro-list2" style="padding-bottom: 0;">
  71. <li class="mui-table-view-cell mui-media mui-col-xs-6"><a name="54">
  72. <img class="mui-media-object" style="background-color: #f9f7f8;border-radius: 5px;" src="https://s.iamberry.com/common/image/product/kdsj.png">
  73. <div class="index-pro-tit" style="margin-top: 10px;">Aiberle口袋热水机</div>
  74. <p class="mui-text-left">小巧便携,3秒即饮</p>
  75. </li>
  76. <li class="mui-table-view-cell mui-media mui-col-xs-6"><a name="52">
  77. <img class="mui-media-object" style="background-color: #f9f7f8;border-radius: 5px;" src="https://s.iamberry.com/common/image/product/new_hs.png">
  78. <div class="index-pro-tit" style="margin-top: 10px;">Aiberle净水花洒升级款</div>
  79. <p class="mui-text-left">高效除氯、净水养肤</p>
  80. </li>
  81. </ul>
  82. -->
  83. <!--<div style="background: #e6584f;height: 60px;display: block;margin-top: 25px;">
  84. <div></div>
  85. </div>-->
  86. <div class="index-title" style="margin-top: 20px;">
  87. <strong style="font-size: 16px; color: #000;">精选产品</strong><span class="mui-pull-right go_pro_list">
  88. <font>More</font><span class="mui-icon mui-icon-arrowright"></span>
  89. </span>
  90. </div>
  91. <ul class="mui-table-view mui-grid-view my-view-no" id="index-pro-list" style="padding-bottom: 0;">
  92. </ul>
  93. <!--<div class="index-title" style="margin-top: 20px;">
  94. <strong style="font-size: 16px;">产品配件</strong><span class="mui-pull-right go_pro_list" pos="bottom">
  95. <font>More</font><span class="mui-icon mui-icon-arrowright"></span>
  96. </span>
  97. </div>
  98. <div style="margin:8px 14px 30px 14px;">
  99. <div id="index-pro-items" class="mui-segmented-control">
  100. </div>
  101. </div>-->
  102. </div>
  103. <ul id="menu">
  104. <li><span class="iconfont icon-guanbi"></span></li>
  105. </ul>
  106. <div class="loading covers">
  107. <div class="loading-bj"></div>
  108. <p>正在加载...</p>
  109. </div>
  110. <!--春节放假通知-->
  111. <div class="year-dalog"></div>
  112. <script src="js/mui.min.js"></script>
  113. <script src="js/jquery-2.1.1.min.js"></script>
  114. <script src="js/jquery.autocompleter.js"></script>
  115. <script src="js/main.js"></script>
  116. <script src="js/wechat-utils-1.0.js"></script>
  117. <script>
  118. // 读取值
  119. var colors = [];
  120. var histoty = JSON.parse(localStorage.getItem('search_histoty'));
  121. var clickdate = JSON.parse(localStorage.getItem('clickdate'));
  122. //console.log(histoty)
  123. if (histoty != null) {
  124. var str = histoty.text;
  125. for (i = 0; i < str.length; i++) {
  126. var childTypeId = ''
  127. if (typeof(str[i].childTypeId) != "undefined") {
  128. childTypeId = 'childTypeid=' + str[i].childTypeId;
  129. }
  130. $("#history").append('<button type="button" class="mui-btn" name="' + str[i].id + '" typeid="' + str[i].typeId +
  131. '" ' + childTypeId + '>' + str[i].label + '</button>');
  132. }
  133. }
  134. /**
  135. *搜索框自动补全参数
  136. */
  137. //var colors = [{
  138. // "id": "1",
  139. // "label": "冲奶机"
  140. //}, {
  141. // "id": "2",
  142. // "label": "净水机"
  143. //}, {
  144. // "id": "3",
  145. // "label": "电动牙刷"
  146. //}, {
  147. // "id": "4",
  148. // "name":"lvxin",
  149. // "label": "滤芯"
  150. //}, {
  151. // "id": "5",
  152. // "label": "奶粉罐"
  153. //}, {
  154. // "id": "6",
  155. // "label": "牙刷头"
  156. //}, {
  157. // "id": "7",
  158. // "label": "水箱"
  159. //}, {
  160. // "id": "8",
  161. // "label": "接水台"
  162. //}, {
  163. // "id": "9",
  164. // "label": "加湿器"
  165. //}];
  166. mui.ready(function() {
  167. var d = new Date().getTime(); //当前时间戳
  168. //弹窗提示时间为1月18日-2月13日
  169. if (d > 1547740800000 && d < 1550073599000) {
  170. if (!window.localStorage) {
  171. mui.alert("您的浏览器不支持localStorage");
  172. } else {
  173. if (clickdate != null) {
  174. var oldDate = new Date(clickdate.text).getDay();
  175. //如果本地存储的getDay比当前时间的getDay大则显示弹窗
  176. if (new Date().getDay() > oldDate) {
  177. $(".year-dalog").addClass("active").show();
  178. }
  179. } else {
  180. //本地没有存储时间也显示弹窗
  181. $(".year-dalog").addClass("active").show();
  182. }
  183. }
  184. }
  185. $.ajax(base_path + '/wechat/indexData?dates=' + new Date().getTime(), {
  186. data: {},
  187. dataType: 'json',
  188. xhrFields: {
  189. withCredentials: true
  190. },
  191. crossDomain: true,
  192. type: 'post',
  193. timeout: 15000,
  194. success: function(dt) {
  195. //判断一下
  196. if (dt.isRedirect) {
  197. location.href = dt.redirectURL;
  198. } else {
  199. console.log(dt)
  200. if (dt.status) {
  201. //遍历banner
  202. var bannerstr = "",
  203. dian = "";
  204. var banner_data = dt.data.banners;
  205. mui(banner_data).each(function(index) {
  206. if (index == 0) {
  207. bannerstr += '<div class="mui-slider-item mui-slider-item-duplicate"><a href="' + banner_data[
  208. banner_data.length - 1].bannerImageCheckOutUrl + '"><img src="' + (banner_data[banner_data.length -
  209. 1].bannerImageUrl) + '"></a></div><div class="mui-slider-item mui-active"><a href="' + this.bannerImageCheckOutUrl +
  210. '"><img src="' + (this.bannerImageUrl) + '"></a></div>';
  211. dian += '<div class="mui-indicator mui-active"></div>'
  212. } else {
  213. bannerstr += '<div class="mui-slider-item"><a href="' + this.bannerImageCheckOutUrl + '"><img src="' +
  214. (this.bannerImageUrl) + '"></a></div>';
  215. dian += '<div class="mui-indicator"></div>'
  216. }
  217. if (index == (banner_data.length - 1) || (banner_data.length - 1) == 0) {
  218. bannerstr += '<div class="mui-slider-item mui-slider-item-duplicate"><a href="' + banner_data[0].bannerImageCheckOutUrl +
  219. '"><img src="' + (banner_data[0].bannerImageUrl) + '"></a></div>'
  220. }
  221. });
  222. dc('mui-slider-loop').innerHTML = bannerstr;
  223. dc('my-slider-indicator').innerHTML = dian;
  224. $(
  225. "<div id='slider' class='mui-slider'><div class='mui-slider-group mui-slider-loop' id='mui-slider-loop'>" +
  226. bannerstr + "</div><div id='my-slider-indicator' class='mui-slider-indicator my-slider-indicator'>" +
  227. dian + "</div></div>").insertBefore(".index-banner");
  228. //初始化banner自动轮播(interval:0为不自动轮播)单位ms
  229. var banner = mui('#slider');
  230. banner.slider({
  231. interval: 5000
  232. });
  233. //遍历精选置顶产品(100%宽度)
  234. var jingxuan1 = dt.data.selectProductTopper;
  235. var table = document.body.querySelector("#index-pro-list");
  236. mui(jingxuan1).each(function(index) {
  237. var li = document.createElement('li');
  238. li.className = 'mui-table-view-cell mui-media mui-col-xs-12';
  239. li.style.margin = '0px 0px 7px 0px';
  240. //console.log(this.productColorList[0].colorDiscount)
  241. if (this.productColorList != null && this.productColorList.length > 0) {
  242. li.innerHTML = '<a name="' + this.productId + '"><img class="mui-media-object" src="' + this.productChoicenessIm +
  243. '"><div class="index-pro-tit" style="margin-top: 10px;" >' + this.productName +
  244. '</div><p class="mui-text-left">' + this.productColorDes + '<span class="f-price">¥' + accDiv(this.productColorList[
  245. 0].colorDiscount, 100) + '</span></p></a>';
  246. table.appendChild(li);
  247. }
  248. });
  249. //遍历精选产品(50%宽度)
  250. var jingxuan2 = dt.data.selectProduct;
  251. mui(jingxuan2).each(function(index) {
  252. var li = document.createElement('li');
  253. li.className = 'mui-table-view-cell mui-media mui-col-xs-6';
  254. if (this.productColorList != null && this.productColorList.length > 0) {
  255. li.innerHTML = '<a name="' + this.productId +
  256. '"><img class="mui-media-object" style="background-color: #f9f7f8;border-radius: 5px;" src="' + this.productChoicenessIm +
  257. '"><div class="index-pro-tit" style="margin-top: 10px;">' + this.productName +
  258. '</div><p class="mui-text-left">' + this.productColorDes +
  259. '</p><p class="l-price" style="margin-top: 5px;">¥' + accDiv(this.productColorList[0].colorDiscount,
  260. 100) + '</p></a>';
  261. table.appendChild(li);
  262. }
  263. });
  264. //遍历菜单
  265. var caidanData = dt.data.productTypeList;
  266. var caidan = document.body.querySelector("#menu");
  267. mui(caidanData).each(function(index) {
  268. var li = document.createElement("li");
  269. li.innerHTML = '<label name="' + this.typeId + '"><div>' + this.typeName + '</div></label>';
  270. caidan.appendChild(li);
  271. colors.push({
  272. "id": colors.length + 1,
  273. "typeId": this.typeId,
  274. "label": this.typeName,
  275. "url": "1"
  276. });
  277. $.each(this.childTypeList, function() {
  278. var li = document.createElement("li");
  279. li.className = 'line';
  280. li.innerHTML = '<a name="' + this.typeId + '" item="' + this.childTypeId + '"><div>' + this.childTypeName +
  281. '</div></a>';
  282. caidan.appendChild(li);
  283. colors.push({
  284. "id": colors.length + 1,
  285. "typeId": this.typeId,
  286. "label": this.childTypeName,
  287. "childTypeId": this.childTypeId,
  288. "url": "1"
  289. });
  290. });
  291. //遍历产品配件
  292. if (this.typeId == 5) {
  293. console.log(this.childTypeList)
  294. var peijian = document.body.querySelector("#index-pro-items");
  295. peijian.innerHTML = '';
  296. $.each(this.childTypeList, function() {
  297. var a = document.createElement("a");
  298. a.className = 'mui-control-item';
  299. a.setAttribute("name", this.typeId);
  300. a.setAttribute("item", this.childTypeId);
  301. a.innerHTML = this.childTypeName;
  302. peijian.appendChild(a);
  303. });
  304. }
  305. });
  306. console.log(colors)
  307. //绑定搜索框自动补全
  308. $('#search').autocompleter({
  309. // marker for autocomplete matches
  310. highlightMatches: true,
  311. // object to local or url to remote search
  312. source: colors,
  313. // custom template 对应 自动补全参数
  314. template: '<span>{{ label }}</span>',
  315. // show hint
  316. hint: true,
  317. // abort source if empty field
  318. empty: false,
  319. // max results
  320. limit: 10,
  321. callback: function(value, index, selected) {
  322. //selected 包含 (id,label)
  323. console.log(selected)
  324. search(selected);
  325. }
  326. });
  327. } else {
  328. mui.alert("获取数据失败!");
  329. }
  330. }
  331. },
  332. error: function(xhr, type, errorThrown) {
  333. console.log(xhr);
  334. mui.alert("获取数据失败!网络错误");
  335. }
  336. });
  337. //搜索框焦点事件
  338. $('#search').on('focus', function(e) {
  339. window.scrollTo(0, 0, 500);
  340. $(".icon-caidan").hide();
  341. $('.my-btn-cancel').show();
  342. if ($(this).val().length > 0) {
  343. $('#search-hot').hide(500);
  344. $(".autocompleter-list").css("height", $(document).height())
  345. } else {
  346. $("#search-hot").css("height", $(document.body).height()).show();
  347. $("body").css("overflow", "hidden");
  348. }
  349. });
  350. //搜索框失去焦点事件
  351. $('#search').on('blur', function(e) {
  352. setTimeout(function() {
  353. $('#search-hot,.my-btn-cancel').hide();
  354. $("body").css("overflow", "auto");
  355. $(".icon-caidan").show();
  356. }, 700);
  357. });
  358. //点击后把text赋值到搜索框
  359. $(document).on('tap', '#history button', function() {
  360. $('#search').val($(this).text());
  361. console.log($(this).text())
  362. $('#search-hot').hide();
  363. $("body").css("overflow", "auto");
  364. var parameter = {};
  365. parameter["id"] = $(this).attr("name");
  366. parameter["label"] = $(this).text();
  367. parameter["typeId"] = $(this).attr("typeid");
  368. if (typeof($(this).attr("childtypeId")) != "undefined") {
  369. parameter["childTypeId"] = $(this).attr("childtypeid");
  370. }
  371. search(parameter);
  372. });
  373. //搜索框本地缓存
  374. function search(selected) {
  375. if (!window.localStorage) {
  376. mui.alert("您的浏览器不支持localStorage");
  377. } else {
  378. //自定义json数据
  379. var obj = {},
  380. searchobj = {};
  381. if (histoty != null) {
  382. var str = histoty.text;
  383. if (str.length > 2) {
  384. str.splice(2, 1)
  385. }
  386. str.splice(0, 0, selected)
  387. obj = {
  388. text: str
  389. }
  390. } else {
  391. obj = {
  392. text: [selected]
  393. };
  394. }
  395. searchobj = {
  396. text: [selected]
  397. }
  398. //json格式化插入
  399. localStorage.setItem('search_histoty', JSON.stringify(obj));
  400. sessionStorage.setItem('search_data', JSON.stringify(searchobj));
  401. mui.openWindow({
  402. url: 'pro-list.html?productId=' + selected.typeId
  403. });
  404. }
  405. }
  406. //监听搜索框值改变事件
  407. $('#search').on('input', function(e) {
  408. if ($(this).val().length > 0) {
  409. $('#search-hot').hide();
  410. $(".autocompleter-list").css("height", $(document).height());
  411. } else {
  412. $('#search-hot').show();
  413. $("body").css("overflow", "hidden");
  414. $(".autocompleter-list").css("height", "auto");
  415. }
  416. });
  417. $(".loading").hide().css("opacity", "0");
  418. });
  419. //取消搜索
  420. $(document).on('tap', '.my-btn-cancel', function() {
  421. $(this).hide();
  422. $('#search-hot').hide();
  423. $("body").css("overflow", "auto");
  424. $('#search').autocompleter("close");
  425. $(".autocompleter-list").empty().css("height", "auto");
  426. $('.autocompleter-hint').removeClass('autocompleter-hint-show').empty();
  427. $(".icon-caidan").show();
  428. $('#search').blur();
  429. });
  430. //打开菜单
  431. $(document).on('tap', '.icon-caidan', function() {
  432. $("#menu").css("height", $(window).height());
  433. $("#menu>li").addClass("active");
  434. });
  435. //关闭菜单
  436. $(document).on('tap', '.icon-guanbi', function() {
  437. $("#menu>li").removeClass("active");
  438. $("#menu").css("height", "0px");
  439. });
  440. //精选产品详情
  441. $(document).on('tap', '#index-pro-list .mui-table-view-cell>a', function() {
  442. location.href = 'pro-details.html?productId=' + $(this).attr("name")
  443. });
  444. //精选产品详情2
  445. $(document).on('tap', '#index-pro-list2 .mui-table-view-cell>a', function() {
  446. location.href = 'pro-details.html?productId=' + $(this).attr("name")
  447. });
  448. //产品详情-配件
  449. $(document).on('tap', '#index-pro-items>.mui-control-item', function() {
  450. location.href = 'pro-list.html?productId=' + $(this).attr("name") + '&childTypeId=' + $(this).attr("item");
  451. });
  452. //more更多产品
  453. $(document).on('tap', '.go_pro_list', function() {
  454. if (typeof($(this).attr("pos")) != "undefined") {
  455. location.href = "pro-list.html?productId=5";
  456. } else {
  457. location.href = "pro-list.html";
  458. }
  459. });
  460. //菜单跳转
  461. $(document).on('tap', '#menu>.line>a', function() {
  462. location.href = 'pro-list.html?productId=' + $(this).attr("name") + '&childTypeId=' + $(this).attr("item");
  463. });
  464. //春节放假通知弹窗点击事件
  465. $(document).on('tap', '.year-dalog', function() {
  466. if (!window.localStorage) {
  467. mui.alert("您的浏览器不支持localStorage");
  468. } else {
  469. //自定义json数据
  470. var obj = {};
  471. obj = {
  472. text: new Date().getTime()
  473. };
  474. //json格式化插入 点击时间
  475. localStorage.setItem('clickdate', JSON.stringify(obj));
  476. }
  477. $(".year-dalog").removeClass("active");
  478. setTimeout(function() {
  479. $(".year-dalog").hide();
  480. }, 500);
  481. });
  482. </script>
  483. </body>
  484. </html>