Files
intelligentProject-phone/unpackage/dist/dev/app-plus/app-service.js
2026-01-26 18:04:27 +08:00

989 lines
37 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
var __defProp = Object.defineProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField = (obj, key, value) => {
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
return value;
};
if (typeof Promise !== "undefined" && !Promise.prototype.finally) {
Promise.prototype.finally = function(callback) {
const promise = this.constructor;
return this.then(
(value) => promise.resolve(callback()).then(() => value),
(reason) => promise.resolve(callback()).then(() => {
throw reason;
})
);
};
}
;
if (typeof uni !== "undefined" && uni && uni.requireGlobal) {
const global2 = uni.requireGlobal();
ArrayBuffer = global2.ArrayBuffer;
Int8Array = global2.Int8Array;
Uint8Array = global2.Uint8Array;
Uint8ClampedArray = global2.Uint8ClampedArray;
Int16Array = global2.Int16Array;
Uint16Array = global2.Uint16Array;
Int32Array = global2.Int32Array;
Uint32Array = global2.Uint32Array;
Float32Array = global2.Float32Array;
Float64Array = global2.Float64Array;
BigInt64Array = global2.BigInt64Array;
BigUint64Array = global2.BigUint64Array;
}
;
if (uni.restoreGlobal) {
uni.restoreGlobal(Vue, weex, plus, setTimeout, clearTimeout, setInterval, clearInterval);
}
(function(vue) {
"use strict";
function formatAppLog(type, filename, ...args) {
if (uni.__log__) {
uni.__log__(type, filename, ...args);
} else {
console[type].apply(console, [...args, filename]);
}
}
function isAndroid() {
return uni.getSystemInfoSync().platform === "android";
}
if (typeof setTimeout === "undefined") {
formatAppLog("log", "at utils/fileUtils.js:12", "setTimeout 未定义,添加 polyfill");
global.setTimeout = function(callback, delay) {
callback();
};
}
async function moveChromeApkToDevice(options = {}) {
const config = {
sourcePath: "/static/apk/com.android.chrome.apk",
targetDir: "yxd",
targetFileName: "com.android.chrome.apk",
...options
};
formatAppLog("log", "at utils/fileUtils.js:52", "开始移动APK文件配置:", config);
return new Promise((resolve, reject) => {
try {
const srcPath = plus.io.convertLocalFileSystemURL(config.sourcePath);
const targetDirPath = "_downloads/";
formatAppLog("log", "at utils/fileUtils.js:60", "源文件路径:", srcPath);
const internalStoragePath = "file:///storage/emulated/0/";
formatAppLog("log", "at utils/fileUtils.js:64", "尝试使用内部存储目录:", internalStoragePath);
plus.io.resolveLocalFileSystemURL(srcPath, (srcEntry) => {
formatAppLog("log", "at utils/fileUtils.js:67", "找到源文件:", srcEntry.fullPath);
plus.io.resolveLocalFileSystemURL(targetDirPath, (downloadDirEntry) => {
formatAppLog("log", "at utils/fileUtils.js:110", "找到下载目录:", downloadDirEntry.fullPath);
downloadDirEntry.getFile(config.targetFileName, {}, (existingFile) => {
formatAppLog("log", "at utils/fileUtils.js:114", "找到已存在的 APK:", existingFile.fullPath);
scanFile(existingFile.fullPath);
resolve(existingFile);
}, () => {
srcEntry.copyTo(downloadDirEntry, config.targetFileName, (newEntry) => {
formatAppLog("log", "at utils/fileUtils.js:121", "APK 复制成功:", newEntry.fullPath);
scanFile(newEntry.fullPath);
resolve(newEntry);
}, (copyErr) => {
formatAppLog("error", "at utils/fileUtils.js:125", "复制失败:", copyErr);
reject(`复制失败: ${JSON.stringify(copyErr)}`);
});
});
}, (dirErr) => {
formatAppLog("error", "at utils/fileUtils.js:131", "获取公共下载目录失败,尝试应用私有目录:", dirErr);
saveToPrivateDir(srcEntry, config, resolve, reject);
});
}, (srcErr) => {
formatAppLog("error", "at utils/fileUtils.js:135", "访问源文件失败:", srcErr);
reject(`访问源文件失败: ${JSON.stringify(srcErr)}`);
});
} catch (e) {
formatAppLog("error", "at utils/fileUtils.js:139", "执行过程中发生异常:", e);
reject(`执行过程中发生异常: ${e}`);
}
});
}
function scanFile(filePath) {
if (!isAndroid())
return;
try {
formatAppLog("log", "at utils/fileUtils.js:148", "开始扫描文件:", filePath);
const Intent = plus.android.importClass("android.content.Intent");
const Uri = plus.android.importClass("android.net.Uri");
const File = plus.android.importClass("java.io.File");
const main = plus.android.runtimeMainActivity();
const intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
intent.setData(Uri.fromFile(new File(filePath)));
main.sendBroadcast(intent);
formatAppLog("log", "at utils/fileUtils.js:156", "文件扫描成功");
} catch (e) {
formatAppLog("error", "at utils/fileUtils.js:158", "文件扫描失败:", e);
}
}
class ChromeBrowser {
/**
* 打开URL自动处理浏览器
* @param {string} url - 要打开的URL
* @returns {Promise<boolean>} 是否成功处理
*/
static async openUrl(url) {
if (!url) {
formatAppLog("error", "at utils/chrome-browser.js:29", "ChromeBrowser: URL为空");
return false;
}
return new Promise((resolve, reject) => {
plus.runtime.openURL(url, async (err) => {
if (err) {
formatAppLog("log", "at utils/chrome-browser.js:36", "检测失败Chrome 可能未安装:", err);
try {
const result = await this.installAndOpen(url);
resolve(result);
} catch (error) {
formatAppLog("error", "at utils/chrome-browser.js:42", "installAndOpen 失败:", error);
resolve(false);
}
} else {
resolve(true);
}
}, "com.android.chrome");
});
}
/**
* 使用谷歌浏览器打开URL
* @param {string} url
*/
static openWithChrome(url) {
plus.runtime.openURL(url, {
pname: "Chrome"
});
return true;
}
/**
* 安装谷歌浏览器并打开URL
* @param {string} url
* @returns {Promise<boolean>}
*/
static async installAndOpen(url) {
try {
const confirm = await this.showInstallConfirm();
if (!confirm) {
plus.runtime.openURL(url);
return false;
}
const installed = await this.initWorkflow();
if (installed) {
this.hasChrome = true;
uni.setStorageSync("has_chrome_browser", true);
setTimeout(() => {
this.openWithChrome(url);
}, 1e3);
return true;
} else {
plus.runtime.openURL(url);
return false;
}
} catch (error) {
formatAppLog("error", "at utils/chrome-browser.js:102", "ChromeBrowser: 安装流程失败:", error);
plus.runtime.openURL(url);
return false;
}
}
/**
* 显示安装确认对话框
* @returns {Promise<boolean>}
*/
static showInstallConfirm() {
return new Promise((resolve) => {
uni.showModal({
title: "安装谷歌浏览器",
content: "检测到您未安装谷歌浏览器\n\n建议安装谷歌浏览器以获得最佳体验\n是否现在安装",
confirmText: "立即安装",
cancelText: "使用其他浏览器",
success: (res) => {
resolve(res.confirm);
}
});
});
}
static async initWorkflow() {
return new Promise(async (resolve) => {
try {
const hasPermission = await this.requestAndroidPermission(
"android.permission.WRITE_EXTERNAL_STORAGE"
);
if (!hasPermission) {
uni.showModal({
title: "提示",
content: "请授予存储权限以保存安装包",
showCancel: false
});
return;
}
uni.showLoading({
title: "正在准备资源..."
});
const result = await moveChromeApkToDevice();
uni.hideLoading();
uni.showModal({
title: "就绪",
content: `安装包已保存至Downloads/${result.name}`,
confirmText: "去安装",
success: (res) => {
if (res.confirm) {
this.installApk(result.fullPath, resolve);
} else {
resolve(false);
}
}
});
} catch (e) {
uni.hideLoading();
formatAppLog("error", "at utils/chrome-browser.js:165", "流程失败:", e);
uni.showToast({
title: "操作失败: " + e,
icon: "none"
});
}
});
}
// 动态权限申请核心代码
static requestAndroidPermission(permissionID) {
return new Promise((resolve) => {
plus.android.requestPermissions(
[permissionID],
(resultObj) => {
if (resultObj.granted.length > 0) {
resolve(true);
} else {
resolve(false);
}
},
(error) => {
formatAppLog("error", "at utils/chrome-browser.js:187", "权限请求错误:", error);
resolve(false);
}
);
});
}
/**
* 实时下载并安装
* @param {Function} resolve
*/
static downloadAndInstall(resolve) {
uni.showLoading({
title: "正在下载...\n约十分钟",
mask: true
});
const downloadUrl = "https://database.yuxindazhineng.com/user-file//690c72a6b8ffa329af2d5607/avatar/com.android.chrome.apk";
const fileName = `_downloads/chrome_${Date.now()}.apk`;
const dtask = plus.downloader.createDownload(
downloadUrl,
{
filename: fileName
},
(d, status) => {
uni.hideLoading();
if (status === 200) {
formatAppLog("log", "at utils/chrome-browser.js:217", "ChromeBrowser: 下载成功,开始安装");
this.installApk(d.filename, resolve);
} else {
formatAppLog("error", "at utils/chrome-browser.js:220", "ChromeBrowser: 下载失败,状态码:", status);
this.showDownloadError();
resolve(false);
}
}
);
dtask.start();
}
/**
* 安装APK文件
* @param {string} filePath
* @param {Function} resolve
*/
static installApk(filePath, resolve) {
uni.showLoading({
title: "准备中...",
mask: true
});
plus.runtime.install(
filePath,
{
force: false
},
() => {
uni.hideLoading();
formatAppLog("log", "at utils/chrome-browser.js:247", "ChromeBrowser: 安装成功");
uni.showToast({
title: "准备完成",
icon: "success",
duration: 1500
});
resolve(true);
},
(error) => {
uni.hideLoading();
formatAppLog("error", "at utils/chrome-browser.js:257", "ChromeBrowser: 安装失败:", error);
uni.removeStorageSync("chrome_apk_path");
this.showInstallError(filePath);
resolve(false);
}
);
}
/**
* 显示下载错误提示
*/
static showDownloadError() {
uni.showModal({
title: "下载失败",
content: "无法下载谷歌浏览器\n请检查网络连接后重试",
showCancel: false
});
}
/**
* 显示安装错误提示
* @param {string} filePath
*/
static showInstallError(filePath) {
uni.showModal({
title: "安装失败",
content: "自动安装失败\n请在文件管理中手动安装\n或退出应用后台重新进入下载",
confirmText: "查看文件",
success: (res) => {
if (res.confirm && filePath) {
plus.runtime.openFile(filePath);
}
}
});
}
/**
* 强制重新检查浏览器状态
* @returns {Promise<boolean>}
*/
static async forceCheck() {
formatAppLog("log", "at utils/chrome-browser.js:299", "ChromeBrowser: 强制重新检查");
this.hasChrome = null;
return await this.init();
}
/**
* 获取当前状态信息
*/
static getStatus() {
return {
hasChrome: this.hasChrome,
apkDownloaded: this.apkDownloaded,
apkPath: this.apkPath,
cachedHasChrome: uni.getStorageSync("has_chrome_browser"),
cachedApkPath: uni.getStorageSync("chrome_apk_path")
};
}
}
// 存储检查结果
__publicField(ChromeBrowser, "hasChrome", null);
__publicField(ChromeBrowser, "apkDownloaded", false);
__publicField(ChromeBrowser, "apkPath", null);
const _imports_0 = "/static/logo.png";
const _export_sfc = (sfc, props) => {
const target = sfc.__vccOpts || sfc;
for (const [key, val] of props) {
target[key] = val;
}
return target;
};
const _sfc_main$3 = {
__name: "light-theme",
setup(__props, { expose: __expose }) {
__expose();
const username = vue.ref("");
const password = vue.ref("");
const rememberMe = vue.ref(false);
const showPassword = vue.ref(false);
const isLoggingIn = vue.ref(false);
const redirectUrl = vue.ref("");
const copySuccess = vue.ref(false);
const usernameError = vue.ref("");
const passwordError = vue.ref("");
const loginError = vue.ref("");
const toggleRememberMe = () => {
rememberMe.value = !rememberMe.value;
};
const validateForm = () => {
let isValid = true;
usernameError.value = "";
passwordError.value = "";
if (!username.value.trim()) {
usernameError.value = "请输入账号";
isValid = false;
}
if (!password.value) {
passwordError.value = "请输入密码";
isValid = false;
} else if (password.value.length < 6) {
passwordError.value = "密码至少6位字符";
isValid = false;
}
return isValid;
};
const clearError = (field) => {
if (field === "username") {
usernameError.value = "";
} else if (field === "password") {
passwordError.value = "";
}
loginError.value = "";
};
const handleLogin = async () => {
if (!validateForm()) {
return;
}
isLoggingIn.value = true;
loginError.value = "";
try {
const res = await uni.request({
url: "http://cloud.yuxindazhineng.com/cloud_api/app/verify_domain",
method: "POST",
header: {
"Content-Type": "application/json"
},
data: {
username: username.value,
password: password.value
}
});
if (res.statusCode !== 200) {
throw new Error(`接口请求失败,状态码:${res.statusCode}`);
}
const responseData = res.data;
formatAppLog("log", "at pages/light-theme/light-theme.vue:176", responseData);
if (responseData.success) {
if (rememberMe.value) {
uni.setStorageSync("yxd_username", username.value);
} else {
uni.removeStorageSync("yxd_username");
}
const domainData = responseData.data;
formatAppLog("log", "at pages/light-theme/light-theme.vue:189", "完整域名:", domainData.full_domain);
formatAppLog("log", "at pages/light-theme/light-theme.vue:190", "域名前缀:", domainData.domain_prefix);
redirectUrl.value = `http://${domainData.full_domain}`;
setTimeout(() => {
openExternalLink();
}, 1e3);
} else {
throw new Error(responseData.message || "登录失败,请检查账号密码");
}
} catch (error) {
loginError.value = error.message || "登录失败,请检查账号密码";
} finally {
isLoggingIn.value = false;
}
};
const openExternalLink = () => {
if (!redirectUrl.value)
return;
ChromeBrowser.openUrl(redirectUrl.value);
setTimeout(() => {
redirectUrl.value = null;
}, 1e3);
};
const copyToClipboard = () => {
if (!redirectUrl.value)
return;
uni.setClipboardData({
data: redirectUrl.value,
success: () => {
copySuccess.value = true;
setTimeout(() => {
copySuccess.value = false;
}, 2e3);
}
});
};
vue.onMounted(() => {
const savedUsername = uni.getStorageSync("yxd_username");
if (savedUsername) {
username.value = savedUsername;
rememberMe.value = true;
}
formatAppLog("log", "at pages/light-theme/light-theme.vue:259", "登录组件已挂载");
});
const __returned__ = { username, password, rememberMe, showPassword, isLoggingIn, redirectUrl, copySuccess, usernameError, passwordError, loginError, toggleRememberMe, validateForm, clearError, handleLogin, openExternalLink, copyToClipboard, ref: vue.ref, onMounted: vue.onMounted, get ChromeBrowser() {
return ChromeBrowser;
} };
Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
return __returned__;
}
};
function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
return vue.openBlock(), vue.createElementBlock("div", { class: "main-view" }, [
vue.createElementVNode("div", { class: "container" }, [
vue.createElementVNode("div", { class: "logo" }, [
vue.createElementVNode("image", {
src: _imports_0,
alt: "YXD"
})
]),
vue.createElementVNode("h1", null, "登录 YXD 智能应用"),
vue.createElementVNode("div", { class: "login-form" }, [
vue.createElementVNode("div", { class: "form-group" }, [
vue.createElementVNode("label", { for: "username" }, "账号"),
vue.withDirectives(vue.createElementVNode(
"input",
{
id: "username",
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => $setup.username = $event),
type: "text",
placeholder: "请输入账号/邮箱/手机号",
class: vue.normalizeClass({ "error": $setup.usernameError }),
onInput: _cache[1] || (_cache[1] = ($event) => $setup.clearError("username"))
},
null,
34
/* CLASS, NEED_HYDRATION */
), [
[vue.vModelText, $setup.username]
]),
$setup.usernameError ? (vue.openBlock(), vue.createElementBlock(
"div",
{
key: 0,
class: "error-message"
},
vue.toDisplayString($setup.usernameError),
1
/* TEXT */
)) : vue.createCommentVNode("v-if", true)
]),
vue.createElementVNode("div", { class: "form-group" }, [
vue.createElementVNode("label", { for: "password" }, "密码"),
vue.createElementVNode("div", { class: "password-input" }, [
vue.withDirectives(vue.createElementVNode("input", {
id: "password",
"onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => $setup.password = $event),
type: $setup.showPassword ? "text" : "password",
placeholder: "请输入密码",
class: vue.normalizeClass({ "error": $setup.passwordError }),
onInput: _cache[3] || (_cache[3] = ($event) => $setup.clearError("password")),
onKeyup: vue.withKeys($setup.handleLogin, ["enter"])
}, null, 42, ["type"]), [
[vue.vModelDynamic, $setup.password]
]),
vue.createElementVNode("button", {
type: "button",
class: "toggle-password",
onClick: _cache[4] || (_cache[4] = ($event) => $setup.showPassword = !$setup.showPassword)
}, [
$setup.showPassword ? (vue.openBlock(), vue.createElementBlock("span", { key: 0 }, "🙈")) : (vue.openBlock(), vue.createElementBlock("span", { key: 1 }, "👁️"))
])
]),
$setup.passwordError ? (vue.openBlock(), vue.createElementBlock(
"div",
{
key: 0,
class: "error-message"
},
vue.toDisplayString($setup.passwordError),
1
/* TEXT */
)) : vue.createCommentVNode("v-if", true)
]),
vue.createElementVNode("div", { class: "form-options" }, [
vue.createElementVNode("label", {
class: "remember-me",
onClick: $setup.toggleRememberMe
}, [
vue.createElementVNode("div", { class: "custom-checkbox-wrapper" }, [
vue.createElementVNode(
"div",
{
class: vue.normalizeClass(["custom-checkbox", { "checked": $setup.rememberMe }])
},
[
$setup.rememberMe ? (vue.openBlock(), vue.createElementBlock("span", { key: 0 }, "✓")) : vue.createCommentVNode("v-if", true)
],
2
/* CLASS */
)
]),
vue.createElementVNode("span", null, "记住账号")
])
]),
vue.createElementVNode("button", {
class: "login-btn",
onClick: $setup.handleLogin,
disabled: $setup.isLoggingIn
}, [
$setup.isLoggingIn ? (vue.openBlock(), vue.createElementBlock("span", { key: 0 }, "⏳")) : (vue.openBlock(), vue.createElementBlock("span", { key: 1 }, "🔑")),
vue.createTextVNode(
" " + vue.toDisplayString($setup.isLoggingIn ? "登录中..." : "立即登录"),
1
/* TEXT */
)
], 8, ["disabled"]),
$setup.loginError ? (vue.openBlock(), vue.createElementBlock("div", {
key: 0,
class: "login-error"
}, [
vue.createElementVNode("span", { class: "error-icon" }, "⚠"),
vue.createTextVNode(
" " + vue.toDisplayString($setup.loginError),
1
/* TEXT */
)
])) : vue.createCommentVNode("v-if", true),
$setup.redirectUrl ? (vue.openBlock(), vue.createElementBlock("div", {
key: 1,
class: "redirect-section"
}, [
vue.createElementVNode("div", { class: "success-message" }, [
vue.createElementVNode("span", { class: "success-icon" }, "✅"),
vue.createTextVNode(" 登录成功!正在为您跳转... ")
])
])) : vue.createCommentVNode("v-if", true)
])
])
]);
}
const PagesLightThemeLightTheme = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["render", _sfc_render$2], ["__scopeId", "data-v-68542e3f"], ["__file", "D:/Projects/intelligentProject-phone/pages/light-theme/light-theme.vue"]]);
const _sfc_main$2 = {
__name: "index",
setup(__props, { expose: __expose }) {
__expose();
const url = vue.ref("https://ws.yuxindazhineng.com");
function openExternalLink() {
plus.runtime.openURL(url.value);
}
const handleAccessClick = () => {
setTimeout(() => {
window.location.href = url.value;
}, 1e3);
};
const handleDirectLinkClick = (e) => {
e.preventDefault();
if (loadingElement.value) {
loadingElement.value.style.display = "block";
}
setTimeout(() => {
window.location.href = url.value;
}, 500);
};
vue.onMounted(() => {
formatAppLog("log", "at pages/index/index.vue:79", "组件已挂载DOM元素可用");
});
const __returned__ = { url, openExternalLink, handleAccessClick, handleDirectLinkClick, ref: vue.ref, onMounted: vue.onMounted };
Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
return __returned__;
}
};
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
return vue.openBlock(), vue.createElementBlock("div", { class: "main-view" }, [
vue.createElementVNode("div", { class: "container" }, [
vue.createElementVNode("div", { class: "logo" }, [
vue.createElementVNode("image", {
src: _imports_0,
alt: "YXD"
})
]),
vue.createElementVNode("h1", null, "访问 YXD 智能应用"),
vue.createElementVNode("p", { class: "description" }, "点击下方按钮跳转至浏览器访问 YXD 智能应用平台,体验智能服务。"),
vue.createElementVNode("div", { class: "url-display" }, [
vue.createElementVNode("input", {
placeholder: "请输入网址",
value: $setup.url
}, null, 8, ["value"])
]),
vue.createElementVNode(
"button",
{
class: "access-btn",
ref: "accessButton",
onClick: $setup.openExternalLink
},
[
vue.createElementVNode("i", { class: "fas fa-external-link-alt" }),
vue.createTextVNode(" 立即访问 ")
],
512
/* NEED_PATCH */
)
])
]);
}
const PagesIndexIndex = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$1], ["__scopeId", "data-v-1cf27b2a"], ["__file", "D:/Projects/intelligentProject-phone/pages/index/index.vue"]]);
const _sfc_main$1 = {
__name: "night-theme",
setup(__props, { expose: __expose }) {
__expose();
const username = vue.ref("");
const password = vue.ref("");
const rememberMe = vue.ref(false);
const showPassword = vue.ref(false);
const isLoggingIn = vue.ref(false);
const redirectUrl = vue.ref("");
const copySuccess = vue.ref(false);
const usernameError = vue.ref("");
const passwordError = vue.ref("");
const loginError = vue.ref("");
const toggleRememberMe = () => {
rememberMe.value = !rememberMe.value;
formatAppLog("log", "at pages/night-theme/night-theme.vue:109", "触发toggleRememberMe");
};
const mockLoginApi = (user, pwd) => {
return new Promise((resolve, reject) => {
setTimeout(() => {
if (user && pwd) {
resolve({
success: true,
redirectUrl: "https://ws.yuxindazhineng.com/",
userInfo: {
username: user,
name: "用户" + user.substring(0, 3)
}
});
} else {
reject({
success: false,
message: "账号或密码错误"
});
}
}, 1500);
});
};
const validateForm = () => {
let isValid = true;
usernameError.value = "";
passwordError.value = "";
if (!username.value.trim()) {
usernameError.value = "请输入账号";
isValid = false;
}
if (!password.value) {
passwordError.value = "请输入密码";
isValid = false;
} else if (password.value.length < 6) {
passwordError.value = "密码至少6位字符";
isValid = false;
}
return isValid;
};
const clearError = (field) => {
if (field === "username") {
usernameError.value = "";
} else if (field === "password") {
passwordError.value = "";
}
loginError.value = "";
};
const handleLogin = async () => {
if (!validateForm()) {
return;
}
isLoggingIn.value = true;
loginError.value = "";
try {
const response = await mockLoginApi(username.value, password.value);
if (response.success) {
if (rememberMe.value) {
uni.setStorageSync("yxd_username", username.value);
} else {
uni.removeStorageSync("yxd_username");
}
redirectUrl.value = response.redirectUrl;
setTimeout(() => {
openExternalLink();
}, 2e3);
}
} catch (error) {
loginError.value = error.message || "登录失败,请检查账号密码";
} finally {
isLoggingIn.value = false;
}
};
function openExternalLink() {
if (!redirectUrl.value)
return;
plus.runtime.openURL(redirectUrl.value);
}
const copyToClipboard = () => {
if (!redirectUrl.value)
return;
uni.setClipboardData({
data: redirectUrl.value,
success: () => {
copySuccess.value = true;
setTimeout(() => {
copySuccess.value = false;
}, 2e3);
}
});
};
vue.onMounted(() => {
const savedUsername = uni.getStorageSync("yxd_username");
if (savedUsername) {
username.value = savedUsername;
rememberMe.value = true;
}
formatAppLog("log", "at pages/night-theme/night-theme.vue:267", "登录组件已挂载");
});
const __returned__ = { username, password, rememberMe, showPassword, isLoggingIn, redirectUrl, copySuccess, usernameError, passwordError, loginError, toggleRememberMe, mockLoginApi, validateForm, clearError, handleLogin, openExternalLink, copyToClipboard, ref: vue.ref, onMounted: vue.onMounted };
Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
return __returned__;
}
};
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return vue.openBlock(), vue.createElementBlock("div", { class: "main-view" }, [
vue.createElementVNode("div", { class: "container" }, [
vue.createElementVNode("div", { class: "logo" }, [
vue.createElementVNode("image", {
src: _imports_0,
alt: "YXD"
})
]),
vue.createElementVNode("h1", null, "登录 YXD 智能应用"),
vue.createElementVNode("div", { class: "login-form" }, [
vue.createElementVNode("div", { class: "form-group" }, [
vue.createElementVNode("label", { for: "username" }, "账号"),
vue.withDirectives(vue.createElementVNode(
"input",
{
id: "username",
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => $setup.username = $event),
type: "text",
placeholder: "请输入账号/邮箱/手机号",
class: vue.normalizeClass({ "error": $setup.usernameError }),
onInput: _cache[1] || (_cache[1] = ($event) => $setup.clearError("username"))
},
null,
34
/* CLASS, NEED_HYDRATION */
), [
[vue.vModelText, $setup.username]
]),
$setup.usernameError ? (vue.openBlock(), vue.createElementBlock(
"div",
{
key: 0,
class: "error-message"
},
vue.toDisplayString($setup.usernameError),
1
/* TEXT */
)) : vue.createCommentVNode("v-if", true)
]),
vue.createElementVNode("div", { class: "form-group" }, [
vue.createElementVNode("label", { for: "password" }, "密码"),
vue.createElementVNode("div", { class: "password-input" }, [
vue.withDirectives(vue.createElementVNode("input", {
id: "password",
"onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => $setup.password = $event),
type: $setup.showPassword ? "text" : "password",
placeholder: "请输入密码",
class: vue.normalizeClass({ "error": $setup.passwordError }),
onInput: _cache[3] || (_cache[3] = ($event) => $setup.clearError("password")),
onKeyup: vue.withKeys($setup.handleLogin, ["enter"])
}, null, 42, ["type"]), [
[vue.vModelDynamic, $setup.password]
]),
vue.createElementVNode("button", {
type: "button",
class: "toggle-password",
onClick: _cache[4] || (_cache[4] = ($event) => $setup.showPassword = !$setup.showPassword)
}, [
$setup.showPassword ? (vue.openBlock(), vue.createElementBlock("span", { key: 0 }, "🙈")) : (vue.openBlock(), vue.createElementBlock("span", { key: 1 }, "👁️"))
])
]),
$setup.passwordError ? (vue.openBlock(), vue.createElementBlock(
"div",
{
key: 0,
class: "error-message"
},
vue.toDisplayString($setup.passwordError),
1
/* TEXT */
)) : vue.createCommentVNode("v-if", true)
]),
vue.createElementVNode("div", { class: "form-options" }, [
vue.createElementVNode("label", {
class: "remember-me",
onClick: $setup.toggleRememberMe
}, [
vue.createElementVNode("div", { class: "custom-checkbox-wrapper" }, [
vue.createElementVNode(
"div",
{
class: vue.normalizeClass(["custom-checkbox", { "checked": $setup.rememberMe }])
},
[
$setup.rememberMe ? (vue.openBlock(), vue.createElementBlock("span", { key: 0 }, "✓")) : vue.createCommentVNode("v-if", true)
],
2
/* CLASS */
)
]),
vue.createElementVNode("span", null, "记住账号")
])
]),
vue.createElementVNode("button", {
class: "login-btn",
onClick: $setup.handleLogin,
disabled: $setup.isLoggingIn
}, [
$setup.isLoggingIn ? (vue.openBlock(), vue.createElementBlock("span", { key: 0 }, "⏳")) : (vue.openBlock(), vue.createElementBlock("span", { key: 1 }, "🔑")),
vue.createTextVNode(
" " + vue.toDisplayString($setup.isLoggingIn ? "登录中..." : "立即登录"),
1
/* TEXT */
)
], 8, ["disabled"]),
$setup.loginError ? (vue.openBlock(), vue.createElementBlock("div", {
key: 0,
class: "login-error"
}, [
vue.createElementVNode("span", null, "⚠️"),
vue.createTextVNode(
" " + vue.toDisplayString($setup.loginError),
1
/* TEXT */
)
])) : vue.createCommentVNode("v-if", true),
$setup.redirectUrl ? (vue.openBlock(), vue.createElementBlock("div", {
key: 1,
class: "redirect-section"
}, [
vue.createElementVNode("div", { class: "success-message" }, [
vue.createElementVNode("span", null, "✅"),
vue.createTextVNode(" 登录成功!正在为您跳转... ")
])
])) : vue.createCommentVNode("v-if", true)
])
])
]);
}
const PagesNightThemeNightTheme = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render], ["__scopeId", "data-v-197fbf56"], ["__file", "D:/Projects/intelligentProject-phone/pages/night-theme/night-theme.vue"]]);
__definePage("pages/light-theme/light-theme", PagesLightThemeLightTheme);
__definePage("pages/index/index", PagesIndexIndex);
__definePage("pages/night-theme/night-theme", PagesNightThemeNightTheme);
const _sfc_main = {
onLaunch: function() {
formatAppLog("log", "at App.vue:5", "App Launch");
},
onShow: function() {
formatAppLog("log", "at App.vue:8", "App Show");
},
onHide: function() {
formatAppLog("log", "at App.vue:11", "App Hide");
}
};
const App = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "D:/Projects/intelligentProject-phone/App.vue"]]);
function createApp() {
const app = vue.createVueApp(App);
return {
app
};
}
const { app: __app__, Vuex: __Vuex__, Pinia: __Pinia__ } = createApp();
uni.Vuex = __Vuex__;
uni.Pinia = __Pinia__;
__app__.provide("__globalStyles", __uniConfig.styles);
__app__._component.mpType = "app";
__app__._component.render = () => {
};
__app__.mount("#app");
})(Vue);