登录方式重构

This commit is contained in:
Aaron
2021-07-19 19:37:35 +08:00
parent 79305d7497
commit b196b5237d
21 changed files with 858 additions and 323 deletions

View File

@ -72,37 +72,34 @@ export default {
!this.loading && this.getProductReplyList();
},
methods: {
getProductReplyCount: function() {
let that = this;
getReplyConfig(that.product_id).then(res => {
that.$set(that, "replyData", res.data);
that.navList[0].num = res.data.sumCount;
that.navList[1].num = res.data.goodCount;
that.navList[2].num = res.data.inCount;
that.navList[3].num = res.data.poorCount;
getProductReplyCount () {
getReplyConfig(this.product_id).then(res => {
this.$set(that, "replyData", res.data);
this.navList[0].num = res.data.sumCount;
this.navList[1].num = res.data.goodCount;
this.navList[2].num = res.data.inCount;
this.navList[3].num = res.data.poorCount;
});
},
getProductReplyList: function() {
let that = this;
if (that.loading) return; //阻止下次请求false可以进行请求
if (that.loadend) return; //阻止结束当前请求false可以进行请求
that.loading = true;
let q = { page: that.page, limit: that.limit, type: that.currentActive };
getReplyList(that.product_id, q).then(res => {
that.loading = false;
getProductReplyList () {
if (this.loading) return; //阻止下次请求false可以进行请求
if (this.loadend) return; //阻止结束当前请求false可以进行请求
this.loading = true;
let q = { page: this.page, limit: this.limit, type: this.currentActive };
getReplyList(this.product_id, q).then(res => {
this.loading = false;
//apply();js将一个数组插入另一个数组;
that.reply.push.apply(that.reply, res.data);
that.loadend = res.data.length < that.limit; //判断所有数据是否加载完成;
that.page = that.page + 1;
this.reply.push.apply(this.reply, res.data);
this.loadend = res.data.length < this.limit; //判断所有数据是否加载完成;
this.page = this.page + 1;
});
},
changeType: function(index) {
let that = this;
that.currentActive = index;
that.page = 1;
that.loadend = false;
that.$set(that, "reply", []);
that.getProductReplyList();
changeType (index) {
this.currentActive = index;
this.page = 1;
this.loadend = false;
this.$set(this, "reply", []);
this.getProductReplyList();
}
}
};

View File

@ -109,7 +109,7 @@ export default {
nows: false,
recommendLoading: false,
target: false,
isIntegral: false,
isIntegral: false
}
},
watch: {
@ -193,10 +193,11 @@ export default {
this.loading = false
if (this.target) {
this.productList = res.data
this.target = false
} else {
this.productList.push.apply(this.productList, res.data)
}
this.target = false
console.log(this.target)
this.loadend = res.data.length < this.where.limit //判断所有数据是否加载完成;
this.where.page = this.where.page + 1
})
@ -209,60 +210,78 @@ export default {
this.getProductList()
},
//点击事件处理
set_where: function(index) {
let that = this
switch (index) {
case 0:
return that.$yrouter.push({
path: '/pages/shop/GoodsClass/index',
})
case 1:
if (that.price === 0) that.price = 1
else if (that.price === 1) that.price = 2
else if (that.price === 2) that.price = 0
that.stock = 0
break
case 2:
if (that.stock === 0) that.stock = 1
else if (that.stock === 1) that.stock = 2
else if (that.stock === 2) that.stock = 0
that.price = 0
break
case 3:
that.nows = !that.nows
break
default:
break
}
this.productList = []
that.$set(that, 'productList', [])
that.where.page = 1
that.target = true
that.loadend = false
that.getProductList()
set_where(index) {
this.productList = []
this.$set(this, 'productList', [])
this.where.page = 1
this.target = true
this.loadend = false
switch (index) {
case 0:
return this.$yrouter.push({
path: '/pages/shop/GoodsClass/index',
})
case 1:
if (this.price === 0) this.price = 1
else if (this.price === 1) this.price = 2
else if (this.price === 2) this.price = 0
this.stock = 0
break
case 2:
if (this.stock === 0) this.stock = 1
else if (this.stock === 1) this.stock = 2
else if (this.stock === 2) this.stock = 0
this.price = 0
break
case 3:
this.nows = !this.nows
break
default:
break
}
// this.getProductList()
this.setWhere()
const { s = '', id = 0, title = '' } = this.$yroute.query
if (s !== this.where.keyword || id !== this.where.sid) {
this.loadend = false
this.loading = false
this.where.page = 1
this.where.sid = id
this.title = title && id ? title : ''
this.nows = false
this.$set(this, 'productList', [])
this.price = 0
this.stock = 0
// this.getProductList();
}
let q = this.where
let getData = this.isIntegral !== 'true' ? getProducts : getProductsIntegral
getData(this.where).then(res => {
this.loading = false
this.productList = res.data
})
},
//设置where条件
setWhere: function() {
let that = this
if (that.price === 0) {
that.where.priceOrder = ''
} else if (that.price === 1) {
that.where.priceOrder = 'asc'
} else if (that.price === 2) {
that.where.priceOrder = 'desc'
setWhere() {
if (this.price === 0) {
this.where.priceOrder = ''
} else if (this.price === 1) {
this.where.priceOrder = 'asc'
} else if (this.price === 2) {
this.where.priceOrder = 'desc'
}
if (that.stock === 0) {
that.where.salesOrder = ''
} else if (that.stock === 1) {
that.where.salesOrder = 'asc'
} else if (that.stock === 2) {
that.where.salesOrder = 'desc'
if (this.stock === 0) {
this.where.salesOrder = ''
} else if (this.stock === 1) {
this.where.salesOrder = 'asc'
} else if (this.stock === 2) {
this.where.salesOrder = 'desc'
}
that.where.news = that.nows ? '1' : '0'
this.where.news = this.nows ? '1' : '0'
},
switchTap: function() {
let that = this
that.Switch = !that.Switch
switchTap() {
this.Switch = !this.Switch
},
},
}