首页上拉加载优化,云仓优化

This commit is contained in:
cc_zbp 2023-06-02 11:17:45 +08:00
parent 90295d897a
commit 4f5351e190
3 changed files with 60 additions and 64 deletions

View File

@ -77,7 +77,7 @@
where: { where: {
category_id: 0, category_id: 0,
page: 1, page: 1,
limit: 30 limit: 15
}, },
currentItemId: 69, // 0 || 69 currentItemId: 69, // 0 || 69
keyword: '', keyword: '',
@ -88,6 +88,7 @@
} }
}, },
onPullDownRefresh() { onPullDownRefresh() {
this.where.page = 1
this.getCateList() this.getCateList()
this.getGoods() this.getGoods()
this.selfLocation() this.selfLocation()
@ -196,7 +197,9 @@
}, ...data] }, ...data]
}, },
tabsChange(item) { tabsChange(item) {
this.cateGoods = []
this.where.category_id = item.category_id this.where.category_id = item.category_id
this.where.page = 1
this.getGoods() this.getGoods()
this.street_id = item.id this.street_id = item.id
this.tabsData.tabsActive = item.index this.tabsData.tabsActive = item.index

View File

@ -161,8 +161,7 @@
}) })
}, },
go_shop() { go_shop() {
if (this.isYunCang == 0) {
if (this.mer_id == 0) {
return Toast('当前区域没有云仓库') return Toast('当前区域没有云仓库')
} }
uni.navigateTo({ uni.navigateTo({

View File

@ -7,84 +7,78 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com> // | Author: CRMEB Team <admin@crmeb.com>
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
import { import { HTTP_REQUEST_URL, HEADER, TOKENNAME } from '@/config/app';
HTTP_REQUEST_URL, import { checkLogin } from '../libs/login';
HEADER,
TOKENNAME
} from '@/config/app';
import {
checkLogin
} from '../libs/login';
import store from '../store'; import store from '../store';
function toLogin(){ function toLogin() {
store.commit("LOGOUT"); store.commit("LOGOUT");
uni.showToast({ uni.showToast({
title: '请登录', title: '请登录',
icon: 'none', icon: 'none',
duration: 1000 duration: 1000
}); });
} }
/** /**
* 发送请求 * 发送请求
*/ */
function baseRequest(url, method, data, { function baseRequest(url, method, data, {
noAuth = false, noAuth = false,
noVerify = false noVerify = false
}) { }) {
let Url = HTTP_REQUEST_URL, let Url = HTTP_REQUEST_URL,
header = HEADER; header = HEADER;
if (!noAuth) { if (!noAuth) {
//登录过期自动登录 //登录过期自动登录
if (!store.state.app.token && !checkLogin()) { if (!store.state.app.token && !checkLogin()) {
toLogin(); toLogin();
return Promise.reject({ return Promise.reject({
msg: '未登录' 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) => { return new Promise((reslove, reject) => {
uni.request({ uni.request({
url: Url + '/api/' + url, url: Url + '/api/' + url,
method: method || 'GET', method: method || 'GET',
header: header, header: header,
data: data || {}, data: data || {},
success: (res) => { success: (res) => {
// #ifdef APP-PLUS // #ifdef APP-PLUS
console.log('app', Url + '/api/' + url, res.data); console.log('app', Url + '/api/' + url, res.data);
// #endif // #endif
if (noVerify) if (noVerify)
reslove(res.data, res); reslove(res.data, res);
else if (res.data.status == 200) else if (res.data.status == 200)
reslove(res.data, res); reslove(res.data, res);
else if ([410000, 410001, 410002, 40000].indexOf(res.data.status) !== -1) { else if ([410000, 410001, 410002, 40000].indexOf(res.data.status) !== -1) {
toLogin(); toLogin();
reject(res.data); reject(res.data);
} else if (res.data.status == 501) { } else if (res.data.status == 501) {
uni.reLaunch({ uni.reLaunch({
url: '/pages/error/index' url: '/pages/error/index'
}) })
reject(res.data); reject(res.data);
} else } else
reject(res.data.message || '系统错误'); reject(res.data.message || '系统错误');
}, },
fail: (message) => { fail: (message) => {
reject('请求失败'); reject('请求失败');
} }
}) })
}); });
} }
const request = {}; const request = {};
['options', 'get', 'post', 'put', 'head', 'delete', 'trace', 'connect'].forEach((method) => { ['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 || {})
}); });