首页上拉加载优化,云仓优化
This commit is contained in:
parent
90295d897a
commit
4f5351e190
@ -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
|
||||
|
@ -161,8 +161,7 @@
|
||||
})
|
||||
},
|
||||
go_shop() {
|
||||
|
||||
if (this.mer_id == 0) {
|
||||
if (this.isYunCang == 0) {
|
||||
return Toast('当前区域没有云仓库')
|
||||
}
|
||||
uni.navigateTo({
|
||||
|
116
utils/request.js
116
utils/request.js
@ -7,86 +7,80 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
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;
|
Loading…
x
Reference in New Issue
Block a user