已支付订单列表:where.payStatus = 1;
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
"use strict";
|
||||
const uni_modules_wsCommon_utils_request = require("../../utils/request.js");
|
||||
const config_setting = require("../../../../config/setting.js");
|
||||
async function getUserInfo() {
|
||||
const res = await uni_modules_wsCommon_utils_request.http.get(config_setting.SERVER_API_URL + "/auth/user");
|
||||
if (res.data.code === 0 && res.data.data) {
|
||||
return res.data.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
exports.getUserInfo = getUserInfo;
|
||||
@@ -0,0 +1,42 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../../../common/vendor.js");
|
||||
const api_layout_index = require("../../../../api/layout/index.js");
|
||||
const useUserStore = common_vendor.defineStore({
|
||||
id: "user",
|
||||
state: () => ({
|
||||
// 当前登录用户的信息
|
||||
info: null,
|
||||
// 当前登录用户的菜单
|
||||
menus: null,
|
||||
// 当前登录用户的权限
|
||||
authorities: [],
|
||||
// 当前登录用户的角色
|
||||
roles: []
|
||||
}),
|
||||
getters: {},
|
||||
actions: {
|
||||
/**
|
||||
* 请求用户信息、权限、角色、菜单
|
||||
*/
|
||||
async fetchUserInfo() {
|
||||
var _a, _b, _c;
|
||||
const result = await api_layout_index.getUserInfo().catch(() => {
|
||||
});
|
||||
if (!result) {
|
||||
return {};
|
||||
}
|
||||
this.info = result;
|
||||
this.authorities = ((_b = (_a = result.authorities) == null ? void 0 : _a.filter((d) => !!d.authority)) == null ? void 0 : _b.map((d) => d.authority)) ?? [];
|
||||
this.roles = ((_c = result.roles) == null ? void 0 : _c.map((d) => d.roleCode)) ?? [];
|
||||
this.menus = [];
|
||||
return result;
|
||||
},
|
||||
/**
|
||||
* 更新用户信息
|
||||
*/
|
||||
setInfo(value) {
|
||||
this.info = value;
|
||||
}
|
||||
}
|
||||
});
|
||||
exports.useUserStore = useUserStore;
|
||||
@@ -0,0 +1,36 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../../common/vendor.js");
|
||||
const config_setting = require("../../../config/setting.js");
|
||||
const http = new common_vendor.Request();
|
||||
http.setConfig((config) => {
|
||||
config.baseURL = config_setting.API_BASE_URL;
|
||||
return config;
|
||||
});
|
||||
http.interceptors.request.use((config) => {
|
||||
const token = common_vendor.index.getStorageSync("access_token");
|
||||
console.log("token: ", token);
|
||||
config.header = {
|
||||
...config.header,
|
||||
tenantId: config_setting.TENANT_ID
|
||||
};
|
||||
if (token) {
|
||||
config.header.Authorization = token;
|
||||
}
|
||||
if (config.data) {
|
||||
config.data.tenantId = config_setting.TENANT_ID;
|
||||
}
|
||||
return config;
|
||||
}, (config) => {
|
||||
return Promise.reject(config);
|
||||
});
|
||||
http.interceptors.response.use((response) => {
|
||||
if (response.data.code == 401) ;
|
||||
if (response.data.code == 1) {
|
||||
return Promise.reject(response.data);
|
||||
}
|
||||
return response;
|
||||
}, (response) => {
|
||||
console.log(response);
|
||||
return Promise.reject(response);
|
||||
});
|
||||
exports.http = http;
|
||||
Reference in New Issue
Block a user