增加数据缓存,去除部分请求的重复/

This commit is contained in:
2024-12-30 16:31:01 +08:00
parent cbcd1c857c
commit 6fb98974d6
15 changed files with 697 additions and 320 deletions

View File

@@ -1,6 +1,8 @@
import configdata from './config'
import cache from './cache'
import {
cacheClearAll
} from '@/store/cashe.js'
module.exports = {
config: function(name) {
var info = null;
@@ -22,6 +24,7 @@ module.exports = {
}
}
}
console.log(info);
return info;
},
logout: function() {
@@ -47,17 +50,20 @@ module.exports = {
uni.removeStorageSync("isInvitation")
uni.removeStorageSync("zhiFuBao")
uni.removeStorageSync("zhiFuBaoName")
cacheClearAll()
uni.showToast({
title: '用户信息失效,请重新登录!',
icon: 'none'
})
uni.navigateTo({ url: "/pages/login/login" })
uni.navigateTo({
url: "/pages/login/login"
})
},
post: function(url, data, header) {
let that = this;
header = header || "application/x-www-form-urlencoded";
url = that.config("APIHOST") + url;
url = that.config("APIHOST") + url.replace(/^\//, "");
return new Promise((succ, error) => {
uni.request({
url: url,
@@ -81,7 +87,7 @@ module.exports = {
postT: function(url, data, header) {
let that = this;
header = header || "application/x-www-form-urlencoded";
url = that.config("APIHOST1") + url;
url = that.config("APIHOST1") + url.replace(/^\//, "");
// let token = uni.getStorageSync("token");
let token = uni.getStorageSync("token");
if (token) {
@@ -130,7 +136,7 @@ module.exports = {
postJson: function(url, data, header) {
let that = this;
header = header || "application/json";
url = that.config("APIHOST1") + url;
url = that.config("APIHOST1") + url.replace(/^\//, "");
// let token = uni.getStorageSync("token");
let token = uni.getStorageSync("token");
if (token) {
@@ -179,7 +185,8 @@ module.exports = {
getT: function(url, data, header) {
let that = this;
header = header || "application/x-www-form-urlencoded";
url = that.config("APIHOST1") + url;
url = that.config("APIHOST1") + url.replace(/^\//, "");
console.log(url);
// let token = uni.getStorageSync("token");
let token = uni.getStorageSync("token");
if (token) {
@@ -299,7 +306,8 @@ module.exports = {
get: function(url, data, header) {
let that = this;
header = header || "application/x-www-form-urlencoded";
url = that.config("APIHOST") + url;
url = that.config("APIHOST") + url.replace(/^\//, "");
console.log(url);
return new Promise((succ, error) => {
uni.request({
url: url,
@@ -346,7 +354,7 @@ module.exports = {
get1: function(url, data, header) {
let that = this;
header = header || "application/json";
url = that.config("APIHOST") + url;
url = that.config("APIHOST") + url.replace(/^\//, "");
return new Promise((succ, error) => {
uni.request({
url: url,