Browse Source

Merge remote-tracking branch 'origin/developerB' into developerB

zhengjinyi 4 năm trước cách đây
mục cha
commit
a2f5e25d59

+ 1 - 1
src/main/resources/static/css/product/instruement.css

@@ -79,7 +79,7 @@
     .floorCon .hotList div a{width: 45.6vw;height: 68vw;overflow: hidden;margin: 0 1.3vw 2.6vw 1.3vw;background: #fff;text-align: left;}
     .hotList div a.img01 img,.hotList div a.img02 img{height: 100%}
     .hotList div a img {width: 45.6vw;height: 45.6vw}
-    .productItem .name{display: block;padding: 0 3.2vw;height:9.3vw;line-height: 4.8vw;font-size: 3.4vw;vertical-align: middle;word-break: break-all;overflow: hidden;text-overflow: ellipsis;display: -webkit-inline-box;-webkit-line-clamp: 2;-webkit-box-orient: vertical;}
+    .productItem .name{margin-top: 8px;display: block;padding: 0 3.2vw;height:9.3vw;line-height: 4.8vw;font-size: 3.4vw;vertical-align: middle;word-break: break-all;overflow: hidden;text-overflow: ellipsis;display: -webkit-inline-box;-webkit-line-clamp: 2;-webkit-box-orient: vertical;}
     .productItem .price em{display: block;height: 7vw;line-height: 7vw;color: #4A4F58;font-style: normal;float: left;}
     .hotList div.unfold{width: 20vw;height: 6.4vw;margin: 5vw auto;border: .27vw solid #cccccc;color: #909090;font-size: 3vw;line-height: 6.4vw;text-align: center;border-radius: .54vw}
     .productItem .price .mIcon:before{width:15.8vw;height: 5vw}

+ 194 - 0
src/main/resources/static/js/product/produce-list.js

@@ -0,0 +1,194 @@
+var productList = new Vue({
+    el:'#productList',
+    data:{
+        userId:0,
+        searchFlag: false,
+        listLoading: true,
+        requestFlag: true,
+        noMore: false,
+        classify:[],
+        smalltypeList:[],//二级分类
+        tinytypeList:[],//三级分类
+        listData:[],
+        bigName:'',
+        smallName:'',
+        tinyName:'',
+        bigTypeID:'',
+        smallTypeID:'',//二级分类id
+        tinyTypeID:'',//三级分类id
+        listRecord: 0,
+        pageInput: '1',
+        source:'www',
+        params: {
+            id:'',
+            identity:GLOBAL_USER_IDENTITY,
+            sortField:'',
+            sortType: 1, // 1降序,其他升序
+            pageSize: 24,
+            pageNum: 1,
+            idType:1
+        },
+    },
+    computed: {
+        pageTotal: function () {
+            var total = Math.ceil(this.listRecord / this.params.pageSize);
+            return total > 0 ? total : 1;
+        },
+        showPageBtn: function () {
+            var total = Math.ceil(this.listRecord / this.params.pageSize);
+            total = total > 0 ? total : 1;
+            var index = this.params.pageNum, arr = [];
+            if (total <= 6) {
+                for (var i = 1; i <= total; i++) {
+                    arr.push(i);
+                }
+                return arr;
+            }
+            if (index <= 3) return [1, 2, 3, 4, 5, 0, total];
+            if (index >= total - 2) return [1, 0, total - 4, total - 3, total - 2, total - 1, total];
+            return [1, 0, index - 2, index - 1, index, index + 1, index + 2, 0, total];
+        }
+    },
+    methods:{
+        getclassify:function(){
+        var _self = this;
+        ProductApi.GetbigTypeclassify({source:_self.source,bigTypeID:_self.bigTypeID},function (res) {
+            if(res.code==0){
+                _self.smalltypeList = res.data;
+            }else {
+           CAIMEI.Alert(res.msg,'确定',false)
+            }
+        })
+    },
+       getproductList:function(){//一级商品列表
+           var _self=this;
+           ProductApi.GetSearchProduct(_self.params,function (res) {
+               if( res.code==0){
+                     var result = JSON.parse(res.data);
+                      _self.listRecord = result.total;
+                       var resultData = setSearchProductList(result.items, _self.userId, function(){
+                            _self.$forceUpdate();
+                            setTimeout(function(){
+                                // 图片懒加载
+                                $("img[data-original]").lazyload();
+                            },500);
+                        });
+                        if(isPC){
+                            _self.listData = resultData;
+                        }else{
+                            _self.listData = _self.listData.concat(resultData);
+                        }
+                        _self.listLoading = false;
+                        _self.requestFlag = true;
+               }else {
+                CAIMEI.Alert(res.msg,'确定',false)
+               }
+           })
+        },
+        checkNum: function () {
+            if (this.pageInput > this.pageTotal) {
+                this.pageInput = this.pageTotal;
+            } else if (this.pageInput < 1) {
+                this.pageInput = 1;
+            }
+        },
+        toPagination: function (pageNum) {
+            if (pageNum <= this.pageTotal) {
+                this.params.pageNum = pageNum;
+                this.getproductList();
+            }
+        },
+        toSortList: function (sortField, sortType) {
+             this.params.sortField= sortField;
+             this.params.sortType = sortType;
+             this.params.pageNum = 1;
+             this.getproductList();
+        },
+         removesmall:function(){//删除二级
+            this.smallName = '';
+        },
+        removetiny:function(){//删除三级分类
+            this.tinyName = ''
+        },
+        checkedClasslyFn:function(item,index){
+            this.params.pageNum = 1;
+            this.params.idType = index;
+            switch (index) {
+                case 1://选择1集分类查询
+                    this.bigName=item.name;
+                    this.smallName = '';
+                    this.bigTypeID = item.bigTypeID;
+                    this.params.id = item.bigTypeID;
+                    this.getclassify();
+                    break;
+                case 2://选择二级分类查询
+                    this.smallName = item.name;
+                    this.tinyName = '';
+                    this.smallTypeID = item.smallTypeID;
+                    this.params.id = item.smallTypeID;
+                    this.tinytypeList =item.tinytypeList;
+                    break;
+                case 3://选择三级分类查询
+                    this.tinyName = item.name;
+                    this.tinyTypeID = item.tinyTypeID;
+                    this.params.id = item.tinyTypeID;
+                    break;
+            }
+           this.getproductList();
+        },
+    },
+    created:function () {
+        var userInfo = localStorage.getItem('userInfo');
+        if(userInfo){
+            this.userId = JSON.parse(userInfo).userId;
+        }
+    },
+    mounted:function () {
+        var _self = this;
+        this.bigTypeID = getUrlParam('bigTypeID');
+        this.params.id=this.bigTypeID;
+        var typeSort =  getUrlParam('typeSort');
+        PublicApi.GetProductClassify({typeSort:typeSort,source:'www'},function (res) {
+                if (res.code==0){
+                    _self.classify = res.data;
+                    _self.classify.forEach(function (item) {
+                        if(_self.bigTypeID == item.bigTypeID){
+                            _self.bigName = item.name;
+                        }
+                    })
+                }else {
+                     CAIMEI.Alert(res.msg, '确定', false);
+                }
+            });
+        this.getclassify();
+        this.getproductList();
+        if(!isPC){
+            _self.getproductList();
+            $('footer').addClass("noneImportant");
+            //移动端上垃加载更多
+            $(window).on('scroll', function(){
+                var scrollTop = $(this).scrollTop();
+                var scrollHeight = $(document).height();
+                var windowHeight = window.innerHeight;
+                if (scrollTop + windowHeight >= scrollHeight) {
+                    //此处是滚动条到底部时候触发的事件,在这里写要加载的数据,或者是拉动滚动条的操作
+                    var totalPage = Math.ceil(_self.listRecord / _self.params.pageSize)?Math.ceil(_self.listRecord / _self.params.pageSize):1;
+                    var next = _self.params.pageNum+1;
+                    if(next <= totalPage){
+                        if (_self.requestFlag){
+                            _self.params.pageNum = next;
+                                // 获取列表数据
+                             _self.getproductList();
+                        }
+                        _self.requestFlag = false;
+                    }else{
+                        //到底了
+                        _self.noMore = true;
+                        $('footer').removeClass("noneImportant");
+                    }
+                }
+            });
+        }
+    }
+
+})