refactor: 重构数据库配置为SQLite开发环境并移除冗余文档

This commit is contained in:
2025-09-21 15:16:48 +08:00
parent d207610009
commit 3c8648a635
259 changed files with 88239 additions and 8379 deletions

View File

@@ -1,80 +1,354 @@
// 保险监管小程序
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: 'insurance_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();
},
// 格式化保险状态
formatInsuranceStatus(status) {
const statusMap = {
'active': { text: '生效中', color: '#28a745' },
'pending': { text: '待生效', color: '#ffc107' },
'expired': { text: '已过期', color: '#dc3545' },
'cancelled': { text: '已取消', color: '#6c757d' },
'suspended': { text: '暂停', color: '#fd7e14' }
};
return statusMap[status] || { text: '未知', color: '#6c757d' };
},
// 格式化理赔状态
formatClaimStatus(status) {
const statusMap = {
'submitted': { text: '已提交', color: '#17a2b8' },
'reviewing': { text: '审核中', color: '#ffc107' },
'approved': { text: '已批准', color: '#28a745' },
'rejected': { text: '已拒绝', color: '#dc3545' },
'paid': { text: '已赔付', color: '#6f42c1' }
};
return statusMap[status] || { text: '未知', color: '#6c757d' };
},
// 格式化风险等级
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' };
}
})
});

View File

@@ -1,14 +1,88 @@
{
"pages": [
"pages/index/index",
"pages/logs/logs"
"pages/auth/login",
"pages/policy/list",
"pages/policy/detail",
"pages/policy/approve",
"pages/claim/list",
"pages/claim/detail",
"pages/claim/process",
"pages/risk/assessment",
"pages/risk/report",
"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": "#17a2b8",
"backgroundColor": "#ffffff",
"borderStyle": "black",
"list": [
{
"pagePath": "pages/index/index",
"text": "首页",
"iconPath": "images/tabbar/home.png",
"selectedIconPath": "images/tabbar/home-active.png"
},
{
"pagePath": "pages/policy/list",
"text": "保单管理",
"iconPath": "images/tabbar/policy.png",
"selectedIconPath": "images/tabbar/policy-active.png"
},
{
"pagePath": "pages/claim/list",
"text": "理赔管理",
"iconPath": "images/tabbar/claim.png",
"selectedIconPath": "images/tabbar/claim-active.png"
},
{
"pagePath": "pages/risk/assessment",
"text": "风险评估",
"iconPath": "images/tabbar/risk.png",
"selectedIconPath": "images/tabbar/risk-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": "#17a2b8",
"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/assessment": {
"network": "all",
"packages": ["risk"]
}
},
"lazyCodeLoading": "requiredComponents"
}

View File

@@ -0,0 +1,53 @@
{
"name": "insurance-supervision",
"appid": "wx5678901234efghij",
"description": "保险监管服务平台",
"versionName": "1.0.0",
"versionCode": "100",
"transformPx": false,
"mp-weixin": {
"appid": "wx5678901234efghij",
"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"
}

View File

@@ -0,0 +1,104 @@
{
"pages": [
{
"path": "pages/index/index",
"style": {
"navigationBarTitleText": "保险监管",
"enablePullDownRefresh": true
}
},
{
"path": "pages/policy/list",
"style": {
"navigationBarTitleText": "保单管理",
"enablePullDownRefresh": true
}
},
{
"path": "pages/policy/detail",
"style": {
"navigationBarTitleText": "保单详情"
}
},
{
"path": "pages/claim/apply",
"style": {
"navigationBarTitleText": "理赔申请"
}
},
{
"path": "pages/claim/list",
"style": {
"navigationBarTitleText": "理赔记录",
"enablePullDownRefresh": true
}
},
{
"path": "pages/claim/detail",
"style": {
"navigationBarTitleText": "理赔详情"
}
},
{
"path": "pages/risk/assessment",
"style": {
"navigationBarTitleText": "风险评估"
}
},
{
"path": "pages/supervision/report",
"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": "#52c41a",
"backgroundColor": "#ffffff",
"list": [
{
"pagePath": "pages/index/index",
"iconPath": "static/tabbar/home.png",
"selectedIconPath": "static/tabbar/home-active.png",
"text": "首页"
},
{
"pagePath": "pages/policy/list",
"iconPath": "static/tabbar/policy.png",
"selectedIconPath": "static/tabbar/policy-active.png",
"text": "保单"
},
{
"pagePath": "pages/claim/list",
"iconPath": "static/tabbar/claim.png",
"selectedIconPath": "static/tabbar/claim-active.png",
"text": "理赔"
},
{
"pagePath": "pages/user/profile",
"iconPath": "static/tabbar/user.png",
"selectedIconPath": "static/tabbar/user-active.png",
"text": "我的"
}
]
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,244 @@
// 保险监管首页
const app = getApp();
Page({
data: {
userInfo: null,
dashboardData: {
totalPolicies: 0,
activeClaims: 0,
pendingApprovals: 0,
riskAlerts: 0
},
recentActivities: [],
claimAlerts: [],
quickActions: [
{
name: '保单审批',
icon: 'policy-approve',
url: '/pages/policy/list?status=pending',
permission: 'policy.approve'
},
{
name: '理赔处理',
icon: 'claim-process',
url: '/pages/claim/list?status=reviewing',
permission: 'claim.process'
},
{
name: '风险评估',
icon: 'risk-assess',
url: '/pages/risk/assessment',
permission: 'risk.assess'
},
{
name: '合规检查',
icon: 'compliance',
url: '/pages/compliance/check',
permission: 'compliance.check'
}
],
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.loadClaimAlerts()
]);
} catch (error) {
console.error('加载数据失败:', error);
app.showError('加载数据失败');
} finally {
this.setData({ loading: false });
}
},
// 加载仪表板数据
async loadDashboardData() {
try {
const res = await app.request({
url: '/insurance/dashboard',
method: 'GET'
});
this.setData({
dashboardData: res.data || {}
});
} catch (error) {
console.error('加载仪表板数据失败:', error);
}
},
// 加载最近活动
async loadRecentActivities() {
try {
const res = await app.request({
url: '/insurance/activities',
method: 'GET',
data: { limit: 10 }
});
this.setData({
recentActivities: res.data.list || []
});
} catch (error) {
console.error('加载最近活动失败:', error);
}
},
// 加载理赔警报
async loadClaimAlerts() {
try {
const res = await app.request({
url: '/insurance/claim-alerts',
method: 'GET',
data: {
status: 'urgent',
limit: 5
}
});
this.setData({
claimAlerts: 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 'policy_approval':
wx.navigateTo({
url: `/pages/policy/detail?id=${activity.target_id}`
});
break;
case 'claim_processing':
wx.navigateTo({
url: `/pages/claim/detail?id=${activity.target_id}`
});
break;
case 'risk_assessment':
wx.navigateTo({
url: `/pages/risk/report?id=${activity.target_id}`
});
break;
case 'compliance_check':
wx.navigateTo({
url: `/pages/compliance/report?id=${activity.target_id}`
});
break;
default:
app.showError('暂不支持查看此类活动详情');
}
},
// 查看理赔警报详情
onClaimAlertTap(e) {
const { alert } = e.currentTarget.dataset;
wx.navigateTo({
url: `/pages/claim/detail?id=${alert.claim_id}`
});
},
// 查看所有活动
onViewAllActivities() {
wx.navigateTo({
url: '/pages/notification/index'
});
},
// 查看所有理赔警报
onViewAllClaimAlerts() {
wx.navigateTo({
url: '/pages/claim/list?status=urgent'
});
},
// 格式化数值
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);
},
// 格式化理赔状态
formatClaimStatus(status) {
return app.formatClaimStatus(status);
}
});

File diff suppressed because it is too large Load Diff