123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
- <meta name="apple-mobile-web-app-capable" content="yes">
- <meta name="apple-mobile-web-app-status-bar-style" content="black">
- <title>产品列表</title>
- <link rel="stylesheet" type="text/css" href="css/mui.min.css" />
- <link rel="stylesheet" type="text/css" href="css/iconfont.css" />
- <link rel="stylesheet" type="text/css" href="css/main.css" />
- <script>
-
- document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
- WeixinJSBridge.call('hideOptionMenu');
- });
- </script>
- </head>
- <body>
-
- <footer class="mui-bar mui-bar-tab" id="footer-bar-tab">
- <a class="mui-tab-item">
- <span class="iconfont icon-shouye"></span>
- <span class="mui-tab-label">首页</span>
- </a>
- <a class="mui-tab-item mui-active">
- <span class="iconfont icon-liebiao"></span>
- <span class="mui-tab-label">列表</span>
- </a>
- <a class="mui-tab-item">
- <span class="iconfont icon-gouwuche"></span>
- <span class="mui-tab-label">购物车</span>
- </a>
- <a class="mui-tab-item">
- <span class="iconfont icon-huiyuan"></span>
- <span class="mui-tab-label">会员</span>
- </a>
- </footer>
-
-
- <div>
-
- <div id="pro-top-menu" class="mui-segmented-control">
-
-
- </div>
- </div>
-
- <div id="pullrefresh_pro_list" class="mui-content mui-scroll-wrapper" style="top: 44px;">
- <div class="mui-scroll">
- <ul class="mui-table-view mui-grid-view my-grid-view-no my-table-pull">
-
- </ul>
- </div>
- </div>
-
-
- <div class="loading covers">
- <div class="loading-bj"></div>
- <p>正在加载...</p>
- </div>
-
- <script src="js/mui.min.js"></script>
- <script src="js/jquery-2.1.1.min.js"></script>
- <script src="js/main.js"></script>
-
- <script>
- window.addEventListener('pageshow', function(e) {
-
- if(e.persisted) {
- location.reload();
- }
- });
- var typeId = getParam("typeId");
- var pageNumber = 0,pagesize = 10;
- mui.init({
- pullRefresh: {
- container: '#pullrefresh_pro_list',
- down: {
-
- },
- up: {
- contentrefresh: '正在加载...',
- callback: pullupRefresh
- }
- }
- });
-
- function pullupRefresh() {
- ++pageNumber;
- $.ajax(base_path + '/wechat/product/listProductColorByTypeId?dates=' + new Date().getTime(), {
- data: {
- "typeId":typeId,
- "pageNo":pageNumber,
- "pageSize":pagesize
- },
- dataType: 'json',
- xhrFields: {
- withCredentials: true
- },
- crossDomain: true,
- type: 'get',
- timeout: 15000,
- success: function(dt) {
- if(dt.isRedirect) {
- location.href = dt.redirectURL;
- } else {
- if(dt.status) {
- var table = document.body.querySelector('.my-table-pull');
- mui('#pullrefresh_pro_list').pullRefresh().endPullupToRefresh(dt.data.productColorList.length<pagesize);
- mui.each(dt.data.productColorList, function(index) {
- var li = document.createElement('li');
- li.className='mui-table-view-cell mui-media mui-col-xs-6';
- li.innerHTML = '<a name="'+this.colorId+'" style="margin-top: 15px;"><img class="mui-media-object" src="'+this.colorImg+'"><div class="pro-name">'+this.productName+'</div><h6 style="margin-top: 5px;">'+this.colorName+'</h6><div class="pro-price" style="margin-top: 10px;">¥'+(this.colorDiscount/100).toFixed(2)+'</div></a>';
- table.appendChild(li);
- });
- } else {
- mui.alert("获取产品列表失败!");
- }
- }
- },
- error: function(xhr, type, errorThrown) {
- console.log(xhr);
- mui.alert("获取产品列表失败!网络错误");
- }
- });
- }
- mui.ready(function() {
-
- $.ajax(base_path + '/wechat/product/listProductType?dates=' + new Date().getTime(), {
- data: {},
- dataType: 'json',
- xhrFields: {
- withCredentials: true
- },
- crossDomain: true,
- type: 'get',
- timeout: 15000,
- success: function(dt) {
- if(dt.isRedirect) {
- location.href = dt.redirectURL;
- } else {
- if(dt.status) {
- var table = document.body.querySelector("#pro-top-menu");
-
- mui.each(dt.data, function(index) {
- var li = document.createElement('a');
- if(typeId != null) {
- if(typeId == this.typeId) {
- li.className = 'mui-control-item mui-active';
- } else {
- li.className = 'mui-control-item';
- }
- } else {
- if(index == 0) {
- li.className = 'mui-control-item mui-active';
- typeId=this.typeId;
- } else {
- li.className = 'mui-control-item';
- }
- }
- li.setAttribute("name",this.typeId);
- li.innerHTML=this.typeName;
- table.appendChild(li);
- });
- mui('#pullrefresh_pro_list').pullRefresh().pullupLoading();
- $(".loading").hide().css("opacity", "0");
- } else {
- mui.alert("获取产品类型失败!");
- }
- }
- },
- error: function(xhr, type, errorThrown) {
- console.log(xhr);
- mui.alert("获取产品类型失败!网络错误");
- }
- });
- });
-
- $(document).on('tap', '#pro-top-menu>a', function() {
- typeId=$(this).attr("name");
- pageNumber=0;
- $('.my-table-pull').empty();
- mui('#pullrefresh_pro_list').pullRefresh().pullupLoading();
- mui('.mui-scroll-wrapper').scroll().scrollTo(0,0,500);
- });
-
- $(document).on('tap', '.my-table-pull>li>a', function() {
- location.href='pro-details.html?colorId='+$(this).attr("name");
- });
- </script>
- </body>
- </html>
|