From b269a9dd8886bb91dde334a67c5bd83b0732ea10 Mon Sep 17 00:00:00 2001
From: weipengfei <2187978347@qq.com>
Date: Wed, 27 Mar 2024 09:44:47 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
api/store.js | 1 -
pages/index/index.vue | 56 +++++++++++++++++++++++++------------------
utils/request.js | 1 -
3 files changed, 33 insertions(+), 25 deletions(-)
diff --git a/api/store.js b/api/store.js
index 9f1c63d..a6cf661 100644
--- a/api/store.js
+++ b/api/store.js
@@ -141,7 +141,6 @@ export function getBrandlist(data) {
*
*/
export function getProductHot(page, limit, sale_type, enLoad=false) {
- console.log(enLoad);
return request.get("product/spu/recommend", {
page: page === undefined ? 1 : page,
limit: limit === undefined ? 10 : limit,
diff --git a/pages/index/index.vue b/pages/index/index.vue
index 10e7352..c45103d 100644
--- a/pages/index/index.vue
+++ b/pages/index/index.vue
@@ -88,12 +88,12 @@
-
-
+ v-if="hostProduct[hostIndex].length > 0 || hotLoading[hostIndex]">
+
{{ hotTitle }}
@@ -169,7 +169,7 @@
暂无商品,去看点什么吧
-
+
@@ -461,11 +461,12 @@
limit: 6
},
is_switch: true,
- hostProduct: [],
+ hostProduct: [[],[],[],[]],
+ hostIndex: 0,
hotPage: 1,
hotLimit: 30,
hotScroll: true,
- hotLoading: false,
+ hotLoading: [false, false, false, false],
hotTitle: '加载更多',
// #ifdef MP || APP-PLUS
isFixed: false,
@@ -1012,65 +1013,74 @@
changeRecommedTab(e) {
this.hotPage = 1;
this.hotScroll = true;
- this.$set(this, 'hostProduct', []);
+ this.hostIndex = e-1;
+ let hostList = this.hostProduct;
+ hostList[e-1] = [];
+ this.$set(this, 'hostProduct', hostList);
this.loadGoods(e);
},
loadGoods(e = 1) {
- if (e == 1) return this.get_host_product(true);
+ if (e == 1) return this.get_host_product(0);
if (e == 2) return this.get_host_home({
mer_type: 1
- }, true);
+ }, 1);
if (e == 3) return this.get_host_home({
mer_type: 2
- }, true);
+ }, 2);
if (e == 4) return this.get_host_home({
mer_type: 3
- }, true);
+ }, 3);
},
/**
* 获取我的推荐
*/
- get_host_product: function(reload=false) {
+ get_host_product: function(e=0) {
let that = this;
let num = that.hotLimit;
if (!that.hotScroll) return;
- if (that.hotLoading) return;
- that.hotLoading = true;
+ if (that.hotLoading[e]) return;
+ that.hotLoading[e] = true;
that.hotTitle = '加载中';
- getProductHot(that.hotPage, that.hotLimit, 1, true).then(res => {
+ getProductHot(that.hotPage, that.hotLimit, 1).then(res => {
let list = res.data.list;
- let productList = that.$util.SplitArray(list, that.hostProduct);
+ let productList = that.hostProduct;
+ if(!productList[e]) productList[e] = [];
+ productList[e] = [...productList[e], ...res.data.list];
let hotScroll = list.length <= num && list.length != 0;
that.hotScroll = hotScroll;
- that.hotLoading = false;
+ that.hotLoading[e] = false;
that.hotTitle = !hotScroll ? '已全部加载' : '加载更多';
that.$set(that, 'hostProduct', productList);
+ if(this.hostIndex==e) this.$forceUpdate();
that.$set(that, 'hotPage', that.hotPage + 1);
});
},
/**
* 获取里海云仓, 云市场, 名优特产
*/
- get_host_home: function(query = {}, reload) {
+ get_host_home: function(query = {}, e=1) {
let that = this;
let num = that.hotLimit;
if (!that.hotScroll) return;
- if (that.hotLoading) return;
- that.hotLoading = true;
+ if (that.hotLoading[e]) return;
+ that.hotLoading[e] = true;
that.hotTitle = '加载中';
query.page = that.hotPage;
query.limit = that.hotLimit;
query.sale_type = 1;
getProductslist({
...query
- }, true).then(res => {
+ }).then(res => {
let list = res.data.list;
- let productList = that.$util.SplitArray(list, that.hostProduct);
+ let productList = that.hostProduct;
+ if(!productList[e]) productList[e] = [];
+ productList[e] = [...productList[e], ...list];
let hotScroll = list.length <= num && list.length != 0;
that.hotScroll = hotScroll;
- that.hotLoading = false;
+ that.hotLoading[e] = false;
that.hotTitle = !hotScroll ? '已全部加载' : '加载更多';
that.$set(that, 'hostProduct', productList);
+ if(this.hostIndex==e) this.$forceUpdate();
that.$set(that, 'hotPage', that.hotPage + 1);
});
},
diff --git a/utils/request.js b/utils/request.js
index 4239f95..653b4f1 100644
--- a/utils/request.js
+++ b/utils/request.js
@@ -81,7 +81,6 @@ function baseRequest(url, method, data, {
}
}
let URL = Url + '/api/' + url
- console.log(enLoad, HTTP_list);
if(enLoad) {
let http = HTTP_list.get(URL);
if(http){