refactor: 重构数据库配置为SQLite开发环境并移除冗余文档
This commit is contained in:
@@ -1,80 +1,341 @@
|
||||
// 银行监管小程序
|
||||
App({
|
||||
onLaunch() {
|
||||
// 小程序初始化
|
||||
console.log('牛肉商城小程序初始化');
|
||||
|
||||
// 检查登录状态
|
||||
this.checkLoginStatus();
|
||||
},
|
||||
|
||||
onShow() {
|
||||
// 小程序显示
|
||||
console.log('牛肉商城小程序显示');
|
||||
},
|
||||
|
||||
onHide() {
|
||||
// 小程序隐藏
|
||||
console.log('牛肉商城小程序隐藏');
|
||||
},
|
||||
|
||||
onError(msg) {
|
||||
// 错误处理
|
||||
console.log('小程序发生错误:', msg);
|
||||
},
|
||||
|
||||
globalData: {
|
||||
userInfo: null,
|
||||
token: null,
|
||||
baseUrl: 'http://localhost:8000/api'
|
||||
apiBase: 'https://api.xlxumu.com',
|
||||
version: '1.0.0',
|
||||
permissions: []
|
||||
},
|
||||
|
||||
// 检查登录状态
|
||||
checkLoginStatus() {
|
||||
try {
|
||||
const token = wx.getStorageSync('token');
|
||||
if (token) {
|
||||
this.globalData.token = token;
|
||||
// 验证token有效性
|
||||
this.verifyToken(token);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('检查登录状态失败:', e);
|
||||
|
||||
onLaunch() {
|
||||
console.log('银行监管小程序启动');
|
||||
|
||||
// 检查更新
|
||||
this.checkForUpdate();
|
||||
|
||||
// 初始化用户信息
|
||||
this.initUserInfo();
|
||||
|
||||
// 设置网络状态监听
|
||||
this.setupNetworkListener();
|
||||
},
|
||||
|
||||
onShow() {
|
||||
console.log('银行监管小程序显示');
|
||||
},
|
||||
|
||||
onHide() {
|
||||
console.log('银行监管小程序隐藏');
|
||||
},
|
||||
|
||||
onError(msg) {
|
||||
console.error('小程序错误:', msg);
|
||||
},
|
||||
|
||||
// 检查小程序更新
|
||||
checkForUpdate() {
|
||||
if (wx.canIUse('getUpdateManager')) {
|
||||
const updateManager = wx.getUpdateManager();
|
||||
|
||||
updateManager.onCheckForUpdate((res) => {
|
||||
if (res.hasUpdate) {
|
||||
console.log('发现新版本');
|
||||
}
|
||||
});
|
||||
|
||||
updateManager.onUpdateReady(() => {
|
||||
wx.showModal({
|
||||
title: '更新提示',
|
||||
content: '新版本已经准备好,是否重启应用?',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
updateManager.applyUpdate();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
updateManager.onUpdateFailed(() => {
|
||||
console.error('新版本下载失败');
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// 验证token
|
||||
verifyToken(token) {
|
||||
wx.request({
|
||||
url: `${this.globalData.baseUrl}/auth/verify`,
|
||||
method: 'GET',
|
||||
header: {
|
||||
'Authorization': `Bearer ${token}`
|
||||
},
|
||||
success: (res) => {
|
||||
if (res.data.valid) {
|
||||
this.globalData.userInfo = res.data.user;
|
||||
} else {
|
||||
// token无效,清除本地存储
|
||||
wx.removeStorageSync('token');
|
||||
this.globalData.token = null;
|
||||
this.globalData.userInfo = null;
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('验证token失败:', err);
|
||||
|
||||
// 初始化用户信息
|
||||
initUserInfo() {
|
||||
try {
|
||||
const token = wx.getStorageSync('token');
|
||||
const userInfo = wx.getStorageSync('userInfo');
|
||||
const permissions = wx.getStorageSync('permissions') || [];
|
||||
|
||||
if (token && userInfo) {
|
||||
this.globalData.token = token;
|
||||
this.globalData.userInfo = userInfo;
|
||||
this.globalData.permissions = permissions;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('初始化用户信息失败:', error);
|
||||
}
|
||||
},
|
||||
|
||||
// 设置网络状态监听
|
||||
setupNetworkListener() {
|
||||
wx.onNetworkStatusChange((res) => {
|
||||
if (!res.isConnected) {
|
||||
this.showError('网络连接已断开');
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 登录方法
|
||||
login(userInfo) {
|
||||
this.globalData.userInfo = userInfo;
|
||||
|
||||
// 微信登录
|
||||
async wxLogin() {
|
||||
try {
|
||||
// 检查登录状态
|
||||
const loginRes = await this.checkSession();
|
||||
if (loginRes) {
|
||||
return this.globalData.userInfo;
|
||||
}
|
||||
} catch (error) {
|
||||
console.log('登录状态已过期,重新登录');
|
||||
}
|
||||
|
||||
try {
|
||||
// 获取登录code
|
||||
const { code } = await this.promisify(wx.login)();
|
||||
|
||||
// 获取用户信息
|
||||
const userProfile = await this.getUserProfile();
|
||||
|
||||
// 发送登录请求
|
||||
const response = await this.request({
|
||||
url: '/auth/wechat/login',
|
||||
method: 'POST',
|
||||
data: {
|
||||
code,
|
||||
encrypted_data: userProfile.encryptedData,
|
||||
iv: userProfile.iv,
|
||||
app_type: 'bank_supervision'
|
||||
}
|
||||
});
|
||||
|
||||
const { token, user, permissions } = response.data;
|
||||
|
||||
// 保存用户信息
|
||||
this.globalData.token = token;
|
||||
this.globalData.userInfo = user;
|
||||
this.globalData.permissions = permissions || [];
|
||||
|
||||
wx.setStorageSync('token', token);
|
||||
wx.setStorageSync('userInfo', user);
|
||||
wx.setStorageSync('permissions', permissions || []);
|
||||
|
||||
return user;
|
||||
|
||||
} catch (error) {
|
||||
console.error('微信登录失败:', error);
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
|
||||
// 登出方法
|
||||
logout() {
|
||||
this.globalData.userInfo = null;
|
||||
|
||||
// 检查登录状态
|
||||
checkSession() {
|
||||
return new Promise((resolve, reject) => {
|
||||
wx.checkSession({
|
||||
success: () => {
|
||||
if (this.globalData.userInfo) {
|
||||
resolve(this.globalData.userInfo);
|
||||
} else {
|
||||
reject(new Error('用户信息不存在'));
|
||||
}
|
||||
},
|
||||
fail: reject
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
// 获取用户信息
|
||||
getUserProfile() {
|
||||
return new Promise((resolve, reject) => {
|
||||
wx.getUserProfile({
|
||||
desc: '用于完善用户资料',
|
||||
success: resolve,
|
||||
fail: reject
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
// 网络请求封装
|
||||
async request(options) {
|
||||
const {
|
||||
url,
|
||||
method = 'GET',
|
||||
data = {},
|
||||
header = {}
|
||||
} = options;
|
||||
|
||||
// 添加认证头
|
||||
if (this.globalData.token) {
|
||||
header.Authorization = `Bearer ${this.globalData.token}`;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await this.promisify(wx.request)({
|
||||
url: this.globalData.apiBase + url,
|
||||
method,
|
||||
data,
|
||||
header: {
|
||||
'Content-Type': 'application/json',
|
||||
...header
|
||||
}
|
||||
});
|
||||
|
||||
const { statusCode, data: responseData } = response;
|
||||
|
||||
if (statusCode === 200) {
|
||||
if (responseData.code === 0) {
|
||||
return responseData;
|
||||
} else {
|
||||
throw new Error(responseData.message || '请求失败');
|
||||
}
|
||||
} else if (statusCode === 401) {
|
||||
// 登录过期,清除用户信息
|
||||
this.clearUserInfo();
|
||||
wx.navigateTo({
|
||||
url: '/pages/auth/login'
|
||||
});
|
||||
throw new Error('登录已过期,请重新登录');
|
||||
} else if (statusCode === 403) {
|
||||
throw new Error('权限不足');
|
||||
} else {
|
||||
throw new Error(`请求失败:${statusCode}`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('请求错误:', error);
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
|
||||
// 清除用户信息
|
||||
clearUserInfo() {
|
||||
this.globalData.token = null;
|
||||
this.globalData.userInfo = null;
|
||||
this.globalData.permissions = [];
|
||||
wx.removeStorageSync('token');
|
||||
wx.removeStorageSync('userInfo');
|
||||
wx.removeStorageSync('permissions');
|
||||
},
|
||||
|
||||
// 检查权限
|
||||
hasPermission(permission) {
|
||||
return this.globalData.permissions.includes(permission);
|
||||
},
|
||||
|
||||
// 权限检查装饰器
|
||||
requirePermission(permission, callback) {
|
||||
if (this.hasPermission(permission)) {
|
||||
callback();
|
||||
} else {
|
||||
this.showError('权限不足,请联系管理员');
|
||||
}
|
||||
},
|
||||
|
||||
// Promise化微信API
|
||||
promisify(fn) {
|
||||
return (options = {}) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
fn({
|
||||
...options,
|
||||
success: resolve,
|
||||
fail: reject
|
||||
});
|
||||
});
|
||||
};
|
||||
},
|
||||
|
||||
// 显示加载提示
|
||||
showLoading(title = '加载中...') {
|
||||
wx.showLoading({
|
||||
title,
|
||||
mask: true
|
||||
});
|
||||
},
|
||||
|
||||
// 隐藏加载提示
|
||||
hideLoading() {
|
||||
wx.hideLoading();
|
||||
},
|
||||
|
||||
// 显示成功提示
|
||||
showSuccess(title) {
|
||||
wx.showToast({
|
||||
title,
|
||||
icon: 'success',
|
||||
duration: 2000
|
||||
});
|
||||
},
|
||||
|
||||
// 显示错误提示
|
||||
showError(title) {
|
||||
wx.showToast({
|
||||
title,
|
||||
icon: 'none',
|
||||
duration: 3000
|
||||
});
|
||||
},
|
||||
|
||||
// 显示确认对话框
|
||||
showConfirm(options) {
|
||||
return new Promise((resolve) => {
|
||||
wx.showModal({
|
||||
title: options.title || '提示',
|
||||
content: options.content,
|
||||
confirmText: options.confirmText || '确定',
|
||||
cancelText: options.cancelText || '取消',
|
||||
success: (res) => {
|
||||
resolve(res.confirm);
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
// 格式化金额
|
||||
formatMoney(amount) {
|
||||
if (!amount) return '¥0.00';
|
||||
return `¥${parseFloat(amount).toLocaleString()}`;
|
||||
},
|
||||
|
||||
// 格式化时间
|
||||
formatTime(timestamp) {
|
||||
const date = new Date(timestamp);
|
||||
return date.toLocaleString();
|
||||
},
|
||||
|
||||
// 格式化日期
|
||||
formatDate(timestamp) {
|
||||
const date = new Date(timestamp);
|
||||
return date.toLocaleDateString();
|
||||
},
|
||||
|
||||
// 格式化风险等级
|
||||
formatRiskLevel(level) {
|
||||
const riskMap = {
|
||||
'low': { text: '低风险', color: '#28a745' },
|
||||
'medium': { text: '中风险', color: '#ffc107' },
|
||||
'high': { text: '高风险', color: '#dc3545' },
|
||||
'critical': { text: '极高风险', color: '#6f42c1' }
|
||||
};
|
||||
return riskMap[level] || { text: '未知', color: '#6c757d' };
|
||||
},
|
||||
|
||||
// 格式化审批状态
|
||||
formatApprovalStatus(status) {
|
||||
const statusMap = {
|
||||
'pending': { text: '待审批', color: '#ffc107' },
|
||||
'approved': { text: '已批准', color: '#28a745' },
|
||||
'rejected': { text: '已拒绝', color: '#dc3545' },
|
||||
'cancelled': { text: '已取消', color: '#6c757d' }
|
||||
};
|
||||
return statusMap[status] || { text: '未知', color: '#6c757d' };
|
||||
}
|
||||
})
|
||||
});
|
||||
@@ -1,14 +1,85 @@
|
||||
{
|
||||
"pages": [
|
||||
"pages/index/index",
|
||||
"pages/logs/logs"
|
||||
"pages/auth/login",
|
||||
"pages/loan/list",
|
||||
"pages/loan/detail",
|
||||
"pages/loan/approve",
|
||||
"pages/risk/dashboard",
|
||||
"pages/risk/analysis",
|
||||
"pages/compliance/check",
|
||||
"pages/compliance/report",
|
||||
"pages/audit/list",
|
||||
"pages/audit/detail",
|
||||
"pages/profile/index",
|
||||
"pages/profile/settings",
|
||||
"pages/notification/index",
|
||||
"pages/common/webview"
|
||||
],
|
||||
"tabBar": {
|
||||
"color": "#666666",
|
||||
"selectedColor": "#007bff",
|
||||
"backgroundColor": "#ffffff",
|
||||
"borderStyle": "black",
|
||||
"list": [
|
||||
{
|
||||
"pagePath": "pages/index/index",
|
||||
"text": "首页",
|
||||
"iconPath": "images/tabbar/home.png",
|
||||
"selectedIconPath": "images/tabbar/home-active.png"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/loan/list",
|
||||
"text": "贷款管理",
|
||||
"iconPath": "images/tabbar/loan.png",
|
||||
"selectedIconPath": "images/tabbar/loan-active.png"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/risk/dashboard",
|
||||
"text": "风险监控",
|
||||
"iconPath": "images/tabbar/risk.png",
|
||||
"selectedIconPath": "images/tabbar/risk-active.png"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/audit/list",
|
||||
"text": "审计",
|
||||
"iconPath": "images/tabbar/audit.png",
|
||||
"selectedIconPath": "images/tabbar/audit-active.png"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/profile/index",
|
||||
"text": "我的",
|
||||
"iconPath": "images/tabbar/profile.png",
|
||||
"selectedIconPath": "images/tabbar/profile-active.png"
|
||||
}
|
||||
]
|
||||
},
|
||||
"window": {
|
||||
"backgroundTextStyle": "light",
|
||||
"navigationBarBackgroundColor": "#fff",
|
||||
"navigationBarTitleText": "锡林郭勒盟智慧养殖",
|
||||
"navigationBarTextStyle": "black"
|
||||
"navigationBarBackgroundColor": "#007bff",
|
||||
"navigationBarTitleText": "银行监管系统",
|
||||
"navigationBarTextStyle": "white",
|
||||
"backgroundColor": "#f5f5f5",
|
||||
"enablePullDownRefresh": true,
|
||||
"onReachBottomDistance": 50
|
||||
},
|
||||
"style": "v2",
|
||||
"sitemapLocation": "sitemap.json"
|
||||
}
|
||||
"networkTimeout": {
|
||||
"request": 10000,
|
||||
"downloadFile": 10000
|
||||
},
|
||||
"debug": false,
|
||||
"permission": {
|
||||
"scope.userLocation": {
|
||||
"desc": "您的位置信息将用于风险评估和合规检查"
|
||||
}
|
||||
},
|
||||
"requiredBackgroundModes": [],
|
||||
"plugins": {},
|
||||
"preloadRule": {
|
||||
"pages/risk/dashboard": {
|
||||
"network": "all",
|
||||
"packages": ["risk"]
|
||||
}
|
||||
},
|
||||
"lazyCodeLoading": "requiredComponents"
|
||||
}
|
||||
53
mini_program/bank-supervision/manifest.json
Normal file
53
mini_program/bank-supervision/manifest.json
Normal file
@@ -0,0 +1,53 @@
|
||||
{
|
||||
"name": "bank-supervision",
|
||||
"appid": "wx4567890123defghi",
|
||||
"description": "银行监管服务平台",
|
||||
"versionName": "1.0.0",
|
||||
"versionCode": "100",
|
||||
"transformPx": false,
|
||||
"mp-weixin": {
|
||||
"appid": "wx4567890123defghi",
|
||||
"setting": {
|
||||
"urlCheck": false,
|
||||
"es6": true,
|
||||
"enhance": true,
|
||||
"postcss": true,
|
||||
"minified": true,
|
||||
"newFeature": false,
|
||||
"coverView": true,
|
||||
"nodeModules": false,
|
||||
"autoAudits": false,
|
||||
"showShadowRootInWxmlPanel": true,
|
||||
"scopeDataCheck": false,
|
||||
"checkInvalidKey": true,
|
||||
"checkSiteMap": true,
|
||||
"uploadWithSourceMap": true,
|
||||
"useMultiFrameRuntime": true,
|
||||
"useApiHook": true,
|
||||
"useApiHostProcess": true,
|
||||
"enableEngineNative": false,
|
||||
"useIsolateContext": true,
|
||||
"minifyWXSS": true,
|
||||
"disableUseStrict": false,
|
||||
"minifyWXML": true
|
||||
},
|
||||
"usingComponents": true,
|
||||
"permission": {
|
||||
"scope.userLocation": {
|
||||
"desc": "用于定位银行网点和服务区域"
|
||||
},
|
||||
"scope.camera": {
|
||||
"desc": "需要使用摄像头扫描证件和二维码"
|
||||
},
|
||||
"scope.album": {
|
||||
"desc": "需要访问相册上传证件照片"
|
||||
}
|
||||
},
|
||||
"requiredPrivateInfos": [
|
||||
"getLocation",
|
||||
"chooseLocation",
|
||||
"chooseImage"
|
||||
]
|
||||
},
|
||||
"vueVersion": "3"
|
||||
}
|
||||
103
mini_program/bank-supervision/pages.json
Normal file
103
mini_program/bank-supervision/pages.json
Normal file
@@ -0,0 +1,103 @@
|
||||
{
|
||||
"pages": [
|
||||
{
|
||||
"path": "pages/index/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "银行监管",
|
||||
"enablePullDownRefresh": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/loan/apply",
|
||||
"style": {
|
||||
"navigationBarTitleText": "贷款申请"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/loan/list",
|
||||
"style": {
|
||||
"navigationBarTitleText": "贷款记录",
|
||||
"enablePullDownRefresh": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/loan/detail",
|
||||
"style": {
|
||||
"navigationBarTitleText": "贷款详情"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/credit/evaluation",
|
||||
"style": {
|
||||
"navigationBarTitleText": "信用评估"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/credit/report",
|
||||
"style": {
|
||||
"navigationBarTitleText": "信用报告"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/supervision/report",
|
||||
"style": {
|
||||
"navigationBarTitleText": "监管报告"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/supervision/audit",
|
||||
"style": {
|
||||
"navigationBarTitleText": "审计记录"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/user/profile",
|
||||
"style": {
|
||||
"navigationBarTitleText": "个人资料"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/user/settings",
|
||||
"style": {
|
||||
"navigationBarTitleText": "设置"
|
||||
}
|
||||
}
|
||||
],
|
||||
"globalStyle": {
|
||||
"navigationBarTextStyle": "black",
|
||||
"navigationBarTitleText": "银行监管",
|
||||
"navigationBarBackgroundColor": "#F8F8F8",
|
||||
"backgroundColor": "#F8F8F8"
|
||||
},
|
||||
"tabBar": {
|
||||
"color": "#7A7E83",
|
||||
"selectedColor": "#1890ff",
|
||||
"backgroundColor": "#ffffff",
|
||||
"list": [
|
||||
{
|
||||
"pagePath": "pages/index/index",
|
||||
"iconPath": "static/tabbar/home.png",
|
||||
"selectedIconPath": "static/tabbar/home-active.png",
|
||||
"text": "首页"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/loan/list",
|
||||
"iconPath": "static/tabbar/loan.png",
|
||||
"selectedIconPath": "static/tabbar/loan-active.png",
|
||||
"text": "贷款"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/credit/evaluation",
|
||||
"iconPath": "static/tabbar/credit.png",
|
||||
"selectedIconPath": "static/tabbar/credit-active.png",
|
||||
"text": "信用"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/user/profile",
|
||||
"iconPath": "static/tabbar/user.png",
|
||||
"selectedIconPath": "static/tabbar/user-active.png",
|
||||
"text": "我的"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
252
mini_program/bank-supervision/pages/index/index.js
Normal file
252
mini_program/bank-supervision/pages/index/index.js
Normal file
@@ -0,0 +1,252 @@
|
||||
// 银行监管首页
|
||||
const app = getApp();
|
||||
|
||||
Page({
|
||||
data: {
|
||||
userInfo: null,
|
||||
dashboardData: {
|
||||
totalLoans: 0,
|
||||
pendingApprovals: 0,
|
||||
riskAlerts: 0,
|
||||
complianceScore: 0
|
||||
},
|
||||
recentActivities: [],
|
||||
riskAlerts: [],
|
||||
quickActions: [
|
||||
{
|
||||
name: '贷款审批',
|
||||
icon: 'loan-approve',
|
||||
url: '/pages/loan/list?status=pending',
|
||||
permission: 'loan.approve'
|
||||
},
|
||||
{
|
||||
name: '风险监控',
|
||||
icon: 'risk-monitor',
|
||||
url: '/pages/risk/dashboard',
|
||||
permission: 'risk.view'
|
||||
},
|
||||
{
|
||||
name: '合规检查',
|
||||
icon: 'compliance',
|
||||
url: '/pages/compliance/check',
|
||||
permission: 'compliance.check'
|
||||
},
|
||||
{
|
||||
name: '审计报告',
|
||||
icon: 'audit-report',
|
||||
url: '/pages/audit/list',
|
||||
permission: 'audit.view'
|
||||
}
|
||||
],
|
||||
loading: true,
|
||||
refreshing: false
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
this.checkLogin();
|
||||
},
|
||||
|
||||
onShow() {
|
||||
if (app.globalData.userInfo) {
|
||||
this.setData({
|
||||
userInfo: app.globalData.userInfo
|
||||
});
|
||||
this.loadData();
|
||||
}
|
||||
},
|
||||
|
||||
onPullDownRefresh() {
|
||||
this.setData({ refreshing: true });
|
||||
this.loadData().finally(() => {
|
||||
this.setData({ refreshing: false });
|
||||
wx.stopPullDownRefresh();
|
||||
});
|
||||
},
|
||||
|
||||
// 检查登录状态
|
||||
checkLogin() {
|
||||
if (!app.globalData.userInfo) {
|
||||
wx.navigateTo({
|
||||
url: '/pages/auth/login'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
this.setData({
|
||||
userInfo: app.globalData.userInfo
|
||||
});
|
||||
this.loadData();
|
||||
},
|
||||
|
||||
// 加载数据
|
||||
async loadData() {
|
||||
try {
|
||||
this.setData({ loading: true });
|
||||
|
||||
await Promise.all([
|
||||
this.loadDashboardData(),
|
||||
this.loadRecentActivities(),
|
||||
this.loadRiskAlerts()
|
||||
]);
|
||||
} catch (error) {
|
||||
console.error('加载数据失败:', error);
|
||||
app.showError('加载数据失败');
|
||||
} finally {
|
||||
this.setData({ loading: false });
|
||||
}
|
||||
},
|
||||
|
||||
// 加载仪表板数据
|
||||
async loadDashboardData() {
|
||||
try {
|
||||
const res = await app.request({
|
||||
url: '/supervision/dashboard',
|
||||
method: 'GET'
|
||||
});
|
||||
|
||||
this.setData({
|
||||
dashboardData: res.data || {}
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('加载仪表板数据失败:', error);
|
||||
}
|
||||
},
|
||||
|
||||
// 加载最近活动
|
||||
async loadRecentActivities() {
|
||||
try {
|
||||
const res = await app.request({
|
||||
url: '/supervision/activities',
|
||||
method: 'GET',
|
||||
data: { limit: 10 }
|
||||
});
|
||||
|
||||
this.setData({
|
||||
recentActivities: res.data.list || []
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('加载最近活动失败:', error);
|
||||
}
|
||||
},
|
||||
|
||||
// 加载风险警报
|
||||
async loadRiskAlerts() {
|
||||
try {
|
||||
const res = await app.request({
|
||||
url: '/supervision/risk-alerts',
|
||||
method: 'GET',
|
||||
data: {
|
||||
status: 'active',
|
||||
limit: 5
|
||||
}
|
||||
});
|
||||
|
||||
this.setData({
|
||||
riskAlerts: res.data.list || []
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('加载风险警报失败:', error);
|
||||
}
|
||||
},
|
||||
|
||||
// 快捷操作点击
|
||||
onQuickAction(e) {
|
||||
const { action } = e.currentTarget.dataset;
|
||||
|
||||
// 检查权限
|
||||
if (action.permission && !app.hasPermission(action.permission)) {
|
||||
app.showError('权限不足,请联系管理员');
|
||||
return;
|
||||
}
|
||||
|
||||
if (action.url.includes('tab')) {
|
||||
wx.switchTab({ url: action.url });
|
||||
} else {
|
||||
wx.navigateTo({ url: action.url });
|
||||
}
|
||||
},
|
||||
|
||||
// 查看活动详情
|
||||
onActivityTap(e) {
|
||||
const { activity } = e.currentTarget.dataset;
|
||||
|
||||
// 根据活动类型跳转到不同页面
|
||||
switch (activity.type) {
|
||||
case 'loan_approval':
|
||||
wx.navigateTo({
|
||||
url: `/pages/loan/detail?id=${activity.target_id}`
|
||||
});
|
||||
break;
|
||||
case 'risk_alert':
|
||||
wx.navigateTo({
|
||||
url: `/pages/risk/analysis?id=${activity.target_id}`
|
||||
});
|
||||
break;
|
||||
case 'compliance_check':
|
||||
wx.navigateTo({
|
||||
url: `/pages/compliance/report?id=${activity.target_id}`
|
||||
});
|
||||
break;
|
||||
case 'audit':
|
||||
wx.navigateTo({
|
||||
url: `/pages/audit/detail?id=${activity.target_id}`
|
||||
});
|
||||
break;
|
||||
default:
|
||||
app.showError('暂不支持查看此类活动详情');
|
||||
}
|
||||
},
|
||||
|
||||
// 查看风险警报详情
|
||||
onRiskAlertTap(e) {
|
||||
const { alert } = e.currentTarget.dataset;
|
||||
wx.navigateTo({
|
||||
url: `/pages/risk/analysis?id=${alert.id}`
|
||||
});
|
||||
},
|
||||
|
||||
// 查看所有活动
|
||||
onViewAllActivities() {
|
||||
wx.navigateTo({
|
||||
url: '/pages/notification/index'
|
||||
});
|
||||
},
|
||||
|
||||
// 查看所有风险警报
|
||||
onViewAllRiskAlerts() {
|
||||
wx.navigateTo({
|
||||
url: '/pages/risk/dashboard?tab=alerts'
|
||||
});
|
||||
},
|
||||
|
||||
// 格式化数值
|
||||
formatNumber(num) {
|
||||
if (num >= 10000) {
|
||||
return (num / 10000).toFixed(1) + '万';
|
||||
}
|
||||
return num.toString();
|
||||
},
|
||||
|
||||
// 格式化金额
|
||||
formatMoney(amount) {
|
||||
return app.formatMoney(amount);
|
||||
},
|
||||
|
||||
// 格式化时间
|
||||
formatTime(timestamp) {
|
||||
return app.formatTime(timestamp);
|
||||
},
|
||||
|
||||
// 格式化风险等级
|
||||
formatRiskLevel(level) {
|
||||
return app.formatRiskLevel(level);
|
||||
},
|
||||
|
||||
// 获取合规分数颜色
|
||||
getComplianceScoreColor(score) {
|
||||
if (score >= 90) return '#28a745';
|
||||
if (score >= 80) return '#ffc107';
|
||||
if (score >= 70) return '#fd7e14';
|
||||
return '#dc3545';
|
||||
}
|
||||
});
|
||||
145
mini_program/bank-supervision/pages/index/index.wxml
Normal file
145
mini_program/bank-supervision/pages/index/index.wxml
Normal file
@@ -0,0 +1,145 @@
|
||||
<!--银行监管首页-->
|
||||
<view class="page-container">
|
||||
<!-- 顶部用户信息 -->
|
||||
<view class="header" wx:if="{{userInfo}}">
|
||||
<view class="user-info">
|
||||
<image class="avatar" src="{{userInfo.avatar || '/images/default-avatar.png'}}" mode="aspectFill"></image>
|
||||
<view class="user-details">
|
||||
<text class="username">{{userInfo.name}}</text>
|
||||
<text class="role">{{userInfo.role_name}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="header-actions">
|
||||
<navigator url="/pages/notification/index" class="notification-btn">
|
||||
<image src="/images/icons/notification.png" mode="aspectFit"></image>
|
||||
<view class="notification-badge" wx:if="{{riskAlerts.length > 0}}">{{riskAlerts.length}}</view>
|
||||
</navigator>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 仪表板统计 -->
|
||||
<view class="dashboard-stats">
|
||||
<view class="stats-grid">
|
||||
<view class="stat-item">
|
||||
<text class="stat-number">{{formatNumber(dashboardData.totalLoans)}}</text>
|
||||
<text class="stat-label">总贷款数</text>
|
||||
<text class="stat-unit">笔</text>
|
||||
</view>
|
||||
<view class="stat-item">
|
||||
<text class="stat-number">{{formatNumber(dashboardData.pendingApprovals)}}</text>
|
||||
<text class="stat-label">待审批</text>
|
||||
<text class="stat-unit">笔</text>
|
||||
</view>
|
||||
<view class="stat-item">
|
||||
<text class="stat-number">{{formatNumber(dashboardData.riskAlerts)}}</text>
|
||||
<text class="stat-label">风险警报</text>
|
||||
<text class="stat-unit">个</text>
|
||||
</view>
|
||||
<view class="stat-item">
|
||||
<text
|
||||
class="stat-number"
|
||||
style="color: {{getComplianceScoreColor(dashboardData.complianceScore)}}"
|
||||
>
|
||||
{{dashboardData.complianceScore}}
|
||||
</text>
|
||||
<text class="stat-label">合规分数</text>
|
||||
<text class="stat-unit">分</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 快捷操作 -->
|
||||
<view class="quick-actions">
|
||||
<view class="section-title">快捷操作</view>
|
||||
<view class="actions-grid">
|
||||
<view
|
||||
class="action-item"
|
||||
wx:for="{{quickActions}}"
|
||||
wx:key="name"
|
||||
data-action="{{item}}"
|
||||
bindtap="onQuickAction"
|
||||
>
|
||||
<view class="action-icon">
|
||||
<image src="/images/icons/{{item.icon}}.png" mode="aspectFit"></image>
|
||||
</view>
|
||||
<text class="action-name">{{item.name}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 风险警报 -->
|
||||
<view class="risk-alerts" wx:if="{{riskAlerts.length > 0}}">
|
||||
<view class="section-header">
|
||||
<text class="section-title">风险警报</text>
|
||||
<text class="section-more" bindtap="onViewAllRiskAlerts">查看全部</text>
|
||||
</view>
|
||||
<view class="alerts-list">
|
||||
<view
|
||||
class="alert-item"
|
||||
wx:for="{{riskAlerts}}"
|
||||
wx:key="id"
|
||||
data-alert="{{item}}"
|
||||
bindtap="onRiskAlertTap"
|
||||
>
|
||||
<view class="alert-icon {{formatRiskLevel(item.level).color}}">
|
||||
<image src="/images/icons/warning.png" mode="aspectFit"></image>
|
||||
</view>
|
||||
<view class="alert-content">
|
||||
<text class="alert-title">{{item.title}}</text>
|
||||
<text class="alert-desc">{{item.description}}</text>
|
||||
<text class="alert-time">{{formatTime(item.created_at)}}</text>
|
||||
</view>
|
||||
<view class="alert-level">
|
||||
<text
|
||||
class="level-badge"
|
||||
style="background-color: {{formatRiskLevel(item.level).color}}"
|
||||
>
|
||||
{{formatRiskLevel(item.level).text}}
|
||||
</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 最近活动 -->
|
||||
<view class="recent-activities" wx:if="{{recentActivities.length > 0}}">
|
||||
<view class="section-header">
|
||||
<text class="section-title">最近活动</text>
|
||||
<text class="section-more" bindtap="onViewAllActivities">查看全部</text>
|
||||
</view>
|
||||
<view class="activities-list">
|
||||
<view
|
||||
class="activity-item"
|
||||
wx:for="{{recentActivities}}"
|
||||
wx:key="id"
|
||||
data-activity="{{item}}"
|
||||
bindtap="onActivityTap"
|
||||
>
|
||||
<view class="activity-icon">
|
||||
<image src="/images/icons/{{item.type}}.png" mode="aspectFit"></image>
|
||||
</view>
|
||||
<view class="activity-content">
|
||||
<text class="activity-title">{{item.title}}</text>
|
||||
<text class="activity-desc">{{item.description}}</text>
|
||||
<text class="activity-time">{{formatTime(item.created_at)}}</text>
|
||||
</view>
|
||||
<view class="activity-arrow">
|
||||
<image src="/images/icons/arrow-right.png" mode="aspectFit"></image>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 加载状态 -->
|
||||
<view class="loading" wx:if="{{loading}}">
|
||||
<view class="loading-spinner"></view>
|
||||
<text>加载中...</text>
|
||||
</view>
|
||||
|
||||
<!-- 空状态 -->
|
||||
<view class="empty" wx:if="{{!loading && recentActivities.length === 0 && riskAlerts.length === 0}}">
|
||||
<image class="empty-icon" src="/images/empty-dashboard.png" mode="aspectFit"></image>
|
||||
<text class="empty-text">暂无数据</text>
|
||||
<text class="empty-desc">系统正在收集监管数据</text>
|
||||
</view>
|
||||
</view>
|
||||
1015
mini_program/bank-supervision/pages/loan/apply.vue
Normal file
1015
mini_program/bank-supervision/pages/loan/apply.vue
Normal file
File diff suppressed because it is too large
Load Diff
1082
mini_program/bank-supervision/pages/loan/loan.vue
Normal file
1082
mini_program/bank-supervision/pages/loan/loan.vue
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user