|
@@ -2,20 +2,14 @@ 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
|
|
|
+ typeSort:0,
|
|
|
+ bigTypeId:0,
|
|
|
+ smallTypeId:0,//二级分类id
|
|
|
+ tinyTypeId:0,//三级分类id
|
|
|
listRecord: 0,
|
|
|
pageInput: '1',
|
|
|
source:'www',
|
|
@@ -24,7 +18,7 @@ var productList = new Vue({
|
|
|
identity:GLOBAL_USER_IDENTITY,
|
|
|
sortField:'',
|
|
|
sortType: 1, // 上传0,下传1 綜合1
|
|
|
- pageSize: 24,
|
|
|
+ pageSize: 4,
|
|
|
pageNum: 1,
|
|
|
idType:1
|
|
|
},
|
|
@@ -40,32 +34,8 @@ var productList = new Vue({
|
|
|
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({ typeId:_self.bigTypeId, idType:1, source:_self.source },function (res) {
|
|
|
- if(res.code==0){
|
|
|
- _self.smalltypeList = res.data.smallTypeList;
|
|
|
- }else {
|
|
|
- CAIMEI.Alert(res.msg,'确定',false)
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
getproductList:function(){//商品列表
|
|
|
var _self=this;
|
|
|
ProductApi.GetSearchProduct(_self.params,function (res) {
|
|
@@ -101,35 +71,22 @@ var productList = new Vue({
|
|
|
},
|
|
|
toPagination: function (pageNum) {
|
|
|
if (pageNum <= this.pageTotal) {
|
|
|
- this.params.pageNum = pageNum;
|
|
|
- this.listData=[];
|
|
|
- this.getproductList();
|
|
|
+ this.params.pageNum = pageNum*1;
|
|
|
+ var url = '/product/classify-'+this.typeSort+'-'+this.bigTypeId+'-'+this.smallTypeId+'-'+this.tinyTypeId+'-'+this.params.pageNum+'-'+this.params.pageSize;
|
|
|
+ if (this.params.sortField) {
|
|
|
+ url += '-'+this.params.sortField+'-'+this.params.sortType+'.html';
|
|
|
+ } else {
|
|
|
+ url += '.html';
|
|
|
+ }
|
|
|
+ window.location.href = url;
|
|
|
}
|
|
|
},
|
|
|
toSortList: function (sortField, sortType) {
|
|
|
- this.params.sortField= sortField;
|
|
|
- this.params.sortType = sortType;
|
|
|
- this.params.pageNum = 1;
|
|
|
- this.listData=[];
|
|
|
- this.getproductList();
|
|
|
- },
|
|
|
- removeNama:function(index){//删除三级分类+
|
|
|
- this.params.idType = index;
|
|
|
- switch (index) {
|
|
|
- case 1:
|
|
|
- this.smallName = '';
|
|
|
- this.params.id = this.bigTypeId;
|
|
|
- this.smallTypeId='';
|
|
|
- this.getproductList();
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- this.tinyName = '';
|
|
|
- this.params.id = this.smallTypeId;
|
|
|
- this.tinyTypeId='';
|
|
|
- this.getproductList();
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
+ var url = '/product/classify-'+this.typeSort+'-'+this.bigTypeId+'-'+this.smallTypeId+'-'+this.tinyTypeId+'-1-'+this.params.pageSize+'-'+sortField+'-'+sortType+'.html';
|
|
|
+ this.params.sortField= sortField;
|
|
|
+ this.params.sortType = sortType;
|
|
|
+ this.params.pageNum = 1;
|
|
|
+ window.location.href = url;
|
|
|
},
|
|
|
PromotionsFormat:function(promo){//促销活动类型数据处理
|
|
|
if(promo!=null){
|
|
@@ -141,102 +98,44 @@ var productList = new Vue({
|
|
|
}
|
|
|
return false
|
|
|
},
|
|
|
- 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.smallName ='';
|
|
|
- this.tinyName ='';
|
|
|
- this.smallTypeId='';
|
|
|
- this.tinyTypeId='';
|
|
|
- this.tinytypeList=[];
|
|
|
- this.getclassify();
|
|
|
- break;
|
|
|
- case 2://选择二级分类查询
|
|
|
- this.smallName = item.name;
|
|
|
- this.tinyName = '';
|
|
|
- this.smallTypeId = item.smallTypeId;
|
|
|
- this.params.id = item.smallTypeId;
|
|
|
- this.tinyTypeId='';
|
|
|
- this.tinytypeList =item.tinytypeList;
|
|
|
- break;
|
|
|
- case 3://选择三级分类查询
|
|
|
- this.tinyName = item.name;
|
|
|
- this.tinyTypeId = item.tinyTypeId;
|
|
|
- this.params.id = item.tinyTypeId;
|
|
|
- break;
|
|
|
- }
|
|
|
- this.listData=[];
|
|
|
- this.getproductList();
|
|
|
- },
|
|
|
},
|
|
|
created:function () {
|
|
|
var userInfo = localStorage.getItem('userInfo');
|
|
|
if(userInfo){
|
|
|
this.userId = JSON.parse(userInfo).userId;
|
|
|
}
|
|
|
+ var paramsArr = window.location.pathname.split(".")[0].split("-");
|
|
|
+ this.typeSort = paramsArr.length>=2 ? paramsArr[1]*1 : 0;
|
|
|
+ this.bigTypeId = paramsArr.length>=3 ? paramsArr[2]*1 : 0;
|
|
|
+ this.smallTypeId = paramsArr.length>=4 ? paramsArr[3]*1 : 0;
|
|
|
+ this.tinyTypeId = paramsArr.length>=5 ? paramsArr[4]*1 : 0;
|
|
|
+ this.params.pageNum = paramsArr.length>=6 ? paramsArr[5]*1 : 1;
|
|
|
+ this.params.sortField= paramsArr.length>=8 ? paramsArr[7] : "";
|
|
|
+ this.params.sortType = paramsArr.length>=9 ? paramsArr[8]*1 : 1;
|
|
|
},
|
|
|
mounted:function () {
|
|
|
var _self = this;
|
|
|
- var paramsArr = window.location.pathname.split(".")[0].split("-");
|
|
|
- var typeSort = paramsArr.length>=1 ? paramsArr[1] : '';
|
|
|
- this.bigTypeId = paramsArr.length>=2 ? paramsArr[2] : '';
|
|
|
- this.smallTypeId = paramsArr.length>=3 ? paramsArr[3] : '';
|
|
|
- this.tinyTypeId = paramsArr.length>=4 ? paramsArr[4] : '';
|
|
|
- console.log( this.smallTypeId)
|
|
|
- console.log( this.tinyTypeId)
|
|
|
- if(this.tinyTypeId==null && this.smallTypeId==null){
|
|
|
- this.params.id=this.bigTypeId;
|
|
|
- this.params.idType = 1;
|
|
|
- }else if(this.tinyTypeId==null){
|
|
|
+ this.listRecord = $('#productCount').val() ? $('#productCount').val()*1 : 0;
|
|
|
+ if (this.bigTypeId && this.smallTypeId && this.tinyTypeId) {
|
|
|
+ this.params.id=this.tinyTypeId;
|
|
|
+ this.params.idType = 3;
|
|
|
+ } else if (this.bigTypeId && this.smallTypeId) {
|
|
|
this.params.id=this.smallTypeId;
|
|
|
this.params.idType = 2;
|
|
|
- }else if(this.smallTypeId==null){
|
|
|
+ } else {
|
|
|
this.params.id=this.bigTypeId;
|
|
|
this.params.idType = 1;
|
|
|
- }else {
|
|
|
- this.params.id=this.tinyTypeId;
|
|
|
- this.params.idType = 3;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- 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;
|
|
|
- if (item.smallTypeList!='' && item.smallTypeList!=null){
|
|
|
- _self.smalltypeList= item.smallTypeList;
|
|
|
- _self.smalltypeList.forEach(function (pros) {
|
|
|
- if(_self.smallTypeId == pros.smallTypeId){
|
|
|
- _self.smallName = pros.name;
|
|
|
- if(pros.tinyTypeList!=''&&pros.tinyTypeList!=null){
|
|
|
- _self.tinytypeList = pros.tinyTypeList;
|
|
|
- _self.tinytypeList.forEach(function (thiny) {
|
|
|
- if (thiny.tinyTypeId ==_self.tinyTypeId){
|
|
|
- _self.tinyName=thiny.name;
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
- }else {
|
|
|
- CAIMEI.Alert(res.msg, '确定', false);
|
|
|
- }
|
|
|
+ if (GLOBAL_USER_ID && GLOBAL_USER_ID>0) {
|
|
|
+ _self.getproductList();
|
|
|
+ } else {
|
|
|
+ _self.listLoading = false;
|
|
|
+ _self.$nextTick(function(){
|
|
|
+ // 图片懒加载
|
|
|
+ $("img[data-original]").lazyload();
|
|
|
});
|
|
|
- this.getclassify();
|
|
|
- this.getproductList();
|
|
|
+ }
|
|
|
if(!isPC){
|
|
|
- _self.getproductList();
|
|
|
$('footer').addClass("noneImportant");
|
|
|
//移动端上垃加载更多
|
|
|
$(window).on('scroll', function(){
|