From 4f5351e1902dbff44357a3f04d7f59d79d63012a Mon Sep 17 00:00:00 2001 From: cc_zbp <487602586@qq.com> Date: Fri, 2 Jun 2023 11:17:45 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E4=B8=8A=E6=8B=89=E5=8A=A0?= =?UTF-8?q?=E8=BD=BD=E4=BC=98=E5=8C=96=EF=BC=8C=E4=BA=91=E4=BB=93=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/index/index.vue | 5 +- pages/supply_chains/supply_chains.vue | 3 +- utils/request.js | 116 ++++++++++++-------------- 3 files changed, 60 insertions(+), 64 deletions(-) diff --git a/pages/index/index.vue b/pages/index/index.vue index 66c0017..d554ffc 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -77,7 +77,7 @@ where: { category_id: 0, page: 1, - limit: 30 + limit: 15 }, currentItemId: 69, // 默认获取 社区的数据 0 表示推荐 || 69 社区 keyword: '', @@ -88,6 +88,7 @@ } }, onPullDownRefresh() { + this.where.page = 1 this.getCateList() this.getGoods() this.selfLocation() @@ -196,7 +197,9 @@ }, ...data] }, tabsChange(item) { + this.cateGoods = [] this.where.category_id = item.category_id + this.where.page = 1 this.getGoods() this.street_id = item.id this.tabsData.tabsActive = item.index diff --git a/pages/supply_chains/supply_chains.vue b/pages/supply_chains/supply_chains.vue index 566b22c..6c7d535 100644 --- a/pages/supply_chains/supply_chains.vue +++ b/pages/supply_chains/supply_chains.vue @@ -161,8 +161,7 @@ }) }, go_shop() { - - if (this.mer_id == 0) { + if (this.isYunCang == 0) { return Toast('当前区域没有云仓库') } uni.navigateTo({ diff --git a/utils/request.js b/utils/request.js index 1d7651d..321ecfa 100644 --- a/utils/request.js +++ b/utils/request.js @@ -7,86 +7,80 @@ // +---------------------------------------------------------------------- // | Author: CRMEB Team // +---------------------------------------------------------------------- -import { - HTTP_REQUEST_URL, - HEADER, - TOKENNAME -} from '@/config/app'; -import { - checkLogin -} from '../libs/login'; +import { HTTP_REQUEST_URL, HEADER, TOKENNAME } from '@/config/app'; +import { checkLogin } from '../libs/login'; import store from '../store'; -function toLogin(){ - store.commit("LOGOUT"); - uni.showToast({ - title: '请登录', - icon: 'none', - duration: 1000 - }); +function toLogin() { + store.commit("LOGOUT"); + uni.showToast({ + title: '请登录', + icon: 'none', + duration: 1000 + }); } /** * 发送请求 */ function baseRequest(url, method, data, { - noAuth = false, - noVerify = false + noAuth = false, + noVerify = false }) { - let Url = HTTP_REQUEST_URL, - header = HEADER; + let Url = HTTP_REQUEST_URL, + header = HEADER; - if (!noAuth) { - //登录过期自动登录 - if (!store.state.app.token && !checkLogin()) { - toLogin(); - return Promise.reject({ - msg: '未登录' - }); - } - } + if (!noAuth) { + //登录过期自动登录 + if (!store.state.app.token && !checkLogin()) { + toLogin(); + return Promise.reject({ + msg: '未登录' + }); + } + } - if (store.state.app.token) header[TOKENNAME] = 'Bearer ' + store.state.app.token; + if (store.state.app.token) header[TOKENNAME] = 'Bearer ' + store.state.app.token; - return new Promise((reslove, reject) => { - uni.request({ - url: Url + '/api/' + url, - method: method || 'GET', - header: header, - data: data || {}, - success: (res) => { - // #ifdef APP-PLUS - console.log('app', Url + '/api/' + url, res.data); - // #endif - if (noVerify) - reslove(res.data, res); - else if (res.data.status == 200) - reslove(res.data, res); - else if ([410000, 410001, 410002, 40000].indexOf(res.data.status) !== -1) { - toLogin(); - reject(res.data); - } else if (res.data.status == 501) { - uni.reLaunch({ - url: '/pages/error/index' - }) - reject(res.data); - } else - reject(res.data.message || '系统错误'); - }, - fail: (message) => { - reject('请求失败'); - } - }) - }); + return new Promise((reslove, reject) => { + uni.request({ + url: Url + '/api/' + url, + method: method || 'GET', + header: header, + data: data || {}, + success: (res) => { + // #ifdef APP-PLUS + console.log('app', Url + '/api/' + url, res.data); + // #endif + if (noVerify) + reslove(res.data, res); + else if (res.data.status == 200) + reslove(res.data, res); + else if ([410000, 410001, 410002, 40000].indexOf(res.data.status) !== -1) { + toLogin(); + reject(res.data); + } else if (res.data.status == 501) { + uni.reLaunch({ + url: '/pages/error/index' + }) + reject(res.data); + } else + reject(res.data.message || '系统错误'); + }, + fail: (message) => { + reject('请求失败'); + } + }) + }); } const request = {}; ['options', 'get', 'post', 'put', 'head', 'delete', 'trace', 'connect'].forEach((method) => { - request[method] = (api, data, opt) => baseRequest(api, method, data, opt || {}) + request[method] = (api, data, opt) => baseRequest(api, method, data, opt || {}) }); -export default request; +export default request; \ No newline at end of file