index.html 20 KB

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