diff --git a/utils/request.js b/utils/request.js index 65393ae..60e6767 100644 --- a/utils/request.js +++ b/utils/request.js @@ -53,12 +53,19 @@ function cleanStorage() { let http = new Request(); -http.setConfig((config) => { - // 没有uuid创建 +/** + * 创建uuid方法 + */ +const createUuid = () => { if (!storage.getUuid()) { storage.setUuid(uuid.v1()); + console.log("uuid", storage.getUuid()); } +} + +http.setConfig((config) => { + createUuid(); /* 设置全局配置 */ config.baseURL = api.buyer; config.header = { @@ -105,9 +112,10 @@ http.interceptors.request.use( } + createUuid(); config.header = { ...config.header, - uuid: storage.getUuid() || uuid.v1(), + uuid: storage.getUuid() }; return config; },