解决小程序上传时出现的问题。
This commit is contained in:
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
102
unpackage/dist/dev/mp-weixin/common/appInit.js
vendored
102
unpackage/dist/dev/mp-weixin/common/appInit.js
vendored
@@ -2,22 +2,6 @@
|
||||
const common_vendor = require("./vendor.js");
|
||||
const uniStarter_config = require("../uni-starter.config.js");
|
||||
const db = common_vendor.tr.database();
|
||||
function redirectToLogin() {
|
||||
const loginPage = "/uni_modules/uni-id-pages/pages/login/login-withpwd";
|
||||
const pages = getCurrentPages();
|
||||
if (pages.length > 0) {
|
||||
const currentPage = pages[pages.length - 1];
|
||||
if (currentPage.route && currentPage.route.includes("login")) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
common_vendor.index.reLaunch({
|
||||
url: loginPage,
|
||||
fail: (err) => {
|
||||
common_vendor.index.__f__("error", "at common/appInit.js:32", "跳转登录页失败:", err);
|
||||
}
|
||||
});
|
||||
}
|
||||
function isLoginApi(url) {
|
||||
if (!url)
|
||||
return false;
|
||||
@@ -27,26 +11,28 @@ function setupRequestInterceptor() {
|
||||
const originalRequest = common_vendor.index.request;
|
||||
common_vendor.index.request = function(options = {}) {
|
||||
const { url, header = {}, method = "GET", ...restOptions } = options;
|
||||
common_vendor.index.__f__("log", "at common/appInit.js:59", "[Request Interceptor] 开始拦截请求:", {
|
||||
url,
|
||||
method: method.toUpperCase(),
|
||||
isLoginApi: isLoginApi(url),
|
||||
originalOptions: options
|
||||
});
|
||||
let tenantId = "";
|
||||
try {
|
||||
tenantId = common_vendor.index.getStorageSync("backend-tenant-id") || "";
|
||||
} catch (e) {
|
||||
common_vendor.index.__f__("error", "at common/appInit.js:63", "获取 tenantId 失败:", e);
|
||||
common_vendor.index.__f__("error", "at common/appInit.js:71", "[Request Interceptor] 获取 tenantId 失败:", e);
|
||||
}
|
||||
common_vendor.index.__f__("log", "at common/appInit.js:74", "[Request Interceptor] tenantId状态:", {
|
||||
tenantId,
|
||||
hasTenantId: !!tenantId
|
||||
});
|
||||
if (!isLoginApi(url) && !tenantId) {
|
||||
const pages = getCurrentPages();
|
||||
const hasLoadedPages = pages.length > 0 && pages[pages.length - 1].route;
|
||||
if (hasLoadedPages) {
|
||||
const currentPage = pages[pages.length - 1];
|
||||
const currentRoute = "/" + currentPage.route;
|
||||
const isHomePage = currentRoute.includes("/pages/furniture_reception/furniture_reception");
|
||||
const isLoginRelated = currentRoute.includes("/uni_modules/uni-id-pages/pages/login") || currentRoute.includes("/uni_modules/uni-id-pages/pages/register") || currentRoute.includes("/uni_modules/uni-id-pages/pages/retrieve");
|
||||
if (!isHomePage && !isLoginRelated) {
|
||||
common_vendor.index.__f__("warn", "at common/appInit.js:85", "[Request Interceptor] 租户ID为空,跳转到登录页面");
|
||||
redirectToLogin();
|
||||
return Promise.reject(new Error("未登录,请先登录"));
|
||||
}
|
||||
}
|
||||
common_vendor.index.__f__("warn", "at common/appInit.js:83", "[Request Interceptor] 租户ID为空,但允许请求继续执行,由后端处理认证");
|
||||
} else if (isLoginApi(url)) {
|
||||
common_vendor.index.__f__("log", "at common/appInit.js:86", "[Request Interceptor] 这是登录接口,跳过租户ID检查");
|
||||
} else {
|
||||
common_vendor.index.__f__("log", "at common/appInit.js:88", "[Request Interceptor] 租户ID存在,正常处理请求");
|
||||
}
|
||||
const newHeader = {
|
||||
"Content-Type": "application/json",
|
||||
@@ -64,7 +50,7 @@ function setupRequestInterceptor() {
|
||||
delete newHeader["Authorization"];
|
||||
}
|
||||
} catch (e) {
|
||||
common_vendor.index.__f__("error", "at common/appInit.js:118", "获取 token 失败:", e);
|
||||
common_vendor.index.__f__("error", "at common/appInit.js:115", "获取 token 失败:", e);
|
||||
}
|
||||
}
|
||||
try {
|
||||
@@ -77,25 +63,42 @@ function setupRequestInterceptor() {
|
||||
newHeader["X-Scenario"] = scenario;
|
||||
}
|
||||
} catch (e) {
|
||||
common_vendor.index.__f__("error", "at common/appInit.js:133", "获取 roleName 或 scenario 失败:", e);
|
||||
common_vendor.index.__f__("error", "at common/appInit.js:130", "获取 roleName 或 scenario 失败:", e);
|
||||
}
|
||||
const finalRequestOptions = {
|
||||
...restOptions,
|
||||
url,
|
||||
method,
|
||||
header: newHeader
|
||||
};
|
||||
common_vendor.index.__f__("log", "at common/appInit.js:141", "[Request Interceptor] 准备发送请求:", {
|
||||
url,
|
||||
method: method.toUpperCase(),
|
||||
headers: newHeader,
|
||||
hasData: !!restOptions.data
|
||||
});
|
||||
return new Promise((resolve, reject) => {
|
||||
common_vendor.index.__f__("log", "at common/appInit.js:151", "[Request Interceptor] 开始调用原始 uni.request");
|
||||
originalRequest.call(common_vendor.index, {
|
||||
...restOptions,
|
||||
url,
|
||||
method,
|
||||
header: newHeader,
|
||||
...finalRequestOptions,
|
||||
success: (res) => {
|
||||
common_vendor.index.__f__("log", "at common/appInit.js:155", "[Request Interceptor] 请求成功:", {
|
||||
url,
|
||||
method: method.toUpperCase(),
|
||||
statusCode: res.statusCode,
|
||||
hasData: !!res.data
|
||||
});
|
||||
if (options.success) {
|
||||
options.success(res);
|
||||
}
|
||||
resolve(res);
|
||||
},
|
||||
fail: (err) => {
|
||||
common_vendor.index.__f__("error", "at common/appInit.js:153", "[Request Interceptor] 请求失败:", {
|
||||
common_vendor.index.__f__("error", "at common/appInit.js:170", "[Request Interceptor] 请求失败:", {
|
||||
url,
|
||||
method: method.toUpperCase(),
|
||||
error: err
|
||||
error: err,
|
||||
errorMessage: err.errMsg || "未知错误"
|
||||
});
|
||||
if (options.fail) {
|
||||
options.fail(err);
|
||||
@@ -103,6 +106,11 @@ function setupRequestInterceptor() {
|
||||
reject(err);
|
||||
},
|
||||
complete: (res) => {
|
||||
common_vendor.index.__f__("log", "at common/appInit.js:184", "[Request Interceptor] 请求完成:", {
|
||||
url,
|
||||
method: method.toUpperCase(),
|
||||
hasResponse: !!res
|
||||
});
|
||||
if (options.complete) {
|
||||
options.complete(res);
|
||||
}
|
||||
@@ -123,7 +131,7 @@ async function initApp() {
|
||||
app.globalData.config = uniStarter_config.config;
|
||||
}
|
||||
} catch (e) {
|
||||
common_vendor.index.__f__("warn", "at common/appInit.js:194", "[appInit] 挂载配置失败:", e);
|
||||
common_vendor.index.__f__("warn", "at common/appInit.js:217", "[appInit] 挂载配置失败:", e);
|
||||
}
|
||||
}, 1);
|
||||
function onDBError({
|
||||
@@ -131,11 +139,11 @@ async function initApp() {
|
||||
// 错误码详见https://uniapp.dcloud.net.cn/uniCloud/clientdb?id=returnvalue
|
||||
message
|
||||
}) {
|
||||
common_vendor.index.__f__("log", "at common/appInit.js:207", "onDBError", {
|
||||
common_vendor.index.__f__("log", "at common/appInit.js:230", "onDBError", {
|
||||
code,
|
||||
message
|
||||
});
|
||||
common_vendor.index.__f__("error", "at common/appInit.js:212", code, message);
|
||||
common_vendor.index.__f__("error", "at common/appInit.js:235", code, message);
|
||||
}
|
||||
db.on("error", onDBError);
|
||||
common_vendor.tr.interceptObject({
|
||||
@@ -148,21 +156,21 @@ async function initApp() {
|
||||
// 参数列表
|
||||
}) {
|
||||
if (objectName == "uni-id-co" && (methodName.includes("loginBy") || ["login", "registerUser"].includes(methodName))) {
|
||||
common_vendor.index.__f__("log", "at common/appInit.js:231", "执行登录相关云对象");
|
||||
common_vendor.index.__f__("log", "at common/appInit.js:254", "执行登录相关云对象");
|
||||
params[0].inviteCode = await new Promise((callBack) => {
|
||||
common_vendor.index.getClipboardData({
|
||||
success: function(res) {
|
||||
common_vendor.index.__f__("log", "at common/appInit.js:235", "剪切板内容:" + res.data);
|
||||
common_vendor.index.__f__("log", "at common/appInit.js:258", "剪切板内容:" + res.data);
|
||||
if (res.data.slice(0, 18) == "uniInvitationCode:") {
|
||||
let uniInvitationCode = res.data.slice(18, 38);
|
||||
common_vendor.index.__f__("log", "at common/appInit.js:238", "当前用户是其他用户推荐下载的,推荐者的code是:" + uniInvitationCode);
|
||||
common_vendor.index.__f__("log", "at common/appInit.js:261", "当前用户是其他用户推荐下载的,推荐者的code是:" + uniInvitationCode);
|
||||
callBack(uniInvitationCode);
|
||||
} else {
|
||||
callBack();
|
||||
}
|
||||
},
|
||||
fail() {
|
||||
common_vendor.index.__f__("log", "at common/appInit.js:250", "error--");
|
||||
common_vendor.index.__f__("log", "at common/appInit.js:273", "error--");
|
||||
callBack();
|
||||
},
|
||||
complete() {
|
||||
@@ -173,12 +181,12 @@ async function initApp() {
|
||||
}
|
||||
},
|
||||
success(e) {
|
||||
common_vendor.index.__f__("log", "at common/appInit.js:265", e);
|
||||
common_vendor.index.__f__("log", "at common/appInit.js:288", e);
|
||||
},
|
||||
complete() {
|
||||
},
|
||||
fail(e) {
|
||||
common_vendor.index.__f__("error", "at common/appInit.js:271", e);
|
||||
common_vendor.index.__f__("error", "at common/appInit.js:294", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
40
unpackage/dist/dev/mp-weixin/common/request.js
vendored
40
unpackage/dist/dev/mp-weixin/common/request.js
vendored
@@ -67,7 +67,16 @@ function request(options = {}) {
|
||||
} = options;
|
||||
const fullUrl = url.startsWith("http") ? url : common_config.getApiUrl(url);
|
||||
const apiEnv = typeof common_config.getApiEnv === "function" ? common_config.getApiEnv() : "";
|
||||
common_vendor.index.__f__("log", "at common/request.js:118", `H5环境(${apiEnv})直接使用完整URL: ${fullUrl}`);
|
||||
common_vendor.index.__f__("log", "at common/request.js:117", "[Request] 开始处理请求:", {
|
||||
originalUrl: url,
|
||||
fullUrl,
|
||||
method: method.toUpperCase(),
|
||||
isLoginApi: isLoginApi(fullUrl),
|
||||
apiEnv,
|
||||
needTenantId,
|
||||
needToken
|
||||
});
|
||||
common_vendor.index.__f__("log", "at common/request.js:129", `[Request] 完整请求URL: ${fullUrl}`);
|
||||
const requestHeader = {
|
||||
"Content-Type": "application/json",
|
||||
...header
|
||||
@@ -92,7 +101,7 @@ function request(options = {}) {
|
||||
if (needTenantId) {
|
||||
const tenantId = getTenantId();
|
||||
if (!isLoginApi(fullUrl) && !tenantId) {
|
||||
common_vendor.index.__f__("warn", "at common/request.js:159", "[Request] 租户ID为空,跳转到登录页面");
|
||||
common_vendor.index.__f__("warn", "at common/request.js:170", "[Request] 租户ID为空,跳转到登录页面");
|
||||
redirectToLogin();
|
||||
return Promise.reject(new Error("未登录,请先登录"));
|
||||
}
|
||||
@@ -100,7 +109,15 @@ function request(options = {}) {
|
||||
requestHeader["X-Tenant-Id"] = tenantId;
|
||||
}
|
||||
}
|
||||
common_vendor.index.__f__("log", "at common/request.js:183", "[Request] 准备发起 uni.request:", {
|
||||
url: fullUrl,
|
||||
method: method.toUpperCase(),
|
||||
hasData: !!requestData,
|
||||
hasHeaders: !!requestHeader,
|
||||
timeout
|
||||
});
|
||||
return new Promise((resolve, reject) => {
|
||||
common_vendor.index.__f__("log", "at common/request.js:192", "[Request] 调用 uni.request 开始执行");
|
||||
common_vendor.index.request({
|
||||
url: fullUrl,
|
||||
method: method.toUpperCase(),
|
||||
@@ -109,13 +126,28 @@ function request(options = {}) {
|
||||
timeout,
|
||||
...restOptions,
|
||||
success: (res) => {
|
||||
common_vendor.index.__f__("log", "at common/request.js:201", "[Request] 收到响应:", {
|
||||
url: fullUrl,
|
||||
method: method.toUpperCase(),
|
||||
statusCode: res.statusCode,
|
||||
hasData: !!res.data,
|
||||
dataType: typeof res.data
|
||||
});
|
||||
if (res.statusCode === 401) {
|
||||
common_vendor.index.__f__("warn", "at common/request.js:211", "[Request] 收到401状态码,跳转到登录页面");
|
||||
redirectToLogin();
|
||||
reject(new Error("登录已过期,请重新登录"));
|
||||
return;
|
||||
}
|
||||
resolve(res);
|
||||
},
|
||||
fail: (err) => {
|
||||
common_vendor.index.__f__("error", "at common/request.js:184", "[Request] 请求失败:", {
|
||||
common_vendor.index.__f__("error", "at common/request.js:219", "[Request] 请求失败:", {
|
||||
url: fullUrl,
|
||||
method: method.toUpperCase(),
|
||||
error: err
|
||||
error: err,
|
||||
errorMessage: err.errMsg || "未知错误",
|
||||
errorCode: err.code || "无错误码"
|
||||
});
|
||||
reject(err);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../common/vendor.js");
|
||||
const common_bluetooth = require("../../common/bluetooth.js");
|
||||
const pagesSubpackage_bluetoothRecorder_utils_bluetooth = require("./utils/bluetooth.js");
|
||||
const common_request = require("../../common/request.js");
|
||||
const common_config = require("../../common/config.js");
|
||||
const _sfc_main = {
|
||||
@@ -29,35 +29,35 @@ const _sfc_main = {
|
||||
*/
|
||||
async initBluetooth() {
|
||||
try {
|
||||
common_bluetooth.bluetoothRecorder.onDeviceFound = (device) => {
|
||||
pagesSubpackage_bluetoothRecorder_utils_bluetooth.bluetoothRecorder.onDeviceFound = (device) => {
|
||||
this.addLog("info", `发现设备: ${device.name || device.deviceId}`);
|
||||
this.deviceList = common_bluetooth.bluetoothRecorder.getDeviceList();
|
||||
this.deviceList = pagesSubpackage_bluetoothRecorder_utils_bluetooth.bluetoothRecorder.getDeviceList();
|
||||
};
|
||||
common_bluetooth.bluetoothRecorder.onDeviceConnected = (deviceId) => {
|
||||
pagesSubpackage_bluetoothRecorder_utils_bluetooth.bluetoothRecorder.onDeviceConnected = (deviceId) => {
|
||||
this.addLog("success", `设备连接成功: ${deviceId}`);
|
||||
this.isConnected = true;
|
||||
this.connectedDeviceId = deviceId;
|
||||
};
|
||||
common_bluetooth.bluetoothRecorder.onDeviceDisconnected = (deviceId) => {
|
||||
pagesSubpackage_bluetoothRecorder_utils_bluetooth.bluetoothRecorder.onDeviceDisconnected = (deviceId) => {
|
||||
this.addLog("warning", `设备断开连接: ${deviceId}`);
|
||||
this.isConnected = false;
|
||||
this.isReceiving = false;
|
||||
this.connectedDeviceId = null;
|
||||
};
|
||||
common_bluetooth.bluetoothRecorder.onAudioDataReceived = (data) => {
|
||||
pagesSubpackage_bluetoothRecorder_utils_bluetooth.bluetoothRecorder.onAudioDataReceived = (data) => {
|
||||
this.audioDataCount++;
|
||||
const estimatedSize = data.data.length * 3 / 4 / 1024;
|
||||
this.audioBufferSize = Math.round(estimatedSize * 100) / 100;
|
||||
this.isReceiving = true;
|
||||
};
|
||||
common_bluetooth.bluetoothRecorder.onError = (error) => {
|
||||
pagesSubpackage_bluetoothRecorder_utils_bluetooth.bluetoothRecorder.onError = (error) => {
|
||||
this.addLog("error", error.message || "发生错误");
|
||||
common_vendor.index.showToast({
|
||||
title: error.message || "操作失败",
|
||||
icon: "none"
|
||||
});
|
||||
};
|
||||
await common_bluetooth.bluetoothRecorder.initBluetoothAdapter();
|
||||
await pagesSubpackage_bluetoothRecorder_utils_bluetooth.bluetoothRecorder.initBluetoothAdapter();
|
||||
this.addLog("success", "蓝牙适配器初始化成功");
|
||||
} catch (error) {
|
||||
this.addLog("error", `初始化失败: ${error.message || error.errMsg}`);
|
||||
@@ -74,8 +74,8 @@ const _sfc_main = {
|
||||
async handleStartScan() {
|
||||
try {
|
||||
this.deviceList = [];
|
||||
common_bluetooth.bluetoothRecorder.clearDeviceList();
|
||||
await common_bluetooth.bluetoothRecorder.startScan({
|
||||
pagesSubpackage_bluetoothRecorder_utils_bluetooth.bluetoothRecorder.clearDeviceList();
|
||||
await pagesSubpackage_bluetoothRecorder_utils_bluetooth.bluetoothRecorder.startScan({
|
||||
allowDuplicatesKey: false,
|
||||
interval: 0
|
||||
});
|
||||
@@ -95,7 +95,7 @@ const _sfc_main = {
|
||||
*/
|
||||
async handleStopScan() {
|
||||
try {
|
||||
await common_bluetooth.bluetoothRecorder.stopScan();
|
||||
await pagesSubpackage_bluetoothRecorder_utils_bluetooth.bluetoothRecorder.stopScan();
|
||||
this.isScanning = false;
|
||||
this.addLog("info", "停止搜索");
|
||||
} catch (error) {
|
||||
@@ -111,7 +111,7 @@ const _sfc_main = {
|
||||
}
|
||||
try {
|
||||
common_vendor.index.showLoading({ title: "连接中..." });
|
||||
await common_bluetooth.bluetoothRecorder.connectDevice(device.deviceId);
|
||||
await pagesSubpackage_bluetoothRecorder_utils_bluetooth.bluetoothRecorder.connectDevice(device.deviceId);
|
||||
this.addLog("success", `正在连接设备: ${device.name || device.deviceId}`);
|
||||
} catch (error) {
|
||||
this.addLog("error", `连接失败: ${error.message || error.errMsg}`);
|
||||
@@ -125,7 +125,7 @@ const _sfc_main = {
|
||||
async handleDisconnect() {
|
||||
try {
|
||||
common_vendor.index.showLoading({ title: "断开中..." });
|
||||
await common_bluetooth.bluetoothRecorder.disconnectDevice();
|
||||
await pagesSubpackage_bluetoothRecorder_utils_bluetooth.bluetoothRecorder.disconnectDevice();
|
||||
this.isConnected = false;
|
||||
this.isReceiving = false;
|
||||
this.connectedDeviceId = null;
|
||||
@@ -142,7 +142,7 @@ const _sfc_main = {
|
||||
* 清空缓冲区
|
||||
*/
|
||||
handleClearBuffer() {
|
||||
common_bluetooth.bluetoothRecorder.clearAudioBuffer();
|
||||
pagesSubpackage_bluetoothRecorder_utils_bluetooth.bluetoothRecorder.clearAudioBuffer();
|
||||
this.audioDataCount = 0;
|
||||
this.audioBufferSize = 0;
|
||||
this.addLog("info", "已清空音频缓冲区");
|
||||
@@ -152,7 +152,7 @@ const _sfc_main = {
|
||||
*/
|
||||
async handleSaveAudio() {
|
||||
try {
|
||||
const audioData = common_bluetooth.bluetoothRecorder.mergeAudioData();
|
||||
const audioData = pagesSubpackage_bluetoothRecorder_utils_bluetooth.bluetoothRecorder.mergeAudioData();
|
||||
if (!audioData) {
|
||||
common_vendor.index.showToast({
|
||||
title: "没有可保存的音频数据",
|
||||
@@ -181,7 +181,7 @@ const _sfc_main = {
|
||||
async handleUploadAudio() {
|
||||
var _a;
|
||||
try {
|
||||
const audioData = common_bluetooth.bluetoothRecorder.mergeAudioData();
|
||||
const audioData = pagesSubpackage_bluetoothRecorder_utils_bluetooth.bluetoothRecorder.mergeAudioData();
|
||||
if (!audioData) {
|
||||
common_vendor.index.showToast({
|
||||
title: "没有可上传的音频数据",
|
||||
@@ -244,12 +244,12 @@ const _sfc_main = {
|
||||
async cleanup() {
|
||||
try {
|
||||
if (this.isConnected) {
|
||||
await common_bluetooth.bluetoothRecorder.disconnectDevice();
|
||||
await pagesSubpackage_bluetoothRecorder_utils_bluetooth.bluetoothRecorder.disconnectDevice();
|
||||
}
|
||||
if (this.isScanning) {
|
||||
await common_bluetooth.bluetoothRecorder.stopScan();
|
||||
await pagesSubpackage_bluetoothRecorder_utils_bluetooth.bluetoothRecorder.stopScan();
|
||||
}
|
||||
await common_bluetooth.bluetoothRecorder.closeBluetoothAdapter();
|
||||
await pagesSubpackage_bluetoothRecorder_utils_bluetooth.bluetoothRecorder.closeBluetoothAdapter();
|
||||
} catch (error) {
|
||||
common_vendor.index.__f__("error", "at pages-subpackage/bluetooth-recorder/bluetooth-recorder.vue:445", "清理资源失败", error);
|
||||
}
|
||||
|
||||
446
unpackage/dist/dev/mp-weixin/pages-subpackage/bluetooth-recorder/utils/bluetooth.js
vendored
Normal file
446
unpackage/dist/dev/mp-weixin/pages-subpackage/bluetooth-recorder/utils/bluetooth.js
vendored
Normal file
@@ -0,0 +1,446 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../../common/vendor.js");
|
||||
class BluetoothRecorder {
|
||||
constructor() {
|
||||
this.adapterState = false;
|
||||
this.isScanning = false;
|
||||
this.connectedDeviceId = null;
|
||||
this.deviceList = [];
|
||||
this.services = [];
|
||||
this.characteristics = [];
|
||||
this.notifyCharacteristicId = null;
|
||||
this.writeCharacteristicId = null;
|
||||
this.audioBuffer = [];
|
||||
this.isReceiving = false;
|
||||
this.onDeviceFound = null;
|
||||
this.onDeviceConnected = null;
|
||||
this.onDeviceDisconnected = null;
|
||||
this.onAudioDataReceived = null;
|
||||
this.onError = null;
|
||||
}
|
||||
/**
|
||||
* 初始化蓝牙适配器
|
||||
*/
|
||||
async initBluetoothAdapter() {
|
||||
return new Promise((resolve, reject) => {
|
||||
common_vendor.index.openBluetoothAdapter({
|
||||
success: (res) => {
|
||||
common_vendor.index.__f__("log", "at pages-subpackage/bluetooth-recorder/utils/bluetooth.js:36", "蓝牙适配器初始化成功", res);
|
||||
this.adapterState = true;
|
||||
this._listenAdapterState();
|
||||
resolve(res);
|
||||
},
|
||||
fail: (err) => {
|
||||
common_vendor.index.__f__("error", "at pages-subpackage/bluetooth-recorder/utils/bluetooth.js:42", "蓝牙适配器初始化失败", err);
|
||||
this.adapterState = false;
|
||||
this._handleError("蓝牙适配器初始化失败", err);
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 监听蓝牙适配器状态变化
|
||||
*/
|
||||
_listenAdapterState() {
|
||||
common_vendor.index.onBluetoothAdapterStateChange((res) => {
|
||||
common_vendor.index.__f__("log", "at pages-subpackage/bluetooth-recorder/utils/bluetooth.js:56", "蓝牙适配器状态变化", res);
|
||||
this.adapterState = res.available;
|
||||
if (!res.available) {
|
||||
this.connectedDeviceId = null;
|
||||
this._handleError("蓝牙适配器不可用", res);
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 开始搜索蓝牙设备
|
||||
* @param {Object} options - 搜索选项
|
||||
* @param {Array} options.services - 服务UUID列表(可选)
|
||||
* @param {number} options.interval - 上报间隔(毫秒)
|
||||
* @param {boolean} options.allowDuplicatesKey - 是否允许重复上报
|
||||
*/
|
||||
async startScan(options = {}) {
|
||||
if (this.isScanning) {
|
||||
common_vendor.index.__f__("warn", "at pages-subpackage/bluetooth-recorder/utils/bluetooth.js:74", "已经在扫描中");
|
||||
return;
|
||||
}
|
||||
if (!this.adapterState) {
|
||||
await this.initBluetoothAdapter();
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
common_vendor.index.onBluetoothDeviceFound((res) => {
|
||||
const devices = res.devices || [];
|
||||
devices.forEach((device) => {
|
||||
const exists = this.deviceList.find((d) => d.deviceId === device.deviceId);
|
||||
if (!exists) {
|
||||
this.deviceList.push({
|
||||
deviceId: device.deviceId,
|
||||
name: device.name || "未知设备",
|
||||
RSSI: device.RSSI,
|
||||
advertisData: device.advertisData,
|
||||
advertisServiceUUIDs: device.advertisServiceUUIDs,
|
||||
localName: device.localName
|
||||
});
|
||||
if (this.onDeviceFound) {
|
||||
this.onDeviceFound(device);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
common_vendor.index.startBluetoothDevicesDiscovery({
|
||||
services: options.services || [],
|
||||
allowDuplicatesKey: options.allowDuplicatesKey || false,
|
||||
interval: options.interval || 0,
|
||||
success: (res) => {
|
||||
common_vendor.index.__f__("log", "at pages-subpackage/bluetooth-recorder/utils/bluetooth.js:113", "开始搜索蓝牙设备", res);
|
||||
this.isScanning = true;
|
||||
resolve(res);
|
||||
},
|
||||
fail: (err) => {
|
||||
common_vendor.index.__f__("error", "at pages-subpackage/bluetooth-recorder/utils/bluetooth.js:118", "搜索蓝牙设备失败", err);
|
||||
this.isScanning = false;
|
||||
this._handleError("搜索蓝牙设备失败", err);
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 停止搜索蓝牙设备
|
||||
*/
|
||||
async stopScan() {
|
||||
if (!this.isScanning) {
|
||||
return;
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
common_vendor.index.stopBluetoothDevicesDiscovery({
|
||||
success: (res) => {
|
||||
common_vendor.index.__f__("log", "at pages-subpackage/bluetooth-recorder/utils/bluetooth.js:138", "停止搜索蓝牙设备", res);
|
||||
this.isScanning = false;
|
||||
resolve(res);
|
||||
},
|
||||
fail: (err) => {
|
||||
common_vendor.index.__f__("error", "at pages-subpackage/bluetooth-recorder/utils/bluetooth.js:143", "停止搜索失败", err);
|
||||
this._handleError("停止搜索失败", err);
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 连接蓝牙设备
|
||||
* @param {string} deviceId - 设备ID
|
||||
*/
|
||||
async connectDevice(deviceId) {
|
||||
if (this.connectedDeviceId === deviceId) {
|
||||
common_vendor.index.__f__("warn", "at pages-subpackage/bluetooth-recorder/utils/bluetooth.js:157", "设备已连接");
|
||||
return;
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
common_vendor.index.createBLEConnection({
|
||||
deviceId,
|
||||
success: async (res) => {
|
||||
common_vendor.index.__f__("log", "at pages-subpackage/bluetooth-recorder/utils/bluetooth.js:165", "蓝牙设备连接成功", res);
|
||||
this.connectedDeviceId = deviceId;
|
||||
this._listenConnectionState(deviceId);
|
||||
try {
|
||||
await this.getServices(deviceId);
|
||||
if (this.onDeviceConnected) {
|
||||
this.onDeviceConnected(deviceId);
|
||||
}
|
||||
resolve(res);
|
||||
} catch (err) {
|
||||
reject(err);
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
common_vendor.index.__f__("error", "at pages-subpackage/bluetooth-recorder/utils/bluetooth.js:186", "蓝牙设备连接失败", err);
|
||||
this._handleError("蓝牙设备连接失败", err);
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 监听连接状态
|
||||
*/
|
||||
_listenConnectionState(deviceId) {
|
||||
common_vendor.index.onBLEConnectionStateChange((res) => {
|
||||
common_vendor.index.__f__("log", "at pages-subpackage/bluetooth-recorder/utils/bluetooth.js:199", "蓝牙连接状态变化", res);
|
||||
if (res.deviceId === deviceId) {
|
||||
if (!res.connected) {
|
||||
this.connectedDeviceId = null;
|
||||
this.isReceiving = false;
|
||||
if (this.onDeviceDisconnected) {
|
||||
this.onDeviceDisconnected(deviceId);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 断开蓝牙设备连接
|
||||
*/
|
||||
async disconnectDevice() {
|
||||
if (!this.connectedDeviceId) {
|
||||
return;
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
common_vendor.index.closeBLEConnection({
|
||||
deviceId: this.connectedDeviceId,
|
||||
success: (res) => {
|
||||
common_vendor.index.__f__("log", "at pages-subpackage/bluetooth-recorder/utils/bluetooth.js:225", "蓝牙设备断开成功", res);
|
||||
this.connectedDeviceId = null;
|
||||
this.isReceiving = false;
|
||||
this.audioBuffer = [];
|
||||
resolve(res);
|
||||
},
|
||||
fail: (err) => {
|
||||
common_vendor.index.__f__("error", "at pages-subpackage/bluetooth-recorder/utils/bluetooth.js:232", "蓝牙设备断开失败", err);
|
||||
this._handleError("蓝牙设备断开失败", err);
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 获取蓝牙设备服务列表
|
||||
* @param {string} deviceId - 设备ID
|
||||
*/
|
||||
async getServices(deviceId) {
|
||||
return new Promise((resolve, reject) => {
|
||||
common_vendor.index.getBLEDeviceServices({
|
||||
deviceId,
|
||||
success: async (res) => {
|
||||
common_vendor.index.__f__("log", "at pages-subpackage/bluetooth-recorder/utils/bluetooth.js:249", "获取服务列表成功", res);
|
||||
this.services = res.services || [];
|
||||
for (const service of this.services) {
|
||||
try {
|
||||
await this.getCharacteristics(deviceId, service.uuid);
|
||||
} catch (err) {
|
||||
common_vendor.index.__f__("warn", "at pages-subpackage/bluetooth-recorder/utils/bluetooth.js:257", "获取特征值失败", service.uuid, err);
|
||||
}
|
||||
}
|
||||
resolve(res);
|
||||
},
|
||||
fail: (err) => {
|
||||
common_vendor.index.__f__("error", "at pages-subpackage/bluetooth-recorder/utils/bluetooth.js:264", "获取服务列表失败", err);
|
||||
this._handleError("获取服务列表失败", err);
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 获取特征值列表
|
||||
* @param {string} deviceId - 设备ID
|
||||
* @param {string} serviceId - 服务UUID
|
||||
*/
|
||||
async getCharacteristics(deviceId, serviceId) {
|
||||
return new Promise((resolve, reject) => {
|
||||
common_vendor.index.getBLEDeviceCharacteristics({
|
||||
deviceId,
|
||||
serviceId,
|
||||
success: (res) => {
|
||||
common_vendor.index.__f__("log", "at pages-subpackage/bluetooth-recorder/utils/bluetooth.js:283", "获取特征值成功", serviceId, res);
|
||||
const chars = res.characteristics || [];
|
||||
this.characteristics.push(...chars);
|
||||
chars.forEach((char) => {
|
||||
if (char.properties.notify || char.properties.indicate) {
|
||||
if (!this.notifyCharacteristicId) {
|
||||
this.notifyCharacteristicId = {
|
||||
deviceId,
|
||||
serviceId,
|
||||
characteristicId: char.uuid
|
||||
};
|
||||
this.enableNotify(deviceId, serviceId, char.uuid);
|
||||
}
|
||||
}
|
||||
if (char.properties.write || char.properties.writeNoResponse) {
|
||||
if (!this.writeCharacteristicId) {
|
||||
this.writeCharacteristicId = {
|
||||
deviceId,
|
||||
serviceId,
|
||||
characteristicId: char.uuid
|
||||
};
|
||||
}
|
||||
}
|
||||
});
|
||||
resolve(res);
|
||||
},
|
||||
fail: (err) => {
|
||||
common_vendor.index.__f__("error", "at pages-subpackage/bluetooth-recorder/utils/bluetooth.js:317", "获取特征值失败", err);
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 启用特征值通知(用于接收音频数据)
|
||||
* @param {string} deviceId - 设备ID
|
||||
* @param {string} serviceId - 服务UUID
|
||||
* @param {string} characteristicId - 特征值UUID
|
||||
*/
|
||||
async enableNotify(deviceId, serviceId, characteristicId) {
|
||||
return new Promise((resolve, reject) => {
|
||||
common_vendor.index.notifyBLECharacteristicValueChange({
|
||||
deviceId,
|
||||
serviceId,
|
||||
characteristicId,
|
||||
state: true,
|
||||
// 启用通知
|
||||
success: (res) => {
|
||||
common_vendor.index.__f__("log", "at pages-subpackage/bluetooth-recorder/utils/bluetooth.js:338", "启用通知成功", res);
|
||||
common_vendor.index.onBLECharacteristicValueChange((res2) => {
|
||||
this._handleAudioData(res2.value);
|
||||
});
|
||||
this.isReceiving = true;
|
||||
resolve(res);
|
||||
},
|
||||
fail: (err) => {
|
||||
common_vendor.index.__f__("error", "at pages-subpackage/bluetooth-recorder/utils/bluetooth.js:349", "启用通知失败", err);
|
||||
this._handleError("启用通知失败", err);
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 处理接收到的音频数据
|
||||
* @param {ArrayBuffer} data - 音频数据
|
||||
*/
|
||||
_handleAudioData(data) {
|
||||
const base64 = common_vendor.index.arrayBufferToBase64(data);
|
||||
this.audioBuffer.push({
|
||||
data: base64,
|
||||
timestamp: Date.now()
|
||||
});
|
||||
if (this.onAudioDataReceived) {
|
||||
this.onAudioDataReceived({
|
||||
data: base64,
|
||||
arrayBuffer: data,
|
||||
timestamp: Date.now()
|
||||
});
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 读取特征值
|
||||
* @param {string} deviceId - 设备ID
|
||||
* @param {string} serviceId - 服务UUID
|
||||
* @param {string} characteristicId - 特征值UUID
|
||||
*/
|
||||
async readCharacteristic(deviceId, serviceId, characteristicId) {
|
||||
return new Promise((resolve, reject) => {
|
||||
common_vendor.index.readBLECharacteristicValue({
|
||||
deviceId,
|
||||
serviceId,
|
||||
characteristicId,
|
||||
success: (res) => {
|
||||
common_vendor.index.__f__("log", "at pages-subpackage/bluetooth-recorder/utils/bluetooth.js:394", "读取特征值成功", res);
|
||||
resolve(res);
|
||||
},
|
||||
fail: (err) => {
|
||||
common_vendor.index.__f__("error", "at pages-subpackage/bluetooth-recorder/utils/bluetooth.js:398", "读取特征值失败", err);
|
||||
this._handleError("读取特征值失败", err);
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 写入特征值(发送命令到设备)
|
||||
* @param {ArrayBuffer} value - 要写入的数据
|
||||
*/
|
||||
async writeCharacteristic(value) {
|
||||
if (!this.writeCharacteristicId) {
|
||||
throw new Error("未找到可写入的特征值");
|
||||
}
|
||||
const { deviceId, serviceId, characteristicId } = this.writeCharacteristicId;
|
||||
return new Promise((resolve, reject) => {
|
||||
common_vendor.index.writeBLECharacteristicValue({
|
||||
deviceId,
|
||||
serviceId,
|
||||
characteristicId,
|
||||
value,
|
||||
success: (res) => {
|
||||
common_vendor.index.__f__("log", "at pages-subpackage/bluetooth-recorder/utils/bluetooth.js:424", "写入特征值成功", res);
|
||||
resolve(res);
|
||||
},
|
||||
fail: (err) => {
|
||||
common_vendor.index.__f__("error", "at pages-subpackage/bluetooth-recorder/utils/bluetooth.js:428", "写入特征值失败", err);
|
||||
this._handleError("写入特征值失败", err);
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 获取已缓存的音频数据
|
||||
*/
|
||||
getAudioBuffer() {
|
||||
return this.audioBuffer;
|
||||
}
|
||||
/**
|
||||
* 清空音频缓冲区
|
||||
*/
|
||||
clearAudioBuffer() {
|
||||
this.audioBuffer = [];
|
||||
}
|
||||
/**
|
||||
* 合并音频数据为完整文件(Base64格式)
|
||||
*/
|
||||
mergeAudioData() {
|
||||
return this.audioBuffer.map((item) => item.data).join("");
|
||||
}
|
||||
/**
|
||||
* 处理错误
|
||||
*/
|
||||
_handleError(message, error) {
|
||||
common_vendor.index.__f__("error", "at pages-subpackage/bluetooth-recorder/utils/bluetooth.js:461", `[BluetoothRecorder] ${message}`, error);
|
||||
if (this.onError) {
|
||||
this.onError({
|
||||
message,
|
||||
error
|
||||
});
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 关闭蓝牙适配器
|
||||
*/
|
||||
async closeBluetoothAdapter() {
|
||||
if (this.connectedDeviceId) {
|
||||
await this.disconnectDevice();
|
||||
}
|
||||
if (this.isScanning) {
|
||||
await this.stopScan();
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
common_vendor.index.closeBluetoothAdapter({
|
||||
success: (res) => {
|
||||
common_vendor.index.__f__("log", "at pages-subpackage/bluetooth-recorder/utils/bluetooth.js:487", "关闭蓝牙适配器成功", res);
|
||||
this.adapterState = false;
|
||||
resolve(res);
|
||||
},
|
||||
fail: (err) => {
|
||||
common_vendor.index.__f__("error", "at pages-subpackage/bluetooth-recorder/utils/bluetooth.js:492", "关闭蓝牙适配器失败", err);
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 获取设备列表
|
||||
*/
|
||||
getDeviceList() {
|
||||
return this.deviceList;
|
||||
}
|
||||
/**
|
||||
* 清空设备列表
|
||||
*/
|
||||
clearDeviceList() {
|
||||
this.deviceList = [];
|
||||
}
|
||||
}
|
||||
const bluetoothRecorder = new BluetoothRecorder();
|
||||
exports.bluetoothRecorder = bluetoothRecorder;
|
||||
//# sourceMappingURL=../../../../.sourcemap/mp-weixin/pages-subpackage/bluetooth-recorder/utils/bluetooth.js.map
|
||||
@@ -1,9 +1,8 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../common/vendor.js");
|
||||
const uni_modules_jsonGps_js_sdk_gps = require("../../uni_modules/json-gps/js_sdk/gps.js");
|
||||
let cdbRef;
|
||||
const statusBar = () => "../../uni_modules/uni-nav-bar/components/uni-nav-bar/uni-status-bar.js";
|
||||
const gps = new uni_modules_jsonGps_js_sdk_gps.Gps(), db = common_vendor.tr.database();
|
||||
const db = common_vendor.tr.database();
|
||||
const _sfc_main = {
|
||||
components: {
|
||||
statusBar
|
||||
@@ -57,9 +56,6 @@ const _sfc_main = {
|
||||
} catch (e) {
|
||||
this.keyword = "";
|
||||
}
|
||||
await gps.getLocation({
|
||||
geocode: true
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
searchClick(e) {
|
||||
@@ -77,18 +73,18 @@ const _sfc_main = {
|
||||
clear: true
|
||||
}, () => {
|
||||
common_vendor.index.stopPullDownRefresh();
|
||||
common_vendor.index.__f__("log", "at pages-subpackage/list/list.nvue:166", "end");
|
||||
common_vendor.index.__f__("log", "at pages-subpackage/list/list.nvue:147", "end");
|
||||
});
|
||||
common_vendor.index.__f__("log", "at pages-subpackage/list/list.nvue:168", "refresh");
|
||||
common_vendor.index.__f__("log", "at pages-subpackage/list/list.nvue:149", "refresh");
|
||||
},
|
||||
loadMore() {
|
||||
cdbRef.loadMore();
|
||||
},
|
||||
onqueryerror(e) {
|
||||
common_vendor.index.__f__("error", "at pages-subpackage/list/list.nvue:174", e);
|
||||
common_vendor.index.__f__("error", "at pages-subpackage/list/list.nvue:155", e);
|
||||
},
|
||||
onpullingdown(e) {
|
||||
common_vendor.index.__f__("log", "at pages-subpackage/list/list.nvue:177", e);
|
||||
common_vendor.index.__f__("log", "at pages-subpackage/list/list.nvue:158", e);
|
||||
this.showRefresh = true;
|
||||
if (e.pullingDistance > 100) {
|
||||
this.refresh();
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
"urlCheck": false,
|
||||
"es6": true,
|
||||
"postcss": false,
|
||||
"minified": false,
|
||||
"minified": true,
|
||||
"newFeature": true,
|
||||
"bigPackageSizeSupport": true,
|
||||
"minifyJS": true,
|
||||
|
||||
@@ -62,16 +62,36 @@ const _sfc_main = {
|
||||
mask: true
|
||||
});
|
||||
try {
|
||||
const loginUrl = common_config.getApiUrl("/api/sys/auth/login");
|
||||
common_vendor.index.__f__("log", "at uni_modules/uni-id-pages/pages/login/login-withpwd.vue:115", "[Login Page] 开始调用登录接口:", {
|
||||
url: loginUrl,
|
||||
method: "POST",
|
||||
payload
|
||||
});
|
||||
const res = await new Promise((resolve, reject) => {
|
||||
common_vendor.index.__f__("log", "at uni_modules/uni-id-pages/pages/login/login-withpwd.vue:122", "[Login Page] 发起 uni.request 调用");
|
||||
common_vendor.index.request({
|
||||
url: common_config.getApiUrl("/api/sys/auth/login"),
|
||||
url: loginUrl,
|
||||
method: "POST",
|
||||
header: {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
data: payload,
|
||||
success: resolve,
|
||||
fail: reject
|
||||
success: (res2) => {
|
||||
common_vendor.index.__f__("log", "at uni_modules/uni-id-pages/pages/login/login-withpwd.vue:131", "[Login Page] 登录请求成功:", {
|
||||
statusCode: res2.statusCode,
|
||||
hasData: !!res2.data,
|
||||
dataType: typeof res2.data
|
||||
});
|
||||
resolve(res2);
|
||||
},
|
||||
fail: (err) => {
|
||||
common_vendor.index.__f__("error", "at uni_modules/uni-id-pages/pages/login/login-withpwd.vue:139", "[Login Page] 登录请求失败:", {
|
||||
error: err,
|
||||
errorMessage: err.errMsg || "未知错误"
|
||||
});
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
const body = res.data || {};
|
||||
@@ -85,34 +105,34 @@ const _sfc_main = {
|
||||
const loginData = body.data;
|
||||
if (loginData.token) {
|
||||
common_vendor.index.setStorageSync("backend-token", loginData.token);
|
||||
common_vendor.index.__f__("log", "at uni_modules/uni-id-pages/pages/login/login-withpwd.vue:141", "[Login] token 已保存,后续请求将自动在 header 中携带");
|
||||
common_vendor.index.__f__("log", "at uni_modules/uni-id-pages/pages/login/login-withpwd.vue:162", "[Login] token 已保存,后续请求将自动在 header 中携带");
|
||||
} else {
|
||||
common_vendor.index.__f__("warn", "at uni_modules/uni-id-pages/pages/login/login-withpwd.vue:143", "[Login] 登录响应中未包含 token");
|
||||
common_vendor.index.__f__("warn", "at uni_modules/uni-id-pages/pages/login/login-withpwd.vue:164", "[Login] 登录响应中未包含 token");
|
||||
}
|
||||
try {
|
||||
common_vendor.index.setStorageSync("backend-login-response", loginData);
|
||||
common_vendor.index.setStorageSync("backend-user-id", loginData.userId);
|
||||
if (loginData.tenantId) {
|
||||
common_vendor.index.setStorageSync("backend-tenant-id", loginData.tenantId);
|
||||
common_vendor.index.__f__("log", "at uni_modules/uni-id-pages/pages/login/login-withpwd.vue:154", "[Login] tenantId 已保存:", loginData.tenantId);
|
||||
common_vendor.index.__f__("log", "at uni_modules/uni-id-pages/pages/login/login-withpwd.vue:175", "[Login] tenantId 已保存:", loginData.tenantId);
|
||||
} else {
|
||||
common_vendor.index.__f__("warn", "at uni_modules/uni-id-pages/pages/login/login-withpwd.vue:156", "[Login] 登录响应中未包含 tenantId,后续请求可能失败");
|
||||
common_vendor.index.__f__("warn", "at uni_modules/uni-id-pages/pages/login/login-withpwd.vue:177", "[Login] 登录响应中未包含 tenantId,后续请求可能失败");
|
||||
}
|
||||
if (loginData.roleName) {
|
||||
common_vendor.index.setStorageSync("backend-role-name", loginData.roleName);
|
||||
common_vendor.index.__f__("log", "at uni_modules/uni-id-pages/pages/login/login-withpwd.vue:162", "[Login] roleName 已保存:", loginData.roleName);
|
||||
common_vendor.index.__f__("log", "at uni_modules/uni-id-pages/pages/login/login-withpwd.vue:183", "[Login] roleName 已保存:", loginData.roleName);
|
||||
}
|
||||
if (loginData.scenario) {
|
||||
common_vendor.index.setStorageSync("backend-scenario", loginData.scenario);
|
||||
common_vendor.index.__f__("log", "at uni_modules/uni-id-pages/pages/login/login-withpwd.vue:166", "[Login] scenario 已保存:", loginData.scenario);
|
||||
common_vendor.index.__f__("log", "at uni_modules/uni-id-pages/pages/login/login-withpwd.vue:187", "[Login] scenario 已保存:", loginData.scenario);
|
||||
}
|
||||
} catch (e) {
|
||||
common_vendor.index.__f__("error", "at uni_modules/uni-id-pages/pages/login/login-withpwd.vue:169", "缓存登录信息失败:", e);
|
||||
common_vendor.index.__f__("error", "at uni_modules/uni-id-pages/pages/login/login-withpwd.vue:190", "缓存登录信息失败:", e);
|
||||
}
|
||||
try {
|
||||
common_vendor.index.$emit("tabbar:refresh");
|
||||
} catch (e) {
|
||||
common_vendor.index.__f__("warn", "at uni_modules/uni-id-pages/pages/login/login-withpwd.vue:176", "触发 tabbar 刷新事件失败:", e);
|
||||
common_vendor.index.__f__("warn", "at uni_modules/uni-id-pages/pages/login/login-withpwd.vue:197", "触发 tabbar 刷新事件失败:", e);
|
||||
}
|
||||
try {
|
||||
common_store.mutations.setUserInfo({
|
||||
@@ -121,9 +141,9 @@ const _sfc_main = {
|
||||
email: loginData.email,
|
||||
avatar_file: loginData.avatar ? { url: loginData.avatar } : void 0
|
||||
}, { cover: true });
|
||||
common_vendor.index.__f__("log", "at uni_modules/uni-id-pages/pages/login/login-withpwd.vue:187", "[Login] Store updated successfully, hasLogin:", common_store.store.hasLogin, "userInfo:", common_store.store.userInfo);
|
||||
common_vendor.index.__f__("log", "at uni_modules/uni-id-pages/pages/login/login-withpwd.vue:208", "[Login] Store updated successfully, hasLogin:", common_store.store.hasLogin, "userInfo:", common_store.store.userInfo);
|
||||
} catch (e) {
|
||||
common_vendor.index.__f__("error", "at uni_modules/uni-id-pages/pages/login/login-withpwd.vue:189", "更新本地用户信息失败:", e);
|
||||
common_vendor.index.__f__("error", "at uni_modules/uni-id-pages/pages/login/login-withpwd.vue:210", "更新本地用户信息失败:", e);
|
||||
}
|
||||
common_vendor.index.showToast({
|
||||
title: body.message || "登录成功",
|
||||
@@ -136,25 +156,25 @@ const _sfc_main = {
|
||||
app.setGlobalRoleInfo();
|
||||
}
|
||||
} catch (e) {
|
||||
common_vendor.index.__f__("warn", "at uni_modules/uni-id-pages/pages/login/login-withpwd.vue:205", "[Login] Failed to update global role info:", e);
|
||||
common_vendor.index.__f__("warn", "at uni_modules/uni-id-pages/pages/login/login-withpwd.vue:226", "[Login] Failed to update global role info:", e);
|
||||
}
|
||||
setTimeout(() => {
|
||||
common_vendor.index.__f__("log", "at uni_modules/uni-id-pages/pages/login/login-withpwd.vue:212", "[Login] Preparing to navigate after login, hasLogin:", common_store.store.hasLogin);
|
||||
common_vendor.index.__f__("log", "at uni_modules/uni-id-pages/pages/login/login-withpwd.vue:233", "[Login] Preparing to navigate after login, hasLogin:", common_store.store.hasLogin);
|
||||
common_vendor.index.switchTab({
|
||||
url: "/pages/furniture_reception/furniture_reception",
|
||||
success: () => {
|
||||
common_vendor.index.__f__("log", "at uni_modules/uni-id-pages/pages/login/login-withpwd.vue:216", "[Login] Navigation successful, checking login status after navigation");
|
||||
common_vendor.index.__f__("log", "at uni_modules/uni-id-pages/pages/login/login-withpwd.vue:237", "[Login] Navigation successful, checking login status after navigation");
|
||||
setTimeout(() => {
|
||||
common_vendor.index.__f__("log", "at uni_modules/uni-id-pages/pages/login/login-withpwd.vue:219", "[Login] Final check - hasLogin:", common_store.store.hasLogin, "backend-token exists:", !!common_vendor.index.getStorageSync("backend-token"));
|
||||
common_vendor.index.__f__("log", "at uni_modules/uni-id-pages/pages/login/login-withpwd.vue:240", "[Login] Final check - hasLogin:", common_store.store.hasLogin, "backend-token exists:", !!common_vendor.index.getStorageSync("backend-token"));
|
||||
}, 500);
|
||||
},
|
||||
fail: (err) => {
|
||||
common_vendor.index.__f__("error", "at uni_modules/uni-id-pages/pages/login/login-withpwd.vue:223", "[Login] Navigation failed:", err);
|
||||
common_vendor.index.__f__("error", "at uni_modules/uni-id-pages/pages/login/login-withpwd.vue:244", "[Login] Navigation failed:", err);
|
||||
}
|
||||
});
|
||||
}, 500);
|
||||
} catch (err) {
|
||||
common_vendor.index.__f__("error", "at uni_modules/uni-id-pages/pages/login/login-withpwd.vue:236", "调用登录接口失败:", err);
|
||||
common_vendor.index.__f__("error", "at uni_modules/uni-id-pages/pages/login/login-withpwd.vue:257", "调用登录接口失败:", err);
|
||||
common_vendor.index.showToast({
|
||||
title: "网络异常,登录失败",
|
||||
icon: "none",
|
||||
@@ -169,7 +189,7 @@ const _sfc_main = {
|
||||
common_vendor.index.navigateTo({
|
||||
url: this.config.isAdmin ? "/uni_modules/uni-id-pages/pages/register/register-admin" : "/uni_modules/uni-id-pages/pages/register/register",
|
||||
fail(e) {
|
||||
common_vendor.index.__f__("error", "at uni_modules/uni-id-pages/pages/login/login-withpwd.vue:252", e);
|
||||
common_vendor.index.__f__("error", "at uni_modules/uni-id-pages/pages/login/login-withpwd.vue:273", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user