index.html 20 KB

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