This commit is contained in:
binbin_pan 2024-08-27 13:32:10 +08:00
parent 39ada29f62
commit c281dbebe9
10 changed files with 394 additions and 127 deletions

View File

@ -3,75 +3,88 @@ import Request from 'luch-request'
import config from '@/config'
import { getToken } from '@/utils/auth.js'
// import store from '@/store';
const baseUrl = config.baseUrl
let baseUrl = ''
if (uni.getStorageSync('jwtToken')) {
baseUrl = config.baseUrl
} else {
baseUrl = config.loginBaseUrl
}
console.log('baseUrl-请求', baseUrl)
const http = new Request({
// baseURL: "http://172.16.19.33:8081/prod-api", //设置请求的base url
// baseURL: "/dev-api", //设置请求的base url
baseURL: baseUrl, //设置请求的base url
timeout: 300000, //超时时长5分钟,
header: {
'Content-Type': 'application/x-www-form-urlencoded',
'Authorization':getToken()
}
// baseURL: "http://172.16.19.33:8081/prod-api", //设置请求的base url
// baseURL: "/dev-api", //设置请求的base url
baseURL: baseUrl, //设置请求的base url
timeout: 300000, //超时时长5分钟,
header: {
'Content-Type': 'application/x-www-form-urlencoded',
Authorization: getToken()
}
})
//请求拦截器
http.interceptors.request.use((config) => { // 可使用async await 做异步操作
// console.log('请求拦截器');
// // console.log(config);
// if (config.method === 'POST' && config.data.h) {
// config.header = {
// ...config.header,
// 'Content-Type': 'application/json;charset=UTF-8;'
// }
// // config.data = JSON.stringify(config.data);
// }else{
// config.header = {
// ...config.header,
// // 'uToken':Vue.prototype.$store.state.token,
// 'content-type':'application/x-www-form-urlencoded',
// }
// }
http.interceptors.request.use(
config => {
// 可使用async await 做异步操作
// console.log('请求拦截器');
// // if(getToken()){
// // console.log(">>>>>>",getToken());
// // config.header.Authorization='Bearer ' +getToken();
// // }
if(config.data&&!config.data.noShowLoading){
uni.showLoading({
title: '加载中'
});
}
console.log(config.data)
return config
}, error => {
return Promise.resolve(error)
})
// // console.log(config);
// if (config.method === 'POST' && config.data.h) {
// config.header = {
// ...config.header,
// 'Content-Type': 'application/json;charset=UTF-8;'
// }
// // config.data = JSON.stringify(config.data);
// }else{
// config.header = {
// ...config.header,
// // 'uToken':Vue.prototype.$store.state.token,
// 'content-type':'application/x-www-form-urlencoded',
// }
// }
// // if(getToken()){
// // console.log(">>>>>>",getToken());
// // config.header.Authorization='Bearer ' +getToken();
// // }
if (config.data && !config.data.noShowLoading) {
uni.showLoading({
title: '加载中'
})
}
console.log(config.data)
return config
},
error => {
return Promise.resolve(error)
}
)
// 响应拦截器
http.interceptors.response.use((response) => {
// console.log('响应拦截器');
uni.hideLoading();
return response
}, (error) => {
if (error.statusCode == 302) {
uni.clearStorageSync();
uni.switchTab({
url: "/pages/gzt/index"
})
}
//未登录时清空缓存跳转
if (error.statusCode == 401) {
uni.clearStorageSync();
uni.switchTab({
// url: "/pages/changguan/subscribe-fill"
url: "/pages/gzt/index"
})
}
return Promise.resolve(error)
})
export default http;
http.interceptors.response.use(
response => {
// console.log('响应拦截器');
uni.hideLoading()
return response
},
error => {
if (error.statusCode == 302) {
uni.clearStorageSync()
uni.switchTab({
url: '/pages/gzt/index'
})
}
//未登录时清空缓存跳转
if (error.statusCode == 401) {
uni.clearStorageSync()
uni.switchTab({
// url: "/pages/changguan/subscribe-fill"
url: '/pages/gzt/index'
})
}
return Promise.resolve(error)
}
)
export default http

View File

@ -1,10 +1,11 @@
// 应用全局配置
module.exports = {
// baseUrl:'/prod-api',
baseUrl:'http://112.29.103.165:1616',
loginBaseUrl:'http://112.29.103.165:1616',
// baseUrl:'http://192.168.0.14:2900',
baseUrl:'http://192.168.0.32:2900',
loginUrl: 'http://112.29.103.165:1616',
login: 'http://192.168.0.14:19200',
// baseUrl:'http://192.168.0.137:2900',
login: 'http://192.168.0.32:19200',
// 图片展示基础地址
fileUrl:'http://192.168.0.137:2909/exam-file/',
// 上传文件地址

View File

@ -1,6 +1,6 @@
{
"name" : "作业管控智慧平台",
"appid" : "__UNI__0EB2E47",
"appid" : "__UNI__4165875",
"description" : "作业管控智慧平台",
"versionName" : "1.0.4",
"versionCode" : 104,
@ -71,33 +71,33 @@
"icons" : {
"ios" : {
"iphone" : {
"app@2x" : "unpackage/res/icons/120x120.png",
"app@3x" : "unpackage/res/icons/180x180.png",
"spotlight@2x" : "unpackage/res/icons/80x80.png",
"notification@2x" : "unpackage/res/icons/40x40.png",
"notification@3x" : "unpackage/res/icons/60x60.png",
"settings@2x" : "unpackage/res/icons/58x58.png",
"settings@3x" : "unpackage/res/icons/87x87.png",
"spotlight@3x" : "unpackage/res/icons/120x120.png"
"app@2x" : "",
"app@3x" : "",
"spotlight@2x" : "",
"notification@2x" : "",
"notification@3x" : "",
"settings@2x" : "",
"settings@3x" : "",
"spotlight@3x" : ""
},
"appstore" : "unpackage/res/icons/1024x1024.png",
"appstore" : "",
"ipad" : {
"app" : "unpackage/res/icons/76x76.png",
"app@2x" : "unpackage/res/icons/152x152.png",
"notification" : "unpackage/res/icons/20x20.png",
"notification@2x" : "unpackage/res/icons/40x40.png",
"proapp@2x" : "unpackage/res/icons/167x167.png",
"settings" : "unpackage/res/icons/29x29.png",
"settings@2x" : "unpackage/res/icons/58x58.png",
"spotlight" : "unpackage/res/icons/40x40.png",
"spotlight@2x" : "unpackage/res/icons/80x80.png"
"app" : "",
"app@2x" : "",
"notification" : "",
"notification@2x" : "",
"proapp@2x" : "",
"settings" : "",
"settings@2x" : "",
"spotlight" : "",
"spotlight@2x" : ""
}
},
"android" : {
"hdpi" : "unpackage/res/icons/72x72.png",
"xhdpi" : "unpackage/res/icons/96x96.png",
"xxhdpi" : "unpackage/res/icons/144x144.png",
"xxxhdpi" : "unpackage/res/icons/192x192.png"
"hdpi" : "",
"xhdpi" : "",
"xxhdpi" : "",
"xxxhdpi" : ""
}
},
"splashscreen" : {

View File

@ -201,6 +201,20 @@
{
"navigationBarTitleText" : "人脸识别"
}
},
{
"path" : "pages/YNEduApp/user/myMsg",
"style" :
{
"navigationBarTitleText" : "消息通知"
}
},
{
"path" : "pages/YNEduApp/user/msgDetail",
"style" :
{
"navigationBarTitleText" : "消息详情"
}
}
],
"globalStyle": {

View File

@ -5,7 +5,7 @@
<uni-icons type="scan" size="24" style="margin-right: 2vw; color: #bababa" @click="toggleScan"></uni-icons>
<uni-easyinput
suffixIcon="search"
v-model="searchIpt"
v-model="keyword"
placeholder="请输入搜索关键词"
@iconClick="toggleSearch"
></uni-easyinput>
@ -28,18 +28,33 @@
scrollable
color="#808080"
background-color="transparent"
text="uni-app 版正式发布开发一次同时发布iOS、Android、H5、微信小程序、支付宝小程序、百度小程序、头条小程序等7大平台。"
:text="msgList.length > 0 ? msgList[0].noticeName : '暂无消息'"
@click="handleMsg"
/>
<view class="my-task">
<h3 style="margin-bottom: 1vh">我的任务</h3>
<view class="task-list">
<div class="task-list">
<div class="list-item" v-for="(item, index) in taskList" :key="index" @click="toggleDetail(item.id)">
<div class="item-title">{{ item.name }}</div>
<div>{{ item.userName }}</div>
<div>{{ item.validityDate }}</div>
<div class="item-progress">
<u-line-progress
:percentage="Number(item.trainPercentage)"
:showText="false"
height="8"
activeColor="#579AF8"
/>
<div>{{ item.trainPercentage }}%</div>
</div>
</div>
<view class="no-task" v-show="taskList.length === 0">
<view class="no-task-img">
<image src="/static/eduImg/no-task.png"></image>
<span>可联系管理员发布</span>
</view>
</view>
</view>
</div>
</view>
<m-tabbar fixed fill :current="0" :tabbar="tabbar"></m-tabbar>
</view>
@ -48,12 +63,14 @@
<script>
import TabbarConfig from '@/tabbar.js'
// import face from '../../../uni_modules/mcc-face/index'
import { getNoticeAnnoByUserId } from '@/api/eduApp/index.js'
import { getNoticeAnnoByUserId, getStudentStudyWorkList } from '@/api/eduApp'
import config from '@/config'
export default {
data() {
return {
userId: uni.getStorageSync('userId'),
tabbar: TabbarConfig,
searchIpt: '',
keyword: '',
opts: [
{ name: '学习项目', src: '/static/eduImg/learnProj.png', url: 'learnProj' },
// { name: '', src: '/static/eduImg/learn.png', url: 'learn' },
@ -74,10 +91,11 @@ export default {
title: '谁念西风独自凉,萧萧黄叶闭疏窗,沉思往事立残阳'
}
],
taskList: []
taskList: [],
msgList: []
}
},
onLoad() {
mounted() {
this.getUserInfo()
},
methods: {
@ -101,14 +119,58 @@ export default {
console.log('🚀 ~ getUserInfo ~ req:', req, req.data.access_token)
uni.setStorageSync('App-Token', req.data.access_token)
uni.setStorageSync('userId', req.data.loginUser.userId)
setTimeout(() => {
// this.getList()
}, 1000)
this.getMsgList()
},
fail: err => {
console.log(err)
}
})
},
toggleSearch() {
console.log(this.searchIpt)
async getList() {
this.taskList = []
let params = {
userId: this.userId,
status: '0'
}
const res = await getStudentStudyWorkList(params)
this.taskList = res.data
},
//
async toggleSearch() {
this.taskList = []
console.log('开始搜索', this.keyword)
let params = {
userId: this.userId,
status: '0',
name: this.keyword
}
const res = await getStudentStudyWorkList(params)
this.taskList = res.data
},
//
async getMsgList() {
uni.request({
url: config.bmwUrl + '/studentUsers/getNoticeList',
method: 'post',
data: {},
header: {
Authorization: this.token
},
success: res => {
console.log('🚀 ~ getMsgList ~ res:', res)
this.msgList = res.data
console.log('🚀 ~ getMsgList ~ this.msgList:', this.msgList)
}
})
},
//
handleMsg() {
uni.navigateTo({
url: '/pages/YNEduApp/user/myMsg'
})
},
toggleScan() {
uni.scanCode({
@ -126,7 +188,12 @@ export default {
face.open(['a', 'c'], function (e) {
face.close()
})
}
},
toggleDetail(id) {
uni.navigateTo({
url: `/pages/YNEduApp/learnProj/learnProjDetail?id=${id}`
})
},
},
onShow() {
/* getNoticeAnnoByUserId({
@ -211,6 +278,27 @@ export default {
flex: 1;
overflow-y: auto;
.list-item {
margin: 10px 0;
background-color: #f8f8f8;
border-radius: 5px;
padding: 5px;
font-size: 13px;
.item-title {
font-size: 16px;
font-weight: bold;
margin-bottom: 5px;
}
.item-progress {
display: flex;
align-items: center;
.u-line-progress {
width: 80%;
margin-right: 10px;
}
}
}
.no-task {
width: 100%;
height: 100%;

View File

@ -15,6 +15,7 @@
:isLink="true"
:border="false"
style="border-bottom: 1px solid #E9E9E9"
@click="handleAvatar"
>
<image
:src="infos.avatar"
@ -57,17 +58,25 @@
return {
infos: {
avatar: '',
username: '马晓峰',
unit: '测试单位'
username: '',
unit: ''
}
}
},
onLoad() {
onLoad(opt) {
console.log('🚀 ~ onLoad')
opt = JSON.parse(opt.params)
this.infos.username = opt.userName
this.infos.unit = opt.className
this.infos.avatar = uni.getStorageSync('facePath')
},
methods: {
//
handleAvatar() {
uni.navigateTo({
url: '/pages/YNEduApp/user/faceScan'
})
}
}
}
</script>

View File

@ -0,0 +1,43 @@
<template>
<view>
<div class="msg-wrapper">
<div class="msg-title">{{ noticeName }}</div>
<div class="msg-content" v-html="noticeContent"></div>
</div>
</view>
</template>
<script>
export default {
data() {
return {
noticeName: '',
noticeContent: ''
}
},
onLoad(opt) {
opt = JSON.parse(opt.params)
console.log('🚀 ~ onLoad ~ opt:', opt)
this.noticeName = opt.noticeName
this.noticeContent = opt.noticeContent
}
}
</script>
<style lang="scss" scoped>
.msg-wrapper {
margin: 10px;
background: #fff;
padding: 10px;
border-radius: 5px;
.msg-title {
font-size: 16px;
font-weight: bold;
margin-bottom: 10px;
}
.msg-content {
font-size: 14px;
line-height: 1.5;
}
}
</style>

View File

@ -0,0 +1,72 @@
<template>
<view>
<div class="msg-list" v-for="(item, index) in msgList" :key="index" @click="handleDetail(item)">
<div class="msg-title">{{ item.noticeName }}</div>
<div class="msg-time">{{ item.createTime }}</div>
</div>
</view>
</template>
<script>
import config from '@/config'
export default {
data() {
return {
userId: uni.getStorageSync('userId'),
token: uni.getStorageSync('App-Token'),
//
msgList: []
}
},
onLoad() {
// this.getMsgList()
},
methods: {
//
async getMsgList() {
uni.request({
url: config.bmwUrl + '/studentUsers/getNoticeList',
method: 'post',
data: {},
header: {
Authorization: this.token
},
success: res => {
console.log('🚀 ~ getMsgList ~ res:', res)
this.msgList = res.data
console.log('🚀 ~ getMsgList ~ this.msgList:', this.msgList)
}
})
},
//
handleDetail(item) {
const params = {
noticeName: item.noticeName,
noticeContent: item.noticeContent,
}
uni.navigateTo({
url: `/pages/YNEduApp/user/msgDetail?params=${JSON.stringify(params)}`
})
}
}
}
</script>
<style lang="scss" scoped>
.msg-list {
margin: 10px;
padding: 10px;
background: #fff;
border-radius: 5px;
.msg-title {
font-size: 16px;
color: #333;
}
.msg-time {
font-size: 14px;
color: #999;
margin-top: 5px;
}
}
</style>

View File

@ -9,7 +9,7 @@
<span style="font-size: 12px; color: #8a8a8b">{{ className }}</span>
</view>
<view class="edit-btn">
<view @click="jumpUrl('editProfile')">修改资料</view>
<view @click="handleEdit">修改资料</view>
</view>
</view>
<view class="learn-infos">
@ -56,18 +56,19 @@ export default {
totalCer: 26
},
allDuration: 0,
value: 0, //
value: 0, //
secList: [
{ id: 1, title: '切换门户', src: '/static/eduImg/changeGate.png', path: 'changeGate' },
{ id: 2, title: '人脸识别', src: '/static/eduImg/faceScan.png', path: 'faceScan' },
{ id: 3, title: '我的消息', src: '/static/eduImg/myMsg.png', path: 'myMsg' },
{ id: 4, title: '设置', src: '/static/eduImg/settings.png', path: 'settings' }
],
token: ''
token: uni.getStorageSync('App-Token')
}
},
onLoad() {
this.token = uni.getStorageSync('App-Token')
// this.token = uni.getStorageSync('App-Token')
console.log('🚀 ~ onLoad ~ this.token:', this.token)
this.getUserInfo()
this.getLearnStats()
},
@ -98,7 +99,7 @@ export default {
this.className = req.data.loginUser.sysUser.className
this.facePath = config.fileUrl + req.data.loginUser.sysUser.facePath
uni.setStorageSync('facePath', this.facePath)
console.log('🚀 ~ getUserInfo ~ this.facePath:', this.facePath)
},
fail: err => {
@ -112,16 +113,25 @@ export default {
url: config.baseUrl + '/exam-student/personalCenter/getStudyAndCer',
method: 'post',
header: {
'Content-Type': 'application/x-www-form-urlencoded',
Authorization: this.token
},
data: {},
success: res => {
console.log('🚀 ~ getLearnStats ~ res:', res)
this.allDuration = res.data.data.allDuration
this.value = res.data.data.value
this.allDuration = (res.data && res.data.data.allDuration) || 0
this.value = (res.data && res.data.data.value) || 0
}
})
},
//
handleEdit() {
const params = {
userName: this.userName,
className: this.className
}
uni.navigateTo({
url: '/pages/YNEduApp/user/editProfile?params=' + JSON.stringify(params)
})
}
}
}

View File

@ -1,11 +1,17 @@
import store from '@/store'
import config from '@/config'
import { getToken } from '@/utils/auth'
import { getToken, setToken } from '@/utils/auth'
import errorCode from '@/utils/errorCode'
import { toast, showConfirm, tansParams } from '@/utils/common'
let timeout = 10000
const baseUrl = config.baseUrl
let baseUrl = ''
if (uni.getStorageSync('jwtToken')) {
baseUrl = config.baseUrl
} else {
baseUrl = config.loginBaseUrl
}
console.log('baseUrl-请求', baseUrl)
const request = config => {
// 是否需要设置 token
@ -13,6 +19,15 @@ const request = config => {
config.header = config.header || {}
if (getToken() && !isToken) {
config.header['Authorization'] = 'Bearer ' + getToken()
} else {
// 没有token - 去登录
// store.dispatch('LogOut').then(() => {
// uni.reLaunch({ url: '/pages/login' })
// })
// const token = 'eyJhbGciOiJIUzUxMiJ9.eyJ1c2VyX2lkIjozMSwidXNlcl9rZXkiOiJiZmJmOGEzZC1hYTc1LTQ4MzQtOGM3NC0yZmQzOTEwZDllYzAiLCJ1c2VybmFtZSI6IuaWueS6riJ9.kv1WmthbgTrqapbsGLvevk-nwbWbYJMniyjj8DC3BSnQjCwm8csQ5GaNpfsLFFFYIHBYa8CrN_sBxXhDKOfR_A'
// const userId = 31
// setUserId(userId)
// setToken(token)
}
// get请求映射params参数
if (config.params) {
@ -20,23 +35,25 @@ const request = config => {
url = url.slice(0, -1)
config.url = url
}
if (config.method === 'post' ) {
config.header = {
...config.header,
'Content-Type': 'application/x-www-form-urlencoded'
}
// config.data = JSON.stringify(config.data);
if (config.method === 'post') {
config.header = {
...config.header,
'Content-Type': 'application/x-www-form-urlencoded'
}
// config.data = JSON.stringify(config.data);
}
return new Promise((resolve, reject) => {
uni.request({
uni
.request({
method: config.method || 'get',
timeout: config.timeout || timeout,
url: config.baseUrl || baseUrl + config.url,
timeout: config.timeout || timeout,
url: baseUrl + config.url,
data: config.data,
header: config.header,
dataType: 'json'
}).then(response => {
// console.log(response)
})
.then(response => {
// console.log(response)
let [error, res] = response
if (error) {
toast('后端接口连接异常')