From 5c9b02ed3bda479c09aea16a89a84ffb6cb73094 Mon Sep 17 00:00:00 2001 From: weipengfei <2187978347@qq.com> Date: Tue, 26 Mar 2024 14:28:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.vue | 10 +++---- api/store.js | 11 +++++--- manifest.json | 4 +-- pages/cloud_warehouse/home/home.vue | 2 +- pages/cloud_warehouse/market/market.vue | 4 +-- pages/cloud_warehouse/specialty/specialty.vue | 2 +- pages/columnGoods/goods_search/index.vue | 9 ++++++- pages/index/index.vue | 16 ++++++------ pages/whole_sale/index.vue | 3 ++- utils/request.js | 26 +++++++++++++++---- 10 files changed, 57 insertions(+), 30 deletions(-) diff --git a/App.vue b/App.vue index 5cda3dd..91e8433 100644 --- a/App.vue +++ b/App.vue @@ -77,10 +77,10 @@ visible: false }) // #ifdef H5 - // uni.setTabBarItem({ - // index: 2, - // visible: false - // }) + uni.setTabBarItem({ + index: 2, + visible: false + }) // #endif this.globalData.statusBarHeight = uni.getSystemInfoSync().statusBarHeight + 'px'; @@ -401,7 +401,7 @@ @import 'static/css/base.css'; @import 'static/iconfont/iconfont.css'; @import 'static/css/style.scss'; - + .bg-color-red { background-color: #e93323 !important; } diff --git a/api/store.js b/api/store.js index 203c180..9f1c63d 100644 --- a/api/store.js +++ b/api/store.js @@ -100,7 +100,7 @@ export function getCategoryIndexList() { * 获取产品列表 * @param object data */ -export function getProductslist(data) { +export function getProductslist(data, enLoad=false) { if (data.brand_id && Array.isArray(data.brand_id)) { data = { ...data @@ -108,7 +108,8 @@ export function getProductslist(data) { data.brand_id = data.brand_id.toString() } return request.get('product/spu/lst', data, { - noAuth: true + noAuth: true, + enLoad: enLoad }); } /** @@ -139,13 +140,15 @@ export function getBrandlist(data) { * 获取推荐产品 * */ -export function getProductHot(page, limit, sale_type) { +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, sale_type: sale_type || null }, { - noAuth: true + noAuth: true, + enLoad: enLoad }); } /** diff --git a/manifest.json b/manifest.json index 549b3f3..d0cc3d5 100644 --- a/manifest.json +++ b/manifest.json @@ -2,8 +2,8 @@ "name" : "惠农生活", "appid" : "__UNI__3A527D1", "description" : "", - "versionName" : "2.0.10", - "versionCode" : 2010, + "versionName" : "2.0.11", + "versionCode" : 2011, "transformPx" : false, /* 5+App特有相关 */ "app-plus" : { diff --git a/pages/cloud_warehouse/home/home.vue b/pages/cloud_warehouse/home/home.vue index 1041ab3..eeb8460 100644 --- a/pages/cloud_warehouse/home/home.vue +++ b/pages/cloud_warehouse/home/home.vue @@ -219,7 +219,7 @@ class="search_content flex_a_c_j_sb"> - diff --git a/pages/cloud_warehouse/market/market.vue b/pages/cloud_warehouse/market/market.vue index 06d5c88..6cd2085 100644 --- a/pages/cloud_warehouse/market/market.vue +++ b/pages/cloud_warehouse/market/market.vue @@ -315,11 +315,11 @@ - - diff --git a/pages/cloud_warehouse/specialty/specialty.vue b/pages/cloud_warehouse/specialty/specialty.vue index cb0ff5d..f4801ae 100644 --- a/pages/cloud_warehouse/specialty/specialty.vue +++ b/pages/cloud_warehouse/specialty/specialty.vue @@ -219,7 +219,7 @@ class="search_content flex_a_c_j_sb"> - diff --git a/pages/columnGoods/goods_search/index.vue b/pages/columnGoods/goods_search/index.vue index 0c345d5..50564fd 100644 --- a/pages/columnGoods/goods_search/index.vue +++ b/pages/columnGoods/goods_search/index.vue @@ -4,7 +4,7 @@ - 搜索 @@ -172,11 +172,18 @@ mainWidth: 960, isShow: true, back: false, + isShop: false, }; }, onLoad(options) { this.searchValue = options.searchVal || '' this.back = options.back; + this.isShop = options.shop || false; + if(options.shop=='true'){ + uni.setNavigationBarTitle({ + title: '搜索店铺' + }) + } }, onShow: function() { try { diff --git a/pages/index/index.vue b/pages/index/index.vue index aaea4bd..10e7352 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -1016,28 +1016,28 @@ this.loadGoods(e); }, loadGoods(e = 1) { - if (e == 1) return this.get_host_product(); + if (e == 1) return this.get_host_product(true); if (e == 2) return this.get_host_home({ mer_type: 1 - }); + }, true); if (e == 3) return this.get_host_home({ mer_type: 2 - }); + }, true); if (e == 4) return this.get_host_home({ mer_type: 3 - }); + }, true); }, /** * 获取我的推荐 */ - get_host_product: function() { + get_host_product: function(reload=false) { let that = this; let num = that.hotLimit; if (!that.hotScroll) return; if (that.hotLoading) return; that.hotLoading = true; that.hotTitle = '加载中'; - getProductHot(that.hotPage, that.hotLimit, 1).then(res => { + getProductHot(that.hotPage, that.hotLimit, 1, true).then(res => { let list = res.data.list; let productList = that.$util.SplitArray(list, that.hostProduct); let hotScroll = list.length <= num && list.length != 0; @@ -1051,7 +1051,7 @@ /** * 获取里海云仓, 云市场, 名优特产 */ - get_host_home: function(query = {}) { + get_host_home: function(query = {}, reload) { let that = this; let num = that.hotLimit; if (!that.hotScroll) return; @@ -1063,7 +1063,7 @@ query.sale_type = 1; getProductslist({ ...query - }).then(res => { + }, true).then(res => { let list = res.data.list; let productList = that.$util.SplitArray(list, that.hostProduct); let hotScroll = list.length <= num && list.length != 0; diff --git a/pages/whole_sale/index.vue b/pages/whole_sale/index.vue index b0d624a..f968225 100644 --- a/pages/whole_sale/index.vue +++ b/pages/whole_sale/index.vue @@ -482,7 +482,8 @@ } if (this.isLoading == -1) return; this.isLoading = 1; - getProductslist(this.where).then(res => { + getProductslist(this.where, true).then(res => { + if (reLoad) this.hostProduct = []; this.hostProduct = [...this.hostProduct, ...res.data.list]; this.isLoading = 0; if (res.data.list.length < this.where.limit) this.isLoading = -1; diff --git a/utils/request.js b/utils/request.js index 371b919..ec1cd8f 100644 --- a/utils/request.js +++ b/utils/request.js @@ -58,12 +58,16 @@ function atob(input) { return output; } + +var HTTP_list = new Map(); + /** * 发送请求 */ function baseRequest(url, method, data, { noAuth = false, - noVerify = false + noVerify = false, + enLoad = false //终止上一个接口相同类型正在请求的接口, 防止快速切换tab时页面抖动 }) { let Url = HTTP_REQUEST_URL, header = HEADER; @@ -76,11 +80,19 @@ 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){ + http.abort(); + } + } if (store.state.app.token) header[TOKENNAME] = 'Bearer ' + store.state.app.token; - if(store.state.app.uuid)header['uuid'] = store.state.app.uuid + if(store.state.app.uuid) header['uuid'] = store.state.app.uuid return new Promise((reslove, reject) => { - uni.request({ - url: Url + '/api/' + url, + let http = uni.request({ + url: URL, method: method || 'GET', header: header, data: data || {}, @@ -110,8 +122,12 @@ function baseRequest(url, method, data, { }, fail: (message) => { reject('请求失败'); - } + }, + complete: () => { + // if(enLoad) HTTP_list.delete(URL); + } }) + if(enLoad) HTTP_list.set(URL, http); }); } const request = {};