更新若干
This commit is contained in:
1 parent
54c90072fb
commit
5682069553
59 files changed
+3753
-1557
No files matched your search
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="user-profile">
|
||||
<div class="profile-page" v-loading="!userInfo">
|
||||
<input
|
||||
ref="avatarInputRef"
|
||||
type="file"
|
||||
@@ -7,32 +7,150 @@
|
||||
class="avatar-file-input"
|
||||
@change="onAvatarPicked"
|
||||
/>
|
||||
<el-row :gutter="20">
|
||||
<el-col :xs="24" :sm="24" :md="8" :lg="8" :xl="8">
|
||||
<ProfileCard
|
||||
:user-info="userInfo"
|
||||
@change-avatar="handleAvatarChange"
|
||||
/>
|
||||
|
||||
<QuickActions @logout="handleLogout" />
|
||||
<div class="profile-hero">
|
||||
<div class="hero-deco hero-deco-a"></div>
|
||||
<div class="hero-deco hero-deco-b"></div>
|
||||
<div class="hero-main">
|
||||
<div class="avatar-wrap" @click="handleAvatarChange" :title="avatarUploading ? '上传中...' : '点击更换头像'">
|
||||
<el-avatar :size="96" :src="userInfo?.avatar || ''" class="hero-avatar">
|
||||
{{ (userInfo?.name || userInfo?.account || "U").charAt(0).toUpperCase() }}
|
||||
</el-avatar>
|
||||
<span class="avatar-badge"><el-icon><Camera /></el-icon></span>
|
||||
</div>
|
||||
<div class="hero-info">
|
||||
<div class="hero-name-row">
|
||||
<h1 class="hero-name">{{ userInfo?.name || userInfo?.account || "用户" }}</h1>
|
||||
<el-tag :type="userInfo?.status === 1 ? 'success' : 'danger'" effect="dark" size="small" round>
|
||||
{{ userInfo?.status === 1 ? "正常" : "禁用" }}
|
||||
</el-tag>
|
||||
</div>
|
||||
<p class="hero-account">@{{ userInfo?.account || "-" }}</p>
|
||||
<div class="hero-meta" v-if="subTitle">
|
||||
<span v-if="department"><el-icon><OfficeBuilding /></el-icon>{{ department }}</span>
|
||||
<span v-if="position"><el-icon><Postcard /></el-icon>{{ position }}</span>
|
||||
<span v-if="roleName"><el-icon><User /></el-icon>{{ roleName }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="hero-actions">
|
||||
<el-button type="primary" round :icon="Edit" @click="handleEditProfile">编辑资料</el-button>
|
||||
<el-button round :icon="SwitchButton" @click="handleLogout">退出登录</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="hero-stats">
|
||||
<div class="stat-item">
|
||||
<span class="stat-value">{{ userInfo?.login_count ?? 0 }}</span>
|
||||
<span class="stat-label">累计登录</span>
|
||||
</div>
|
||||
<div class="stat-divider"></div>
|
||||
<div class="stat-item">
|
||||
<span class="stat-value stat-date">{{ formatDate(userInfo?.create_time) }}</span>
|
||||
<span class="stat-label">注册时间</span>
|
||||
</div>
|
||||
<div class="stat-divider"></div>
|
||||
<div class="stat-item">
|
||||
<span class="stat-value">{{ securityScore }}/3</span>
|
||||
<span class="stat-label">安全完善度</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<el-row :gutter="20" class="profile-body">
|
||||
<el-col :xs="24" :sm="24" :md="9" :lg="8" :xl="8">
|
||||
<div class="panel">
|
||||
<div class="panel-head">
|
||||
<span class="panel-icon icon-blue"><el-icon><User /></el-icon></span>
|
||||
<h3 class="panel-title">账户信息</h3>
|
||||
</div>
|
||||
<div class="info-list">
|
||||
<div class="info-item">
|
||||
<span class="info-label">账号</span>
|
||||
<span class="info-value">{{ userInfo?.account || "-" }}</span>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<span class="info-label">手机号</span>
|
||||
<span class="info-value" :class="{ 'value-empty': !userInfo?.phone }">{{ userInfo?.phone || "未绑定" }}</span>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<span class="info-label">邮箱</span>
|
||||
<span class="info-value" :class="{ 'value-empty': !userInfo?.email }">{{ userInfo?.email || "未绑定" }}</span>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<span class="info-label">性别</span>
|
||||
<span class="info-value">{{ getSexText(userInfo?.sex) }}</span>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<span class="info-label">生日</span>
|
||||
<span class="info-value">{{ userInfo?.birth || "-" }}</span>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<span class="info-label">最后登录</span>
|
||||
<span class="info-value">{{ userInfo?.last_login_ip || "-" }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel">
|
||||
<div class="panel-head">
|
||||
<span class="panel-icon icon-green"><el-icon><Lock /></el-icon></span>
|
||||
<h3 class="panel-title">安全中心</h3>
|
||||
<span class="panel-extra">已完善 {{ securityScore }}/3 项</span>
|
||||
</div>
|
||||
<div class="security-list">
|
||||
<div class="security-item">
|
||||
<span class="security-ico ico-blue"><el-icon><Lock /></el-icon></span>
|
||||
<div class="security-text">
|
||||
<div class="security-title">登录密码</div>
|
||||
<div class="security-desc">已设置 · 定期更换更安全</div>
|
||||
</div>
|
||||
<el-button type="primary" link size="small" @click="handleChangePassword">修改</el-button>
|
||||
</div>
|
||||
<div class="security-item">
|
||||
<span class="security-ico" :class="userInfo?.phone ? 'ico-green' : 'ico-gray'"><el-icon><Iphone /></el-icon></span>
|
||||
<div class="security-text">
|
||||
<div class="security-title">手机绑定</div>
|
||||
<div class="security-desc">{{ userInfo?.phone ? maskPhone(userInfo.phone) : "未绑定 · 建议绑定" }}</div>
|
||||
</div>
|
||||
<el-button type="primary" link size="small" @click="bindPhoneDialogVisible = true">
|
||||
{{ userInfo?.phone ? "更换" : "绑定" }}
|
||||
</el-button>
|
||||
</div>
|
||||
<div class="security-item">
|
||||
<span class="security-ico" :class="userInfo?.email ? 'ico-green' : 'ico-gray'"><el-icon><Message /></el-icon></span>
|
||||
<div class="security-text">
|
||||
<div class="security-title">邮箱绑定</div>
|
||||
<div class="security-desc">{{ userInfo?.email ? maskEmail(userInfo.email) : "未绑定 · 建议绑定" }}</div>
|
||||
</div>
|
||||
<el-button type="primary" link size="small" @click="bindEmailDialogVisible = true">
|
||||
{{ userInfo?.email ? "更换" : "绑定" }}
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</el-col>
|
||||
|
||||
<el-col :xs="24" :sm="24" :md="16" :lg="16" :xl="16">
|
||||
<DetailCard
|
||||
:user-info="userInfo"
|
||||
:format-date="formatDate"
|
||||
:get-sex-text="getSexText"
|
||||
@edit="handleEditProfile"
|
||||
/>
|
||||
|
||||
<SecurityCard
|
||||
:user-info="userInfo"
|
||||
@change-password="handleChangePassword"
|
||||
@bind-phone="bindPhoneDialogVisible = true"
|
||||
@bind-email="bindEmailDialogVisible = true"
|
||||
/>
|
||||
<el-col :xs="24" :sm="24" :md="15" :lg="16" :xl="16">
|
||||
<div class="panel">
|
||||
<div class="panel-head">
|
||||
<span class="panel-icon icon-purple"><el-icon><Tickets /></el-icon></span>
|
||||
<h3 class="panel-title">个人简介</h3>
|
||||
<el-button type="primary" link size="small" :icon="Edit" @click="handleEditProfile">编辑</el-button>
|
||||
</div>
|
||||
<el-descriptions :column="2" border class="profile-desc">
|
||||
<el-descriptions-item label="姓名">{{ userInfo?.name || "-" }}</el-descriptions-item>
|
||||
<el-descriptions-item label="账号">{{ userInfo?.account || "-" }}</el-descriptions-item>
|
||||
<el-descriptions-item label="性别">{{ getSexText(userInfo?.sex) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="生日">{{ userInfo?.birth || "-" }}</el-descriptions-item>
|
||||
<el-descriptions-item label="手机号">{{ userInfo?.phone || "-" }}</el-descriptions-item>
|
||||
<el-descriptions-item label="邮箱">{{ userInfo?.email || "-" }}</el-descriptions-item>
|
||||
<el-descriptions-item label="注册时间">{{ formatDate(userInfo?.create_time) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="最后登录IP">{{ userInfo?.last_login_ip || "-" }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</div>
|
||||
|
||||
<div class="panel wechat-panel">
|
||||
<WechatBindCard />
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
@@ -42,19 +160,13 @@
|
||||
:user-id="authStore.user?.id"
|
||||
@saved="fetchUserInfo"
|
||||
/>
|
||||
|
||||
<ChangePasswordDialog
|
||||
v-model="passwordDialogVisible"
|
||||
:user-id="authStore.user?.id"
|
||||
/>
|
||||
|
||||
<ChangePasswordDialog v-model="passwordDialogVisible" :user-id="authStore.user?.id" />
|
||||
<BindPhoneDialog
|
||||
v-model="bindPhoneDialogVisible"
|
||||
:user-info="userInfo"
|
||||
:user-id="authStore.user?.id"
|
||||
@saved="fetchUserInfo"
|
||||
/>
|
||||
|
||||
<BindEmailDialog
|
||||
v-model="bindEmailDialogVisible"
|
||||
:user-info="userInfo"
|
||||
@@ -65,15 +177,13 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted } from "vue";
|
||||
import { ref, computed, onMounted } from "vue";
|
||||
import { ElMessage, ElMessageBox } from "element-plus";
|
||||
import { Camera, Edit, SwitchButton, User, Lock, Iphone, Message, OfficeBuilding, Postcard, Tickets } from "@element-plus/icons-vue";
|
||||
import { getUserInfo, uploadAvatar } from "@/api/user";
|
||||
import { useAuthStore } from "@/stores/auth";
|
||||
import { formatDateTime as formatDate } from "@/utils/datetime";
|
||||
import ProfileCard from "./components/ProfileCard.vue";
|
||||
import QuickActions from "./components/QuickActions.vue";
|
||||
import DetailCard from "./components/DetailCard.vue";
|
||||
import SecurityCard from "./components/SecurityCard.vue";
|
||||
import { getCurrentUserProfile } from "@/api/login";
|
||||
import EditProfileDialog from "./components/EditProfileDialog.vue";
|
||||
import ChangePasswordDialog from "./components/ChangePasswordDialog.vue";
|
||||
import BindPhoneDialog from "./components/BindPhoneDialog.vue";
|
||||
@@ -88,15 +198,35 @@ const passwordDialogVisible = ref(false);
|
||||
const bindPhoneDialogVisible = ref(false);
|
||||
const bindEmailDialogVisible = ref(false);
|
||||
|
||||
const extraProfile = ref({ department: "", position: "", role_name: "" });
|
||||
const department = computed(() => extraProfile.value.department || "");
|
||||
const position = computed(() => extraProfile.value.position || "");
|
||||
const roleName = computed(() => extraProfile.value.role_name || "");
|
||||
const subTitle = computed(() => department.value || position.value || roleName.value);
|
||||
|
||||
const securityScore = computed(() => {
|
||||
const u = userInfo.value || {};
|
||||
return 1 + (u.phone ? 1 : 0) + (u.email ? 1 : 0);
|
||||
});
|
||||
|
||||
const getSexText = (sex) => {
|
||||
const map = {
|
||||
0: "保密",
|
||||
1: "男",
|
||||
2: "女"
|
||||
};
|
||||
const map = { 0: "保密", 1: "男", 2: "女" };
|
||||
return map[sex] || "-";
|
||||
};
|
||||
|
||||
const maskPhone = (phone) => {
|
||||
const s = String(phone || "");
|
||||
return s.length >= 7 ? `${s.slice(0, 3)}****${s.slice(-4)}` : s;
|
||||
};
|
||||
|
||||
const maskEmail = (email) => {
|
||||
const s = String(email || "");
|
||||
const at = s.indexOf("@");
|
||||
if (at <= 0) return s;
|
||||
const name = s.slice(0, at);
|
||||
return `${name.slice(0, Math.min(2, name.length))}***${s.slice(at)}`;
|
||||
};
|
||||
|
||||
const fetchUserInfo = async () => {
|
||||
try {
|
||||
const userId = authStore.user?.id;
|
||||
@@ -105,22 +235,29 @@ const fetchUserInfo = async () => {
|
||||
return;
|
||||
}
|
||||
const res = await getUserInfo(userId);
|
||||
if (res.code === 200) {
|
||||
userInfo.value = res.data;
|
||||
}
|
||||
if (res.code === 200) userInfo.value = res.data;
|
||||
} catch (error) {
|
||||
console.error("获取用户信息失败", error);
|
||||
ElMessage.error("获取用户信息失败");
|
||||
}
|
||||
};
|
||||
|
||||
const handleEditProfile = () => {
|
||||
editDialogVisible.value = true;
|
||||
const fetchExtraProfile = async () => {
|
||||
try {
|
||||
const res = await getCurrentUserProfile();
|
||||
if (res && res.code === 200 && res.data) {
|
||||
extraProfile.value = {
|
||||
department: res.data.department || "",
|
||||
position: res.data.position || "",
|
||||
role_name: res.data.role_name || "",
|
||||
};
|
||||
}
|
||||
} catch {
|
||||
}
|
||||
};
|
||||
|
||||
const handleChangePassword = () => {
|
||||
passwordDialogVisible.value = true;
|
||||
};
|
||||
const handleEditProfile = () => { editDialogVisible.value = true; };
|
||||
const handleChangePassword = () => { passwordDialogVisible.value = true; };
|
||||
|
||||
const avatarInputRef = ref(null);
|
||||
const avatarUploading = ref(false);
|
||||
@@ -149,7 +286,6 @@ async function onAvatarPicked(event) {
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("file", file);
|
||||
|
||||
avatarUploading.value = true;
|
||||
try {
|
||||
const res = await uploadAvatar(formData);
|
||||
@@ -173,28 +309,15 @@ const handleLogout = () => {
|
||||
ElMessageBox.confirm("确定要退出登录吗?", "提示", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning"
|
||||
type: "warning",
|
||||
}).then(async () => {
|
||||
try {
|
||||
await authStore.logout(authStore.user?.id);
|
||||
} catch (error) {
|
||||
console.error("退出登录接口调用失败:", error);
|
||||
}
|
||||
|
||||
localStorage.removeItem("active_tab");
|
||||
localStorage.removeItem("1123567809876");
|
||||
localStorage.removeItem("tabs_list");
|
||||
localStorage.removeItem("token");
|
||||
localStorage.removeItem("user");
|
||||
localStorage.removeItem("tenant");
|
||||
|
||||
sessionStorage.removeItem("active_tab");
|
||||
sessionStorage.removeItem("456");
|
||||
sessionStorage.removeItem("tabs_list");
|
||||
sessionStorage.removeItem("token");
|
||||
sessionStorage.removeItem("user");
|
||||
sessionStorage.removeItem("tenant");
|
||||
|
||||
["active_tab", "1123567809876", "tabs_list", "token", "user", "tenant"].forEach((k) => localStorage.removeItem(k));
|
||||
["active_tab", "456", "tabs_list", "token", "user", "tenant"].forEach((k) => sessionStorage.removeItem(k));
|
||||
const clearCookie = (name) => {
|
||||
document.cookie = `${name}=;expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/`;
|
||||
document.cookie = `${name}=;expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/; domain=`;
|
||||
@@ -203,22 +326,11 @@ const handleLogout = () => {
|
||||
document.cookie = `${name}=;expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/; domain=${location.hostname}`;
|
||||
}
|
||||
};
|
||||
|
||||
clearCookie("PHPSESSID");
|
||||
clearCookie("token");
|
||||
clearCookie("user");
|
||||
clearCookie("tenant");
|
||||
|
||||
const cookies = document.cookie.split(";");
|
||||
for (let i = 0; i < cookies.length; i++) {
|
||||
const cookie = cookies[i].trim();
|
||||
const eqPos = cookie.indexOf("=");
|
||||
const name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie;
|
||||
if (name) {
|
||||
clearCookie(name);
|
||||
}
|
||||
}
|
||||
|
||||
["PHPSESSID", "token", "user", "tenant"].forEach(clearCookie);
|
||||
document.cookie.split(";").forEach((cookie) => {
|
||||
const name = cookie.trim().split("=")[0];
|
||||
if (name) clearCookie(name);
|
||||
});
|
||||
authStore.clearToken();
|
||||
ElMessage.success("已退出登录");
|
||||
}).catch(() => {});
|
||||
@@ -226,15 +338,242 @@ const handleLogout = () => {
|
||||
|
||||
onMounted(() => {
|
||||
fetchUserInfo();
|
||||
fetchExtraProfile();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.user-profile {
|
||||
.profile-page {
|
||||
padding: 0;
|
||||
|
||||
.avatar-file-input {
|
||||
display: none;
|
||||
min-height: 100%;
|
||||
}
|
||||
|
||||
.avatar-file-input { display: none; }
|
||||
|
||||
/* 顶部横幅 */
|
||||
.profile-hero {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
border-radius: 16px;
|
||||
padding: 32px 36px 0;
|
||||
color: #fff;
|
||||
background: linear-gradient(120deg, #2563eb 0%, #3b82f6 45%, #6366f1 100%);
|
||||
box-shadow: 0 10px 30px rgba(37, 99, 235, 0.18);
|
||||
|
||||
.hero-deco {
|
||||
position: absolute;
|
||||
border-radius: 50%;
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
pointer-events: none;
|
||||
}
|
||||
.hero-deco-a { width: 260px; height: 260px; right: -60px; top: -110px; }
|
||||
.hero-deco-b { width: 180px; height: 180px; right: 160px; bottom: -90px; background: rgba(255, 255, 255, 0.06); }
|
||||
|
||||
.hero-main {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 24px;
|
||||
flex-wrap: wrap;
|
||||
|
||||
.avatar-wrap {
|
||||
position: relative;
|
||||
cursor: pointer;
|
||||
flex-shrink: 0;
|
||||
|
||||
.hero-avatar {
|
||||
border: 3px solid rgba(255, 255, 255, 0.85);
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
font-size: 36px;
|
||||
font-weight: 700;
|
||||
box-shadow: 0 6px 18px rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
|
||||
.avatar-badge {
|
||||
position: absolute;
|
||||
right: -2px;
|
||||
bottom: -2px;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
border-radius: 50%;
|
||||
background: #fff;
|
||||
color: #2563eb;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 15px;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
|
||||
transition: transform 0.2s;
|
||||
}
|
||||
&:hover .avatar-badge { transform: scale(1.1); }
|
||||
}
|
||||
|
||||
.hero-info {
|
||||
flex: 1;
|
||||
min-width: 220px;
|
||||
|
||||
.hero-name-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
|
||||
.hero-name { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: 0.5px; }
|
||||
}
|
||||
.hero-account { margin: 6px 0 0; font-size: 14px; color: rgba(255, 255, 255, 0.82); }
|
||||
.hero-meta {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 14px;
|
||||
margin-top: 12px;
|
||||
span { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: rgba(255, 255, 255, 0.9); }
|
||||
}
|
||||
}
|
||||
|
||||
.hero-actions {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
flex-shrink: 0;
|
||||
:deep(.el-button--primary) {
|
||||
background: #fff;
|
||||
color: #2563eb;
|
||||
border-color: #fff;
|
||||
font-weight: 600;
|
||||
}
|
||||
:deep(.el-button:not(.el-button--primary)) {
|
||||
background: rgba(255, 255, 255, 0.16);
|
||||
color: #fff;
|
||||
border-color: rgba(255, 255, 255, 0.5);
|
||||
&:hover { background: rgba(255, 255, 255, 0.26); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.hero-stats {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 36px;
|
||||
margin-top: 28px;
|
||||
padding: 18px 0 20px;
|
||||
border-top: 1px solid rgba(255, 255, 255, 0.2);
|
||||
|
||||
.stat-item { display: flex; flex-direction: column; gap: 4px; }
|
||||
.stat-value { font-size: 22px; font-weight: 700; }
|
||||
.stat-value.stat-date { font-size: 16px; }
|
||||
.stat-label { font-size: 12px; color: rgba(255, 255, 255, 0.78); }
|
||||
.stat-divider { width: 1px; height: 30px; background: rgba(255, 255, 255, 0.25); }
|
||||
}
|
||||
}
|
||||
|
||||
.profile-body { margin-top: 20px; }
|
||||
|
||||
.panel {
|
||||
background: var(--el-bg-color);
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: 14px;
|
||||
padding: 20px 22px;
|
||||
margin-bottom: 20px;
|
||||
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
|
||||
transition: box-shadow 0.3s;
|
||||
&:hover { box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08); }
|
||||
|
||||
.panel-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
margin-bottom: 18px;
|
||||
padding-bottom: 14px;
|
||||
border-bottom: 1px solid var(--el-border-color-lighter);
|
||||
|
||||
.panel-title { margin: 0; font-size: 16px; font-weight: 600; color: var(--el-text-color-primary); flex: 1; }
|
||||
.panel-extra { font-size: 12px; color: var(--el-text-color-secondary); }
|
||||
}
|
||||
|
||||
.panel-icon {
|
||||
width: 34px;
|
||||
height: 34px;
|
||||
border-radius: 9px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 18px;
|
||||
}
|
||||
.icon-blue { background: #eaf2ff; color: #2563eb; }
|
||||
.icon-green { background: #e8f8f0; color: #16a34a; }
|
||||
.icon-purple { background: #f1ecff; color: #7c3aed; }
|
||||
}
|
||||
|
||||
.info-list {
|
||||
.info-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
padding: 11px 0;
|
||||
border-bottom: 1px dashed var(--el-border-color-lighter);
|
||||
&:last-child { border-bottom: none; }
|
||||
.info-label { font-size: 13px; color: var(--el-text-color-secondary); flex-shrink: 0; }
|
||||
.info-value { font-size: 14px; font-weight: 500; color: var(--el-text-color-primary); text-align: right; word-break: break-all; }
|
||||
.info-value.value-empty { color: var(--el-text-color-placeholder); font-weight: 400; }
|
||||
}
|
||||
}
|
||||
|
||||
.security-list {
|
||||
.security-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 12px;
|
||||
border-radius: 10px;
|
||||
margin-bottom: 10px;
|
||||
background: var(--el-fill-color-lighter);
|
||||
&:last-child { margin-bottom: 0; }
|
||||
.security-ico {
|
||||
width: 38px;
|
||||
height: 38px;
|
||||
border-radius: 10px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 18px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.ico-blue { background: #eaf2ff; color: #2563eb; }
|
||||
.ico-green { background: #e8f8f0; color: #16a34a; }
|
||||
.ico-gray { background: var(--el-fill-color); color: var(--el-text-color-placeholder); }
|
||||
.security-text { flex: 1; min-width: 0; }
|
||||
.security-title { font-size: 14px; font-weight: 600; color: var(--el-text-color-primary); }
|
||||
.security-desc { margin-top: 3px; font-size: 12px; color: var(--el-text-color-secondary); }
|
||||
}
|
||||
}
|
||||
|
||||
.profile-desc {
|
||||
:deep(.el-descriptions__label) { font-weight: 500; color: var(--el-text-color-secondary); }
|
||||
}
|
||||
|
||||
.wechat-panel {
|
||||
:deep(.wechat-bind-card) {
|
||||
margin-top: 0 !important;
|
||||
border: none !important;
|
||||
box-shadow: none !important;
|
||||
background: transparent !important;
|
||||
}
|
||||
:deep(.el-card__header) { padding-left: 0; padding-right: 0; border-bottom-color: var(--el-border-color-lighter); }
|
||||
:deep(.el-card__body) { padding-left: 0; padding-right: 0; }
|
||||
:deep(.card-title) { color: var(--el-text-color-primary); font-size: 16px; font-weight: 600; }
|
||||
:deep(.bound-info p) { color: var(--el-text-color-regular); }
|
||||
:deep(.tip) { color: var(--el-text-color-secondary); }
|
||||
:deep(.guide-list) { color: var(--el-text-color-regular); }
|
||||
:deep(.qr-box) { border-color: var(--el-border-color); }
|
||||
:deep(.qr-empty) { color: var(--el-text-color-placeholder); }
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.profile-hero { padding: 22px 20px 0; }
|
||||
.hero-main { gap: 16px; }
|
||||
.hero-actions { width: 100%; }
|
||||
.hero-stats { gap: 18px; }
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,366 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"server/models"
|
||||
"server/pkg/jwtutil"
|
||||
"server/services"
|
||||
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
)
|
||||
|
||||
// AppCrmProjectController 提供 App 端(uniapp)CRM 项目管理接口。
|
||||
// 与 Web 后台的 /backend/crm/project/* 共用同一套模型、权限与核心逻辑,
|
||||
// 差异仅在于鉴权入口(App/Backend 双端令牌)与响应包装。
|
||||
type AppCrmProjectController struct {
|
||||
AppErpBaseController
|
||||
}
|
||||
|
||||
type crmProjectSavePayload struct {
|
||||
ID uint64 `json:"id"`
|
||||
projectPayload
|
||||
}
|
||||
|
||||
// List GET /api/crm/project/list
|
||||
func (c *AppCrmProjectController) List() {
|
||||
cl, err := c.erpClaims()
|
||||
if c.erpDenied(err) {
|
||||
return
|
||||
}
|
||||
page, pageSize := c.erpPage()
|
||||
tenantID := pipelineTenantID(cl)
|
||||
|
||||
cond := orm.NewCondition().
|
||||
And("tenant_id", tenantID).
|
||||
And("delete_time__isnull", true)
|
||||
cond = crmApplyOwnerScope(cond, cl)
|
||||
|
||||
if kw := c.erpQuery("keyword"); kw != "" {
|
||||
cond = cond.AndCond(orm.NewCondition().
|
||||
Or("project_name__contains", kw).
|
||||
Or("project_no__contains", kw).
|
||||
Or("customer_name__contains", kw).
|
||||
Or("supplier_name__contains", kw))
|
||||
}
|
||||
if st := c.erpQuery("status"); st != "" {
|
||||
cond = cond.And("status", st)
|
||||
}
|
||||
if pt := c.erpQuery("project_type"); pt != "" {
|
||||
if _, err := strconv.Atoi(pt); err == nil {
|
||||
cond = cond.And("project_type", pt)
|
||||
}
|
||||
}
|
||||
if y := c.erpQuery("year"); y != "" {
|
||||
if year, err := strconv.Atoi(y); err == nil && year > 0 {
|
||||
from := time.Date(year, time.January, 1, 0, 0, 0, 0, time.Local)
|
||||
cond = cond.AndCond(orm.NewCondition().
|
||||
And("start_date__gte", from).
|
||||
And("start_date__lt", from.AddDate(1, 0, 0)))
|
||||
}
|
||||
}
|
||||
|
||||
qs := models.Orm.QueryTable(new(models.TenantCrmProject)).SetCond(cond)
|
||||
total, _ := qs.Count()
|
||||
list := make([]models.TenantCrmProject, 0)
|
||||
if total > 0 {
|
||||
if _, err := qs.OrderBy("-start_date", "-id").
|
||||
Limit(pageSize, (page-1)*pageSize).All(&list); err != nil {
|
||||
c.erpFail(500, 500, "查询失败: "+err.Error())
|
||||
return
|
||||
}
|
||||
attachBusinessName(tenantID, list)
|
||||
}
|
||||
c.erpListOK(list, total, page, pageSize, nil)
|
||||
}
|
||||
|
||||
// Detail GET /api/crm/project/detail/:id
|
||||
func (c *AppCrmProjectController) Detail() {
|
||||
cl, err := c.erpClaims()
|
||||
if c.erpDenied(err) {
|
||||
return
|
||||
}
|
||||
id := c.erpPathID()
|
||||
if id == 0 {
|
||||
c.erpFail(400, 400, "无效的ID")
|
||||
return
|
||||
}
|
||||
tenantID := pipelineTenantID(cl)
|
||||
var proj models.TenantCrmProject
|
||||
if err := models.Orm.QueryTable(new(models.TenantCrmProject)).
|
||||
Filter("id", id).Filter("tenant_id", tenantID).
|
||||
Filter("delete_time__isnull", true).One(&proj); err != nil {
|
||||
c.erpFail(404, 404, "项目未找到")
|
||||
return
|
||||
}
|
||||
if !canAccessCrmRecord(cl, proj.OwnerUserID, proj.CreateUserID) {
|
||||
c.erpFail(403, 403, "无权查看该项目数据")
|
||||
return
|
||||
}
|
||||
list := []models.TenantCrmProject{proj}
|
||||
attachBusinessName(tenantID, list)
|
||||
c.erpOk(list[0])
|
||||
}
|
||||
|
||||
// Save POST /api/crm/project/save
|
||||
// id 为 0 时新建,否则更新。
|
||||
func (c *AppCrmProjectController) Save() {
|
||||
cl, err := c.erpClaims()
|
||||
if c.erpDenied(err) {
|
||||
return
|
||||
}
|
||||
var p crmProjectSavePayload
|
||||
if !c.erpBody(&p, false) {
|
||||
return
|
||||
}
|
||||
if strings.TrimSpace(p.ProjectName) == "" {
|
||||
c.erpFail(400, 400, "项目名称不能为空")
|
||||
return
|
||||
}
|
||||
tenantID := pipelineTenantID(cl)
|
||||
if p.ID == 0 {
|
||||
c.createProject(cl, tenantID, &p)
|
||||
return
|
||||
}
|
||||
c.updateProject(cl, tenantID, &p)
|
||||
}
|
||||
|
||||
func (c *AppCrmProjectController) createProject(cl *jwtutil.Claims, tenantID string, p *crmProjectSavePayload) {
|
||||
custIDVal, custRefType, customerName := resolveProjectCustomer(tenantID, p.CustomerRefType, p.CustomerID, p.CustomerName)
|
||||
status := p.Status
|
||||
if status == 0 {
|
||||
status = 1
|
||||
}
|
||||
pt, upstream, downstream, upContact, upPhone, downContact, downPhone := normalizeProjectFields(&p.projectPayload)
|
||||
supplierID, supplierRefType, supplierName := resolveProjectSupplier(tenantID, p.SupplierRefType, p.SupplierID, p.SupplierName)
|
||||
if pt == 1 {
|
||||
supplierID, supplierRefType, supplierName = nil, 0, ""
|
||||
}
|
||||
now := time.Now()
|
||||
proj := models.TenantCrmProject{
|
||||
TenantID: tenantID,
|
||||
ProjectName: strings.TrimSpace(p.ProjectName),
|
||||
ProjectNo: strings.TrimSpace(p.ProjectNo),
|
||||
ProjectType: pt,
|
||||
CustomerID: custIDVal,
|
||||
CustomerRefType: custRefType,
|
||||
CustomerName: customerName,
|
||||
SupplierID: supplierID,
|
||||
SupplierRefType: supplierRefType,
|
||||
SupplierName: supplierName,
|
||||
SupplierIndustry: strings.TrimSpace(p.SupplierIndustry),
|
||||
OwnerUserID: firstNonEmpty(p.OwnerUserID, pipelineUID(cl)),
|
||||
OwnerUserName: firstNonEmpty(p.OwnerUserName, resolveUserName(cl)),
|
||||
Industry: strings.TrimSpace(p.Industry),
|
||||
UpstreamAmount: upstream,
|
||||
DownstreamAmount: downstream,
|
||||
Amount: upstream,
|
||||
Status: status,
|
||||
StartDate: parsePipelineDate(p.StartDate),
|
||||
EndDate: parsePipelineDate(p.EndDate),
|
||||
UpstreamContact: upContact,
|
||||
UpstreamPhone: upPhone,
|
||||
DownstreamContact: downContact,
|
||||
DownstreamPhone: downPhone,
|
||||
ContactPerson: upContact,
|
||||
ContactPhone: upPhone,
|
||||
Address: strings.TrimSpace(p.Address),
|
||||
Remark: p.Remark,
|
||||
CreateUserID: pipelineUID(cl),
|
||||
CreateTime: now,
|
||||
UpdateTime: now,
|
||||
}
|
||||
if crmProjectNameDuplicated(tenantID, proj.ProjectName, proj.CustomerID, proj.CustomerRefType) {
|
||||
c.erpFail(409, 409, "该客户下已存在同名项目(可能由其他同事创建)")
|
||||
return
|
||||
}
|
||||
id, err := models.Orm.Insert(&proj)
|
||||
if err != nil {
|
||||
c.erpFail(500, 500, "创建失败: "+err.Error())
|
||||
return
|
||||
}
|
||||
if cid, err := services.EnsureCrmProjectDocCategory(cl.TenantId, uint64(id), proj.ProjectName, 0); err == nil {
|
||||
proj.DocCategoryID = cid
|
||||
}
|
||||
crmWriteLog(tenantID, 3, uint64(id), "create", "创建项目:"+proj.ProjectName, cl)
|
||||
c.erpOk(map[string]interface{}{"id": id, "doc_category_id": proj.DocCategoryID})
|
||||
}
|
||||
|
||||
func (c *AppCrmProjectController) updateProject(cl *jwtutil.Claims, tenantID string, p *crmProjectSavePayload) {
|
||||
var proj models.TenantCrmProject
|
||||
if err := models.Orm.QueryTable(new(models.TenantCrmProject)).
|
||||
Filter("id", p.ID).Filter("tenant_id", tenantID).
|
||||
Filter("delete_time__isnull", true).One(&proj); err != nil {
|
||||
c.erpFail(404, 404, "项目未找到")
|
||||
return
|
||||
}
|
||||
if !canAccessCrmRecord(cl, proj.OwnerUserID, proj.CreateUserID) {
|
||||
c.erpFail(403, 403, "无权操作该项目数据")
|
||||
return
|
||||
}
|
||||
|
||||
proj.ProjectName = strings.TrimSpace(p.ProjectName)
|
||||
proj.ProjectNo = strings.TrimSpace(p.ProjectNo)
|
||||
if p.CustomerID > 0 {
|
||||
cid, cref, cname := resolveProjectCustomer(tenantID, p.CustomerRefType, p.CustomerID, p.CustomerName)
|
||||
proj.CustomerID = cid
|
||||
proj.CustomerRefType = cref
|
||||
proj.CustomerName = cname
|
||||
} else if strings.TrimSpace(p.CustomerName) != "" {
|
||||
proj.CustomerName = strings.TrimSpace(p.CustomerName)
|
||||
}
|
||||
if strings.TrimSpace(p.OwnerUserID) != "" {
|
||||
proj.OwnerUserID = strings.TrimSpace(p.OwnerUserID)
|
||||
}
|
||||
if strings.TrimSpace(p.OwnerUserName) != "" {
|
||||
proj.OwnerUserName = strings.TrimSpace(p.OwnerUserName)
|
||||
}
|
||||
proj.Industry = strings.TrimSpace(p.Industry)
|
||||
pt, upstream, downstream, upContact, upPhone, downContact, downPhone := normalizeProjectFields(&p.projectPayload)
|
||||
supplierID, supplierRefType, supplierName := resolveProjectSupplier(tenantID, p.SupplierRefType, p.SupplierID, p.SupplierName)
|
||||
if pt == 1 {
|
||||
supplierID, supplierRefType, supplierName = nil, 0, ""
|
||||
}
|
||||
proj.ProjectType = pt
|
||||
proj.SupplierID = supplierID
|
||||
proj.SupplierRefType = supplierRefType
|
||||
proj.SupplierName = supplierName
|
||||
proj.SupplierIndustry = strings.TrimSpace(p.SupplierIndustry)
|
||||
proj.UpstreamAmount = upstream
|
||||
proj.DownstreamAmount = downstream
|
||||
proj.Amount = upstream
|
||||
proj.UpstreamContact = upContact
|
||||
proj.UpstreamPhone = upPhone
|
||||
proj.DownstreamContact = downContact
|
||||
proj.DownstreamPhone = downPhone
|
||||
proj.ContactPerson = upContact
|
||||
proj.ContactPhone = upPhone
|
||||
|
||||
prevStatus := proj.Status
|
||||
if p.Status != 0 {
|
||||
proj.Status = p.Status
|
||||
}
|
||||
proj.StartDate = parsePipelineDate(p.StartDate)
|
||||
proj.EndDate = parsePipelineDate(p.EndDate)
|
||||
proj.Address = strings.TrimSpace(p.Address)
|
||||
proj.Remark = p.Remark
|
||||
proj.UpdateTime = time.Now()
|
||||
|
||||
statusChanged := p.Status != 0 && p.Status != prevStatus
|
||||
reason := strings.TrimSpace(p.Reason)
|
||||
if p.Status == 5 && prevStatus != 5 && reason == "" {
|
||||
c.erpFail(400, 400, "请填写项目异常原因")
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := models.Orm.Update(&proj); err != nil {
|
||||
c.erpFail(500, 500, "更新失败: "+err.Error())
|
||||
return
|
||||
}
|
||||
if proj.DocCategoryID > 0 {
|
||||
_ = services.RenameCrmProjectDocCategory(cl.TenantId, proj.DocCategoryID, proj.ProjectName)
|
||||
}
|
||||
if statusChanged {
|
||||
logText := "项目状态:" + projectStatusName(prevStatus) + " → " + projectStatusName(proj.Status)
|
||||
if proj.Status == 5 && reason != "" {
|
||||
logText += ";异常原因:" + reason
|
||||
}
|
||||
crmWriteLog(tenantID, 3, proj.ID, "status", logText, cl)
|
||||
}
|
||||
crmWriteLog(tenantID, 3, proj.ID, "update", "更新项目:"+proj.ProjectName, cl)
|
||||
c.erpOk(map[string]interface{}{"id": proj.ID})
|
||||
}
|
||||
|
||||
// ChangeStatus POST /api/crm/project/status/:id
|
||||
func (c *AppCrmProjectController) ChangeStatus() {
|
||||
cl, err := c.erpClaims()
|
||||
if c.erpDenied(err) {
|
||||
return
|
||||
}
|
||||
id := c.erpPathID()
|
||||
if id == 0 {
|
||||
c.erpFail(400, 400, "无效的ID")
|
||||
return
|
||||
}
|
||||
var body struct {
|
||||
Status int8 `json:"status"`
|
||||
Reason string `json:"reason"`
|
||||
}
|
||||
if !c.erpBody(&body, false) {
|
||||
return
|
||||
}
|
||||
if body.Status < 1 || body.Status > 5 {
|
||||
c.erpFail(400, 400, "项目状态不合法")
|
||||
return
|
||||
}
|
||||
reason := strings.TrimSpace(body.Reason)
|
||||
if body.Status == 5 && reason == "" {
|
||||
c.erpFail(400, 400, "请填写项目异常原因")
|
||||
return
|
||||
}
|
||||
tenantID := pipelineTenantID(cl)
|
||||
var proj models.TenantCrmProject
|
||||
if err := models.Orm.QueryTable(new(models.TenantCrmProject)).
|
||||
Filter("id", id).Filter("tenant_id", tenantID).
|
||||
Filter("delete_time__isnull", true).One(&proj); err != nil {
|
||||
c.erpFail(404, 404, "项目未找到")
|
||||
return
|
||||
}
|
||||
if !canAccessCrmRecord(cl, proj.OwnerUserID, proj.CreateUserID) {
|
||||
c.erpFail(403, 403, "无权操作该项目数据")
|
||||
return
|
||||
}
|
||||
prevStatus := proj.Status
|
||||
proj.Status = body.Status
|
||||
proj.UpdateTime = time.Now()
|
||||
if _, err := models.Orm.Update(&proj); err != nil {
|
||||
c.erpFail(500, 500, "状态更新失败: "+err.Error())
|
||||
return
|
||||
}
|
||||
logText := "项目状态:" + projectStatusName(prevStatus) + " → " + projectStatusName(proj.Status)
|
||||
if proj.Status == 5 && reason != "" {
|
||||
logText += ";异常原因:" + reason
|
||||
}
|
||||
crmWriteLog(tenantID, 3, proj.ID, "status", logText, cl)
|
||||
c.erpOk(map[string]interface{}{"id": proj.ID, "status": proj.Status})
|
||||
}
|
||||
|
||||
// Delete DELETE /api/crm/project/delete/:id
|
||||
func (c *AppCrmProjectController) Delete() {
|
||||
cl, err := c.erpClaims()
|
||||
if c.erpDenied(err) {
|
||||
return
|
||||
}
|
||||
id := c.erpPathID()
|
||||
if id == 0 {
|
||||
c.erpFail(400, 400, "无效的ID")
|
||||
return
|
||||
}
|
||||
tenantID := pipelineTenantID(cl)
|
||||
var proj models.TenantCrmProject
|
||||
if err := models.Orm.QueryTable(new(models.TenantCrmProject)).
|
||||
Filter("id", id).Filter("tenant_id", tenantID).
|
||||
Filter("delete_time__isnull", true).One(&proj); err != nil {
|
||||
c.erpFail(404, 404, "项目未找到")
|
||||
return
|
||||
}
|
||||
if !canAccessCrmRecord(cl, proj.OwnerUserID, proj.CreateUserID) {
|
||||
c.erpFail(403, 403, "无权操作该项目数据")
|
||||
return
|
||||
}
|
||||
if !canDeleteCrmRecord(cl, proj.CreateUserID) {
|
||||
c.erpFail(403, 403, "只有创建人、租户管理员或平台管理员可以删除该项目")
|
||||
return
|
||||
}
|
||||
now := time.Now()
|
||||
if _, err := models.Orm.QueryTable(new(models.TenantCrmProject)).
|
||||
Filter("id", id).Filter("tenant_id", tenantID).
|
||||
Update(map[string]interface{}{"delete_time": now, "update_time": now}); err != nil {
|
||||
c.erpFail(500, 500, "删除失败: "+err.Error())
|
||||
return
|
||||
}
|
||||
crmWriteLog(tenantID, 3, proj.ID, "delete", "删除项目:"+proj.ProjectName, cl)
|
||||
c.erpOk(map[string]interface{}{"id": proj.ID})
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io"
|
||||
"strings"
|
||||
|
||||
"server/services"
|
||||
authsvc "server/services/auth"
|
||||
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
)
|
||||
|
||||
// AuthCodeLoginController 手机号/邮箱验证码登录(统一认证体系)。
|
||||
type AuthCodeLoginController struct {
|
||||
beego.Controller
|
||||
}
|
||||
|
||||
func (c *AuthCodeLoginController) serveJSON(data map[string]interface{}) {
|
||||
c.Data["json"] = data
|
||||
_ = c.ServeJSON()
|
||||
}
|
||||
|
||||
func (c *AuthCodeLoginController) fail(bizCode int, msg string) {
|
||||
c.Ctx.Output.SetStatus(400)
|
||||
c.serveJSON(map[string]interface{}{"code": bizCode, "msg": msg})
|
||||
}
|
||||
|
||||
func (c *AuthCodeLoginController) readBody() map[string]interface{} {
|
||||
body := c.Ctx.Input.RequestBody
|
||||
if len(body) == 0 {
|
||||
body, _ = io.ReadAll(c.Ctx.Request.Body)
|
||||
}
|
||||
var req map[string]interface{}
|
||||
if err := json.Unmarshal(body, &req); err != nil {
|
||||
return map[string]interface{}{}
|
||||
}
|
||||
return req
|
||||
}
|
||||
|
||||
func codeLoginString(req map[string]interface{}, key string) string {
|
||||
if req == nil {
|
||||
return ""
|
||||
}
|
||||
if v, ok := req[key].(string); ok {
|
||||
return strings.TrimSpace(v)
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// SendCode 发送登录验证码。account 为手机号或邮箱,channel 为 sms/email。
|
||||
func (c *AuthCodeLoginController) SendCode() {
|
||||
req := c.readBody()
|
||||
account := codeLoginString(req, "account")
|
||||
channel := codeLoginString(req, "channel")
|
||||
if account == "" {
|
||||
c.fail(400, "请输入手机号或邮箱")
|
||||
return
|
||||
}
|
||||
if channel == "" {
|
||||
if services.IsEmail(account) {
|
||||
channel = "email"
|
||||
} else if services.IsMobile(account) {
|
||||
channel = "sms"
|
||||
}
|
||||
}
|
||||
if channel == "sms" && !services.IsMobile(account) {
|
||||
c.fail(400, "请输入正确的手机号")
|
||||
return
|
||||
}
|
||||
if channel == "email" && !services.IsEmail(account) {
|
||||
c.fail(400, "请输入正确的邮箱")
|
||||
return
|
||||
}
|
||||
|
||||
var err error
|
||||
if channel == "email" {
|
||||
err = services.SendIdentityEmailCode("login", account)
|
||||
} else {
|
||||
err = services.SendIdentityCode("login", account)
|
||||
}
|
||||
if err != nil {
|
||||
c.fail(400, err.Error())
|
||||
return
|
||||
}
|
||||
c.serveJSON(map[string]interface{}{"code": 200, "msg": "验证码已发送"})
|
||||
}
|
||||
|
||||
// Login 验证码登录。校验验证码后签发统一认证登录态。
|
||||
func (c *AuthCodeLoginController) Login() {
|
||||
req := c.readBody()
|
||||
account := codeLoginString(req, "account")
|
||||
code := codeLoginString(req, "code")
|
||||
channel := codeLoginString(req, "channel")
|
||||
clientID := codeLoginString(req, "client_id")
|
||||
if clientID == "" {
|
||||
clientID = "yz-miniapp"
|
||||
}
|
||||
if account == "" || code == "" {
|
||||
c.fail(400, "请输入手机号/邮箱和验证码")
|
||||
return
|
||||
}
|
||||
if channel == "" {
|
||||
if services.IsEmail(account) {
|
||||
channel = "email"
|
||||
} else {
|
||||
channel = "sms"
|
||||
}
|
||||
}
|
||||
|
||||
var verifyErr error
|
||||
if channel == "email" {
|
||||
verifyErr = services.VerifyIdentityEmailCode("login", account, code)
|
||||
} else {
|
||||
verifyErr = services.VerifyIdentityCode("login", account, code)
|
||||
}
|
||||
if verifyErr != nil {
|
||||
c.fail(400, verifyErr.Error())
|
||||
return
|
||||
}
|
||||
|
||||
identity, err := authsvc.FindIdentityByAccount(account)
|
||||
if err != nil || identity == nil {
|
||||
c.fail(404, "账号不存在")
|
||||
return
|
||||
}
|
||||
|
||||
amr := authsvc.AmrSms
|
||||
loginType := "sms"
|
||||
if channel == "email" {
|
||||
amr = "email"
|
||||
loginType = "email"
|
||||
}
|
||||
|
||||
clientIP := c.Ctx.Input.IP()
|
||||
userAgent := c.Ctx.Request.UserAgent()
|
||||
result, err := authsvc.CodeLogin(identity, clientID, clientIP, userAgent, amr, loginType)
|
||||
if err != nil {
|
||||
if err == authsvc.ErrNoTenantBound {
|
||||
c.fail(403, err.Error())
|
||||
return
|
||||
}
|
||||
logs.Warn("[auth-code-login] 登录失败: %v", err)
|
||||
c.fail(400, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp := map[string]interface{}{
|
||||
"code": 200,
|
||||
"msg": "登录成功",
|
||||
"tokens": result.Tokens,
|
||||
"tenants": result.Tenants,
|
||||
"identity": result.Identity,
|
||||
}
|
||||
if result.NeedChooseTenant {
|
||||
resp["need_choose_tenant"] = true
|
||||
resp["sid"] = result.Tokens.Sid
|
||||
}
|
||||
c.serveJSON(resp)
|
||||
}
|
||||
@@ -305,6 +305,7 @@ func (c *BackendProductPurchaseController) GetPackageList() {
|
||||
if _, err := models.Orm.QueryTable(new(models.SystemTenantPackage)).
|
||||
Filter("delete_time__isnull", true).
|
||||
Filter("status", 1).
|
||||
Filter("can_purchase", 1).
|
||||
OrderBy("sort", "id").
|
||||
All(&rows); err != nil {
|
||||
c.jsonErr(500, 500, "获取失败:"+err.Error())
|
||||
@@ -349,6 +350,7 @@ func (c *BackendProductPurchaseController) GetPackageList() {
|
||||
"extra_user_price": r.ExtraUserPrice,
|
||||
"is_default": r.IsDefault,
|
||||
"allow_repurchase": r.AllowRepurchase,
|
||||
"can_purchase": r.CanPurchase,
|
||||
"purchased": purchased[r.ID],
|
||||
"sort": r.Sort,
|
||||
"status": r.Status,
|
||||
@@ -378,6 +380,7 @@ func (c *BackendProductPurchaseController) GetPackageDetailByCode() {
|
||||
Filter("code", code).
|
||||
Filter("delete_time__isnull", true).
|
||||
Filter("status", 1).
|
||||
Filter("can_purchase", 1).
|
||||
One(&row); err != nil {
|
||||
c.jsonErr(404, 404, "套餐不存在或已下架")
|
||||
return
|
||||
@@ -448,6 +451,10 @@ func (c *BackendProductPurchaseController) CreatePackageOrder() {
|
||||
c.jsonErr(404, 404, "套餐不存在或已下架")
|
||||
return
|
||||
}
|
||||
if pkg.CanPurchase == 0 {
|
||||
c.jsonErr(403, 403, "该套餐暂不支持购买,请联系平台管理员")
|
||||
return
|
||||
}
|
||||
if pkg.Price <= 0 {
|
||||
c.jsonErr(400, 400, "该套餐未配置价格,请联系平台")
|
||||
return
|
||||
|
||||
@@ -38,6 +38,8 @@ type tenantDTO struct {
|
||||
UserQuota int `json:"user_quota"`
|
||||
UserUsed int `json:"user_used"`
|
||||
StorageQuotaMB int `json:"storage_quota_mb"`
|
||||
StorageUsedMB float64 `json:"storage_used_mb"`
|
||||
StoragePercent float64 `json:"storage_percent"`
|
||||
Remark string `json:"remark"`
|
||||
CreateTime *time.Time `json:"create_time,omitempty"`
|
||||
UpdateTime *time.Time `json:"update_time,omitempty"`
|
||||
@@ -164,6 +166,11 @@ func (c *PlatformTenantController) GetTenant() {
|
||||
dto := toTenantDTO(t)
|
||||
dto.PackageName = packageNames[t.PackageID]
|
||||
dto.UserUsed = userCounts[t.ID]
|
||||
if info, ierr := services.GetTenantStorageInfo(t.ID); ierr == nil && info != nil {
|
||||
dto.StorageQuotaMB = info.QuotaMB
|
||||
dto.StorageUsedMB = math.Round(float64(info.UsedBytes)/float64(1024*1024)*10) / 10
|
||||
dto.StoragePercent = info.UsedPercent
|
||||
}
|
||||
list = append(list, dto)
|
||||
}
|
||||
|
||||
|
||||
@@ -92,6 +92,7 @@ type tenantPackagePayload struct {
|
||||
ExtraUserPrice *float64 `json:"extra_user_price"`
|
||||
IsDefault *int8 `json:"is_default"`
|
||||
AllowRepurchase *int8 `json:"allow_repurchase"`
|
||||
CanPurchase *int8 `json:"can_purchase"`
|
||||
Sort *int `json:"sort"`
|
||||
Status *int8 `json:"status"`
|
||||
Remark string `json:"remark"`
|
||||
@@ -182,6 +183,7 @@ func (c *PlatformTenantPackageController) GetPackageList() {
|
||||
"extra_user_price": r.ExtraUserPrice,
|
||||
"is_default": r.IsDefault,
|
||||
"allow_repurchase": r.AllowRepurchase,
|
||||
"can_purchase": r.CanPurchase,
|
||||
"sort": r.Sort,
|
||||
"status": r.Status,
|
||||
"remark": r.Remark,
|
||||
@@ -241,6 +243,7 @@ func (c *PlatformTenantPackageController) GetPackageSelectList() {
|
||||
"extra_user_price": r.ExtraUserPrice,
|
||||
"is_default": r.IsDefault,
|
||||
"allow_repurchase": r.AllowRepurchase,
|
||||
"can_purchase": r.CanPurchase,
|
||||
"modules": modules,
|
||||
"module_codes": moduleCodes(modules),
|
||||
})
|
||||
@@ -401,6 +404,7 @@ func (c *PlatformTenantPackageController) CreatePackage() {
|
||||
ExtraUserPrice: valueFloat(p.ExtraUserPrice, services.DefaultTenantExtraUserPrice),
|
||||
IsDefault: valueInt8(p.IsDefault, 0),
|
||||
AllowRepurchase: valueInt8(p.AllowRepurchase, 1),
|
||||
CanPurchase: valueInt8(p.CanPurchase, 1),
|
||||
Sort: valueInt(p.Sort, 0),
|
||||
Status: valueInt8(p.Status, 1),
|
||||
Remark: strings.TrimSpace(p.Remark),
|
||||
@@ -491,6 +495,9 @@ func (c *PlatformTenantPackageController) EditPackage() {
|
||||
if p.AllowRepurchase != nil {
|
||||
update["allow_repurchase"] = *p.AllowRepurchase
|
||||
}
|
||||
if p.CanPurchase != nil {
|
||||
update["can_purchase"] = *p.CanPurchase
|
||||
}
|
||||
|
||||
allowRepurchase := int8(1)
|
||||
if p.AllowRepurchase != nil {
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
SET @sql := CONCAT(
|
||||
'ALTER TABLE `yz_system_tenant_package` ',
|
||||
IF(
|
||||
(SELECT COUNT(*) FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = 'yz_system_tenant_package'
|
||||
AND COLUMN_NAME = 'can_purchase') = 0,
|
||||
'ADD COLUMN `can_purchase` TINYINT NOT NULL DEFAULT 1 COMMENT ''1=允许租户购买 0=仅后台指派'' AFTER `allow_repurchase`',
|
||||
''
|
||||
)
|
||||
);
|
||||
|
||||
SET @sql := IF(RIGHT(TRIM(@sql), 1) = '`', 'SELECT 1 AS column_already_exists', @sql);
|
||||
|
||||
PREPARE stmt FROM @sql;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
@@ -13,6 +13,7 @@ type SystemTenantPackage struct {
|
||||
ExtraUserPrice float64 `orm:"column(extra_user_price);digits(10);decimals(2)" json:"extra_user_price"`
|
||||
IsDefault int8 `orm:"column(is_default);default(0)" json:"is_default"`
|
||||
AllowRepurchase int8 `orm:"column(allow_repurchase);default(1)" json:"allow_repurchase"`
|
||||
CanPurchase int8 `orm:"column(can_purchase);default(1)" json:"can_purchase"`
|
||||
Sort int `orm:"column(sort);default(0)" json:"sort"`
|
||||
Status int8 `orm:"column(status);default(1)" json:"status"`
|
||||
Remark string `orm:"column(remark);size(255)" json:"remark"`
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
|
||||
func Register() {
|
||||
RegisterErpRoutes()
|
||||
RegisterCrmRoutes()
|
||||
|
||||
beego.Router("/api/softwareupgrade/check", &controllers.ApiSoftwareUpgradeController{}, "get:Check")
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"server/controllers"
|
||||
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
)
|
||||
|
||||
func RegisterCrmRoutes() {
|
||||
beego.Router("/api/crm/project/list", &controllers.AppCrmProjectController{}, "get:List")
|
||||
beego.Router("/api/crm/project/detail/:id", &controllers.AppCrmProjectController{}, "get:Detail")
|
||||
beego.Router("/api/crm/project/save", &controllers.AppCrmProjectController{}, "post:Save")
|
||||
beego.Router("/api/crm/project/status/:id", &controllers.AppCrmProjectController{}, "post:ChangeStatus")
|
||||
beego.Router("/api/crm/project/delete/:id", &controllers.AppCrmProjectController{}, "delete:Delete")
|
||||
}
|
||||
@@ -35,6 +35,9 @@ func Register() {
|
||||
beego.Router("/auth/sessions/kick", &authctl.AuthLoginController{}, "post:KickSession")
|
||||
beego.Router("/auth/verify-config", &authctl.AuthLoginController{}, "get:VerifyConfig")
|
||||
|
||||
beego.Router("/auth/login/code/send", &authctl.AuthCodeLoginController{}, "post:SendCode")
|
||||
beego.Router("/auth/login/code/verify", &authctl.AuthCodeLoginController{}, "post:Login")
|
||||
|
||||
beego.Router("/auth/register", &authctl.AuthAccountController{}, "get:RegisterPage")
|
||||
beego.Router("/auth/register/send-code", &authctl.AuthAccountController{}, "post:SendRegisterCode")
|
||||
beego.Router("/auth/register/verify", &authctl.AuthAccountController{}, "post:RegisterVerify")
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"server/models"
|
||||
)
|
||||
|
||||
// CodeLogin 通过已校验的验证码完成登录,登录态结构与 PasswordLogin 保持一致。
|
||||
// identity 由调用方按手机号/邮箱查得并已完成验证码校验。
|
||||
func CodeLogin(identity *models.AuthIdentity, clientID, ip, userAgent, amr, loginType string) (*LoginResult, error) {
|
||||
if identity == nil {
|
||||
return nil, ErrPasswordWrong
|
||||
}
|
||||
if err := checkIdentityStatus(identity); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
tenants, err := ListTenantOptions(identity.ID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(tenants) == 0 {
|
||||
_ = writeLoginLog(0, identity.ID, accountOf(identity), "", clientID, loginType, amr, 0, ErrNoTenantBound.Error(), ip, userAgent)
|
||||
return nil, ErrNoTenantBound
|
||||
}
|
||||
|
||||
profile, err := BuildProfile(identity)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
result := &LoginResult{Tenants: tenants, Identity: profile}
|
||||
|
||||
targetTid := uint64(PendingTenantID)
|
||||
if len(tenants) == 1 {
|
||||
targetTid = tenants[0].Tid
|
||||
}
|
||||
sess, err := CreateSession(SessionInfo{
|
||||
IdentityID: identity.ID,
|
||||
Tid: targetTid,
|
||||
ClientID: clientID,
|
||||
IP: ip,
|
||||
UserAgent: userAgent,
|
||||
LoginType: loginType,
|
||||
Amr: amr,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
accessTTL := 0
|
||||
if targetTid == PendingTenantID {
|
||||
accessTTL = 600
|
||||
result.NeedChooseTenant = true
|
||||
}
|
||||
|
||||
tokens, err := IssueTokens(TokenIssue{
|
||||
IdentityID: identity.ID,
|
||||
Tid: targetTid,
|
||||
ClientID: clientID,
|
||||
Sid: sess.Sid,
|
||||
Username: profile.Nickname,
|
||||
Amr: amr,
|
||||
AccessTTL: accessTTL,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result.Tokens = tokens
|
||||
|
||||
_ = writeLoginLog(targetTid, identity.ID, accountOf(identity), profile.Nickname, clientID, loginType, amr, 1, "登录成功", ip, userAgent)
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func accountOf(identity *models.AuthIdentity) string {
|
||||
if identity != nil && identity.Account != nil {
|
||||
return *identity.Account
|
||||
}
|
||||
if identity != nil && identity.Mobile != nil {
|
||||
return *identity.Mobile
|
||||
}
|
||||
if identity != nil && identity.Email != nil {
|
||||
return *identity.Email
|
||||
}
|
||||
return ""
|
||||
}
|
||||
@@ -34,23 +34,31 @@ func FindIdentityByAccount(account string) (*models.AuthIdentity, error) {
|
||||
if account == "" {
|
||||
return nil, orm.ErrNoRows
|
||||
}
|
||||
base := models.Orm.QueryTable(new(models.AuthIdentity)).Filter("delete_time__isnull", true)
|
||||
|
||||
for _, field := range []string{"account", "mobile", "email"} {
|
||||
m := &models.AuthIdentity{}
|
||||
if err := base.Filter(field, account).One(m); err == nil {
|
||||
return m, nil
|
||||
}
|
||||
}
|
||||
|
||||
// 优先走企业绑定关系:企业用户名通过 AuthTenantUser 明确关联到唯一 identity。
|
||||
// 若先按 identity 表的 account 直接匹配,可能命中历史遗留的同名账号(账号相同但密码/手机号不同),
|
||||
// 导致用错误的密码哈希校验而登录失败。
|
||||
var bind models.AuthTenantUser
|
||||
if err := models.Orm.QueryTable(new(models.AuthTenantUser)).
|
||||
Filter("account", account).
|
||||
Filter("delete_time__isnull", true).
|
||||
OrderBy("-is_default", "id").
|
||||
One(&bind); err == nil {
|
||||
One(&bind); err == nil && bind.IdentityID > 0 {
|
||||
m := &models.AuthIdentity{}
|
||||
if err := models.Orm.QueryTable(new(models.AuthIdentity)).Filter("id", bind.IdentityID).One(m); err == nil {
|
||||
if err := models.Orm.QueryTable(new(models.AuthIdentity)).
|
||||
Filter("id", bind.IdentityID).
|
||||
Filter("delete_time__isnull", true).
|
||||
One(m); err == nil {
|
||||
return m, nil
|
||||
}
|
||||
}
|
||||
|
||||
// 回退:身份只认手机号/邮箱作为凭证,不用 account 字段直接匹配身份。
|
||||
// 企业账号必须经上面的 AuthTenantUser 绑定关系定位身份,避免账号撞名命中错误身份。
|
||||
base := models.Orm.QueryTable(new(models.AuthIdentity)).Filter("delete_time__isnull", true)
|
||||
for _, field := range []string{"mobile", "email"} {
|
||||
m := &models.AuthIdentity{}
|
||||
if err := base.Filter(field, account).One(m); err == nil {
|
||||
return m, nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ func SendIdentityCode(purpose, phone string) error {
|
||||
if !IsMobile(phone) {
|
||||
return errors.New("请输入正确的手机号")
|
||||
}
|
||||
if purpose != "register" && purpose != "reset" {
|
||||
if purpose != "register" && purpose != "reset" && purpose != "login" {
|
||||
return errors.New("参数错误")
|
||||
}
|
||||
|
||||
@@ -61,7 +61,10 @@ func SendIdentityCode(purpose, phone string) error {
|
||||
if purpose == "register" && existed != nil {
|
||||
return errors.New("该手机号已注册,请直接登录或找回密码")
|
||||
}
|
||||
if purpose == "reset" && existed == nil {
|
||||
if (purpose == "reset" || purpose == "login") && existed == nil {
|
||||
if purpose == "login" {
|
||||
return errors.New("该手机号尚未注册,请先注册")
|
||||
}
|
||||
return errors.New("该手机号尚未注册")
|
||||
}
|
||||
|
||||
|
||||
@@ -77,10 +77,13 @@ func SendIdentityEmailCode(purpose, email string) error {
|
||||
if !IsEmail(email) {
|
||||
return errors.New("请输入正确的邮箱地址")
|
||||
}
|
||||
if purpose != "reset" {
|
||||
if purpose != "reset" && purpose != "login" {
|
||||
return errors.New("参数错误")
|
||||
}
|
||||
if findIdentityByEmail(email) == nil {
|
||||
if purpose == "login" {
|
||||
return errors.New("该邮箱尚未注册,请先注册")
|
||||
}
|
||||
return errors.New("该邮箱尚未绑定账号")
|
||||
}
|
||||
|
||||
@@ -97,15 +100,21 @@ func SendIdentityEmailCode(purpose, email string) error {
|
||||
}
|
||||
|
||||
code := fmt.Sprintf("%06d", rand.Intn(1000000)) //nolint:gosec // 验证码场景可接受
|
||||
mailTitle := "找回密码验证码"
|
||||
mailHeading := "找回密码验证码"
|
||||
if purpose == "login" {
|
||||
mailTitle = "登录验证码"
|
||||
mailHeading = "登录验证码"
|
||||
}
|
||||
html := fmt.Sprintf(`
|
||||
<div style="font-family: Arial, sans-serif; padding: 22px; border: 1px solid #eee; border-radius: 6px; max-width: 520px;">
|
||||
<h3 style="color: #2563eb; margin: 0 0 16px;">找回密码验证码</h3>
|
||||
<h3 style="color: #2563eb; margin: 0 0 16px;">%s</h3>
|
||||
<p style="font-size: 15px; color: #333; margin: 0 0 6px;">您的验证码是:</p>
|
||||
<p style="font-size: 30px; font-weight: 700; letter-spacing: 6px; color: #2563eb; margin: 0 0 18px;">%s</p>
|
||||
<p style="font-size: 13px; color: #666; margin: 0;">验证码 5 分钟内有效。为保护账号安全,请勿转发给他人。</p>
|
||||
</div>
|
||||
`, code)
|
||||
if err := SendHTMLEmailSMTP(cfg, email, "找回密码验证码", html); err != nil {
|
||||
`, mailHeading, code)
|
||||
if err := SendHTMLEmailSMTP(cfg, email, mailTitle, html); err != nil {
|
||||
return errors.New("邮件发送失败,请稍后重试")
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,351 @@
|
||||
<template>
|
||||
<div class="container-box storage-page">
|
||||
<div class="header-bar">
|
||||
<h2>存储空间</h2>
|
||||
<div class="header-actions">
|
||||
<el-button @click="loadOrders"><el-icon><Refresh /></el-icon>刷新订单</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<el-alert
|
||||
type="info"
|
||||
:closable="false"
|
||||
show-icon
|
||||
class="tips"
|
||||
title="查看并调整各租户的附件空间。租户实际可用空间 = max(基础额度, 已生效扩容套餐容量)。扩容套餐的维护在「基础设置 → 存储套餐」。"
|
||||
/>
|
||||
|
||||
<div class="panel">
|
||||
<div class="panel-head">
|
||||
<h3>租户存储额度</h3>
|
||||
<span class="tip">输入租户 ID 查询用量,可直接调整基础额度</span>
|
||||
</div>
|
||||
<div class="query-bar">
|
||||
<el-input
|
||||
v-model="tidInput"
|
||||
type="number"
|
||||
placeholder="请输入租户 ID"
|
||||
clearable
|
||||
style="width: 220px"
|
||||
@keyup.enter="queryTenant"
|
||||
/>
|
||||
<el-button type="primary" @click="queryTenant">查询</el-button>
|
||||
</div>
|
||||
|
||||
<div v-if="tenantLoading" v-loading="tenantLoading" class="tenant-placeholder"></div>
|
||||
|
||||
<template v-else-if="info && info.tid">
|
||||
<div class="usage-row">
|
||||
<span class="used">{{ formatSize(info.used_bytes) }}</span>
|
||||
<span class="total">/ {{ formatSize(info.quota_bytes) }}</span>
|
||||
<el-tag size="small" type="info" effect="plain">已用 {{ info.used_percent || 0 }}%</el-tag>
|
||||
</div>
|
||||
<el-progress
|
||||
:percentage="progressPercent"
|
||||
:status="progressStatus"
|
||||
:stroke-width="10"
|
||||
:format="() => `${progressPercent}%`"
|
||||
/>
|
||||
<div class="usage-foot">
|
||||
<span>基础额度 {{ info.base_quota_mb }} MB</span>
|
||||
<span v-if="info.package_quota_mb">· 套餐 {{ info.package_name }} {{ formatCapacity(info.package_quota_mb) }}(剩 {{ info.days_remaining }} 天)</span>
|
||||
<span>· 剩余 {{ formatSize(info.remaining_bytes) }}</span>
|
||||
</div>
|
||||
|
||||
<div class="quota-edit">
|
||||
<span class="label">调整基础额度</span>
|
||||
<el-input-number v-model="quotaInput" :min="0" :max="1024 * 1024" :step="100" controls-position="right" />
|
||||
<span class="unit">MB(0 = 恢复默认 {{ 500 }}MB)</span>
|
||||
<el-button type="primary" :loading="quotaSaving" @click="saveQuota">保存</el-button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<el-empty v-else description="请输入租户 ID 查询存储用量" />
|
||||
</div>
|
||||
|
||||
<div class="panel">
|
||||
<div class="panel-head">
|
||||
<h3>存储购买订单</h3>
|
||||
<div class="order-filter">
|
||||
<el-select v-model="orderStatus" placeholder="状态" clearable style="width: 130px" @change="loadOrders">
|
||||
<el-option label="待支付" value="pending" />
|
||||
<el-option label="已支付" value="paid" />
|
||||
<el-option label="已取消" value="cancelled" />
|
||||
<el-option label="已替换" value="replaced" />
|
||||
</el-select>
|
||||
</div>
|
||||
</div>
|
||||
<el-table :data="orders" v-loading="ordersLoading" size="small" border stripe>
|
||||
<el-table-column prop="order_no" label="订单号" min-width="180" show-overflow-tooltip />
|
||||
<el-table-column prop="tid" label="租户ID" width="90" align="center" />
|
||||
<el-table-column prop="package_name" label="套餐" min-width="120" />
|
||||
<el-table-column label="容量" width="100" align="center">
|
||||
<template #default="{ row }">{{ formatCapacity(row.capacity_mb) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="金额" width="100" align="center">
|
||||
<template #default="{ row }">¥{{ Number(row.amount || 0).toFixed(2) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="状态" width="100" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag size="small" :type="orderStatusType(row.status)">{{ orderStatusText(row.status) }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="有效期" min-width="190" align="center">
|
||||
<template #default="{ row }">
|
||||
<span v-if="row.start_time && row.end_time">{{ formatDate(row.start_time) }} ~ {{ formatDate(row.end_time) }}</span>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="create_time" label="下单时间" min-width="160" align="center">
|
||||
<template #default="{ row }">{{ formatDate(row.create_time) }}</template>
|
||||
</el-table-column>
|
||||
<template #empty><el-empty description="暂无存储订单" /></template>
|
||||
</el-table>
|
||||
<div class="pagination-bar">
|
||||
<el-pagination
|
||||
:current-page="orderPage"
|
||||
:page-size="orderPageSize"
|
||||
:total="orderTotal"
|
||||
@current-change="handleOrderPage"
|
||||
layout="total, prev, pager, next"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from "vue";
|
||||
import { ElMessage } from "element-plus";
|
||||
import { Refresh } from "@element-plus/icons-vue";
|
||||
import {
|
||||
getTenantStorageInfo,
|
||||
getStorageOrders,
|
||||
updateTenantStorageQuota,
|
||||
} from "@/api/storage";
|
||||
|
||||
const tidInput = ref<string>("");
|
||||
const tenantLoading = ref(false);
|
||||
const info = ref<Record<string, any>>({});
|
||||
const quotaInput = ref<number>(500);
|
||||
const quotaSaving = ref(false);
|
||||
|
||||
const orders = ref<any[]>([]);
|
||||
const ordersLoading = ref(false);
|
||||
const orderStatus = ref("");
|
||||
const orderPage = ref(1);
|
||||
const orderPageSize = ref(10);
|
||||
const orderTotal = ref(0);
|
||||
|
||||
const progressPercent = computed(() => {
|
||||
const p = Number(info.value.used_percent) || 0;
|
||||
return Math.min(100, Math.max(0, Math.round(p * 10) / 10));
|
||||
});
|
||||
|
||||
const progressStatus = computed(() => {
|
||||
const p = progressPercent.value;
|
||||
if (p >= 95) return "exception";
|
||||
if (p >= 80) return "warning";
|
||||
return "";
|
||||
});
|
||||
|
||||
const formatSize = (bytes: any) => {
|
||||
const n = Number(bytes) || 0;
|
||||
if (n >= 1024 ** 3) return `${(n / 1024 ** 3).toFixed(2)} GB`;
|
||||
if (n >= 1024 ** 2) return `${(n / 1024 ** 2).toFixed(1)} MB`;
|
||||
if (n >= 1024) return `${(n / 1024).toFixed(1)} KB`;
|
||||
return `${n} B`;
|
||||
};
|
||||
|
||||
const formatCapacity = (mb: any) => {
|
||||
const n = Number(mb) || 0;
|
||||
return n >= 1024 ? `${(n / 1024).toFixed(n % 1024 === 0 ? 0 : 1)} GB` : `${n} MB`;
|
||||
};
|
||||
|
||||
const formatDate = (value: any) => {
|
||||
if (!value) return "-";
|
||||
const d = new Date(value);
|
||||
if (Number.isNaN(d.getTime())) return String(value).slice(0, 19).replace("T", " ");
|
||||
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}`;
|
||||
};
|
||||
|
||||
const orderStatusText = (s: string) =>
|
||||
({ pending: "待支付", paid: "已支付", cancelled: "已取消", replaced: "已替换" }[s] || s);
|
||||
const orderStatusType = (s: string) =>
|
||||
({ pending: "warning", paid: "success", cancelled: "info", replaced: "info" }[s] || "info");
|
||||
|
||||
const queryTenant = async () => {
|
||||
const tid = Number(tidInput.value || 0);
|
||||
if (!tid || tid <= 0) {
|
||||
ElMessage.warning("请输入有效的租户 ID");
|
||||
return;
|
||||
}
|
||||
tenantLoading.value = true;
|
||||
try {
|
||||
const res = await getTenantStorageInfo(tid);
|
||||
if (res?.code === 200) {
|
||||
info.value = res.data || {};
|
||||
quotaInput.value = Number(info.value.base_quota_mb || 500);
|
||||
} else {
|
||||
info.value = {};
|
||||
ElMessage.error(res?.msg || "查询失败");
|
||||
}
|
||||
} catch (e: any) {
|
||||
info.value = {};
|
||||
ElMessage.error(e?.message || "查询失败");
|
||||
} finally {
|
||||
tenantLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const saveQuota = async () => {
|
||||
const tid = Number(info.value.tid || 0);
|
||||
if (!tid) return;
|
||||
quotaSaving.value = true;
|
||||
try {
|
||||
const res = await updateTenantStorageQuota(tid, Number(quotaInput.value || 0));
|
||||
if (res?.code === 200) {
|
||||
info.value = res.data || info.value;
|
||||
ElMessage.success("基础额度已更新");
|
||||
} else {
|
||||
ElMessage.error(res?.msg || "保存失败");
|
||||
}
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e?.message || "保存失败");
|
||||
} finally {
|
||||
quotaSaving.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const loadOrders = async () => {
|
||||
ordersLoading.value = true;
|
||||
try {
|
||||
const res = await getStorageOrders({
|
||||
page: orderPage.value,
|
||||
pageSize: orderPageSize.value,
|
||||
status: orderStatus.value || undefined,
|
||||
});
|
||||
if (res?.code === 200) {
|
||||
orders.value = res.data?.list || [];
|
||||
orderTotal.value = Number(res.data?.total || 0);
|
||||
}
|
||||
} catch {
|
||||
orders.value = [];
|
||||
} finally {
|
||||
ordersLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const handleOrderPage = (val: number) => {
|
||||
orderPage.value = val;
|
||||
loadOrders();
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
loadOrders();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.storage-page {
|
||||
.tips {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.panel {
|
||||
padding: 18px 20px;
|
||||
margin-bottom: 18px;
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: 12px;
|
||||
background: var(--el-bg-color);
|
||||
}
|
||||
|
||||
.panel-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 16px;
|
||||
|
||||
h3 {
|
||||
margin: 0;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
|
||||
.tip {
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
}
|
||||
|
||||
.query-bar {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
|
||||
.tenant-placeholder {
|
||||
min-height: 60px;
|
||||
}
|
||||
|
||||
.usage-row {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 8px;
|
||||
margin-bottom: 10px;
|
||||
|
||||
.used {
|
||||
font-size: 26px;
|
||||
font-weight: 700;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
|
||||
.total {
|
||||
font-size: 14px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
}
|
||||
|
||||
.usage-foot {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
margin-top: 10px;
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
.quota-edit {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
margin-top: 20px;
|
||||
padding-top: 18px;
|
||||
border-top: 1px solid var(--el-border-color-lighter);
|
||||
|
||||
.label {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
|
||||
.unit {
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
}
|
||||
|
||||
.order-filter {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.pagination-bar {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
margin-top: 14px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -115,6 +115,11 @@
|
||||
<span class="field-tip">关闭后每个租户仅可购买一次(体验套餐),已购买过则无法再次下单</span>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="允许租户购买" prop="can_purchase">
|
||||
<el-switch v-model="form.can_purchase" :active-value="1" :inactive-value="0" />
|
||||
<span class="field-tip">关闭后该套餐不会出现在租户端购买列表,仅可由平台后台为租户指派</span>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-radio-group v-model="form.status">
|
||||
<el-radio :label="1">启用</el-radio>
|
||||
@@ -174,6 +179,7 @@ const emptyForm = () => ({
|
||||
extra_user_price: 200,
|
||||
is_default: 0,
|
||||
allow_repurchase: 1,
|
||||
can_purchase: 1,
|
||||
sort: 0,
|
||||
status: 1,
|
||||
remark: "",
|
||||
@@ -254,6 +260,7 @@ const loadDetail = async (id: number) => {
|
||||
extra_user_price: Number(d.extra_user_price || 0),
|
||||
is_default: Number(d.is_default || 0),
|
||||
allow_repurchase: Number(d.allow_repurchase ?? 1),
|
||||
can_purchase: Number(d.can_purchase ?? 1),
|
||||
sort: Number(d.sort || 0),
|
||||
status: Number(d.status ?? 1),
|
||||
remark: d.remark || "",
|
||||
|
||||
@@ -90,6 +90,17 @@
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="购买方式" width="110" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag
|
||||
size="small"
|
||||
:type="Number(row.can_purchase) === 0 ? 'warning' : 'success'"
|
||||
effect="plain"
|
||||
>
|
||||
{{ Number(row.can_purchase) === 0 ? "后台指派" : "租户购买" }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="sort" label="排序" width="80" align="center" />
|
||||
<el-table-column prop="status" label="状态" width="80" align="center">
|
||||
<template #default="{ row }">
|
||||
|
||||
@@ -123,6 +123,18 @@
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="存储用量" min-width="180" align="center">
|
||||
<template #default="scope">
|
||||
<div class="storage-cell">
|
||||
<el-progress
|
||||
:percentage="storagePercent(scope.row)"
|
||||
:color="storageColor(scope.row)"
|
||||
:stroke-width="8"
|
||||
:format="() => storageText(scope.row)"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="status" label="租户状态" width="90" align="center" fixed="right">
|
||||
<template #default="scope">
|
||||
<el-tag :type="scope.row.status === 1 ? 'success' : 'danger'">{{
|
||||
@@ -218,6 +230,29 @@ const handlePageChange = (val: number) => {
|
||||
refresh();
|
||||
};
|
||||
|
||||
const formatMB = (mb: number) => {
|
||||
const v = Number(mb || 0);
|
||||
return v >= 1024 ? `${(v / 1024).toFixed(2)} GB` : `${v.toFixed(1)} MB`;
|
||||
};
|
||||
|
||||
const storagePercent = (row: any) => {
|
||||
const p = Number(row.storage_percent || 0);
|
||||
return Math.max(0, Math.min(100, p));
|
||||
};
|
||||
|
||||
const storageColor = (row: any) => {
|
||||
const p = storagePercent(row);
|
||||
if (p >= 85) return "#f56c6c";
|
||||
if (p >= 60) return "#e6a23c";
|
||||
return "#67c23a";
|
||||
};
|
||||
|
||||
const storageText = (row: any) => {
|
||||
const used = Number(row.storage_used_mb || 0);
|
||||
const quota = Number(row.storage_quota_mb || 0);
|
||||
return `${formatMB(used)} / ${formatMB(quota)}`;
|
||||
};
|
||||
|
||||
const searchForm = reactive({
|
||||
tenant_name: "",
|
||||
tenant_code: "",
|
||||
@@ -297,6 +332,17 @@ onMounted(() => {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.storage-cell {
|
||||
padding: 0 6px;
|
||||
:deep(.el-progress) {
|
||||
line-height: 1;
|
||||
}
|
||||
:deep(.el-progress__text) {
|
||||
font-size: 11px !important;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
}
|
||||
|
||||
.search-form {
|
||||
background: var(--el-bg-color-page, #f5f7fa);
|
||||
padding: 20px 20px 0 20px;
|
||||
|
||||
@@ -1,37 +1,5 @@
|
||||
<script>
|
||||
import { getBaseURL } from '@/api/request.js'
|
||||
import { isLoggedIn } from '@/utils/auth.js'
|
||||
import { getGuestToken } from '@/utils/guest.js'
|
||||
|
||||
const LOGIN_PAGE = '/pages/login/login'
|
||||
const PUBLIC_ROUTES = [
|
||||
'pages/nav/nav',
|
||||
'pages/login/login',
|
||||
'pages/login/register',
|
||||
'pages/login/forget',
|
||||
'pages/login/geetest-webview',
|
||||
'pages/register/confirm',
|
||||
'pages/index/index'
|
||||
]
|
||||
|
||||
function currentRoute() {
|
||||
try {
|
||||
const pages = getCurrentPages()
|
||||
if (!pages.length) return ''
|
||||
const cur = pages[pages.length - 1]
|
||||
return (cur && (cur.route || (cur.$page && cur.$page.path))) || ''
|
||||
} catch (e) {
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
function ensureLogin() {
|
||||
const route = currentRoute()
|
||||
if (!route || PUBLIC_ROUTES.indexOf(route) !== -1) return
|
||||
if (isLoggedIn()) return
|
||||
if (getGuestToken()) return
|
||||
uni.reLaunch({ url: LOGIN_PAGE })
|
||||
}
|
||||
|
||||
export default {
|
||||
onLaunch() {
|
||||
@@ -39,7 +7,6 @@
|
||||
},
|
||||
onShow() {
|
||||
console.log('App Show')
|
||||
ensureLogin()
|
||||
},
|
||||
onHide() {
|
||||
console.log('App Hide')
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
const fs = require('fs');
|
||||
const p = require('path');
|
||||
|
||||
const root = 'dist/build/mp-weixin';
|
||||
const appJson = JSON.parse(fs.readFileSync(p.join(root, 'app.json'), 'utf8'));
|
||||
|
||||
// 收集所有被 app.json 引用/声明的页面路径
|
||||
const declared = new Set();
|
||||
(appJson.pages || []).forEach((x) => declared.add(x));
|
||||
(appJson.subPackages || []).forEach((s) => {
|
||||
const base = s.root.replace(/\/$/, '');
|
||||
(s.pages || []).forEach((x) => declared.add(`${base}/${x}`));
|
||||
});
|
||||
|
||||
function walk(d, out) {
|
||||
for (const f of fs.readdirSync(d, { withFileTypes: true })) {
|
||||
const fp = p.join(d, f.name);
|
||||
if (f.isDirectory()) walk(fp, out);
|
||||
else out.push({ rel: p.relative(root, fp).replace(/\\/g, '/'), size: fs.statSync(fp).size });
|
||||
}
|
||||
}
|
||||
const all = [];
|
||||
walk(root, all);
|
||||
|
||||
// 找出 pages 与 components 下没有被声明的页面文件
|
||||
const orphans = [];
|
||||
for (const x of all) {
|
||||
const rel = x.rel;
|
||||
if (!rel.startsWith('pages/')) continue;
|
||||
const noExt = rel.replace(/\.(js|json|wxml|wxss)$/, '');
|
||||
if (!declared.has(noExt)) orphans.push(x);
|
||||
}
|
||||
|
||||
const orphanTotal = orphans.reduce((s, x) => s + x.size, 0);
|
||||
console.log('孤儿页面文件数:', orphans.length, '总大小:', (orphanTotal / 1024).toFixed(1), 'KB');
|
||||
console.log('\n孤儿文件 TOP 20:');
|
||||
orphans.sort((a, b) => b.size - a.size).slice(0, 20).forEach((x) => console.log((x.size / 1024).toFixed(1).padStart(9), 'KB', x.rel));
|
||||
|
||||
// 检查 app.json 声明的页面是否都真实存在
|
||||
const missing = [];
|
||||
for (const d of declared) {
|
||||
const base = p.join(root, d);
|
||||
if (!fs.existsSync(base + '.js') && !fs.existsSync(base + '.wxml')) missing.push(d);
|
||||
}
|
||||
console.log('\n声明但缺失的页面:', missing.length);
|
||||
missing.slice(0, 10).forEach((m) => console.log(' MISSING:', m));
|
||||
|
||||
console.log('\n主包 & 分包文件总数:', all.length);
|
||||
+22
-2
@@ -16,7 +16,8 @@ export function loginUAC(data) {
|
||||
return request({
|
||||
url: '/auth/login',
|
||||
method: 'POST',
|
||||
data: Object.assign({ client_id: clientId }, data)
|
||||
data: Object.assign({ client_id: clientId }, data),
|
||||
skipAuthRedirect: true
|
||||
})
|
||||
}
|
||||
|
||||
@@ -86,7 +87,8 @@ export function loginByMiniapp({ code, phoneCode = '' } = {}) {
|
||||
client_id: 'yz-miniapp',
|
||||
code,
|
||||
phone_code: phoneCode
|
||||
}
|
||||
},
|
||||
skipAuthRedirect: true
|
||||
})
|
||||
}
|
||||
|
||||
@@ -136,6 +138,24 @@ export function sendLoginCode(data) {
|
||||
})
|
||||
}
|
||||
|
||||
export function sendAuthLoginCode(data) {
|
||||
return request({
|
||||
url: '/auth/login/code/send',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function loginByAuthCode(data) {
|
||||
const clientId = 'yz-miniapp'
|
||||
return request({
|
||||
url: '/auth/login/code/verify',
|
||||
method: 'POST',
|
||||
data: Object.assign({ client_id: clientId }, data),
|
||||
skipAuthRedirect: true
|
||||
})
|
||||
}
|
||||
|
||||
export function loginBySms(data) {
|
||||
return request({
|
||||
url: '/api/loginBySms',
|
||||
|
||||
@@ -0,0 +1,145 @@
|
||||
import { request } from '@/api/request.js'
|
||||
import { moneyText } from '@/api/erp.js'
|
||||
|
||||
export const PROJECT_TYPE = {
|
||||
SINGLE: 1,
|
||||
UP_DOWN: 2,
|
||||
UP_MID: 3
|
||||
}
|
||||
|
||||
export const PROJECT_TYPE_LABEL = {
|
||||
1: '单一项目',
|
||||
2: '上下游项目',
|
||||
3: '上中游项目'
|
||||
}
|
||||
|
||||
export const PROJECT_STATUS = {
|
||||
PENDING: 1,
|
||||
OPERATING: 2,
|
||||
WAITING: 3,
|
||||
SUSPENDED: 4,
|
||||
ABNORMAL: 5
|
||||
}
|
||||
|
||||
export const PROJECT_STATUS_LABEL = {
|
||||
1: '未开始',
|
||||
2: '进行中',
|
||||
3: '已完成',
|
||||
4: '已暂停',
|
||||
5: '异常'
|
||||
}
|
||||
|
||||
export function projectTypeLabel(type) {
|
||||
return PROJECT_TYPE_LABEL[type] || '项目'
|
||||
}
|
||||
|
||||
export function projectStatusLabel(status) {
|
||||
return PROJECT_STATUS_LABEL[status] || '未知'
|
||||
}
|
||||
|
||||
export function projectTypeOptions() {
|
||||
return Object.keys(PROJECT_TYPE).map((k) => ({
|
||||
value: Number(k),
|
||||
label: projectTypeLabel(Number(k))
|
||||
}))
|
||||
}
|
||||
|
||||
export function projectStatusOptions() {
|
||||
return Object.keys(PROJECT_STATUS).map((k) => ({
|
||||
value: Number(k),
|
||||
label: projectStatusLabel(Number(k))
|
||||
}))
|
||||
}
|
||||
|
||||
export function formatDate(value) {
|
||||
const s = String(value || '')
|
||||
return s ? s.slice(0, 10) : ''
|
||||
}
|
||||
|
||||
export function formatMoney(value) {
|
||||
return moneyText(value)
|
||||
}
|
||||
|
||||
export async function fetchProjects(params = {}) {
|
||||
const data = await request({
|
||||
url: '/api/crm/project/list',
|
||||
data: {
|
||||
page: params.page || 1,
|
||||
pageSize: params.pageSize || 20,
|
||||
keyword: params.keyword || '',
|
||||
status: params.status ?? '',
|
||||
project_type: params.projectType ?? '',
|
||||
year: params.year || ''
|
||||
}
|
||||
})
|
||||
return { list: (data.list || []).map(normalizeProject), total: data.total || 0 }
|
||||
}
|
||||
|
||||
export async function getProject(id) {
|
||||
const data = await request({ url: `/api/crm/project/detail/${id}` })
|
||||
return data ? normalizeProject(data) : null
|
||||
}
|
||||
|
||||
export async function saveProject(project) {
|
||||
const data = await request({
|
||||
url: '/api/crm/project/save',
|
||||
method: 'POST',
|
||||
data: normalizeSavePayload(project)
|
||||
})
|
||||
return data
|
||||
}
|
||||
|
||||
export async function changeProjectStatus(id, status, reason) {
|
||||
return request({
|
||||
url: `/api/crm/project/status/${id}`,
|
||||
method: 'POST',
|
||||
data: { status, reason: reason || '' }
|
||||
})
|
||||
}
|
||||
|
||||
export async function deleteProject(id) {
|
||||
return request({
|
||||
url: `/api/crm/project/delete/${id}`,
|
||||
method: 'DELETE'
|
||||
})
|
||||
}
|
||||
|
||||
function normalizeProject(p) {
|
||||
return {
|
||||
...p,
|
||||
upstream_amount: Number(p.upstream_amount || 0),
|
||||
downstream_amount: Number(p.downstream_amount || 0),
|
||||
amount: Number(p.amount || 0),
|
||||
status: Number(p.status || 1)
|
||||
}
|
||||
}
|
||||
|
||||
function normalizeSavePayload(p) {
|
||||
return {
|
||||
id: p.id || 0,
|
||||
project_name: p.projectName || '',
|
||||
project_no: p.projectNo || '',
|
||||
project_type: p.projectType || 1,
|
||||
customer_id: p.customerId || 0,
|
||||
customer_ref_type: p.customerRefType || 1,
|
||||
customer_name: p.customerName || '',
|
||||
supplier_id: p.supplierId || 0,
|
||||
supplier_ref_type: p.supplierRefType || 0,
|
||||
supplier_name: p.supplierName || '',
|
||||
supplier_industry: p.supplierIndustry || '',
|
||||
owner_user_id: p.ownerUserId || '',
|
||||
owner_user_name: p.ownerUserName || '',
|
||||
industry: p.industry || '',
|
||||
upstream_amount: p.upstreamAmount || 0,
|
||||
downstream_amount: p.downstreamAmount || 0,
|
||||
status: p.status || 1,
|
||||
start_date: formatDate(p.startDate),
|
||||
end_date: formatDate(p.endDate),
|
||||
upstream_contact: p.upstreamContact || '',
|
||||
upstream_phone: p.upstreamPhone || '',
|
||||
downstream_contact: p.downstreamContact || '',
|
||||
downstream_phone: p.downstreamPhone || '',
|
||||
address: p.address || '',
|
||||
remark: p.remark || ''
|
||||
}
|
||||
}
|
||||
@@ -61,7 +61,7 @@ async function replayRequest(options) {
|
||||
}
|
||||
|
||||
export function request(options = {}) {
|
||||
const { url, method = 'GET', data, header = {}, silent = false, timeout = 30000 } = options
|
||||
const { url, method = 'GET', data, header = {}, silent = false, timeout = 30000, skipAuthRedirect = false } = options
|
||||
const headers = {
|
||||
'Content-Type': 'application/json',
|
||||
...header
|
||||
@@ -82,6 +82,14 @@ export function request(options = {}) {
|
||||
const body = res.data || {}
|
||||
|
||||
if (status === 401 || body.code === 401) {
|
||||
if (skipAuthRedirect) {
|
||||
const msg = body.msg || '登录失败'
|
||||
const err = new Error(msg)
|
||||
err.code = 401
|
||||
err.response = body
|
||||
reject(err)
|
||||
return
|
||||
}
|
||||
if (!isLoggedIn() && getGuestToken()) {
|
||||
clearGuestToken()
|
||||
if (!silent) {
|
||||
|
||||
@@ -43,7 +43,62 @@ const parsed = computed(() => {
|
||||
return { name: raw.replace(/^fa-/, ''), brands: props.type === 'brands' }
|
||||
})
|
||||
|
||||
const iconChar = computed(() => FA_ICONS[parsed.value.name] || '')
|
||||
// Element Plus / 历史菜单使用的是 PascalCase 图标名,这里统一转换为 Font Awesome 名称
|
||||
const ICON_ALIAS = {
|
||||
notebook: 'book',
|
||||
tickets: 'ticket',
|
||||
ticket: 'ticket',
|
||||
document: 'file-lines',
|
||||
files: 'folder-open',
|
||||
calendar: 'calendar-days',
|
||||
reading: 'book-open',
|
||||
postcard: 'envelope',
|
||||
chatdotround: 'comments',
|
||||
chatdot: 'comment',
|
||||
editpen: 'pen',
|
||||
pencil: 'pen',
|
||||
pricetag: 'tag',
|
||||
operation: 'sliders',
|
||||
coin: 'coins',
|
||||
goods: 'box',
|
||||
setting: 'gear',
|
||||
dataline: 'chart-line',
|
||||
officebuilding: 'building',
|
||||
fold: 'folder',
|
||||
menu: 'bars',
|
||||
search: 'magnifying-glass',
|
||||
bell: 'bell',
|
||||
notification: 'bell',
|
||||
homefilled: 'house',
|
||||
position: 'location-dot',
|
||||
promotion: 'gift',
|
||||
discount: 'tag',
|
||||
userfilled: 'user',
|
||||
documentcopy: 'copy',
|
||||
memo: 'note-sticky',
|
||||
management: 'list',
|
||||
tools: 'wrench',
|
||||
service: 'headset'
|
||||
}
|
||||
|
||||
function toKebabCase(name) {
|
||||
return String(name)
|
||||
.replace(/([a-z0-9])([A-Z])/g, '$1-$2')
|
||||
.replace(/([A-Z]+)([A-Z][a-z])/g, '$1-$2')
|
||||
.replace(/[\s_]+/g, '-')
|
||||
.toLowerCase()
|
||||
}
|
||||
|
||||
const iconChar = computed(() => {
|
||||
const name = parsed.value.name
|
||||
if (!name) return ''
|
||||
if (FA_ICONS[name]) return FA_ICONS[name]
|
||||
const kebab = toKebabCase(name)
|
||||
if (FA_ICONS[kebab]) return FA_ICONS[kebab]
|
||||
const alias = ICON_ALIAS[kebab]
|
||||
if (alias && FA_ICONS[alias]) return FA_ICONS[alias]
|
||||
return ''
|
||||
})
|
||||
|
||||
const fontClass = computed(() =>
|
||||
parsed.value.brands ? 'fa-font-brands' : 'fa-font-solid'
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
v-if="isOa && dash"
|
||||
part="top"
|
||||
:data="dash"
|
||||
@view-notices="goNotices"
|
||||
@view-schedules="goSchedules"
|
||||
/>
|
||||
|
||||
@@ -87,7 +86,7 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view v-if="isOa" class="block">
|
||||
<view v-if="isOa && !embedded" class="block">
|
||||
<view class="block-head">
|
||||
<text class="block-title">最新公告</text>
|
||||
<view class="block-more" @tap="goNotices">
|
||||
@@ -158,7 +157,6 @@
|
||||
v-if="isOa && dash"
|
||||
part="bottom"
|
||||
:data="dash"
|
||||
@view-notices="goNotices"
|
||||
@view-schedules="goSchedules"
|
||||
/>
|
||||
</view>
|
||||
@@ -229,7 +227,7 @@ import { isLoggedIn } from '@/utils/auth.js'
|
||||
import { getGuestToken } from '@/utils/guest.js'
|
||||
import { request } from '@/api/request.js'
|
||||
import { clearHomeCache } from '@/api/workspace.js'
|
||||
import { openMenu } from '@/utils/nav.js'
|
||||
import { openMenu, orderQuickMenus } from '@/utils/nav.js'
|
||||
import { useSubsystem } from '@/utils/subsystem.js'
|
||||
import AppTabbar from '@/components/AppTabbar.vue'
|
||||
import SubOaDashboard from '@/components/sub/SubOaDashboard.vue'
|
||||
@@ -268,11 +266,13 @@ function isDashboardMenu(m) {
|
||||
}
|
||||
|
||||
const quickCandidates = computed(() =>
|
||||
orderQuickMenus(
|
||||
allMenus.value
|
||||
.filter((m) => m.leaf !== false && !isDashboardMenu(m))
|
||||
.slice()
|
||||
.sort((a, b) => (a.sort || 0) - (b.sort || 0))
|
||||
)
|
||||
)
|
||||
|
||||
const QUICK_MAX = 7
|
||||
|
||||
@@ -419,7 +419,7 @@ async function loadTodo() {
|
||||
}
|
||||
|
||||
async function loadNotices() {
|
||||
if (!isOa.value) return
|
||||
if (!isOa.value || props.embedded) return
|
||||
try {
|
||||
const data = await request({ url: '/api/oa/notice/list', data: { pageSize: 3 } })
|
||||
notices.value = (data && data.list) || []
|
||||
|
||||
@@ -152,7 +152,7 @@ function handleLogout() {
|
||||
clearPendingAuth()
|
||||
clearHomeCache()
|
||||
logout()
|
||||
uni.reLaunch({ url: '/pages/login/login' })
|
||||
uni.reLaunch({ url: '/pages/nav/nav' })
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,47 +1,6 @@
|
||||
<template>
|
||||
<view class="oa-dash">
|
||||
<template v-if="part !== 'bottom'">
|
||||
<view class="dash-card">
|
||||
<view class="dash-head">
|
||||
<view class="dash-head-left">
|
||||
<view class="head-icon hi-notice">
|
||||
<FaIcon name="bullhorn" color="#2563eb" :size="12" />
|
||||
</view>
|
||||
<text class="dash-title">公告</text>
|
||||
</view>
|
||||
<view class="dash-more" @tap="emit('view-notices')">
|
||||
<text class="dash-more-text">查看全部</text>
|
||||
<FaIcon name="chevron-right" color="#94a3b8" :size="11" />
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="!notices.length" class="dash-empty">
|
||||
<FaIcon name="bullhorn" color="#c0c4cc" :size="24" />
|
||||
<text class="dash-empty-text">暂无公告</text>
|
||||
</view>
|
||||
<swiper
|
||||
v-else
|
||||
class="notice-swiper"
|
||||
vertical
|
||||
autoplay
|
||||
circular
|
||||
:interval="3000"
|
||||
:duration="500"
|
||||
>
|
||||
<swiper-item v-for="n in notices" :key="n.id" @tap="emit('view-notices')">
|
||||
<view class="notice-line">
|
||||
<view class="notice-main">
|
||||
<text class="notice-tag" :class="'nt-' + (n.notice_type || 0)">
|
||||
{{ noticeTypeLabel(n.notice_type) }}
|
||||
</text>
|
||||
<text v-if="n.is_top === 1" class="notice-top">置顶</text>
|
||||
<text class="notice-title">{{ n.title }}</text>
|
||||
</view>
|
||||
<text class="notice-time">{{ noticeTime(n.publish_time) }}</text>
|
||||
</view>
|
||||
</swiper-item>
|
||||
</swiper>
|
||||
</view>
|
||||
|
||||
<view class="dash-card">
|
||||
<view class="dash-head">
|
||||
<view class="dash-head-left">
|
||||
@@ -148,7 +107,7 @@ const props = defineProps({
|
||||
data: { type: Object, default: () => ({}) },
|
||||
part: { type: String, default: 'top' }
|
||||
})
|
||||
const emit = defineEmits(['view-notices', 'view-schedules'])
|
||||
const emit = defineEmits(['view-schedules'])
|
||||
|
||||
const num = (v) => Number(v || 0)
|
||||
|
||||
@@ -187,22 +146,6 @@ const statusList = computed(() => {
|
||||
.map((x) => ({ ...x, pct: Math.round((num(x.count) / total) * 100) + '%' }))
|
||||
})
|
||||
|
||||
const notices = computed(() => props.data?.notices || [])
|
||||
|
||||
const noticeTypeLabel = (type) => ({ 1: '公告', 2: '活动' }[type] || '通知')
|
||||
|
||||
const pad2 = (n) => String(n).padStart(2, '0')
|
||||
const fmtDate = (d) => `${d.getFullYear()}-${pad2(d.getMonth() + 1)}-${pad2(d.getDate())}`
|
||||
function noticeTime(ts) {
|
||||
if (!ts) return ''
|
||||
const d = new Date(String(ts).replace(/-/g, '/'))
|
||||
if (Number.isNaN(d.getTime())) return String(ts).slice(5, 10)
|
||||
const now = new Date()
|
||||
if (fmtDate(d) === fmtDate(now)) return `${pad2(d.getHours())}:${pad2(d.getMinutes())}`
|
||||
if (d.getFullYear() === now.getFullYear()) return `${d.getMonth() + 1}/${d.getDate()}`
|
||||
return `${d.getFullYear()}-${d.getMonth() + 1}-${d.getDate()}`
|
||||
}
|
||||
|
||||
const money = (value) =>
|
||||
Number(value || 0).toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })
|
||||
</script>
|
||||
@@ -242,7 +185,6 @@ const money = (value) =>
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
&.hi-notice,
|
||||
&.hi-stat {
|
||||
background: $color-primary-bg;
|
||||
}
|
||||
@@ -277,19 +219,6 @@ const money = (value) =>
|
||||
color: $color-text-muted;
|
||||
}
|
||||
|
||||
.dash-empty {
|
||||
padding: 36rpx 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 12rpx;
|
||||
}
|
||||
|
||||
.dash-empty-text {
|
||||
font-size: 24rpx;
|
||||
color: $color-text-muted;
|
||||
}
|
||||
|
||||
.stat-tile {
|
||||
padding: 20rpx 20rpx 8rpx;
|
||||
border-radius: $radius-md;
|
||||
@@ -503,63 +432,4 @@ const money = (value) =>
|
||||
color: $color-text-muted;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.notice-swiper {
|
||||
height: 68rpx;
|
||||
}
|
||||
|
||||
.notice-line {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12rpx;
|
||||
height: 68rpx;
|
||||
|
||||
&:active {
|
||||
opacity: 0.6;
|
||||
}
|
||||
}
|
||||
|
||||
.notice-main {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10rpx;
|
||||
}
|
||||
|
||||
.notice-tag {
|
||||
flex-shrink: 0;
|
||||
font-size: 20rpx;
|
||||
padding: 2rpx 12rpx;
|
||||
border-radius: $radius-sm;
|
||||
background: $color-primary-bg;
|
||||
color: $color-primary;
|
||||
|
||||
&.nt-2 {
|
||||
background: #ecfdf5;
|
||||
color: $color-success;
|
||||
}
|
||||
}
|
||||
|
||||
.notice-top {
|
||||
flex-shrink: 0;
|
||||
font-size: 20rpx;
|
||||
color: $color-danger;
|
||||
}
|
||||
|
||||
.notice-title {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
font-size: 26rpx;
|
||||
color: $color-text;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.notice-time {
|
||||
flex-shrink: 0;
|
||||
font-size: 20rpx;
|
||||
color: $color-text-muted;
|
||||
}
|
||||
</style>
|
||||
@@ -60,7 +60,7 @@
|
||||
"appid" : "wxd500522c8b9440a6",
|
||||
"setting" : {
|
||||
"urlCheck" : false,
|
||||
"minified" : true,
|
||||
"minified" : false,
|
||||
"postcss" : true
|
||||
},
|
||||
"usingComponents" : true,
|
||||
|
||||
@@ -161,6 +161,14 @@
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": "客户关系 · 我的"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "project/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "客户项目",
|
||||
"navigationBarBackgroundColor": "#F8FAFC",
|
||||
"navigationBarTextStyle": "black"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
@@ -157,7 +157,7 @@ const currentNodeLabel = computed(() => {
|
||||
|
||||
onLoad((options) => {
|
||||
if (!isLoggedIn()) {
|
||||
uni.reLaunch({ url: '/pages/login/login' })
|
||||
uni.reLaunch({ url: '/pages/nav/nav' })
|
||||
return
|
||||
}
|
||||
const id = options && options.id
|
||||
|
||||
@@ -14,21 +14,24 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<scroll-view class="tab-scroll" scroll-x :show-scrollbar="false">
|
||||
<view class="tab-list">
|
||||
<view class="body">
|
||||
<scroll-view class="side-nav" scroll-y :show-scrollbar="false">
|
||||
<view
|
||||
v-for="tab in statusTabs"
|
||||
:key="String(tab.value)"
|
||||
class="tab-item"
|
||||
class="side-item"
|
||||
:class="{ active: currentStatus === tab.value }"
|
||||
@tap="onStatusChange(tab.value)"
|
||||
>
|
||||
<text>{{ tab.label }}</text>
|
||||
</view>
|
||||
<text class="side-text">{{ tab.label }}</text>
|
||||
</view>
|
||||
</scroll-view>
|
||||
|
||||
<view class="content">
|
||||
<view class="content-head">
|
||||
<text class="content-title">{{ currentTabLabel }}</text>
|
||||
<text class="page-tip">审批由各业务模块提交后在此查看与处理</text>
|
||||
</view>
|
||||
|
||||
<scroll-view class="list-scroll" scroll-y :show-scrollbar="false" @scrolltolower="loadMore">
|
||||
<view v-if="loading && !list.length" class="state-box">
|
||||
@@ -76,10 +79,12 @@
|
||||
<view class="bottom-space" />
|
||||
</scroll-view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { onShow } from '@dcloudio/uni-app'
|
||||
import {
|
||||
fetchApprovalList,
|
||||
@@ -103,9 +108,14 @@ const finished = ref(false)
|
||||
const keyword = ref('')
|
||||
const currentStatus = ref('')
|
||||
|
||||
const currentTabLabel = computed(() => {
|
||||
const hit = statusTabs.find(tab => tab.value === currentStatus.value)
|
||||
return hit ? hit.label : '全部'
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
if (!isLoggedIn()) {
|
||||
uni.reLaunch({ url: '/pages/login/login' })
|
||||
uni.reLaunch({ url: '/pages/nav/nav' })
|
||||
return
|
||||
}
|
||||
refresh()
|
||||
@@ -215,37 +225,62 @@ function openDetail(id) {
|
||||
}
|
||||
}
|
||||
|
||||
.tab-scroll {
|
||||
.body {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.side-nav {
|
||||
flex-shrink: 0;
|
||||
white-space: nowrap;
|
||||
align-self: stretch;
|
||||
width: 184rpx;
|
||||
background: $color-card;
|
||||
padding: 0 $page-padding-x 12rpx;
|
||||
border-right: 1rpx solid $color-divider;
|
||||
}
|
||||
|
||||
.tab-list {
|
||||
display: inline-flex;
|
||||
gap: 16rpx;
|
||||
padding: 16rpx 0 4rpx;
|
||||
}
|
||||
|
||||
.tab-item {
|
||||
padding: 10rpx 28rpx;
|
||||
border-radius: $radius-full;
|
||||
background: $color-bg-page;
|
||||
.side-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 26rpx 12rpx;
|
||||
border-left: 6rpx solid transparent;
|
||||
font-size: 26rpx;
|
||||
color: $color-text-secondary;
|
||||
box-shadow: $shadow-card;
|
||||
|
||||
&.active {
|
||||
background: $color-primary;
|
||||
color: #ffffff;
|
||||
font-weight: 500;
|
||||
background: $color-bg-page;
|
||||
border-left-color: $color-primary;
|
||||
color: $color-primary;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
|
||||
.content {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.content-head {
|
||||
flex-shrink: 0;
|
||||
padding: 18rpx 20rpx 0;
|
||||
}
|
||||
|
||||
.content-title {
|
||||
display: block;
|
||||
font-size: 28rpx;
|
||||
font-weight: 600;
|
||||
color: $color-text;
|
||||
}
|
||||
|
||||
.page-tip {
|
||||
display: block;
|
||||
padding: 12rpx $page-padding-x 0;
|
||||
margin-top: 4rpx;
|
||||
font-size: 22rpx;
|
||||
color: $color-text-muted;
|
||||
}
|
||||
@@ -257,7 +292,7 @@ function openDetail(id) {
|
||||
|
||||
.approval-card {
|
||||
@include card;
|
||||
margin: 16rpx $page-padding-x 0;
|
||||
margin: 16rpx 20rpx 0;
|
||||
padding: 24rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
@@ -88,7 +88,7 @@ const keyword = ref('')
|
||||
|
||||
onLoad(() => {
|
||||
if (!isLoggedIn()) {
|
||||
uni.reLaunch({ url: '/pages/login/login' })
|
||||
uni.reLaunch({ url: '/pages/nav/nav' })
|
||||
return
|
||||
}
|
||||
refresh()
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -183,7 +183,7 @@ const headPad = mpHeadPad()
|
||||
import { onShow } from '@dcloudio/uni-app'
|
||||
import { isLoggedIn } from '@/utils/auth.js'
|
||||
import { fetchHome } from '@/api/workspace.js'
|
||||
import { openMenu, resolveNativeRoute } from '@/utils/nav.js'
|
||||
import { openMenu, resolveNativeRoute, orderQuickMenus, QUICK_TITLE_ICONS } from '@/utils/nav.js'
|
||||
import { request } from '@/api/request.js'
|
||||
import AppTabbar from '@/components/MainTabbar.vue'
|
||||
|
||||
@@ -286,16 +286,16 @@ const quickApps = computed(() => {
|
||||
key: 'm' + menu.id,
|
||||
name: menu.title,
|
||||
menu,
|
||||
icon: icon || 'circle',
|
||||
icon: icon || menu.icon || QUICK_TITLE_ICONS[menu.title] || 'circle',
|
||||
tint: 'tint-' + (picked.length % 8)
|
||||
})
|
||||
}
|
||||
|
||||
leafMenus.value.filter((m) => resolveNativeRoute(m)).forEach((m) => push(m))
|
||||
moduleGroups.value.filter((g) => !g.locked).forEach((g) => push(g.items[0], g.icon))
|
||||
commonMenus.value.forEach((m, i) => push(m, TOOL_ICONS[i % TOOL_ICONS.length]))
|
||||
commonMenus.value.forEach((m, i) => push(m, QUICK_TITLE_ICONS[m.title] || TOOL_ICONS[i % TOOL_ICONS.length]))
|
||||
|
||||
return picked
|
||||
return orderQuickMenus(picked)
|
||||
})
|
||||
|
||||
const kpiList = computed(() => [
|
||||
@@ -410,7 +410,7 @@ function formatTime(dateStr) {
|
||||
|
||||
onMounted(() => {
|
||||
if (!isLoggedIn()) {
|
||||
uni.reLaunch({ url: '/pages/login/login' })
|
||||
uni.reLaunch({ url: '/pages/nav/nav' })
|
||||
return
|
||||
}
|
||||
loadAll()
|
||||
|
||||
@@ -97,7 +97,7 @@ const headPad = mpHeadPad()
|
||||
import { onShow } from '@dcloudio/uni-app'
|
||||
import { isLoggedIn } from '@/utils/auth.js'
|
||||
import { fetchHome } from '@/api/workspace.js'
|
||||
import { openMenu } from '@/utils/nav.js'
|
||||
import { openMenu, orderQuickMenus } from '@/utils/nav.js'
|
||||
import AppTabbar from '@/components/MainTabbar.vue'
|
||||
|
||||
const MODULE_ICONS = {
|
||||
@@ -159,6 +159,7 @@ const groups = computed(() => {
|
||||
const dirGroups = []
|
||||
groupMap.forEach((g) => dirGroups.push(g))
|
||||
dirGroups.sort((a, b) => (a.sort || 0) - (b.sort || 0))
|
||||
common.items = orderQuickMenus(common.items)
|
||||
|
||||
const all = []
|
||||
if (common.items.length) all.push(common)
|
||||
@@ -216,7 +217,7 @@ async function load() {
|
||||
|
||||
onMounted(() => {
|
||||
if (!isLoggedIn()) {
|
||||
uni.reLaunch({ url: '/pages/login/login' })
|
||||
uni.reLaunch({ url: '/pages/nav/nav' })
|
||||
return
|
||||
}
|
||||
load()
|
||||
|
||||
@@ -7,10 +7,9 @@
|
||||
|
||||
<script>
|
||||
import { onShow } from '@dcloudio/uni-app'
|
||||
import { isLoggedIn } from '@/utils/auth.js'
|
||||
|
||||
onShow(() => {
|
||||
uni.reLaunch({ url: isLoggedIn() ? '/pages/nav/nav' : '/pages/login/login' })
|
||||
uni.reLaunch({ url: '/pages/nav/nav' })
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
@@ -417,7 +417,7 @@ async function handleResetPassword() {
|
||||
resetCountdown()
|
||||
uni.showToast({ title: '重置成功,请登录', icon: 'success' })
|
||||
setTimeout(() => {
|
||||
uni.reLaunch({ url: '/pages/login/login' })
|
||||
uni.reLaunch({ url: '/pages/nav/nav' })
|
||||
}, 600)
|
||||
} catch (err) {
|
||||
} finally {
|
||||
@@ -432,7 +432,7 @@ function backToPrev() {
|
||||
}
|
||||
|
||||
function goBack() {
|
||||
uni.navigateBack({ fail: () => uni.reLaunch({ url: '/pages/login/login' }) })
|
||||
uni.navigateBack({ fail: () => uni.reLaunch({ url: '/pages/nav/nav' }) })
|
||||
}
|
||||
|
||||
onUnmounted(() => {
|
||||
|
||||
+336
-1017
File diff suppressed because it is too large.
Load diff
@@ -195,7 +195,7 @@ async function handleSubmit() {
|
||||
setTenantName(form.tenant_name.trim())
|
||||
uni.showToast({ title: '注册成功,请登录', icon: 'success' })
|
||||
setTimeout(() => {
|
||||
uni.navigateBack({ fail: () => uni.reLaunch({ url: '/pages/login/login' }) })
|
||||
uni.navigateBack({ fail: () => uni.reLaunch({ url: '/pages/nav/nav' }) })
|
||||
}, 500)
|
||||
} catch {
|
||||
} finally {
|
||||
@@ -204,7 +204,7 @@ async function handleSubmit() {
|
||||
}
|
||||
|
||||
function goBack() {
|
||||
uni.navigateBack({ fail: () => uni.reLaunch({ url: '/pages/login/login' }) })
|
||||
uni.navigateBack({ fail: () => uni.reLaunch({ url: '/pages/nav/nav' }) })
|
||||
}
|
||||
|
||||
onUnmounted(() => {
|
||||
|
||||
+122
-202
@@ -7,7 +7,7 @@
|
||||
<text class="head-title">工作台</text>
|
||||
</view>
|
||||
<view v-if="!guest" class="account-chip" @tap="goProfile"><FaIcon name="user" color="#3478f6" :size="15" /><text>{{ user.name || user.nickname || '未设置姓名' }}</text></view>
|
||||
<button v-else class="account-chip account-chip-button" open-type="getPhoneNumber" @getphonenumber="onCardPhone($event)"><FaIcon name="user" color="#3478f6" :size="15" /><text>游客</text></button>
|
||||
<view v-else class="account-chip" @tap="goLogin"><FaIcon name="user" color="#3478f6" :size="15" /><text>登录 / 注册</text></view>
|
||||
</view>
|
||||
<view v-if="!guest" class="tenant-switch" @tap="chooseTenant">
|
||||
<view class="tenant-mark"><FaIcon name="building" color="#ffffff" :size="19" /></view>
|
||||
@@ -32,26 +32,8 @@
|
||||
</view>
|
||||
|
||||
<view v-else class="grid">
|
||||
<!-- #ifdef MP-WEIXIN -->
|
||||
<button
|
||||
v-for="card in cards"
|
||||
v-show="guest"
|
||||
:key="'phone-' + (card.code || card.id)"
|
||||
class="cell cell-button"
|
||||
open-type="getPhoneNumber"
|
||||
@getphonenumber="onCardPhone($event, card)"
|
||||
>
|
||||
<view class="portal-card" :class="{ locked: card.locked }">
|
||||
<view class="tint-icon portal-icon" :class="card.tint">
|
||||
<FaIcon :name="card.icon" color="#ffffff" :size="26" />
|
||||
</view>
|
||||
<text class="portal-name">{{ card.name }}</text>
|
||||
</view>
|
||||
</button>
|
||||
<!-- #endif -->
|
||||
<view
|
||||
v-for="card in cards"
|
||||
v-show="!guest || !isMp"
|
||||
:key="card.code || card.id"
|
||||
class="cell"
|
||||
@tap="enter(card)"
|
||||
@@ -61,6 +43,7 @@
|
||||
<FaIcon :name="card.icon" color="#ffffff" :size="26" />
|
||||
</view>
|
||||
<text class="portal-name">{{ card.name }}</text>
|
||||
<text v-if="card.locked" class="portal-lock-tag">登录后可体验</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -115,6 +98,19 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view v-if="guestLoginVisible" class="guest-login-mask" @tap="closeGuestLogin">
|
||||
<view class="guest-login-card" @tap.stop>
|
||||
<view class="guest-login-icon"><FaIcon name="lock" color="#2563eb" :size="24" /></view>
|
||||
<text class="guest-login-title">{{ guestLoginTitle }}</text>
|
||||
<text class="guest-login-desc">该功能需要登录企业账号后使用,您也可以继续以游客身份浏览公开功能。</text>
|
||||
<button class="guest-login-btn" @tap="goLogin">
|
||||
<FaIcon name="user" color="#ffffff" :size="18" />
|
||||
<text>登录 / 注册</text>
|
||||
</button>
|
||||
<view class="guest-login-cancel" @tap="closeGuestLogin"><text>暂不登录</text></view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@@ -127,36 +123,22 @@ import { onShow } from '@dcloudio/uni-app'
|
||||
import { isLoggedIn, getTenants, getTid, setAuthTokens, setTenants, setTid, setTenantName, getUser, setUser } from '@/utils/auth.js'
|
||||
import { switchTenant, loginByMiniapp } from '@/api/auth.js'
|
||||
import { fetchHome, fetchPublicModules, fetchPublicMenus, clearHomeCache } from '@/api/workspace.js'
|
||||
import { onboardingPhone, getOnboardingStatus } from '@/api/onboarding.js'
|
||||
import { setPendingCard, takePendingCard } from '@/utils/onboarding.js'
|
||||
import { getOnboardingStatus } from '@/api/onboarding.js'
|
||||
import { openMenu } from '@/utils/nav.js'
|
||||
import { getSubsystemByModule, goSubsystem } from '@/config/subsystems.js'
|
||||
import { getGuestToken, setGuestToken, clearGuestToken } from '@/utils/guest.js'
|
||||
import { guestMiniLogin, guestMerge } from '@/api/guest.js'
|
||||
import { getGuestToken, clearGuestToken } from '@/utils/guest.js'
|
||||
import { guestMerge } from '@/api/guest.js'
|
||||
|
||||
const guestAuthVisible = ref(false)
|
||||
const guestAuthLoading = ref(false)
|
||||
const guestAuthDismissed = ref(false)
|
||||
const phoneBusy = ref(false)
|
||||
let isMp = false
|
||||
// #ifdef MP-WEIXIN
|
||||
isMp = true
|
||||
// #endif
|
||||
const guestLoginVisible = ref(false)
|
||||
const guestLoginTitle = ref('登录后可体验')
|
||||
|
||||
function canRequestGuestPhone() {
|
||||
// #ifdef MP-WEIXIN
|
||||
return true
|
||||
// #endif
|
||||
// eslint-disable-next-line no-unreachable
|
||||
return false
|
||||
function openGuestLogin(name) {
|
||||
guestLoginTitle.value = name ? '「' + name + '」登录后可体验' : '登录后可体验'
|
||||
guestLoginVisible.value = true
|
||||
}
|
||||
|
||||
function maybeAskGuestAuth() {
|
||||
if (!guest.value || getGuestToken() || guestAuthDismissed.value || !canRequestGuestPhone()) {
|
||||
guestAuthVisible.value = false
|
||||
return
|
||||
}
|
||||
guestAuthVisible.value = true
|
||||
function closeGuestLogin() {
|
||||
guestLoginVisible.value = false
|
||||
}
|
||||
|
||||
function navUniLoginCode() {
|
||||
@@ -169,58 +151,6 @@ function navUniLoginCode() {
|
||||
})
|
||||
}
|
||||
|
||||
async function onGuestPhone(e) {
|
||||
const detail = (e && e.detail) || {}
|
||||
if (String(detail.errMsg || '').indexOf('ok') === -1 || !detail.code) {
|
||||
uni.showToast({ title: '未获取到手机号,请重试', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (guestAuthLoading.value) return
|
||||
guestAuthLoading.value = true
|
||||
try {
|
||||
const code = await navUniLoginCode()
|
||||
let appid = ''
|
||||
try {
|
||||
appid = (uni.getAccountInfoSync().miniProgram || {}).appId || ''
|
||||
} catch (err) {
|
||||
appid = ''
|
||||
}
|
||||
const res = await guestMiniLogin({ code, phoneCode: detail.code, appid })
|
||||
if (res && res.type === 'user') {
|
||||
guestAuthVisible.value = false
|
||||
await completeUserLogin(res)
|
||||
return
|
||||
}
|
||||
if (!res || !res.token) throw new Error('未返回游客令牌')
|
||||
setGuestToken(res.token)
|
||||
guestAuthVisible.value = false
|
||||
uni.showToast({ title: '验证成功,数据可保存了', icon: 'none' })
|
||||
} catch (err) {
|
||||
console.error('[nav] guest mini-login failed:', err)
|
||||
uni.showToast({ title: (err && err.message) || '验证失败,请重试', icon: 'none' })
|
||||
} finally {
|
||||
guestAuthLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function completeUserLogin(res) {
|
||||
const list = Array.isArray(res.tenants) ? res.tenants : []
|
||||
setAuthTokens(res.tokens || {})
|
||||
if (res.need_choose_tenant && list.length > 1) {
|
||||
askChooseTenant(list)
|
||||
return
|
||||
}
|
||||
const t0 = list[0] || {}
|
||||
setTenants(list)
|
||||
if (t0.tid) {
|
||||
setTid(t0.tid)
|
||||
setTenantName(t0.tenant_name || '')
|
||||
}
|
||||
await mergeGuestIfAny()
|
||||
await load(true)
|
||||
uni.showToast({ title: '已登录,欢迎回来', icon: 'none' })
|
||||
}
|
||||
|
||||
const tenantPickerVisible = ref(false)
|
||||
const tenantPickerRequired = ref(false)
|
||||
const tenantPickerMode = ref('login')
|
||||
@@ -294,11 +224,6 @@ async function pickTenant(item) {
|
||||
}
|
||||
}
|
||||
|
||||
function skipGuestAuth() {
|
||||
guestAuthDismissed.value = true
|
||||
guestAuthVisible.value = false
|
||||
}
|
||||
|
||||
async function mergeGuestIfAny() {
|
||||
if (!getGuestToken()) return
|
||||
try {
|
||||
@@ -346,15 +271,16 @@ const cards = computed(() => {
|
||||
return publicModules.value.map((mod, index) => {
|
||||
const code = String(mod.code || '').toLowerCase()
|
||||
const needTenant = mod.require_login !== 0
|
||||
const locked = needTenant
|
||||
return {
|
||||
id: mod.id,
|
||||
code: mod.code,
|
||||
path: mod.path || '',
|
||||
name: mod.name || '未命名系统',
|
||||
desc: mod.description || (needTenant ? '加入企业后可用' : '可直接使用'),
|
||||
desc: locked ? '登录后可体验完整功能' : (mod.description || '可直接使用'),
|
||||
icon: MODULE_ICONS[code] || 'cube',
|
||||
tint: 'tint-' + (index % 8),
|
||||
locked: false,
|
||||
locked,
|
||||
needTenant,
|
||||
items: [],
|
||||
total: 0
|
||||
@@ -429,6 +355,11 @@ function goProfile() {
|
||||
uni.navigateTo({ url: '/pages/profile/profile' })
|
||||
}
|
||||
|
||||
function goLogin() {
|
||||
closeGuestLogin()
|
||||
uni.navigateTo({ url: '/pages/login/login' })
|
||||
}
|
||||
|
||||
function chooseTenant() {
|
||||
const list = tenants.value
|
||||
if (list.length <= 1) { uni.showToast({ title: list.length ? '当前账号仅绑定一个企业' : '暂无可切换的企业', icon: 'none' })
|
||||
@@ -438,49 +369,6 @@ function chooseTenant() {
|
||||
openTenantPicker(list, 'switch', false)
|
||||
}
|
||||
|
||||
async function onCardPhone(e, card = null) {
|
||||
const detail = (e && e.detail) || {}
|
||||
if (String(detail.errMsg || '').indexOf('ok') === -1 || !detail.code) {
|
||||
uni.showToast({ title: '请先完成手机号验证才能使用', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (phoneBusy.value) return
|
||||
phoneBusy.value = true
|
||||
uni.showLoading({ title: '验证中...', mask: true })
|
||||
try {
|
||||
const code = await navUniLoginCode()
|
||||
let appid = ''
|
||||
try {
|
||||
appid = (uni.getAccountInfoSync().miniProgram || {}).appId || ''
|
||||
} catch (err) {
|
||||
appid = ''
|
||||
}
|
||||
if (card) setPendingCard(card)
|
||||
const res = await onboardingPhone({ code, phoneCode: detail.code, appid })
|
||||
if (res && res.need_register) {
|
||||
uni.hideLoading()
|
||||
uni.navigateTo({
|
||||
url: '/pages/onboarding/register?token=' + encodeURIComponent(res.register_token || '') +
|
||||
'&mobile_mask=' + encodeURIComponent(res.mobile_mask || '')
|
||||
})
|
||||
return
|
||||
}
|
||||
const ready = await silentLogin(code, detail.code)
|
||||
if (!ready) return
|
||||
await load(true)
|
||||
if (card) {
|
||||
await enter(card)
|
||||
takePendingCard()
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('[nav] onboarding phone failed:', err)
|
||||
uni.showToast({ title: (err && err.message) || '验证失败,请重试', icon: 'none' })
|
||||
} finally {
|
||||
uni.hideLoading()
|
||||
phoneBusy.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function silentLogin(code, phoneCode) {
|
||||
const res = await loginByMiniapp({ code, phoneCode })
|
||||
if (!res || !res.tokens || !res.tokens.access_token) {
|
||||
@@ -503,11 +391,20 @@ async function silentLogin(code, phoneCode) {
|
||||
|
||||
async function enter(card) {
|
||||
if (card.locked) {
|
||||
if (guest.value) {
|
||||
openGuestLogin(card.name)
|
||||
return
|
||||
}
|
||||
openMenu({ locked: true, title: card.name })
|
||||
return
|
||||
}
|
||||
if (guest.value) {
|
||||
uni.showToast({ title: '请先完成手机号验证', icon: 'none' })
|
||||
if (goSubsystemByModule(card.code)) return
|
||||
if (card.path) {
|
||||
openMenu({ title: card.name, path: card.path, leaf: true }, card.name)
|
||||
return
|
||||
}
|
||||
uni.showToast({ title: card.name + '暂未开放', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (card.needTenant) {
|
||||
@@ -554,10 +451,6 @@ onMounted(() => {
|
||||
|
||||
onShow(() => {
|
||||
if (!loading.value) load()
|
||||
const pending = takePendingCard()
|
||||
if (pending && isLoggedIn()) {
|
||||
setTimeout(() => enter(pending), 600)
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -770,64 +663,18 @@ onShow(() => {
|
||||
color: $color-text-muted;
|
||||
}
|
||||
|
||||
.cell-button {
|
||||
display: block;
|
||||
margin: 0 0 20rpx 0;
|
||||
padding: 0 20rpx 0 0;
|
||||
background: transparent;
|
||||
border: none;
|
||||
border-radius: 0;
|
||||
line-height: normal;
|
||||
text-align: left;
|
||||
|
||||
&::after {
|
||||
border: none;
|
||||
}
|
||||
.portal-lock-tag {
|
||||
padding: 4rpx 14rpx;
|
||||
border-radius: 20rpx;
|
||||
background: #eef2f8;
|
||||
color: #8a9bb3;
|
||||
font-size: 20rpx;
|
||||
}
|
||||
|
||||
.bottom-space {
|
||||
height: 48rpx;
|
||||
}
|
||||
|
||||
.guest-auth-mask {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
right: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
z-index: 99;
|
||||
}
|
||||
|
||||
.guest-auth-full {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
border: none;
|
||||
border-radius: 0;
|
||||
background: transparent;
|
||||
opacity: 0;
|
||||
|
||||
&::after {
|
||||
border: none;
|
||||
}
|
||||
}
|
||||
|
||||
.guest-auth-later {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 64rpx;
|
||||
z-index: 100;
|
||||
text-align: center;
|
||||
font-size: 24rpx;
|
||||
color: #94a3b8;
|
||||
padding: 16rpx;
|
||||
}
|
||||
|
||||
.tenant-picker-mask {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
@@ -995,4 +842,77 @@ onShow(() => {
|
||||
font-size: 22rpx;
|
||||
color: $color-text-muted;
|
||||
}
|
||||
|
||||
.guest-login-mask {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
right: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
z-index: 1200;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 0 60rpx;
|
||||
background: rgba(15, 23, 42, .48);
|
||||
}
|
||||
.guest-login-card {
|
||||
width: 100%;
|
||||
max-width: 560rpx;
|
||||
padding: 48rpx 40rpx 32rpx;
|
||||
border-radius: 28rpx;
|
||||
background: #ffffff;
|
||||
box-shadow: 0 20rpx 60rpx rgba(15, 23, 42, .18);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
.guest-login-icon {
|
||||
width: 96rpx;
|
||||
height: 96rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 28rpx;
|
||||
background: #eaf2ff;
|
||||
}
|
||||
.guest-login-title {
|
||||
margin-top: 24rpx;
|
||||
font-size: 32rpx;
|
||||
font-weight: 700;
|
||||
color: #17345f;
|
||||
text-align: center;
|
||||
}
|
||||
.guest-login-desc {
|
||||
margin-top: 16rpx;
|
||||
font-size: 24rpx;
|
||||
line-height: 1.6;
|
||||
color: #64748b;
|
||||
text-align: center;
|
||||
}
|
||||
.guest-login-btn {
|
||||
width: 100%;
|
||||
height: 88rpx;
|
||||
margin: 36rpx 0 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 12rpx;
|
||||
border: none;
|
||||
border-radius: $radius-full;
|
||||
background: linear-gradient(135deg, #60a5fa, #2563eb);
|
||||
color: #ffffff;
|
||||
font-size: 28rpx;
|
||||
font-weight: 600;
|
||||
box-shadow: 0 10rpx 24rpx rgba(37, 99, 235, .22);
|
||||
|
||||
&::after { border: none; }
|
||||
}
|
||||
.guest-login-cancel {
|
||||
margin-top: 20rpx;
|
||||
padding: 16rpx;
|
||||
font-size: 26rpx;
|
||||
color: #8a9bb3;
|
||||
}
|
||||
</style>
|
||||
@@ -623,7 +623,7 @@ async function punch(type) {
|
||||
|
||||
onShow(() => {
|
||||
if (!isLoggedIn()) {
|
||||
uni.reLaunch({ url: '/pages/login/login' })
|
||||
uni.reLaunch({ url: '/pages/nav/nav' })
|
||||
return
|
||||
}
|
||||
startTimer()
|
||||
|
||||
@@ -155,7 +155,7 @@ const deductItems = computed(() => {
|
||||
|
||||
onMounted(() => {
|
||||
if (!isLoggedIn()) {
|
||||
uni.reLaunch({ url: '/pages/login/login' })
|
||||
uni.reLaunch({ url: '/pages/nav/nav' })
|
||||
return
|
||||
}
|
||||
const pages = getCurrentPages()
|
||||
|
||||
@@ -58,7 +58,7 @@ const currentMonth = `${now.getFullYear()}-${pad(now.getMonth() + 1)}`
|
||||
|
||||
onMounted(() => {
|
||||
if (!isLoggedIn()) {
|
||||
uni.reLaunch({ url: '/pages/login/login' })
|
||||
uni.reLaunch({ url: '/pages/nav/nav' })
|
||||
return
|
||||
}
|
||||
loadPayrolls()
|
||||
|
||||
@@ -159,7 +159,7 @@ const callPhone = computed(() => (contact.value ? primaryPhone(contact.value) :
|
||||
|
||||
onLoad((options) => {
|
||||
if (!isLoggedIn()) {
|
||||
uni.reLaunch({ url: '/pages/login/login' })
|
||||
uni.reLaunch({ url: '/pages/nav/nav' })
|
||||
return
|
||||
}
|
||||
id.value = Number((options && options.id) || 0)
|
||||
|
||||
@@ -109,7 +109,7 @@ const hasMore = ref(false)
|
||||
|
||||
onMounted(() => {
|
||||
if (!isLoggedIn()) {
|
||||
uni.reLaunch({ url: '/pages/login/login' })
|
||||
uni.reLaunch({ url: '/pages/nav/nav' })
|
||||
return
|
||||
}
|
||||
loadOrgTree()
|
||||
|
||||
@@ -406,7 +406,7 @@ function onCalendarCellTap(cell) {
|
||||
|
||||
onShow(() => {
|
||||
if (!isLoggedIn()) {
|
||||
uni.reLaunch({ url: '/pages/login/login' })
|
||||
uni.reLaunch({ url: '/pages/nav/nav' })
|
||||
return
|
||||
}
|
||||
reload()
|
||||
|
||||
@@ -103,7 +103,7 @@ const loading = ref(true)
|
||||
|
||||
onMounted(() => {
|
||||
if (!isLoggedIn()) {
|
||||
uni.reLaunch({ url: '/pages/login/login' })
|
||||
uni.reLaunch({ url: '/pages/nav/nav' })
|
||||
return
|
||||
}
|
||||
const pages = getCurrentPages()
|
||||
|
||||
@@ -105,7 +105,7 @@ const loading = ref(false)
|
||||
|
||||
onMounted(() => {
|
||||
if (!isLoggedIn()) {
|
||||
uni.reLaunch({ url: '/pages/login/login' })
|
||||
uni.reLaunch({ url: '/pages/nav/nav' })
|
||||
return
|
||||
}
|
||||
loadCategories()
|
||||
|
||||
@@ -192,7 +192,7 @@ const recordGroups = computed(() => {
|
||||
|
||||
onLoad((options) => {
|
||||
if (!isLoggedIn()) {
|
||||
uni.reLaunch({ url: '/pages/login/login' })
|
||||
uni.reLaunch({ url: '/pages/nav/nav' })
|
||||
return
|
||||
}
|
||||
fileId.value = Number((options && options.id) || 0)
|
||||
|
||||
@@ -109,7 +109,7 @@ const hasMore = ref(false)
|
||||
|
||||
onLoad(() => {
|
||||
if (!isLoggedIn()) {
|
||||
uni.reLaunch({ url: '/pages/login/login' })
|
||||
uni.reLaunch({ url: '/pages/nav/nav' })
|
||||
return
|
||||
}
|
||||
init()
|
||||
|
||||
@@ -58,7 +58,7 @@ const loading = ref(true)
|
||||
|
||||
onMounted(() => {
|
||||
if (!isLoggedIn()) {
|
||||
uni.reLaunch({ url: '/pages/login/login' })
|
||||
uni.reLaunch({ url: '/pages/nav/nav' })
|
||||
return
|
||||
}
|
||||
const pages = getCurrentPages()
|
||||
|
||||
@@ -57,7 +57,7 @@ const loading = ref(false)
|
||||
|
||||
onMounted(() => {
|
||||
if (!isLoggedIn()) {
|
||||
uni.reLaunch({ url: '/pages/login/login' })
|
||||
uni.reLaunch({ url: '/pages/nav/nav' })
|
||||
return
|
||||
}
|
||||
loadNotices()
|
||||
|
||||
@@ -1,9 +1,18 @@
|
||||
<template>
|
||||
<view class="page">
|
||||
<view class="nav-bar" :style="headPad">
|
||||
<view class="nav-back" @tap="goBack">
|
||||
<FaIcon name="chevron-left" color="#1e293b" :size="20" />
|
||||
<text class="nav-back-text">返回</text>
|
||||
</view>
|
||||
<text class="nav-title">设置登录密码</text>
|
||||
<view class="nav-side" />
|
||||
</view>
|
||||
|
||||
<view class="hero">
|
||||
<text class="eyebrow">YUNZE WORKSPACE</text>
|
||||
<text class="title">设置登录密码</text>
|
||||
<text class="desc">手机号 {{ mobileMask || '已验证' }} 尚未注册,设置密码后即可使用工作台</text>
|
||||
<text class="title">设置登录密码(可选)</text>
|
||||
<text class="desc">手机号 {{ mobileMask || '已验证' }} 尚未注册。可设置密码解锁完整服务,也可直接返回,继续免登录体验公开功能</text>
|
||||
</view>
|
||||
|
||||
<view class="card">
|
||||
@@ -15,11 +24,12 @@
|
||||
<text class="label">确认密码</text>
|
||||
<input v-model="confirmPassword" class="input" type="password" placeholder="再输入一次" :maxlength="32" />
|
||||
</view>
|
||||
<text class="hint">密码至少 6 位;当前账号会在注册时自动绑定,下次可直接进入</text>
|
||||
<text class="hint">密码至少 6 位;此步骤为可选,跳过不影响继续浏览公开功能</text>
|
||||
<view v-if="errorMsg" class="error"><text>{{ errorMsg }}</text></view>
|
||||
<button class="submit" :disabled="loading" @tap="handleSubmit">
|
||||
{{ loading ? '注册中…' : '完成注册' }}
|
||||
</button>
|
||||
<view class="skip" @tap="goBack"><text>暂不设置,返回工作台</text></view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
@@ -27,12 +37,15 @@
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import { mpHeadPad } from '@/utils/mpHead.js'
|
||||
import FaIcon from '@/components/FaIcon.vue'
|
||||
import { onboardingRegister } from '@/api/onboarding.js'
|
||||
import { setAuthTokens, setTid, setTenantName } from '@/utils/auth.js'
|
||||
import { guestMerge } from '@/api/guest.js'
|
||||
import { getGuestToken, clearGuestToken } from '@/utils/guest.js'
|
||||
import { clearHomeCache } from '@/api/workspace.js'
|
||||
|
||||
const headPad = mpHeadPad()
|
||||
const token = ref('')
|
||||
const mobileMask = ref('')
|
||||
const password = ref('')
|
||||
@@ -44,15 +57,21 @@ onLoad((options = {}) => {
|
||||
token.value = options.token || ''
|
||||
mobileMask.value = decodeURIComponent(options.mobile_mask || '')
|
||||
if (!token.value) {
|
||||
errorMsg.value = '验证会话已失效,请返回工作台重新验证手机号'
|
||||
errorMsg.value = '验证会话已失效,可返回工作台继续使用公开功能'
|
||||
}
|
||||
})
|
||||
|
||||
function goBack() {
|
||||
const pages = (typeof getCurrentPages === 'function' && getCurrentPages()) || []
|
||||
if (pages.length > 1) uni.navigateBack()
|
||||
else uni.reLaunch({ url: '/pages/nav/nav' })
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
if (loading.value) return
|
||||
errorMsg.value = ''
|
||||
if (!token.value) {
|
||||
errorMsg.value = '验证会话已失效,请返回工作台重新验证手机号'
|
||||
errorMsg.value = '验证会话已失效,可返回工作台继续使用公开功能'
|
||||
return
|
||||
}
|
||||
if (password.value.length < 6) {
|
||||
@@ -103,7 +122,24 @@ async function handleSubmit() {
|
||||
background: linear-gradient(160deg, #eaf3ff 0%, #f8fafc 42%, #f8fafc 100%);
|
||||
}
|
||||
|
||||
.hero { padding: 120rpx 8rpx 56rpx; }
|
||||
.nav-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding-bottom: 16rpx;
|
||||
}
|
||||
.nav-back {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6rpx;
|
||||
min-width: 120rpx;
|
||||
padding: 10rpx 0;
|
||||
}
|
||||
.nav-back-text { font-size: 28rpx; color: #1e293b; }
|
||||
.nav-title { flex: 1; text-align: center; font-size: 30rpx; font-weight: 600; color: #1e293b; }
|
||||
.nav-side { min-width: 120rpx; }
|
||||
|
||||
.hero { padding: 56rpx 8rpx 48rpx; }
|
||||
.eyebrow { display: block; font-size: 20rpx; font-weight: 700; letter-spacing: 3rpx; color: #6e9de5; }
|
||||
.title { display: block; margin-top: 14rpx; font-size: 46rpx; font-weight: 700; color: #17345f; }
|
||||
.desc { display: block; margin-top: 16rpx; font-size: 25rpx; line-height: 1.6; color: #64748b; }
|
||||
@@ -142,4 +178,11 @@ async function handleSubmit() {
|
||||
&::after { border: none; }
|
||||
&[disabled] { opacity: .6; }
|
||||
}
|
||||
.skip {
|
||||
margin-top: 28rpx;
|
||||
padding: 18rpx 0;
|
||||
text-align: center;
|
||||
font-size: 26rpx;
|
||||
color: #64748b;
|
||||
}
|
||||
</style>
|
||||
+234
-2
@@ -9,6 +9,10 @@
|
||||
<text class="hero-name">{{ sub.title }}</text>
|
||||
<text class="hero-desc">{{ sub.desc }}</text>
|
||||
</view>
|
||||
<view v-if="isOa" class="hero-notice" hover-class="hero-notice-on" @tap="openNotices">
|
||||
<FaIcon name="bell" color="#ffffff" :size="20" />
|
||||
<view v-if="noticeCount > 0" class="notice-badge">{{ noticeCount > 99 ? '99+' : noticeCount }}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -27,15 +31,49 @@
|
||||
</scroll-view>
|
||||
</view>
|
||||
|
||||
<view v-if="noticeVisible" class="popup-mask" @tap="closeNotices">
|
||||
<view class="notice-sheet" @tap.stop>
|
||||
<view class="notice-head">
|
||||
<text class="notice-sheet-title">最新公告</text>
|
||||
<view class="notice-more" @tap="goNoticeList">
|
||||
<text class="notice-more-text">全部</text>
|
||||
<FaIcon name="chevron-right" color="#8a94ad" :size="11" />
|
||||
</view>
|
||||
</view>
|
||||
<scroll-view class="notice-body" scroll-y :show-scrollbar="false">
|
||||
<view v-if="notices.length === 0" class="notice-empty">
|
||||
<FaIcon name="bullhorn" color="#c0c4cc" :size="26" />
|
||||
<text class="notice-empty-text">暂无公告</text>
|
||||
</view>
|
||||
<view
|
||||
v-for="item in notices"
|
||||
:key="item.id"
|
||||
class="notice-item"
|
||||
@tap="goNoticeDetail(item.id)"
|
||||
>
|
||||
<view class="notice-dot" :class="{ 'notice-dot-top': item.is_top }" />
|
||||
<view class="notice-item-body">
|
||||
<text class="notice-item-title">{{ item.title }}</text>
|
||||
<text class="notice-item-time">{{ item.publish_time || item.publisher_name || '' }}</text>
|
||||
</view>
|
||||
<FaIcon name="chevron-right" color="#c0c4cc" :size="11" />
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<AppTabbar variant="switch" :current="activeTab" :tabs="tabs" @change="onTabChange" />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import { ref, computed } from 'vue'
|
||||
import { onLoad, onShow } from '@dcloudio/uni-app'
|
||||
import { getSubsystem } from '@/config/subsystems.js'
|
||||
import { mpHeadPad } from '@/utils/mpHead.js'
|
||||
import { fetchNotices } from '@/api/oa.js'
|
||||
import { isLoggedIn } from '@/utils/auth.js'
|
||||
import { getGuestToken } from '@/utils/guest.js'
|
||||
import AppTabbar from '@/components/AppTabbar.vue'
|
||||
import SubHome from '@/components/sub/SubHome.vue'
|
||||
import SubFunctions from '@/components/sub/SubFunctions.vue'
|
||||
@@ -55,12 +93,56 @@ const visited = ref({ home: true, functions: false, mine: false })
|
||||
|
||||
const headPad = mpHeadPad()
|
||||
|
||||
const isOa = computed(() => String((sub.value && sub.value.module) || '').toLowerCase() === 'oa')
|
||||
|
||||
const notices = ref([])
|
||||
const noticeTotal = ref(0)
|
||||
const noticeVisible = ref(false)
|
||||
|
||||
const noticeCount = computed(() => Number(noticeTotal.value) || notices.value.length)
|
||||
|
||||
async function loadNotices() {
|
||||
if (!isOa.value) return
|
||||
if (!isLoggedIn() && !getGuestToken()) return
|
||||
try {
|
||||
const res = await fetchNotices({ pageSize: 10 })
|
||||
notices.value = res.list || []
|
||||
noticeTotal.value = res.total || 0
|
||||
} catch (e) {
|
||||
notices.value = []
|
||||
noticeTotal.value = 0
|
||||
}
|
||||
}
|
||||
|
||||
function openNotices() {
|
||||
noticeVisible.value = true
|
||||
if (!notices.value.length && noticeTotal.value > 0) loadNotices()
|
||||
}
|
||||
|
||||
function closeNotices() {
|
||||
noticeVisible.value = false
|
||||
}
|
||||
|
||||
function goNoticeList() {
|
||||
closeNotices()
|
||||
uni.navigateTo({ url: '/pages/oa/notice/index' })
|
||||
}
|
||||
|
||||
function goNoticeDetail(id) {
|
||||
closeNotices()
|
||||
uni.navigateTo({ url: `/pages/oa/notice/detail?id=${id}` })
|
||||
}
|
||||
|
||||
onLoad((options) => {
|
||||
slug.value = options && options.slug ? options.slug : 'crm'
|
||||
sub.value = getSubsystem(slug.value)
|
||||
if (!sub.value) uni.reLaunch({ url: '/pages/nav/nav' })
|
||||
})
|
||||
|
||||
onShow(() => {
|
||||
loadNotices()
|
||||
})
|
||||
|
||||
function onTabChange(name) {
|
||||
activeTab.value = name
|
||||
if (!visited.value[name]) visited.value[name] = true
|
||||
@@ -151,4 +233,154 @@ function goBackNav() {
|
||||
.pane-bottom {
|
||||
height: 32rpx;
|
||||
}
|
||||
|
||||
.hero-notice {
|
||||
position: relative;
|
||||
margin-left: auto;
|
||||
flex-shrink: 0;
|
||||
width: 64rpx;
|
||||
height: 64rpx;
|
||||
border-radius: 50%;
|
||||
background: rgba(255, 255, 255, 0.18);
|
||||
border: 1rpx solid rgba(255, 255, 255, 0.28);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
&.hero-notice-on {
|
||||
opacity: 0.7;
|
||||
}
|
||||
}
|
||||
|
||||
.notice-badge {
|
||||
position: absolute;
|
||||
top: -10rpx;
|
||||
right: -10rpx;
|
||||
min-width: 32rpx;
|
||||
height: 32rpx;
|
||||
padding: 0 8rpx;
|
||||
box-sizing: border-box;
|
||||
border-radius: $radius-full;
|
||||
background: #f04438;
|
||||
color: #ffffff;
|
||||
font-size: 20rpx;
|
||||
line-height: 32rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.popup-mask {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
z-index: 999;
|
||||
background: rgba(15, 23, 42, 0.5);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 60rpx;
|
||||
}
|
||||
|
||||
.notice-sheet {
|
||||
width: 100%;
|
||||
max-height: 900rpx;
|
||||
background: $color-card;
|
||||
border-radius: $radius-lg;
|
||||
box-shadow: $shadow-float;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
@include sheet-responsive(560px);
|
||||
}
|
||||
|
||||
.notice-head {
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 26rpx 28rpx 18rpx;
|
||||
border-bottom: 1rpx solid $color-divider;
|
||||
}
|
||||
|
||||
.notice-sheet-title {
|
||||
font-size: 30rpx;
|
||||
font-weight: 600;
|
||||
color: $color-text;
|
||||
}
|
||||
|
||||
.notice-more {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4rpx;
|
||||
}
|
||||
|
||||
.notice-more-text {
|
||||
font-size: 24rpx;
|
||||
color: $color-text-muted;
|
||||
}
|
||||
|
||||
.notice-body {
|
||||
flex: 1;
|
||||
height: 0;
|
||||
padding: 8rpx 28rpx 20rpx;
|
||||
}
|
||||
|
||||
.notice-empty {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 12rpx;
|
||||
padding: 80rpx 0;
|
||||
}
|
||||
|
||||
.notice-empty-text {
|
||||
font-size: 24rpx;
|
||||
color: $color-text-muted;
|
||||
}
|
||||
|
||||
.notice-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 14rpx;
|
||||
padding: 22rpx 0;
|
||||
border-bottom: 1rpx solid $color-divider;
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
}
|
||||
|
||||
.notice-dot {
|
||||
flex-shrink: 0;
|
||||
width: 12rpx;
|
||||
height: 12rpx;
|
||||
border-radius: 50%;
|
||||
background: $color-primary-light;
|
||||
|
||||
&.notice-dot-top {
|
||||
background: #f04438;
|
||||
}
|
||||
}
|
||||
|
||||
.notice-item-body {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6rpx;
|
||||
}
|
||||
|
||||
.notice-item-title {
|
||||
font-size: 28rpx;
|
||||
color: $color-text;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.notice-item-time {
|
||||
font-size: 22rpx;
|
||||
color: $color-text-muted;
|
||||
}
|
||||
</style>
|
||||
@@ -280,7 +280,7 @@ function pickDay(cell) {
|
||||
|
||||
onMounted(() => {
|
||||
if (!isLoggedIn()) {
|
||||
uni.reLaunch({ url: '/pages/login/login' })
|
||||
uni.reLaunch({ url: '/pages/nav/nav' })
|
||||
return
|
||||
}
|
||||
loadSchedules()
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"setting": {
|
||||
"es6": true,
|
||||
"postcss": true,
|
||||
"minified": true,
|
||||
"minified": false,
|
||||
"uglifyFileName": false,
|
||||
"enhance": true,
|
||||
"urlCheck": false,
|
||||
|
||||
@@ -22,6 +22,8 @@ const NATIVE_RULES = [
|
||||
{ pattern: /\/apps\/erp\/finance\/payable/i, route: '/pages/erp/finance/bill?bill_type=2' },
|
||||
{ pattern: /\/apps\/erp\/finance\/payment/i, route: '/pages/erp/finance/fund' },
|
||||
{ pattern: /\/apps\/erp\/report/i, route: '/pages/erp/report/index' },
|
||||
{ pattern: /\/apps\/crm\/project/i, route: '/pages/crm/project/index' },
|
||||
{ pattern: /客户项目|项目管理|项目列表|crmProject/i, route: '/pages/crm/project/index' },
|
||||
{ pattern: /记事本|笔记|便签|notebook/i, route: '/pages/tools/notepad/index' },
|
||||
{ pattern: /账号管理|密码库|passwordStore|password-store/i, route: '/pages/tools/account/index' },
|
||||
{ pattern: /提醒|reminder/i, route: '/pages/tools/schedule/reminder' },
|
||||
@@ -40,6 +42,49 @@ const NATIVE_RULES = [
|
||||
|
||||
const WEBVIEW_PAGE = '/pages/apps/webview'
|
||||
|
||||
// 常用功能默认展示顺序(用户未自定义前按此顺序排列)
|
||||
export const DEFAULT_QUICK_TITLES = [
|
||||
'考勤打卡',
|
||||
'报销管理',
|
||||
'工作日程',
|
||||
'通讯录',
|
||||
'审批列表',
|
||||
'文档库',
|
||||
'工作日报'
|
||||
]
|
||||
|
||||
// 常用功能标题对应的图标(菜单未配图标时兜底)
|
||||
export const QUICK_TITLE_ICONS = {
|
||||
'考勤打卡': 'alarm-clock',
|
||||
'报销管理': 'receipt',
|
||||
'工作日程': 'calendar-days',
|
||||
'通讯录': 'address-book',
|
||||
'审批列表': 'clipboard-check',
|
||||
'文档库': 'folder-open',
|
||||
'工作日报': 'book'
|
||||
}
|
||||
|
||||
/**
|
||||
* 按默认常用功能顺序排序,未命中的保持原有相对顺序
|
||||
* @param {Array} list 菜单/应用列表
|
||||
* @param {Array<string>} titles 优先顺序
|
||||
*/
|
||||
export function orderQuickMenus(list = [], titles = DEFAULT_QUICK_TITLES) {
|
||||
const items = Array.isArray(list) ? list : []
|
||||
const rank = new Map(titles.map((t, i) => [String(t).trim(), i]))
|
||||
return items
|
||||
.map((item, index) => ({ item, index }))
|
||||
.sort((a, b) => {
|
||||
const ta = a.item && (a.item.title || a.item.name)
|
||||
const tb = b.item && (b.item.title || b.item.name)
|
||||
const ra = rank.has(ta) ? rank.get(ta) : titles.length
|
||||
const rb = rank.has(tb) ? rank.get(tb) : titles.length
|
||||
if (ra !== rb) return ra - rb
|
||||
return a.index - b.index
|
||||
})
|
||||
.map((entry) => entry.item)
|
||||
}
|
||||
|
||||
export const WEB_RULES = [
|
||||
'审批设置',
|
||||
'审批流配置',
|
||||
|
||||
@@ -21,6 +21,14 @@ const rootDir = resolveRootDir()
|
||||
export default defineConfig({
|
||||
base: '/h5/',
|
||||
plugins: [uni()],
|
||||
// 微信小程序的代码压缩器不支持 ES2020 语法(?? / ?.),
|
||||
// 在构建阶段统一降级到 ES2017,避免上传时「代码压缩」报 Unexpected token ?
|
||||
build: {
|
||||
target: ['es2017', 'chrome61', 'safari11', 'firefox60'],
|
||||
},
|
||||
esbuild: {
|
||||
target: 'es2017',
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': rootDir,
|
||||
|
||||
Reference in new issue
Block a user