init
This commit is contained in:
commit
1ab9f9c458
1319 files changed
+137505
No files matched your search
@@ -0,0 +1,71 @@
|
||||
<script>
|
||||
export default {
|
||||
onLaunch: function () {
|
||||
console.log('App Launch');
|
||||
},
|
||||
onShow: function () {
|
||||
console.log('App Show');
|
||||
},
|
||||
onHide: function () {
|
||||
console.log('App Hide');
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
/* 全局样式 */
|
||||
page {
|
||||
background-color: #f5f5f5;
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu',
|
||||
'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
|
||||
}
|
||||
|
||||
/* 通用类 */
|
||||
.container {
|
||||
padding: 20rpx;
|
||||
}
|
||||
|
||||
.flex {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.flex-center {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.flex-between {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.text-center {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.text-right {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.mb-20 {
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.mt-20 {
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
|
||||
.p-20 {
|
||||
padding: 20rpx;
|
||||
}
|
||||
|
||||
.card {
|
||||
background: #fff;
|
||||
border-radius: 12rpx;
|
||||
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.1);
|
||||
margin-bottom: 20rpx;
|
||||
padding: 20rpx;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* 认证相关API
|
||||
*/
|
||||
|
||||
import { post, get } from '@/utils/request.js';
|
||||
|
||||
/**
|
||||
* 用户登录
|
||||
*/
|
||||
export function loginApi(data) {
|
||||
return post('/auth/login', data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户退出
|
||||
*/
|
||||
export function logoutApi() {
|
||||
return post('/auth/logout');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
*/
|
||||
export function getUserInfoApi() {
|
||||
return get('/auth/userinfo');
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新Token
|
||||
*/
|
||||
export function refreshTokenApi(refreshToken) {
|
||||
return post('/auth/refresh', { refreshToken });
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改密码
|
||||
*/
|
||||
export function changePasswordApi(data) {
|
||||
return post('/auth/change-password', data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置密码
|
||||
*/
|
||||
export function resetPasswordApi(data) {
|
||||
return post('/auth/reset-password', data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送验证码
|
||||
*/
|
||||
export function sendCodeApi(data) {
|
||||
return post('/auth/send-code', data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定手机号
|
||||
*/
|
||||
export function bindPhoneApi(data) {
|
||||
return post('/auth/bind-phone', data);
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/**
|
||||
* 通用API接口
|
||||
*/
|
||||
|
||||
import { get, post, uploadFile } from '@/utils/request.js';
|
||||
|
||||
/**
|
||||
* 获取轮播图列表
|
||||
*/
|
||||
export function getBannerListApi() {
|
||||
return get('/common/banner');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取通知公告列表
|
||||
*/
|
||||
export function getNoticeListApi(params) {
|
||||
return get('/common/notice', params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取新闻列表
|
||||
*/
|
||||
export function getNewsListApi(params) {
|
||||
return get('/common/news', params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典数据
|
||||
*/
|
||||
export function getDictDataApi(dictType) {
|
||||
return get(`/common/dict/${dictType}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件上传
|
||||
*/
|
||||
export function uploadFileApi(filePath, options = {}) {
|
||||
return uploadFile('/common/upload', filePath, {
|
||||
name: 'file',
|
||||
...options,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取系统配置
|
||||
*/
|
||||
export function getConfigApi() {
|
||||
return get('/common/config');
|
||||
}
|
||||
|
||||
/**
|
||||
* 意见反馈
|
||||
*/
|
||||
export function feedbackApi(data) {
|
||||
return post('/common/feedback', data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取版本信息
|
||||
*/
|
||||
export function getVersionApi() {
|
||||
return get('/common/version');
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查更新
|
||||
*/
|
||||
export function checkUpdateApi() {
|
||||
return get('/common/check-update');
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* 应用配置文件
|
||||
*/
|
||||
|
||||
// 环境配置
|
||||
const ENV_CONFIG = {
|
||||
// 开发环境
|
||||
development: {
|
||||
BASE_URL: 'http://localhost:8080',
|
||||
TIMEOUT: 10000,
|
||||
},
|
||||
// 生产环境
|
||||
production: {
|
||||
BASE_URL: 'https://your-api-domain.com',
|
||||
TIMEOUT: 15000,
|
||||
},
|
||||
// 测试环境
|
||||
test: {
|
||||
BASE_URL: 'http://test-api.your-domain.com',
|
||||
TIMEOUT: 10000,
|
||||
},
|
||||
};
|
||||
|
||||
// 当前环境(可以通过构建工具设置,这里默认为开发环境)
|
||||
const CURRENT_ENV = process.env.NODE_ENV || 'development';
|
||||
|
||||
// 导出当前环境配置
|
||||
export const config = ENV_CONFIG[CURRENT_ENV];
|
||||
|
||||
// 导出所有配置供其他模块使用
|
||||
export default {
|
||||
...config,
|
||||
// 应用信息
|
||||
APP_NAME: '校园管理移动端',
|
||||
APP_VERSION: '1.0.0',
|
||||
// API相关配置
|
||||
API_PREFIX: '/api',
|
||||
// 存储配置
|
||||
STORAGE_PREFIX: 'xgxt_mobile_',
|
||||
// 其他配置
|
||||
PAGE_SIZE: 10,
|
||||
MAX_FILE_SIZE: 10 * 1024 * 1024, // 10MB
|
||||
};
|
||||
@@ -0,0 +1,10 @@
|
||||
import { createSSRApp } from 'vue';
|
||||
import App from './App.vue';
|
||||
|
||||
export function createApp() {
|
||||
const app = createSSRApp(App);
|
||||
|
||||
return {
|
||||
app,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
{
|
||||
"name": "xgxt-mobile",
|
||||
"appid": "__UNI__XGXT_MOBILE",
|
||||
"description": "校园管理移动端",
|
||||
"versionName": "1.0.0",
|
||||
"versionCode": "100",
|
||||
"transformPx": false,
|
||||
"app-plus": {
|
||||
"usingComponents": true,
|
||||
"nvueStyleCompiler": "uni-app",
|
||||
"compilerVersion": 3,
|
||||
"splashscreen": {
|
||||
"alwaysShowBeforeRender": true,
|
||||
"waiting": true,
|
||||
"autoclose": true,
|
||||
"delay": 0
|
||||
},
|
||||
"modules": {},
|
||||
"distribute": {
|
||||
"android": {
|
||||
"permissions": [
|
||||
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\" />",
|
||||
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\" />",
|
||||
"<uses-permission android:name=\"android.permission.VIBRATE\" />",
|
||||
"<uses-permission android:name=\"android.permission.READ_LOGS\" />",
|
||||
"<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\" />",
|
||||
"<uses-feature android:name=\"android.hardware.camera.autofocus\" />",
|
||||
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\" />",
|
||||
"<uses-permission android:name=\"android.permission.CAMERA\" />",
|
||||
"<uses-permission android:name=\"android.permission.GET_ACCOUNTS\" />",
|
||||
"<uses-permission android:name=\"android.permission.READ_PHONE_STATE\" />",
|
||||
"<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\" />",
|
||||
"<uses-permission android:name=\"android.permission.WAKE_LOCK\" />",
|
||||
"<uses-permission android:name=\"android.permission.FLASHLIGHT\" />",
|
||||
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\" />"
|
||||
]
|
||||
},
|
||||
"ios": {},
|
||||
"sdkConfigs": {}
|
||||
}
|
||||
},
|
||||
"quickapp": {},
|
||||
"mp-weixin": {
|
||||
"appid": "",
|
||||
"setting": {
|
||||
"urlCheck": false
|
||||
},
|
||||
"usingComponents": true
|
||||
},
|
||||
"mp-alipay": {
|
||||
"usingComponents": true
|
||||
},
|
||||
"mp-baidu": {
|
||||
"usingComponents": true
|
||||
},
|
||||
"mp-toutiao": {
|
||||
"usingComponents": true
|
||||
},
|
||||
"uniStatistics": {
|
||||
"enable": false
|
||||
},
|
||||
"h5": {
|
||||
"title": "校园管理移动端",
|
||||
"template": "index.html"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
{
|
||||
"easycom": {
|
||||
"^u-(.*)": "@/uni_modules/uview-ui/components/u-$1/u-$1.vue"
|
||||
},
|
||||
"pages": [
|
||||
{
|
||||
"path": "pages/login/login",
|
||||
"style": {
|
||||
"navigationBarTitleText": "登录",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/index/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "首页",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/workbench/workbench",
|
||||
"style": {
|
||||
"navigationBarTitleText": "工作台",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/mine/mine",
|
||||
"style": {
|
||||
"navigationBarTitleText": "我的",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
}
|
||||
],
|
||||
"globalStyle": {
|
||||
"navigationBarTextStyle": "black",
|
||||
"navigationBarTitleText": "校园管理",
|
||||
"navigationBarBackgroundColor": "#F8F8F8",
|
||||
"backgroundColor": "#F8F8F8",
|
||||
"app-plus": {
|
||||
"background": "#efeff4"
|
||||
}
|
||||
},
|
||||
"tabBar": {
|
||||
"color": "#7A7E83",
|
||||
"selectedColor": "#3c9cff",
|
||||
"backgroundColor": "#ffffff",
|
||||
"borderStyle": "black",
|
||||
"list": [
|
||||
{
|
||||
"pagePath": "pages/index/index",
|
||||
"iconPath": "static/tabbar/home.png",
|
||||
"selectedIconPath": "static/tabbar/home-active.png",
|
||||
"text": "首页"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/workbench/workbench",
|
||||
"iconPath": "static/tabbar/workbench.png",
|
||||
"selectedIconPath": "static/tabbar/workbench-active.png",
|
||||
"text": "工作台"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/mine/mine",
|
||||
"iconPath": "static/tabbar/mine.png",
|
||||
"selectedIconPath": "static/tabbar/mine-active.png",
|
||||
"text": "我的"
|
||||
}
|
||||
]
|
||||
},
|
||||
"condition": {
|
||||
"current": 0,
|
||||
"list": [
|
||||
{
|
||||
"name": "首页",
|
||||
"path": "pages/index/index",
|
||||
"query": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,353 @@
|
||||
<template>
|
||||
<view class="index-container">
|
||||
<!-- 自定义导航栏 -->
|
||||
<u-navbar
|
||||
:is-back="false"
|
||||
:border-bottom="false"
|
||||
:custom-style="{ background: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)' }"
|
||||
>
|
||||
<template #left>
|
||||
<view class="nav-left">
|
||||
<u-avatar :src="userInfo.avatar" size="60"></u-avatar>
|
||||
<view class="user-info">
|
||||
<text class="nickname">{{ userInfo.nickname }}</text>
|
||||
<text class="time">{{ currentTime }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<template #right>
|
||||
<u-icon name="bell" color="#fff" size="44" @click="showNotifications"></u-icon>
|
||||
</template>
|
||||
</u-navbar>
|
||||
|
||||
<!-- 主体内容 -->
|
||||
<view class="content">
|
||||
<!-- 轮播图 -->
|
||||
<view class="banner-section">
|
||||
<u-swiper
|
||||
:list="bannerList"
|
||||
:autoplay="true"
|
||||
:circular="true"
|
||||
height="300"
|
||||
border-radius="20"
|
||||
@click="onBannerClick"
|
||||
></u-swiper>
|
||||
</view>
|
||||
|
||||
<!-- 快捷功能 -->
|
||||
<view class="quick-actions card">
|
||||
<view class="section-title">
|
||||
<text>快捷功能</text>
|
||||
</view>
|
||||
<view class="actions-grid">
|
||||
<view
|
||||
v-for="(item, index) in quickActions"
|
||||
:key="index"
|
||||
class="action-item"
|
||||
@click="onActionClick(item)"
|
||||
>
|
||||
<view class="action-icon" :style="{ background: item.color }">
|
||||
<u-icon :name="item.icon" color="#fff" size="40"></u-icon>
|
||||
</view>
|
||||
<text class="action-text">{{ item.name }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 数据统计 -->
|
||||
<view class="statistics card">
|
||||
<view class="section-title">
|
||||
<text>数据统计</text>
|
||||
</view>
|
||||
<view class="stats-grid">
|
||||
<view v-for="(item, index) in statistics" :key="index" class="stat-item">
|
||||
<text class="stat-value">{{ item.value }}</text>
|
||||
<text class="stat-label">{{ item.label }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 最新动态 -->
|
||||
<view class="news-section card">
|
||||
<view class="section-title">
|
||||
<text>最新动态</text>
|
||||
<text class="more" @click="goToNews">查看更多</text>
|
||||
</view>
|
||||
<view class="news-list">
|
||||
<view
|
||||
v-for="(item, index) in newsList"
|
||||
:key="index"
|
||||
class="news-item"
|
||||
@click="onNewsClick(item)"
|
||||
>
|
||||
<view class="news-content">
|
||||
<text class="news-title">{{ item.title }}</text>
|
||||
<text class="news-time">{{ item.time }}</text>
|
||||
</view>
|
||||
<u-icon name="arrow-right" color="#c8c9cc" size="28"></u-icon>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'Index',
|
||||
data() {
|
||||
return {
|
||||
userInfo: {},
|
||||
currentTime: '',
|
||||
bannerList: [
|
||||
{ image: '/static/logo.png', title: '欢迎使用校园管理系统' },
|
||||
{ image: '/static/logo.png', title: '便捷高效的移动办公' },
|
||||
{ image: '/static/logo.png', title: '智慧校园,美好未来' },
|
||||
],
|
||||
quickActions: [
|
||||
{ name: '考勤管理', icon: 'clock', color: '#ff6b6b' },
|
||||
{ name: '请假申请', icon: 'file-text', color: '#4ecdc4' },
|
||||
{ name: '工资查询', icon: 'rmb-circle', color: '#45b7d1' },
|
||||
{ name: '通知公告', icon: 'volume', color: '#f9ca24' },
|
||||
{ name: '课程表', icon: 'table', color: '#6c5ce7' },
|
||||
{ name: '成绩查询', icon: 'star', color: '#a29bfe' },
|
||||
{ name: '图书馆', icon: 'book', color: '#fd79a8' },
|
||||
{ name: '更多', icon: 'grid', color: '#636e72' },
|
||||
],
|
||||
statistics: [
|
||||
{ label: '今日签到', value: '156' },
|
||||
{ label: '本月请假', value: '23' },
|
||||
{ label: '待审批', value: '8' },
|
||||
{ label: '已完成', value: '234' },
|
||||
],
|
||||
newsList: [
|
||||
{ title: '关于2024年春季学期开学安排的通知', time: '2024-02-15 09:30' },
|
||||
{ title: '校园疫情防控最新要求', time: '2024-02-14 16:20' },
|
||||
{ title: '学生宿舍管理规定更新', time: '2024-02-13 14:10' },
|
||||
{ title: '图书馆开放时间调整通知', time: '2024-02-12 11:40' },
|
||||
],
|
||||
};
|
||||
},
|
||||
onLoad() {
|
||||
this.initPage();
|
||||
},
|
||||
onShow() {
|
||||
this.updateTime();
|
||||
},
|
||||
methods: {
|
||||
// 初始化页面
|
||||
initPage() {
|
||||
this.getUserInfo();
|
||||
this.updateTime();
|
||||
this.setTimeInterval();
|
||||
},
|
||||
|
||||
// 获取用户信息
|
||||
getUserInfo() {
|
||||
const userInfo = uni.getStorageSync('userInfo');
|
||||
if (userInfo) {
|
||||
this.userInfo = userInfo;
|
||||
} else {
|
||||
// 如果没有用户信息,跳转到登录页
|
||||
uni.reLaunch({
|
||||
url: '/pages/login/login',
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// 更新时间
|
||||
updateTime() {
|
||||
const now = new Date();
|
||||
const hour = now.getHours();
|
||||
let greeting = '早上好';
|
||||
if (hour >= 12 && hour < 18) {
|
||||
greeting = '下午好';
|
||||
} else if (hour >= 18) {
|
||||
greeting = '晚上好';
|
||||
}
|
||||
this.currentTime = greeting;
|
||||
},
|
||||
|
||||
// 设置时间更新定时器
|
||||
setTimeInterval() {
|
||||
setInterval(() => {
|
||||
this.updateTime();
|
||||
}, 60000); // 每分钟更新一次
|
||||
},
|
||||
|
||||
// 轮播图点击
|
||||
onBannerClick(index) {
|
||||
console.log('点击轮播图', index);
|
||||
},
|
||||
|
||||
// 快捷功能点击
|
||||
onActionClick(item) {
|
||||
console.log('点击功能', item.name);
|
||||
this.$u.toast(item.name);
|
||||
},
|
||||
|
||||
// 新闻点击
|
||||
onNewsClick(item) {
|
||||
console.log('点击新闻', item.title);
|
||||
this.$u.toast('查看:' + item.title);
|
||||
},
|
||||
|
||||
// 显示通知
|
||||
showNotifications() {
|
||||
this.$u.toast('暂无新通知');
|
||||
},
|
||||
|
||||
// 查看更多新闻
|
||||
goToNews() {
|
||||
this.$u.toast('跳转到新闻列表');
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.index-container {
|
||||
background: #f5f5f5;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.nav-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 20rpx;
|
||||
|
||||
.user-info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4rpx;
|
||||
|
||||
.nickname {
|
||||
font-size: 28rpx;
|
||||
font-weight: bold;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.time {
|
||||
font-size: 24rpx;
|
||||
color: rgba(255, 255, 255, 0.8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.content {
|
||||
padding: 20rpx;
|
||||
}
|
||||
|
||||
.banner-section {
|
||||
margin-bottom: 30rpx;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 30rpx;
|
||||
|
||||
text {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
.more {
|
||||
font-size: 24rpx;
|
||||
color: #909399;
|
||||
}
|
||||
}
|
||||
|
||||
.quick-actions {
|
||||
.actions-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
gap: 30rpx;
|
||||
|
||||
.action-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 16rpx;
|
||||
|
||||
.action-icon {
|
||||
width: 80rpx;
|
||||
height: 80rpx;
|
||||
border-radius: 20rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.action-text {
|
||||
font-size: 24rpx;
|
||||
color: #303133;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.statistics {
|
||||
.stats-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
gap: 20rpx;
|
||||
|
||||
.stat-item {
|
||||
text-align: center;
|
||||
padding: 30rpx 0;
|
||||
|
||||
.stat-value {
|
||||
display: block;
|
||||
font-size: 40rpx;
|
||||
font-weight: bold;
|
||||
color: #3c9cff;
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
|
||||
.stat-label {
|
||||
font-size: 24rpx;
|
||||
color: #909399;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.news-section {
|
||||
.news-list {
|
||||
.news-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 30rpx 0;
|
||||
border-bottom: 2rpx solid #f5f5f5;
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.news-content {
|
||||
flex: 1;
|
||||
|
||||
.news-title {
|
||||
display: block;
|
||||
font-size: 28rpx;
|
||||
color: #303133;
|
||||
margin-bottom: 10rpx;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.news-time {
|
||||
font-size: 24rpx;
|
||||
color: #909399;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,208 @@
|
||||
<template>
|
||||
<view class="login-container">
|
||||
<!-- 头部区域 -->
|
||||
<view class="header">
|
||||
<view class="logo">
|
||||
<image src="/static/logo.png" mode="aspectFit" class="logo-img"></image>
|
||||
</view>
|
||||
<view class="title">校园管理系统</view>
|
||||
<view class="subtitle">欢迎登录</view>
|
||||
</view>
|
||||
|
||||
<!-- 登录表单 -->
|
||||
<view class="form-container">
|
||||
<view class="form-item">
|
||||
<input
|
||||
v-model="loginForm.username"
|
||||
placeholder="请输入用户名"
|
||||
class="input-field"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<view class="form-item">
|
||||
<input
|
||||
v-model="loginForm.password"
|
||||
type="password"
|
||||
placeholder="请输入密码"
|
||||
class="input-field"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<!-- 登录按钮 -->
|
||||
<button class="login-btn" :class="{ loading: loading }" @click="handleLogin">
|
||||
{{ loading ? '登录中...' : '登录' }}
|
||||
</button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'Login',
|
||||
data() {
|
||||
return {
|
||||
loading: false,
|
||||
loginForm: {
|
||||
username: 'admin',
|
||||
password: 'admin',
|
||||
},
|
||||
};
|
||||
},
|
||||
onLoad() {
|
||||
// 检查是否已登录
|
||||
const token = uni.getStorageSync('token');
|
||||
if (token) {
|
||||
this.redirectToHome();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 处理登录
|
||||
async handleLogin() {
|
||||
// 简单验证
|
||||
if (!this.loginForm.username || !this.loginForm.password) {
|
||||
uni.showToast({
|
||||
title: '请输入用户名和密码',
|
||||
icon: 'none',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
this.loading = true;
|
||||
|
||||
try {
|
||||
// 模拟登录API调用
|
||||
await this.mockLogin();
|
||||
|
||||
// 保存登录状态
|
||||
uni.setStorageSync('token', 'mock-token-123456');
|
||||
uni.setStorageSync('userInfo', {
|
||||
id: 1,
|
||||
username: this.loginForm.username,
|
||||
nickname: '管理员',
|
||||
avatar: '/static/avatar.png',
|
||||
});
|
||||
|
||||
uni.showToast({
|
||||
title: '登录成功',
|
||||
icon: 'success',
|
||||
});
|
||||
|
||||
// 延迟跳转,让用户看到成功提示
|
||||
setTimeout(() => {
|
||||
this.redirectToHome();
|
||||
}, 1000);
|
||||
} catch (error) {
|
||||
uni.showToast({
|
||||
title: '登录失败:' + error.message,
|
||||
icon: 'none',
|
||||
});
|
||||
} finally {
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
|
||||
// 模拟登录API
|
||||
mockLogin() {
|
||||
return new Promise((resolve, reject) => {
|
||||
setTimeout(() => {
|
||||
if (
|
||||
this.loginForm.username === 'admin' &&
|
||||
this.loginForm.password === 'admin'
|
||||
) {
|
||||
resolve({ success: true });
|
||||
} else {
|
||||
reject(new Error('用户名或密码错误'));
|
||||
}
|
||||
}, 1000);
|
||||
});
|
||||
},
|
||||
|
||||
// 跳转到首页
|
||||
redirectToHome() {
|
||||
uni.reLaunch({
|
||||
url: '/pages/index/index',
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.login-container {
|
||||
min-height: 100vh;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
padding: 100rpx 60rpx 60rpx;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.header {
|
||||
text-align: center;
|
||||
margin-bottom: 100rpx;
|
||||
|
||||
.logo {
|
||||
margin-bottom: 40rpx;
|
||||
|
||||
.logo-img {
|
||||
width: 120rpx;
|
||||
height: 120rpx;
|
||||
border-radius: 20rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 48rpx;
|
||||
font-weight: bold;
|
||||
color: #fff;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.subtitle {
|
||||
font-size: 28rpx;
|
||||
color: rgba(255, 255, 255, 0.8);
|
||||
}
|
||||
}
|
||||
|
||||
.form-container {
|
||||
background: #fff;
|
||||
border-radius: 20rpx;
|
||||
padding: 60rpx 40rpx;
|
||||
box-shadow: 0 20rpx 40rpx rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.form-item {
|
||||
margin-bottom: 40rpx;
|
||||
|
||||
.input-field {
|
||||
width: 100%;
|
||||
height: 88rpx;
|
||||
padding: 0 20rpx;
|
||||
border: 2rpx solid #e4e7ed;
|
||||
border-radius: 8rpx;
|
||||
font-size: 28rpx;
|
||||
box-sizing: border-box;
|
||||
|
||||
&:focus {
|
||||
border-color: #3c9cff;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.login-btn {
|
||||
width: 100%;
|
||||
height: 88rpx;
|
||||
background: #3c9cff;
|
||||
color: #fff;
|
||||
border: none;
|
||||
border-radius: 44rpx;
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
|
||||
&.loading {
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
&:active {
|
||||
background: #2b85e4;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,441 @@
|
||||
<template>
|
||||
<view class="mine-container">
|
||||
<!-- 用户信息区域 -->
|
||||
<view class="user-section">
|
||||
<view class="user-bg">
|
||||
<image src="/static/mine-bg.jpg" mode="aspectFill" class="bg-image"></image>
|
||||
</view>
|
||||
<view class="user-info">
|
||||
<view class="user-avatar">
|
||||
<u-avatar :src="userInfo.avatar" size="120"></u-avatar>
|
||||
<view class="avatar-badge">
|
||||
<u-icon name="checkmark" color="#fff" size="20"></u-icon>
|
||||
</view>
|
||||
</view>
|
||||
<view class="user-details">
|
||||
<text class="username">{{ userInfo.nickname }}</text>
|
||||
<text class="user-title">{{ userInfo.title || '管理员' }}</text>
|
||||
</view>
|
||||
<view class="user-stats">
|
||||
<view class="stat-item">
|
||||
<text class="stat-value">{{ userStats.loginDays }}</text>
|
||||
<text class="stat-label">连续登录</text>
|
||||
</view>
|
||||
<view class="stat-item">
|
||||
<text class="stat-value">{{ userStats.completedTasks }}</text>
|
||||
<text class="stat-label">完成任务</text>
|
||||
</view>
|
||||
<view class="stat-item">
|
||||
<text class="stat-value">{{ userStats.points }}</text>
|
||||
<text class="stat-label">积分</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 功能菜单 -->
|
||||
<view class="menu-section">
|
||||
<!-- 个人中心 -->
|
||||
<view class="menu-group card">
|
||||
<view class="group-title">个人中心</view>
|
||||
<view class="menu-list">
|
||||
<view
|
||||
v-for="(item, index) in personalMenus"
|
||||
:key="index"
|
||||
class="menu-item"
|
||||
@click="onMenuClick(item)"
|
||||
>
|
||||
<view class="menu-left">
|
||||
<view class="menu-icon" :style="{ background: item.color }">
|
||||
<u-icon :name="item.icon" color="#fff" size="32"></u-icon>
|
||||
</view>
|
||||
<text class="menu-text">{{ item.name }}</text>
|
||||
</view>
|
||||
<view class="menu-right">
|
||||
<text class="menu-badge" v-if="item.badge">{{ item.badge }}</text>
|
||||
<u-icon name="arrow-right" color="#c8c9cc" size="28"></u-icon>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 应用设置 -->
|
||||
<view class="menu-group card">
|
||||
<view class="group-title">应用设置</view>
|
||||
<view class="menu-list">
|
||||
<view
|
||||
v-for="(item, index) in settingMenus"
|
||||
:key="index"
|
||||
class="menu-item"
|
||||
@click="onMenuClick(item)"
|
||||
>
|
||||
<view class="menu-left">
|
||||
<view class="menu-icon" :style="{ background: item.color }">
|
||||
<u-icon :name="item.icon" color="#fff" size="32"></u-icon>
|
||||
</view>
|
||||
<text class="menu-text">{{ item.name }}</text>
|
||||
</view>
|
||||
<view class="menu-right">
|
||||
<u-switch
|
||||
v-if="item.type === 'switch'"
|
||||
v-model="item.value"
|
||||
@change="onSwitchChange(item)"
|
||||
></u-switch>
|
||||
<text class="menu-value" v-else-if="item.value">{{ item.value }}</text>
|
||||
<u-icon name="arrow-right" color="#c8c9cc" size="28" v-else></u-icon>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 其他功能 -->
|
||||
<view class="menu-group card">
|
||||
<view class="group-title">其他功能</view>
|
||||
<view class="menu-list">
|
||||
<view
|
||||
v-for="(item, index) in otherMenus"
|
||||
:key="index"
|
||||
class="menu-item"
|
||||
@click="onMenuClick(item)"
|
||||
>
|
||||
<view class="menu-left">
|
||||
<view class="menu-icon" :style="{ background: item.color }">
|
||||
<u-icon :name="item.icon" color="#fff" size="32"></u-icon>
|
||||
</view>
|
||||
<text class="menu-text">{{ item.name }}</text>
|
||||
</view>
|
||||
<view class="menu-right">
|
||||
<u-icon name="arrow-right" color="#c8c9cc" size="28"></u-icon>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 退出登录 -->
|
||||
<view class="logout-section">
|
||||
<u-button
|
||||
type="error"
|
||||
:plain="true"
|
||||
@click="showLogoutConfirm"
|
||||
:custom-style="{ width: '100%', height: '88rpx' }"
|
||||
>
|
||||
退出登录
|
||||
</u-button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'Mine',
|
||||
data() {
|
||||
return {
|
||||
userInfo: {},
|
||||
userStats: {
|
||||
loginDays: 15,
|
||||
completedTasks: 128,
|
||||
points: 2580,
|
||||
},
|
||||
personalMenus: [
|
||||
{ name: '个人资料', icon: 'account', color: '#3c9cff' },
|
||||
{ name: '我的消息', icon: 'chat', color: '#5ac725', badge: '5' },
|
||||
{ name: '我的收藏', icon: 'heart', color: '#f9ae3d' },
|
||||
{ name: '我的任务', icon: 'list', color: '#f56c6c' },
|
||||
],
|
||||
settingMenus: [
|
||||
{ name: '消息推送', icon: 'bell', color: '#ff6b6b', type: 'switch', value: true },
|
||||
{ name: '夜间模式', icon: 'moon', color: '#4ecdc4', type: 'switch', value: false },
|
||||
{ name: '语言设置', icon: 'globe', color: '#45b7d1', value: '简体中文' },
|
||||
{ name: '清除缓存', icon: 'trash', color: '#f9ca24' },
|
||||
],
|
||||
otherMenus: [
|
||||
{ name: '意见反馈', icon: 'edit-pen', color: '#6c5ce7' },
|
||||
{ name: '帮助中心', icon: 'question-circle', color: '#a29bfe' },
|
||||
{ name: '关于我们', icon: 'info-circle', color: '#fd79a8' },
|
||||
{ name: '检查更新', icon: 'download', color: '#636e72' },
|
||||
],
|
||||
};
|
||||
},
|
||||
onLoad() {
|
||||
this.initPage();
|
||||
},
|
||||
methods: {
|
||||
// 初始化页面
|
||||
initPage() {
|
||||
this.getUserInfo();
|
||||
},
|
||||
|
||||
// 获取用户信息
|
||||
getUserInfo() {
|
||||
const userInfo = uni.getStorageSync('userInfo');
|
||||
if (userInfo) {
|
||||
this.userInfo = userInfo;
|
||||
}
|
||||
},
|
||||
|
||||
// 菜单点击
|
||||
onMenuClick(item) {
|
||||
console.log('点击菜单', item.name);
|
||||
|
||||
if (item.name === '清除缓存') {
|
||||
this.clearCache();
|
||||
} else if (item.name === '检查更新') {
|
||||
this.checkUpdate();
|
||||
} else {
|
||||
this.$u.toast(item.name);
|
||||
}
|
||||
},
|
||||
|
||||
// 开关变化
|
||||
onSwitchChange(item) {
|
||||
console.log('开关变化', item.name, item.value);
|
||||
this.$u.toast(`${item.name}已${item.value ? '开启' : '关闭'}`);
|
||||
},
|
||||
|
||||
// 清除缓存
|
||||
clearCache() {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要清除缓存吗?',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
// 模拟清除缓存
|
||||
setTimeout(() => {
|
||||
this.$u.toast('缓存清除成功');
|
||||
}, 1000);
|
||||
}
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
// 检查更新
|
||||
checkUpdate() {
|
||||
uni.showLoading({
|
||||
title: '检查中...',
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
uni.hideLoading();
|
||||
this.$u.toast('当前已是最新版本');
|
||||
}, 2000);
|
||||
},
|
||||
|
||||
// 显示退出确认
|
||||
showLogoutConfirm() {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要退出登录吗?',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
this.logout();
|
||||
}
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
// 退出登录
|
||||
logout() {
|
||||
// 清除本地存储
|
||||
uni.removeStorageSync('token');
|
||||
uni.removeStorageSync('userInfo');
|
||||
|
||||
this.$u.toast('退出成功');
|
||||
|
||||
// 跳转到登录页
|
||||
setTimeout(() => {
|
||||
uni.reLaunch({
|
||||
url: '/pages/login/login',
|
||||
});
|
||||
}, 1000);
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.mine-container {
|
||||
background: #f5f5f5;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.user-section {
|
||||
position: relative;
|
||||
margin-bottom: 20rpx;
|
||||
|
||||
.user-bg {
|
||||
height: 400rpx;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
|
||||
.bg-image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
&::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: linear-gradient(
|
||||
135deg,
|
||||
rgba(102, 126, 234, 0.8) 0%,
|
||||
rgba(118, 75, 162, 0.8) 100%
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
.user-info {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
z-index: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 60rpx 40rpx 40rpx;
|
||||
|
||||
.user-avatar {
|
||||
position: relative;
|
||||
margin-bottom: 30rpx;
|
||||
|
||||
.avatar-badge {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
width: 40rpx;
|
||||
height: 40rpx;
|
||||
background: #5ac725;
|
||||
border-radius: 50%;
|
||||
border: 4rpx solid #fff;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
|
||||
.user-details {
|
||||
text-align: center;
|
||||
margin-bottom: 40rpx;
|
||||
|
||||
.username {
|
||||
display: block;
|
||||
font-size: 36rpx;
|
||||
font-weight: bold;
|
||||
color: #fff;
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
|
||||
.user-title {
|
||||
font-size: 24rpx;
|
||||
color: rgba(255, 255, 255, 0.8);
|
||||
}
|
||||
}
|
||||
|
||||
.user-stats {
|
||||
display: flex;
|
||||
gap: 60rpx;
|
||||
|
||||
.stat-item {
|
||||
text-align: center;
|
||||
|
||||
.stat-value {
|
||||
display: block;
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
color: #fff;
|
||||
margin-bottom: 8rpx;
|
||||
}
|
||||
|
||||
.stat-label {
|
||||
font-size: 24rpx;
|
||||
color: rgba(255, 255, 255, 0.8);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.menu-section {
|
||||
padding: 0 20rpx 40rpx;
|
||||
}
|
||||
|
||||
.menu-group {
|
||||
margin-bottom: 20rpx;
|
||||
|
||||
.group-title {
|
||||
font-size: 28rpx;
|
||||
font-weight: bold;
|
||||
color: #303133;
|
||||
margin-bottom: 20rpx;
|
||||
padding: 0 20rpx;
|
||||
}
|
||||
|
||||
.menu-list {
|
||||
.menu-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 30rpx 20rpx;
|
||||
border-bottom: 2rpx solid #f5f5f5;
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.menu-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 20rpx;
|
||||
|
||||
.menu-icon {
|
||||
width: 60rpx;
|
||||
height: 60rpx;
|
||||
border-radius: 12rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.menu-text {
|
||||
font-size: 28rpx;
|
||||
color: #303133;
|
||||
}
|
||||
}
|
||||
|
||||
.menu-right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16rpx;
|
||||
|
||||
.menu-badge {
|
||||
background: #f56c6c;
|
||||
color: #fff;
|
||||
font-size: 20rpx;
|
||||
padding: 4rpx 12rpx;
|
||||
border-radius: 20rpx;
|
||||
min-width: 32rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.menu-value {
|
||||
font-size: 24rpx;
|
||||
color: #909399;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.logout-section {
|
||||
margin-top: 40rpx;
|
||||
padding: 0 20rpx;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,494 @@
|
||||
<template>
|
||||
<view class="workbench-container">
|
||||
<!-- 自定义导航栏 -->
|
||||
<u-navbar
|
||||
title="工作台"
|
||||
:is-back="false"
|
||||
:border-bottom="false"
|
||||
:custom-style="{ background: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)' }"
|
||||
title-color="#fff"
|
||||
>
|
||||
<template #right>
|
||||
<u-icon name="search" color="#fff" size="44" @click="showSearch"></u-icon>
|
||||
</template>
|
||||
</u-navbar>
|
||||
|
||||
<!-- 主体内容 -->
|
||||
<view class="content">
|
||||
<!-- 工作统计 -->
|
||||
<view class="work-stats card">
|
||||
<view class="section-title">
|
||||
<text>工作统计</text>
|
||||
<text class="date">{{ today }}</text>
|
||||
</view>
|
||||
<view class="stats-row">
|
||||
<view
|
||||
v-for="(item, index) in workStats"
|
||||
:key="index"
|
||||
class="stat-item"
|
||||
@click="onStatClick(item)"
|
||||
>
|
||||
<view class="stat-icon" :style="{ background: item.color }">
|
||||
<u-icon :name="item.icon" color="#fff" size="36"></u-icon>
|
||||
</view>
|
||||
<view class="stat-info">
|
||||
<text class="stat-value">{{ item.value }}</text>
|
||||
<text class="stat-label">{{ item.label }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 待办事项 -->
|
||||
<view class="todo-section card">
|
||||
<view class="section-title">
|
||||
<text>待办事项</text>
|
||||
<view class="badge" v-if="todoList.length > 0">{{ todoList.length }}</view>
|
||||
</view>
|
||||
<view class="todo-list" v-if="todoList.length > 0">
|
||||
<view
|
||||
v-for="(item, index) in todoList"
|
||||
:key="index"
|
||||
class="todo-item"
|
||||
@click="onTodoClick(item)"
|
||||
>
|
||||
<view class="todo-left">
|
||||
<view class="priority-dot" :class="item.priority"></view>
|
||||
<view class="todo-content">
|
||||
<text class="todo-title">{{ item.title }}</text>
|
||||
<text class="todo-time">{{ item.deadline }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="todo-status" :class="item.status">
|
||||
{{ getStatusText(item.status) }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view v-else class="empty-state">
|
||||
<u-icon name="checkbox-mark" color="#c8c9cc" size="80"></u-icon>
|
||||
<text>暂无待办事项</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 工作流程 -->
|
||||
<view class="workflow-section card">
|
||||
<view class="section-title">
|
||||
<text>工作流程</text>
|
||||
</view>
|
||||
<view class="workflow-grid">
|
||||
<view
|
||||
v-for="(item, index) in workflowItems"
|
||||
:key="index"
|
||||
class="workflow-item"
|
||||
@click="onWorkflowClick(item)"
|
||||
>
|
||||
<view class="workflow-icon" :style="{ background: item.color }">
|
||||
<u-icon :name="item.icon" color="#fff" size="40"></u-icon>
|
||||
</view>
|
||||
<text class="workflow-text">{{ item.name }}</text>
|
||||
<view class="workflow-badge" v-if="item.badge">{{ item.badge }}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 快速操作 -->
|
||||
<view class="quick-ops card">
|
||||
<view class="section-title">
|
||||
<text>快速操作</text>
|
||||
</view>
|
||||
<view class="ops-list">
|
||||
<view
|
||||
v-for="(item, index) in quickOps"
|
||||
:key="index"
|
||||
class="ops-item"
|
||||
@click="onQuickOpClick(item)"
|
||||
>
|
||||
<view class="ops-left">
|
||||
<u-icon :name="item.icon" :color="item.color" size="40"></u-icon>
|
||||
<view class="ops-info">
|
||||
<text class="ops-title">{{ item.title }}</text>
|
||||
<text class="ops-desc">{{ item.desc }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<u-icon name="arrow-right" color="#c8c9cc" size="28"></u-icon>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'Workbench',
|
||||
data() {
|
||||
return {
|
||||
today: '',
|
||||
workStats: [
|
||||
{ label: '今日任务', value: '8', icon: 'list', color: '#3c9cff' },
|
||||
{ label: '已完成', value: '5', icon: 'checkmark', color: '#5ac725' },
|
||||
{ label: '进行中', value: '2', icon: 'clock', color: '#f9ae3d' },
|
||||
{ label: '待审批', value: '1', icon: 'eye', color: '#f56c6c' },
|
||||
],
|
||||
todoList: [
|
||||
{
|
||||
title: '审核学生请假申请',
|
||||
deadline: '今天 18:00',
|
||||
priority: 'high',
|
||||
status: 'pending',
|
||||
},
|
||||
{
|
||||
title: '提交月度工作报告',
|
||||
deadline: '明天 12:00',
|
||||
priority: 'medium',
|
||||
status: 'in-progress',
|
||||
},
|
||||
{
|
||||
title: '参加部门例会',
|
||||
deadline: '2024-02-16 14:00',
|
||||
priority: 'low',
|
||||
status: 'pending',
|
||||
},
|
||||
],
|
||||
workflowItems: [
|
||||
{ name: '请假审批', icon: 'file-text', color: '#ff6b6b', badge: '3' },
|
||||
{ name: '报销审批', icon: 'rmb-circle', color: '#4ecdc4', badge: '1' },
|
||||
{ name: '采购审批', icon: 'shopping-cart', color: '#45b7d1' },
|
||||
{ name: '合同审批', icon: 'file', color: '#f9ca24' },
|
||||
],
|
||||
quickOps: [
|
||||
{
|
||||
title: '创建任务',
|
||||
desc: '快速创建新的工作任务',
|
||||
icon: 'plus-circle',
|
||||
color: '#3c9cff',
|
||||
},
|
||||
{
|
||||
title: '工作日志',
|
||||
desc: '记录今日工作内容',
|
||||
icon: 'edit-pen',
|
||||
color: '#5ac725',
|
||||
},
|
||||
{
|
||||
title: '团队协作',
|
||||
desc: '查看团队成员工作状态',
|
||||
icon: 'account',
|
||||
color: '#f9ae3d',
|
||||
},
|
||||
{
|
||||
title: '数据统计',
|
||||
desc: '查看工作效率统计',
|
||||
icon: 'bar-chart',
|
||||
color: '#f56c6c',
|
||||
},
|
||||
],
|
||||
};
|
||||
},
|
||||
onLoad() {
|
||||
this.initPage();
|
||||
},
|
||||
methods: {
|
||||
// 初始化页面
|
||||
initPage() {
|
||||
this.setToday();
|
||||
},
|
||||
|
||||
// 设置当前日期
|
||||
setToday() {
|
||||
const now = new Date();
|
||||
const year = now.getFullYear();
|
||||
const month = String(now.getMonth() + 1).padStart(2, '0');
|
||||
const day = String(now.getDate()).padStart(2, '0');
|
||||
this.today = `${year}-${month}-${day}`;
|
||||
},
|
||||
|
||||
// 获取状态文本
|
||||
getStatusText(status) {
|
||||
const statusMap = {
|
||||
pending: '待处理',
|
||||
'in-progress': '进行中',
|
||||
completed: '已完成',
|
||||
};
|
||||
return statusMap[status] || '未知';
|
||||
},
|
||||
|
||||
// 统计项点击
|
||||
onStatClick(item) {
|
||||
console.log('点击统计', item.label);
|
||||
this.$u.toast(`查看${item.label}`);
|
||||
},
|
||||
|
||||
// 待办事项点击
|
||||
onTodoClick(item) {
|
||||
console.log('点击待办', item.title);
|
||||
this.$u.toast(`处理:${item.title}`);
|
||||
},
|
||||
|
||||
// 工作流程点击
|
||||
onWorkflowClick(item) {
|
||||
console.log('点击工作流', item.name);
|
||||
this.$u.toast(`打开${item.name}`);
|
||||
},
|
||||
|
||||
// 快速操作点击
|
||||
onQuickOpClick(item) {
|
||||
console.log('点击快速操作', item.title);
|
||||
this.$u.toast(item.title);
|
||||
},
|
||||
|
||||
// 显示搜索
|
||||
showSearch() {
|
||||
this.$u.toast('搜索功能');
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.workbench-container {
|
||||
background: #f5f5f5;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.content {
|
||||
padding: 20rpx;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 30rpx;
|
||||
|
||||
text {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
.date {
|
||||
font-size: 24rpx;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
.badge {
|
||||
background: #f56c6c;
|
||||
color: #fff;
|
||||
font-size: 20rpx;
|
||||
padding: 8rpx 16rpx;
|
||||
border-radius: 20rpx;
|
||||
min-width: 32rpx;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
||||
.work-stats {
|
||||
.stats-row {
|
||||
display: flex;
|
||||
gap: 20rpx;
|
||||
|
||||
.stat-item {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 20rpx;
|
||||
padding: 20rpx;
|
||||
background: #fafafa;
|
||||
border-radius: 12rpx;
|
||||
|
||||
.stat-icon {
|
||||
width: 60rpx;
|
||||
height: 60rpx;
|
||||
border-radius: 12rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.stat-info {
|
||||
.stat-value {
|
||||
display: block;
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
color: #303133;
|
||||
margin-bottom: 4rpx;
|
||||
}
|
||||
|
||||
.stat-label {
|
||||
font-size: 20rpx;
|
||||
color: #909399;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.todo-section {
|
||||
.todo-list {
|
||||
.todo-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 30rpx 0;
|
||||
border-bottom: 2rpx solid #f5f5f5;
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.todo-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 20rpx;
|
||||
flex: 1;
|
||||
|
||||
.priority-dot {
|
||||
width: 12rpx;
|
||||
height: 12rpx;
|
||||
border-radius: 50%;
|
||||
|
||||
&.high {
|
||||
background: #f56c6c;
|
||||
}
|
||||
|
||||
&.medium {
|
||||
background: #f9ae3d;
|
||||
}
|
||||
|
||||
&.low {
|
||||
background: #5ac725;
|
||||
}
|
||||
}
|
||||
|
||||
.todo-content {
|
||||
.todo-title {
|
||||
display: block;
|
||||
font-size: 28rpx;
|
||||
color: #303133;
|
||||
margin-bottom: 8rpx;
|
||||
}
|
||||
|
||||
.todo-time {
|
||||
font-size: 24rpx;
|
||||
color: #909399;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.todo-status {
|
||||
font-size: 24rpx;
|
||||
padding: 8rpx 16rpx;
|
||||
border-radius: 8rpx;
|
||||
|
||||
&.pending {
|
||||
background: #fef0f0;
|
||||
color: #f56c6c;
|
||||
}
|
||||
|
||||
&.in-progress {
|
||||
background: #fdf6ec;
|
||||
color: #f9ae3d;
|
||||
}
|
||||
|
||||
&.completed {
|
||||
background: #f0f9ff;
|
||||
color: #5ac725;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
text-align: center;
|
||||
padding: 80rpx 0;
|
||||
color: #c8c9cc;
|
||||
|
||||
text {
|
||||
display: block;
|
||||
margin-top: 20rpx;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.workflow-section {
|
||||
.workflow-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
gap: 30rpx;
|
||||
|
||||
.workflow-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 16rpx;
|
||||
position: relative;
|
||||
|
||||
.workflow-icon {
|
||||
width: 80rpx;
|
||||
height: 80rpx;
|
||||
border-radius: 20rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.workflow-text {
|
||||
font-size: 24rpx;
|
||||
color: #303133;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.workflow-badge {
|
||||
position: absolute;
|
||||
top: -10rpx;
|
||||
right: 10rpx;
|
||||
background: #f56c6c;
|
||||
color: #fff;
|
||||
font-size: 20rpx;
|
||||
padding: 4rpx 8rpx;
|
||||
border-radius: 10rpx;
|
||||
min-width: 20rpx;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.quick-ops {
|
||||
.ops-list {
|
||||
.ops-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 30rpx 0;
|
||||
border-bottom: 2rpx solid #f5f5f5;
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.ops-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 20rpx;
|
||||
flex: 1;
|
||||
|
||||
.ops-info {
|
||||
.ops-title {
|
||||
display: block;
|
||||
font-size: 28rpx;
|
||||
color: #303133;
|
||||
margin-bottom: 8rpx;
|
||||
}
|
||||
|
||||
.ops-desc {
|
||||
font-size: 24rpx;
|
||||
color: #909399;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,2 @@
|
||||
# 默认头像占位文件
|
||||
# 实际使用时请替换为对应的头像图片文件
|
||||
@@ -0,0 +1,2 @@
|
||||
# 应用logo占位文件
|
||||
# 实际使用时请替换为对应的logo图片文件
|
||||
@@ -0,0 +1,2 @@
|
||||
# 我的页面背景图占位文件
|
||||
# 实际使用时请替换为对应的背景图片文件
|
||||
@@ -0,0 +1,2 @@
|
||||
# 首页激活图标占位文件
|
||||
# 实际使用时请替换为对应的图标文件
|
||||
@@ -0,0 +1,2 @@
|
||||
# 首页图标占位文件
|
||||
# 实际使用时请替换为对应的图标文件
|
||||
@@ -0,0 +1,2 @@
|
||||
# 我的激活图标占位文件
|
||||
# 实际使用时请替换为对应的图标文件
|
||||
@@ -0,0 +1,2 @@
|
||||
# 我的图标占位文件
|
||||
# 实际使用时请替换为对应的图标文件
|
||||
@@ -0,0 +1,2 @@
|
||||
# 工作台激活图标占位文件
|
||||
# 实际使用时请替换为对应的图标文件
|
||||
@@ -0,0 +1,2 @@
|
||||
# 工作台图标占位文件
|
||||
# 实际使用时请替换为对应的图标文件
|
||||
@@ -0,0 +1,42 @@
|
||||
// uni.scss 全局样式变量
|
||||
|
||||
// 主题色彩
|
||||
$uni-primary: #3c9cff;
|
||||
$uni-success: #5ac725;
|
||||
$uni-warning: #f9ae3d;
|
||||
$uni-error: #f56c6c;
|
||||
$uni-info: #909399;
|
||||
|
||||
// 辅助色彩
|
||||
$uni-main-color: #303133;
|
||||
$uni-base-color: #606266;
|
||||
$uni-secondary-color: #909399;
|
||||
$uni-placeholder-color: #C0C4CC;
|
||||
|
||||
// 背景色
|
||||
$uni-bg-color: #f5f5f5;
|
||||
$uni-bg-color-grey: #f8f8f8;
|
||||
$uni-bg-color-hover: #f1f1f1;
|
||||
$uni-bg-color-mask: rgba(0, 0, 0, 0.4);
|
||||
|
||||
// 边框色
|
||||
$uni-border-1: #DCDFE6;
|
||||
$uni-border-2: #E4E7ED;
|
||||
$uni-border-3: #EBEEF5;
|
||||
$uni-border-4: #F2F6FC;
|
||||
|
||||
// 尺寸变量
|
||||
$uni-border-radius-sm: 4rpx;
|
||||
$uni-border-radius-base: 6rpx;
|
||||
$uni-border-radius-lg: 12rpx;
|
||||
$uni-border-radius-circle: 50%;
|
||||
|
||||
// 字体大小
|
||||
$uni-font-size-sm: 24rpx;
|
||||
$uni-font-size-base: 28rpx;
|
||||
$uni-font-size-lg: 32rpx;
|
||||
|
||||
// 间距
|
||||
$uni-spacing-sm: 16rpx;
|
||||
$uni-spacing-base: 24rpx;
|
||||
$uni-spacing-lg: 32rpx;
|
||||
@@ -0,0 +1,127 @@
|
||||
/**
|
||||
* 认证工具类
|
||||
*/
|
||||
|
||||
const TOKEN_KEY = 'token';
|
||||
const USER_INFO_KEY = 'userInfo';
|
||||
|
||||
/**
|
||||
* 获取Token
|
||||
*/
|
||||
export function getToken() {
|
||||
return uni.getStorageSync(TOKEN_KEY);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置Token
|
||||
*/
|
||||
export function setToken(token) {
|
||||
return uni.setStorageSync(TOKEN_KEY, token);
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除Token
|
||||
*/
|
||||
export function removeToken() {
|
||||
return uni.removeStorageSync(TOKEN_KEY);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
*/
|
||||
export function getUserInfo() {
|
||||
return uni.getStorageSync(USER_INFO_KEY);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置用户信息
|
||||
*/
|
||||
export function setUserInfo(userInfo) {
|
||||
return uni.setStorageSync(USER_INFO_KEY, userInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除用户信息
|
||||
*/
|
||||
export function removeUserInfo() {
|
||||
return uni.removeStorageSync(USER_INFO_KEY);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查是否已登录
|
||||
*/
|
||||
export function isLoggedIn() {
|
||||
const token = getToken();
|
||||
return !!token;
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除所有认证信息
|
||||
*/
|
||||
export function clearAuth() {
|
||||
removeToken();
|
||||
removeUserInfo();
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录
|
||||
*/
|
||||
export function login(loginData) {
|
||||
return new Promise((resolve, reject) => {
|
||||
// 模拟登录API调用
|
||||
setTimeout(() => {
|
||||
if (loginData.username === 'admin' && loginData.password === 'admin') {
|
||||
const token = 'mock-token-' + Date.now();
|
||||
const userInfo = {
|
||||
id: 1,
|
||||
username: loginData.username,
|
||||
nickname: '管理员',
|
||||
avatar: '/static/avatar.png',
|
||||
title: '系统管理员',
|
||||
};
|
||||
|
||||
setToken(token);
|
||||
setUserInfo(userInfo);
|
||||
|
||||
resolve({
|
||||
success: true,
|
||||
data: {
|
||||
token,
|
||||
userInfo,
|
||||
},
|
||||
});
|
||||
} else {
|
||||
reject(new Error('用户名或密码错误'));
|
||||
}
|
||||
}, 1000);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 退出登录
|
||||
*/
|
||||
export function logout() {
|
||||
return new Promise((resolve) => {
|
||||
clearAuth();
|
||||
|
||||
// 跳转到登录页
|
||||
uni.reLaunch({
|
||||
url: '/pages/login/login',
|
||||
});
|
||||
|
||||
resolve({ success: true });
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查登录状态并跳转
|
||||
*/
|
||||
export function checkAuth() {
|
||||
if (!isLoggedIn()) {
|
||||
uni.reLaunch({
|
||||
url: '/pages/login/login',
|
||||
});
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,226 @@
|
||||
/**
|
||||
* 网络请求工具类
|
||||
*/
|
||||
|
||||
import { getToken, logout } from './auth.js';
|
||||
|
||||
// 基础URL配置 - 修正为本地后端地址
|
||||
const BASE_URL = 'http://localhost:8080';
|
||||
|
||||
// 请求超时时间
|
||||
const TIMEOUT = 10000;
|
||||
|
||||
/**
|
||||
* 网络请求封装
|
||||
*/
|
||||
export function request(options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const token = getToken();
|
||||
|
||||
// 默认配置
|
||||
const defaultOptions = {
|
||||
url: BASE_URL + options.url,
|
||||
method: options.method || 'GET',
|
||||
timeout: TIMEOUT,
|
||||
header: {
|
||||
'Content-Type': 'application/json',
|
||||
...options.header,
|
||||
},
|
||||
data: options.data || {},
|
||||
};
|
||||
|
||||
// 添加Authorization header
|
||||
if (token) {
|
||||
defaultOptions.header['Authorization'] = `Bearer ${token}`;
|
||||
}
|
||||
|
||||
// 显示加载提示
|
||||
if (options.loading !== false) {
|
||||
uni.showLoading({
|
||||
title: options.loadingText || '加载中...',
|
||||
mask: true,
|
||||
});
|
||||
}
|
||||
|
||||
uni.request({
|
||||
...defaultOptions,
|
||||
success: (res) => {
|
||||
// 隐藏加载提示
|
||||
if (options.loading !== false) {
|
||||
uni.hideLoading();
|
||||
}
|
||||
|
||||
const { statusCode, data } = res;
|
||||
|
||||
// 请求成功
|
||||
if (statusCode === 200) {
|
||||
// 业务成功
|
||||
if (data.code === 200 || data.success === true) {
|
||||
resolve(data);
|
||||
} else {
|
||||
// 业务失败
|
||||
const message = data.message || data.msg || '请求失败';
|
||||
|
||||
// Token过期,跳转登录
|
||||
if (data.code === 401) {
|
||||
uni.showToast({
|
||||
title: '登录已过期,请重新登录',
|
||||
icon: 'none',
|
||||
});
|
||||
logout();
|
||||
return;
|
||||
}
|
||||
|
||||
// 显示错误信息
|
||||
if (options.showError !== false) {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none',
|
||||
});
|
||||
}
|
||||
|
||||
reject(new Error(message));
|
||||
}
|
||||
} else {
|
||||
// HTTP状态码错误
|
||||
const message = `请求失败 (${statusCode})`;
|
||||
|
||||
if (options.showError !== false) {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none',
|
||||
});
|
||||
}
|
||||
|
||||
reject(new Error(message));
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
// 隐藏加载提示
|
||||
if (options.loading !== false) {
|
||||
uni.hideLoading();
|
||||
}
|
||||
|
||||
const message = err.errMsg || '网络请求失败';
|
||||
|
||||
if (options.showError !== false) {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none',
|
||||
});
|
||||
}
|
||||
|
||||
reject(new Error(message));
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* GET请求
|
||||
*/
|
||||
export function get(url, params = {}, options = {}) {
|
||||
return request({
|
||||
url,
|
||||
method: 'GET',
|
||||
data: params,
|
||||
...options,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* POST请求
|
||||
*/
|
||||
export function post(url, data = {}, options = {}) {
|
||||
return request({
|
||||
url,
|
||||
method: 'POST',
|
||||
data,
|
||||
...options,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* PUT请求
|
||||
*/
|
||||
export function put(url, data = {}, options = {}) {
|
||||
return request({
|
||||
url,
|
||||
method: 'PUT',
|
||||
data,
|
||||
...options,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* DELETE请求
|
||||
*/
|
||||
export function del(url, params = {}, options = {}) {
|
||||
return request({
|
||||
url,
|
||||
method: 'DELETE',
|
||||
data: params,
|
||||
...options,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
*/
|
||||
export function uploadFile(url, filePath, options = {}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const token = getToken();
|
||||
|
||||
// 显示上传进度
|
||||
if (options.loading !== false) {
|
||||
uni.showLoading({
|
||||
title: options.loadingText || '上传中...',
|
||||
mask: true,
|
||||
});
|
||||
}
|
||||
|
||||
uni.uploadFile({
|
||||
url: BASE_URL + url,
|
||||
filePath,
|
||||
name: options.name || 'file',
|
||||
header: {
|
||||
Authorization: token ? `Bearer ${token}` : '',
|
||||
...options.header,
|
||||
},
|
||||
formData: options.formData || {},
|
||||
success: (res) => {
|
||||
if (options.loading !== false) {
|
||||
uni.hideLoading();
|
||||
}
|
||||
|
||||
try {
|
||||
const data = JSON.parse(res.data);
|
||||
if (data.code === 200 || data.success === true) {
|
||||
resolve(data);
|
||||
} else {
|
||||
const message = data.message || data.msg || '上传失败';
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none',
|
||||
});
|
||||
reject(new Error(message));
|
||||
}
|
||||
} catch (e) {
|
||||
reject(new Error('响应数据解析失败'));
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
if (options.loading !== false) {
|
||||
uni.hideLoading();
|
||||
}
|
||||
|
||||
const message = err.errMsg || '上传失败';
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none',
|
||||
});
|
||||
reject(new Error(message));
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user