chanpin_list_20190618.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>产品列表</title>
  6. <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
  7. <meta name="apple-mobile-web-app-capable" content="yes">
  8. <meta name="apple-mobile-web-app-status-bar-style" content="black">
  9. <link rel="stylesheet" type="text/css" href="css/mui.min.css" />
  10. <link rel="stylesheet" type="text/css" href="css/iconfont.css" />
  11. <link rel="stylesheet" type="text/css" href="css/style.css" />
  12. <style>
  13. #pullrefresh_chanpin_list .mui-table-view-chevron .wh-100{padding:0;}
  14. .mui-table-view.mui-grid-view .mui-table-view-cell .mui-media-object:nth-of-type(odd){padding-right: 4px;}
  15. .mui-pull-caption{font-size: 12px;}
  16. .tab-with-chanpin-list{margin-top: 0;padding-top: 5px;}
  17. #pullrefresh_chanpin_list{padding-top: 46px;}
  18. #pullrefresh_chanpin_list .mui-table-view-cell{border-bottom: 0;text-align: left;}
  19. #pullrefresh_chanpin_list .mui-table-view-chevron .mui-table-view-cell:last-child{border-bottom: 0;}
  20. #pullrefresh_chanpin_list .mui-table-view-cell:after{display: none;}
  21. #pullrefresh_chanpin_list .mui-grid-view{padding:0 10px 10px 0;}
  22. #pullrefresh_chanpin_list .mui-grid-view .mui-table-view-cell>a{background: #fff;}
  23. #pullrefresh_chanpin_list .mui-grid-view .mui-table-view-cell:nth-of-type(odd){border-right: 0;}
  24. #pullrefresh_chanpin_list .mui-grid-view .mui-table-view-cell:nth-of-type(even){border-left: 0;}
  25. #pullrefresh_chanpin_list .mui-grid-view .mui-table-view-cell:nth-of-type(odd):last-child{border-bottom: 0;}
  26. #pullrefresh_chanpin_list .mui-table-view-chevron .wh-100{padding:0;}
  27. #pullrefresh_chanpin_list .mui-grid-view .shop-price {padding:0;}
  28. #pullrefresh_chanpin_list .my-tab-view-pull:after{display: none;}
  29. .go_chanpin_details .mui-h6{margin-top: 5px;}
  30. </style>
  31. <script type="text/javascript">
  32. // 屏蔽分享
  33. window.hiddenAllWechatMenu = true;
  34. </script>
  35. </head>
  36. <script>
  37. var d = new Date().getTime(); //当前时间戳
  38. if (d > 1560873599000) {
  39. location.href = "chanpin_list.html";
  40. }
  41. </script>
  42. <body>
  43. <div class="loading-bg">
  44. <div class="mui-loading">
  45. <div class="mui-spinner">
  46. </div>
  47. &nbsp;&nbsp;加载中...
  48. </div>
  49. </div>
  50. <nav class="mui-bar mui-bar-tab" id="footer-bar">
  51. <a class="mui-tab-item" >
  52. <div class="iconfont icon-shouye"></div>
  53. <span class="mui-tab-label">首页</span>
  54. </a>
  55. <a class="mui-tab-item">
  56. <div class="iconfont icon-gouwuche"><span class="mui-badge">0</span></div>
  57. <span class="mui-tab-label">购物车</span>
  58. </a>
  59. <a class="mui-tab-item">
  60. <div class="iconfont icon-dingdan"></div>
  61. <span class="mui-tab-label">订单</span>
  62. </a>
  63. <a class="mui-tab-item">
  64. <div class="iconfont icon-wode"></div>
  65. <span class="mui-tab-label">我的</span>
  66. </a>
  67. </nav>
  68. <div class="mui-segmented-control tab-with-chanpin-list">
  69. <a class="mui-control-item mui-active">
  70. <span class="mui-tab-label">WaterO</span>
  71. </a>
  72. <a class="mui-control-item">
  73. <span class="mui-tab-label">Aiberle</span>
  74. </a>
  75. </div>
  76. <!--下拉刷新容器-->
  77. <div id="pullrefresh_chanpin_list" class="mui-content mui-scroll-wrapper" style="background: #fff;">
  78. <div class="mui-scroll">
  79. <!--数据列表-->
  80. <ul class="mui-table-view mui-grid-view my-tab-view-pull">
  81. </ul>
  82. </div>
  83. </div>
  84. <script src="js/mui.min.js"></script>
  85. <script src="js/jquery-2.1.1.min.js"></script>
  86. <script src="js/main.js"></script>
  87. <script src="js/page/wechat-utils-1.0.js"></script>
  88. <script src="js/page/validate.js"></script>
  89. <script>
  90. mui.init({
  91. pullRefresh: {
  92. container: '#pullrefresh_chanpin_list',
  93. down: {},
  94. up: {
  95. contentrefresh: '正在加载...',
  96. callback: pullupRefresh
  97. }
  98. }
  99. });
  100. var pageNumber = 0,
  101. pagesize = 10,
  102. proType = "1";
  103. function pullupRefresh() {
  104. pageNumber += 1;
  105. $.ajax(base_path + '/product/productIndex?dates=' + new Date().getTime(), {
  106. data: {
  107. "pageSize": pagesize,
  108. "pageNO": pageNumber,
  109. "productType": proType
  110. },
  111. dataType: 'json',
  112. type: 'post',
  113. timeout: 15000,
  114. xhrFields: {
  115. withCredentials: true
  116. },
  117. crossDomain: true,
  118. success: function(dt) {
  119. if (dt.isRedirect) {
  120. location.href = dt.redirectURL;
  121. } else {
  122. if(dt.status) {
  123. var chanpin_data = [];
  124. chanpin_data = dt.data.productList;
  125. mui('#pullrefresh_chanpin_list').pullRefresh().endPullupToRefresh(chanpin_data.length < pagesize);
  126. var table = document.body.querySelector('.my-tab-view-pull');
  127. mui(chanpin_data).each(function(index) {
  128. var pro_color = this.productColor;
  129. var li = document.createElement('li');
  130. var yuanjia = '<s class="gwc-pp">原价:¥' + accDiv(this.productPrice, 100) + '</s>';
  131. if(marquee != '' && this.productDiscount == '328000') {
  132. yuanjia = '<span class="mui-h6">购买即赠3年滤芯</span>'
  133. }
  134. var img='';
  135. img=this.colorImg;
  136. if($(".box-list-card .iconfont").hasClass("icon-list")) {
  137. li.className = 'mui-table-view-cell mui-media';
  138. li.innerHTML = '<a proid="' + this.productId + '" colorid="'+this.colorId+'" class="go_chanpin_details"><img class="mui-media-object mui-pull-left wh-100" src="' + img + '"><div class="mui-media-body gwc-tit">' + this.productName + '</div><div class="mui-ellipsis mui-h6">' + this.productColorDes + '</div><div class="shop-price">' + marquee + '<span class="price-sp">¥' + accDiv(this.productDiscount, 100) + '</span>' + yuanjia + '</div></div></a>">';
  139. } else {
  140. li.className = 'mui-table-view-cell mui-media mui-col-xs-6';
  141. li.innerHTML = '<a proid="' + this.productId + '" colorid="'+this.colorId+'" class="go_chanpin_details"><img class="mui-media-object" src="' + img + '"><div class="mui-media-body gwc-tit">' + this.productName + '</div><div class="mui-ellipsis mui-h6">' + this.productColorDes + '</div><div class="shop-price">' + marquee + '<span class="price-sp">¥' + accDiv(this.productDiscount, 100) + '</span>' + yuanjia + '</div></a>';
  142. }
  143. table.appendChild(li)
  144. mui('#pullrefresh_chanpin_list').pullRefresh().disablePullupToRefresh();
  145. });
  146. if(chanpin_data.length==0){
  147. mui('#pullrefresh_chanpin_list').pullRefresh().disablePullupToRefresh();
  148. var li = document.createElement('li');
  149. li.className = 'mui-table-view-cell mui-media mui-col-xs-12 mui-text-center';
  150. li.innerHTML='<img style="width:100px;display:block;margin:40px auto 0 auto;" src="images/null-4.png" /><h6 class="mui-text-center">暂无产品信息,逛逛别的产品吧!</h6>';
  151. table.appendChild(li);
  152. }
  153. } else {
  154. mui('#pullrefresh_chanpin_list').pullRefresh().endPullupToRefresh(true)
  155. }
  156. }
  157. },
  158. error: function(xhr, type, errorThrown) {
  159. console.log(xhr)
  160. }
  161. })
  162. };
  163. function search_pullrefresh(str) {
  164. if(str != null && str != '') {
  165. if(!checkParameter(str)) {
  166. mui.alert('您输入的格式有误,请重新输入!')
  167. } else {
  168. pageNumber = 0;
  169. $('.my-tab-view-pull').empty();
  170. search_str = str;
  171. mui('#pullrefresh_chanpin_list').pullRefresh().refresh(true);
  172. mui('#pullrefresh_chanpin_list').pullRefresh().pullupLoading()
  173. }
  174. } else {
  175. pageNumber = 0;
  176. $('.my-tab-view-pull').empty();
  177. search_str = str;
  178. mui('#pullrefresh_chanpin_list').pullRefresh().refresh(true);
  179. mui('#pullrefresh_chanpin_list').pullRefresh().pullupLoading()
  180. }
  181. };
  182. //mui.os.ios ? listener_ipt() : keyup_fn();
  183. //
  184. //function keyup_fn() {
  185. // $('body').on('keyup', '#chanpin-search', function(e) {
  186. // var currKey = 0,
  187. // e = e || event;
  188. // currKey = e.keyCode || e.which || e.charCode;
  189. // var keyName = String.fromCharCode(currKey);
  190. // if(currKey == "13") {
  191. // var str = $.trim($('#chanpin-search').val());
  192. // search_pullrefresh(str)
  193. // }
  194. // })
  195. //};
  196. //document.getElementById('chanpin-search').addEventListener('input', function(e) {
  197. // var value = e.target.value
  198. //});
  199. //function listener_ipt() {
  200. // document.getElementById('chanpin-search').onblur = function() {
  201. // var str = $.trim($('#chanpin-search').val());
  202. // search_pullrefresh(str)
  203. // }
  204. //};
  205. mui.ready(function() {
  206. proType = getParam("proType");
  207. proType == null ? proType = "1" : proType;
  208. //springFestivalPop();
  209. marquee_Show();
  210. if(proType != 1) {
  211. $(".tab-with-chanpin-list .mui-control-item:first-child").removeClass('mui-active');
  212. $(".tab-with-chanpin-list .mui-control-item:last-child").addClass('mui-active');
  213. }
  214. mui('#pullrefresh_chanpin_list').pullRefresh().pullupLoading();
  215. getCartNum();
  216. document.querySelector('.loading-bg').style.display = 'none'
  217. });
  218. function checkParameter(remark) {
  219. if(!/^[\u4e00-\u9fa5_a-zA-Z0-9-]+$/.test(remark)) {
  220. return false
  221. }
  222. return true
  223. };
  224. $(document).on('tap', '.box-list-card', function() {
  225. var listcard = $(this).children().first();
  226. if(listcard.hasClass("icon-list")) {
  227. listcard.removeClass("icon-list").addClass("icon-list-card");
  228. $(".my-tab-view-pull").removeClass("mui-table-view-chevron").addClass("mui-grid-view");
  229. $(".mui-media-object").removeClass("mui-pull-left wh-100");
  230. $(".my-tab-view-pull .mui-table-view-cell").addClass("mui-col-xs-6")
  231. } else {
  232. listcard.removeClass("icon-list-card").addClass("icon-list");
  233. $(".my-tab-view-pull").removeClass("mui-grid-view").addClass("mui-table-view-chevron");
  234. $(".mui-media-object").addClass("mui-pull-left wh-100");
  235. $(".my-tab-view-pull .mui-table-view-cell").removeClass("mui-col-xs-6")
  236. }
  237. });
  238. mui.each(document.querySelectorAll('.tab-with-chanpin-list .mui-control-item'), function(index, el) {
  239. el.addEventListener('tap', function() {
  240. pageNumber = 0;
  241. switch(index) {
  242. case 0:
  243. proType = 1;
  244. break;
  245. case 1:
  246. proType = 16;
  247. break;
  248. default:
  249. proType = 1;
  250. break
  251. }
  252. // var href=location.href;
  253. // if(href.indexOf("proType")>0){
  254. // history.pushState("", "产品列表",'//'+location.host+'/wateroWechat/chanpin_list_20190618.html?proType='+proType);
  255. // }
  256. $('.my-tab-view-pull').empty();
  257. mui('#pullrefresh_chanpin_list').pullRefresh().refresh(true);
  258. mui('#pullrefresh_chanpin_list').pullRefresh().pullupLoading()
  259. }, false)
  260. });
  261. </script>
  262. </body>
  263. </html>