提交 52d20774 authored 作者: 王鹏飞's avatar 王鹏飞

merge...

{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "dev",
"program": "${workspaceFolder}/server/server/distRun.js",
"env": {
"SERVER_PORT": "4002",
"NODE_ENV": "test"
}
},
{
"type": "node",
"request": "launch",
"name": "production",
"program": "${workspaceFolder}/server/server/distRun.js",
"env": {
"SERVER_PORT": "4004",
"NODE_ENV": "production"
}
}
]
}
module.exports = {
demain: 'dev.ezijing.com',
url: 'http://dev.ezijing.com:4002/api',
// apiBaseURL: '//demo-login.ezijing.com/'
url: 'https://collage-learning2.ezijing.com/api',
apiBaseURL: '/',
others: {
url: '/app/learn/course'
},
webpack: {
externals: {
'CKEDITOR': 'window.CKEDITOR',
'VideoJs': 'window.swfobject',
'Base64': 'window.Base64',
'md5': 'window.md5',
'regeneratorRuntime': 'window.regeneratorRuntime',
'$': 'window.$',
'Aliplayer': 'window.Aliplayer',
'AliPlayerComponent': 'window.AliPlayerComponent'
CKEDITOR: 'window.CKEDITOR',
VideoJs: 'window.swfobject',
Base64: 'window.Base64',
md5: 'window.md5',
regeneratorRuntime: 'window.regeneratorRuntime',
$: 'window.$',
Aliplayer: 'window.Aliplayer',
AliPlayerComponent: 'window.AliPlayerComponent'
// 'sentNotify': 'window.sentNotify',
}
},
ProvidePlugin: {
}
ProvidePlugin: {}
}
module.exports = {
url: '//api.ezijing.com',
DesDir: '../server/client-dist',
apiBaseURL: '/api',
url: '/',
DesDir: '../client-dist',
apiBaseURL: '/',
others: {
url: '/app/learn/course'
},
webpack: {
externals: {
'CKEDITOR': 'window.CKEDITOR',
'VideoJs': 'window.swfobject',
'Base64': 'window.Base64',
'md5': 'window.md5',
'regeneratorRuntime': 'window.regeneratorRuntime',
'$': 'window.$',
'Aliplayer': 'window.Aliplayer',
'AliPlayerComponent': 'window.AliPlayerComponent'
CKEDITOR: 'window.CKEDITOR',
VideoJs: 'window.swfobject',
Base64: 'window.Base64',
md5: 'window.md5',
regeneratorRuntime: 'window.regeneratorRuntime',
$: 'window.$',
Aliplayer: 'window.Aliplayer',
AliPlayerComponent: 'window.AliPlayerComponent'
// 'sentNotify': 'window.sentNotify',
}
},
ProvidePlugin: {
}
ProvidePlugin: {}
}
module.exports = {
url: '//api.ezijing.com',
DesDir: '../server/client-dist',
apiBaseURL: '/api',
url: '/',
DesDir: '../client-dist',
apiBaseURL: '/',
others: {
url: '/app/learn/course'
},
isUploadStatic: false,
webpack: {
externals: {
'CKEDITOR': 'window.CKEDITOR',
'VideoJs': 'window.swfobject',
'Base64': 'window.Base64',
'md5': 'window.md5',
'regeneratorRuntime': 'window.regeneratorRuntime',
'$': 'window.$',
'Aliplayer': 'window.Aliplayer',
'AliPlayerComponent': 'window.AliPlayerComponent'
CKEDITOR: 'window.CKEDITOR',
VideoJs: 'window.swfobject',
Base64: 'window.Base64',
md5: 'window.md5',
regeneratorRuntime: 'window.regeneratorRuntime',
$: 'window.$',
Aliplayer: 'window.Aliplayer',
AliPlayerComponent: 'window.AliPlayerComponent'
// 'sentNotify': 'window.sentNotify',
}
},
ProvidePlugin: {
}
ProvidePlugin: {}
}
......@@ -69,6 +69,7 @@
"js-cookie": "^2.2.1",
"lodash": "^4.17.15",
"promise.prototype.finally": "^3.1.2",
"qs": "^6.9.4",
"regenerator": "^0.14.4",
"vue": "^2.6.11",
"vue-i18n": "^8.16.0",
......
......@@ -37,7 +37,11 @@ export default class OtherAction extends BaseACTION {
*/
uploadFile (obj) { return Other.uploadFile(obj).then(res => res) }
/**
* 调用个人信心 - 修改密码
* 修改密码
*/
updatePwd (obj) { return Other.updatePwd(obj).then(res => res) }
/**
* 修改用户信息
*/
updateUser (obj) { return Other.updateUser(obj).then(res => res) }
}
......@@ -4,11 +4,11 @@ export default class AffairsAPI extends BaseAPI {
/**
* 获取事务类型
*/
getAffairsType = () => this.get('/v2/lobby/affairs')
getAffairsType = () => this.get('/api/lms/v2/lobby/affairs')
/**
* 获取事务类型
*/
getAffairsData = (obj = {}) => this.get('/v2/lobby/processes', obj)
getAffairsData = (obj = {}) => this.get('/api/lms/v2/lobby/processes', obj)
/**
* 提交活动申请
* affair_id 活动名称
......@@ -20,13 +20,13 @@ export default class AffairsAPI extends BaseAPI {
* symposium_lecturer
* 返回 {'flag' : true, 'errors' : []}
*/
submitLearning = (obj = {}) => this.post('/v2/lobby/processes', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
submitLearning = (obj = {}) => this.post('/api/lms/v2/lobby/processes', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
/* 删除事务 */
deleteAffairs = (reid) => this.delete(`/v2/lobby/processes/${reid}`, {})
deleteAffairs = (reid) => this.delete(`/api/lms/v2/lobby/processes/${reid}`, {})
/* 获取事务详情 */
getAffairsDetails = (rid) => this.get(`/v2/lobby/processes/${rid}`, {})
getAffairsDetails = (rid) => this.get(`/api/lms/v2/lobby/processes/${rid}`, {})
/* 修改事务 */
updateAffairs = (rid, obj = {}) => this.post(`/v2/lobby/processes/${rid}`, obj, { headers: { 'Content-Type': 'multipart/form-data' } })
updateAffairs = (rid, obj = {}) => this.post(`/api/lms/v2/lobby/processes/${rid}`, obj, { headers: { 'Content-Type': 'multipart/form-data' } })
/* 重修图片提交 */
uploadFile = (obj = {}) => this.post('/v2/lobby/tools/upload', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
uploadFile = (obj = {}) => this.post('/api/lms/v2/lobby/tools/upload', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
}
import axios from 'axios'
import _ from 'lodash'
import qs from 'qs'
import { MessageBox, Message } from 'element-ui'
export default class API {
constructor (config) {
constructor(config) {
/* 创建一个 自定义配置axios实例 */
// 让ajax携带cookie
axios.defaults.withCredentials = true
......@@ -24,14 +25,16 @@ export default class API {
}
/* 获取当前Vue创建实例 */
getVueInstance () {
getVueInstance() {
return window.G.$instance_vue
}
/* 重新封装 请求时的执行函数 */
_request (_config = {}) {
_request(_config = {}) {
/* 具体执行请求成功后业务逻辑前,先执行该方法 */
const beforeSuccess = _config.beforeSuccess ? _config.beforeSuccess : this._reqSuccess
const beforeSuccess = _config.beforeSuccess
? _config.beforeSuccess
: this._reqSuccess
/* 具体执行请求失败后业务逻辑前,先执行该方法 */
const beforeFail = _config.beforeFail ? _config.beforeFail : this._reqFail
const headers = {
......@@ -40,13 +43,16 @@ export default class API {
}
_config.headers = _.assignIn(_config.headers, headers)
/* 判别 传输方式 */
if (_config.headers['Content-Type'] === 'application/x-www-form-urlencoded') {
if (
_config.headers['Content-Type'] === 'application/x-www-form-urlencoded'
) {
let str = ''
const _obj = _config.data || _config.params
for (const key in _obj) {
str += key + '=' + _obj[key] + '&'
}
str = str.substr(0, str.length - 1)
// for (const key in _obj) {
// str += key + '=' + _obj[key] + '&'
// }
// str = str.substr(0, str.length - 1)
str = qs.stringify(_obj)
if (_config.data) {
_config.data = str
} else {
......@@ -62,11 +68,13 @@ export default class API {
_config.data = fr
}
/* 创建并根据参数发起请求 */
return this._axios(_config)
.then(beforeSuccess.bind(this), beforeFail.bind(this))
return this._axios(_config).then(
beforeSuccess.bind(this),
beforeFail.bind(this)
)
}
setConfirm (titleStr, btnStr, msgStr) {
setConfirm(titleStr, btnStr, msgStr) {
return MessageBox.confirm(msgStr, titleStr, {
confirmButtonText: btnStr,
type: 'warning',
......@@ -77,12 +85,16 @@ export default class API {
})
}
goLoginIndex (_vIn) {
goLoginIndex(_vIn) {
const href = window.location.href
if (/\/login\/index/gi.test(href)) {
_vIn.$router.go(0)
} else {
_vIn.$router.push({ path: '/login/index?rd=' + encodeURIComponent(href.replace(/.*?\/\/.*?\//gi, '/')) })
_vIn.$router.push({
path:
'/login/index?rd=' +
encodeURIComponent(href.replace(/.*?\/\/.*?\//gi, '/'))
})
}
}
......@@ -91,35 +103,15 @@ export default class API {
* 注意:如果不能满足需求,可在接口定义处重新实现
* @param {[object]} res 返回数据
*/
_reqSuccess (res) {
const _vIn = this.getVueInstance()
const { status, data } = res
if (status === 200) {
/* 针对 不同的 接口做一下 统一处理 */
/* 带 code 参数,新接口模型 */
if (data && data.code !== undefined) {
if (data.code !== 0) {
if (!/account\/get-user-info/gi.test(res.config.url)) {
data.msg && Message({ type: 'error', message: data.msg })
}
return data
} else if (data.code === 0) {
return data.data
}
_reqSuccess(res) {
const { data } = res
/* 带 code 参数,新接口模型 */
if (data.code !== undefined) {
if (data.code !== 0 && !/get-user-info$/gi.test(res.config.url)) {
data.msg && Message({ type: 'error', message: data.msg })
}
return data
} else if (status === 403 && !/\/getinfo$/gi.test(res.config.url)) {
/* 不带 code 参数,老接口模型 */
this.setConfirm('提示', '确定', '登录状态已过期, 请重新登录。').then(() => {
this.goLoginIndex(_vIn)
}).catch(() => {
Message({ type: 'info', message: '操作已取消,将不再记录任何数据操作,除非重新登录' })
})
} else if (status !== 200 && data.message) {
throw new Error(data.message)
} else {
throw new Error(JSON.stringify(res.data))
}
return data
}
/**
......@@ -127,28 +119,32 @@ export default class API {
* 注意:如果不能满足需求,可在接口定义处重新实现
* @param {[object]} res 如果未到达 response 阶段,则无res.response
*/
_reqFail (res) {
_reqFail(res) {
const _vIn = this.getVueInstance()
let err = null
if (res.code === 'ECONNABORTED') {
err = new Error('网络超时,请稍后重试')
} else if (res.response) {
const { status, data } = res.response
/* 不带 code 参数,老接口模型 */
if (res.response.data) {
if (!/\/getinfo$/gi.test(res.config.url) && res.response.status === 403) {
this.setConfirm('提示', '确定', '登录状态已过期, 请重新登录。').then(() => {
this.goLoginIndex(_vIn)
}).catch(() => {
Message({ type: 'info', message: '已取消,将不再记录任何数据操作,除非重新登录' })
})
if (data) {
if (status === 403 && !/check-access$/gi.test(res.config.url)) {
this.setConfirm('提示', '确定', '登录状态已过期, 请重新登录。')
.then(() => {
this.goLoginIndex(_vIn)
})
.catch(() => {
Message({
type: 'info',
message: '已取消,将不再记录任何数据操作,除非重新登录'
})
})
} else if (status === 401) {
this.setConfirm('提示', '关闭', data.message).then(() => {})
}
} else if (res.response.status === 401) {
this.setConfirm('提示', '关闭', res.response.data.message).then(() => {
_vIn.$router.go(0)
})
}
err = new Error(res.response.data.message || JSON.stringify(res.response.data))
err.code = res.response.data.code
err = new Error(data.message || JSON.stringify(data))
err.code = data.code
} else {
err = new Error('msg:' + res.message + 'stack:' + res.stack)
err.code = 500
......@@ -158,11 +154,28 @@ export default class API {
}
/* 重新实现 get请求 */
get (url, data, config) { return this._request(_.assignIn({ url, method: 'GET', params: data }, config)) }
get(url, data, config) {
return this._request(
_.assignIn({ url, method: 'GET', params: data }, config)
)
}
/* 重新实现 post请求 */
post (url, data, config) { return this._request(_.assignIn({ url, method: 'POST', data: data }, config)) }
post(url, data, config) {
return this._request(
_.assignIn({ url, method: 'POST', data: data }, config)
)
}
/* 重新实现 put请求 */
put (url, data, config) { return this._request(_.assignIn({ url, method: 'PUT', data: data }, config)) }
put(url, data, config) {
return this._request(_.assignIn({ url, method: 'PUT', data: data }, config))
}
/* 重新实现 delete请求 */
delete (url, data, config) { return this._request(_.assignIn({ url, method: 'DELETE', params: data }, config)) }
delete(url, data, config) {
return this._request(
_.assignIn({ url, method: 'DELETE', params: data }, config)
)
}
}
......@@ -4,35 +4,35 @@ export default class CourseAPI extends BaseAPI {
/**
* 获取学期分类信息
*/
getLearnFind = () => this.get('/v2/education/semesters', {})
getLearnFind = () => this.get('/api/lms/v2/education/semesters', {})
/**
* 获取所有课程列表 - 选课广场 和 我的课程 共用同一个,通过 isMy判断
* @param {[string]} isMy
* @param {[object]} param
*/
getCourseList = (isMy, param) => this.get('/v2/education/courses' + (isMy ? '/my' : ''), param)
getCourseList = (isMy, param) => this.get('/api/lms/v2/education/courses' + (isMy ? '/my' : ''), param)
/**
* 获取某个课程详细信息 - 课程考核 和 课程讨论单独获取
* @param {[string]} id
* @param {[string]} sid
*/
getCourseDetail = (id, sid) => this.get(`/v2/education/courses/${sid}/${id}`, {})
getCourseDetail = (id, sid) => this.get(`/api/lms/v2/education/courses/${sid}/${id}`, {})
/**
* 获取课程考核信息
* @param {[string]} cid
* @param {[string]} sid
*/
getCourseAssess = (cid, sid) => this.get(`/v2/analytics/courses/${sid}/${cid}/evaluation`, {})
getCourseAssess = (cid, sid) => this.get(`/api/lms/v2/analytics/courses/${sid}/${cid}/evaluation`, {})
/**
* 选课
* @param {[string]} cid
* @param {[string]} sid
*/
selectCourse = (cid, sid) => this.post('/v2/education/courses/major', { course_id: cid, semester_id: sid }, { headers: { 'Content-Type': 'application/json' } })
selectCourse = (cid, sid) => this.post('/api/lms/v2/education/courses/major', { course_id: cid, semester_id: sid }, { headers: { 'Content-Type': 'application/json' } })
/**
* 退课
* @param {[string]} cid
* @param {[string]} sid
*/
outSelectCourse = (cid, sid) => this.post('/v2/education/courses/drop', { course_id: cid, semester_id: sid }, { headers: { 'Content-Type': 'application/json' } })
outSelectCourse = (cid, sid) => this.post('/api/lms/v2/education/courses/drop', { course_id: cid, semester_id: sid }, { headers: { 'Content-Type': 'application/json' } })
}
......@@ -8,7 +8,7 @@ export default class DiscussAPI extends BaseAPI {
* @param {[string]} path
* @param {[object]} dataJson
*/
getDiscussList = (path, dataJson) => this.get('/v2/qa/questions' + path, dataJson)
getDiscussList = (path, dataJson) => this.get('/api/lms/v2/qa/questions' + path, dataJson)
/**
* 获取讨论题目列表,“课程的问题”信息
* dataJson.limit - 获取数量
......@@ -18,50 +18,50 @@ export default class DiscussAPI extends BaseAPI {
* @param {[string]} sid
* @param {[object]} dataJson
*/
getCourseDiscussList = (cid, sid, dataJson) => this.get(`/v2/qa/questions/course/${sid}/${cid}`, dataJson)
getCourseDiscussList = (cid, sid, dataJson) => this.get(`/api/lms/v2/qa/questions/course/${sid}/${cid}`, dataJson)
/**
* 获取问题详情
* @param {[string]} qid
*/
getDiscussDetail = (qid) => this.get(`/v2/qa/questions/${qid}`, {})
getDiscussDetail = (qid) => this.get(`/api/lms/v2/qa/questions/${qid}`, {})
/**
* 删除提问
* @param {[string]} qid
*/
deleteDiscuss = (qid) => this.delete(`/v2/qa/questions/${qid}`, {})
deleteDiscuss = (qid) => this.delete(`/api/lms/v2/qa/questions/${qid}`, {})
/**
* 提出问题
* @param {[object]} param
*/
publishQues = (param) => this.post('/v2/qa/questions', param, { headers: { 'Content-Type': 'application/json' } })
publishQues = (param) => this.post('/api/lms/v2/qa/questions', param, { headers: { 'Content-Type': 'application/json' } })
/**
* 回答问题
* @param {[object]} param
*/
answerQues = (param) => this.post('/v2/qa/answers', param, { headers: { 'Content-Type': 'application/json' } })
answerQues = (param) => this.post('/api/lms/v2/qa/answers', param, { headers: { 'Content-Type': 'application/json' } })
/**
* 删除回答
* @param {[string]} aid
*/
deleteAnswer = (aid) => this.delete(`/v2/qa/answers/${aid}`, {})
deleteAnswer = (aid) => this.delete(`/api/lms/v2/qa/answers/${aid}`, {})
/**
* 回复评论
* @param {[object]} param
*/
callbackComment = (param) => this.post('/v2/qa/comments', param, { headers: { 'Content-Type': 'application/json' } })
callbackComment = (param) => this.post('/api/lms/v2/qa/comments', param, { headers: { 'Content-Type': 'application/json' } })
/**
* 删除评论
* @param {[string]} cid
*/
deleteComment = (cid) => this.delete(`/v2/qa/comments/${cid}`)
deleteComment = (cid) => this.delete(`/api/lms/v2/qa/comments/${cid}`)
/**
* 点赞
* @param {[object]} param
*/
like = (param) => this.post('/v2/qa/tags', param, { headers: { 'Content-Type': 'application/json' } })
like = (param) => this.post('/api/lms/v2/qa/tags', param, { headers: { 'Content-Type': 'application/json' } })
/**
* 取消点赞
* @param {[string]} tagid
*/
unlike = (tagid) => this.delete(`/v2/qa/tags/${tagid}`, {})
unlike = (tagid) => this.delete(`/api/lms/v2/qa/tags/${tagid}`, {})
}
......@@ -4,22 +4,22 @@ export default class FeedbackAPI extends BaseAPI {
/**
* 提交 重修课程
*/
submitRebuild = (obj = {}) => this.post('/v2/education/retake', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
submitRebuild = (obj = {}) => this.post('/api/lms/v2/education/retake', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
/**
* 获取意见列表
* type_id [int]
* page [int]
* pageSize [int]
*/
feedbackList = (obj = {}) => this.get('/v2/feedback/lists', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
feedbackList = (obj = {}) => this.get('/api/lms/v2/feedback/lists', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
/**
* 意见反馈回复
* feedback_id [int]
* contents [string]
*/
feedbackReply = (obj = {}) => this.post('/v2/feedback/reply', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
feedbackReply = (obj = {}) => this.post('/api/lms/v2/feedback/reply', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
/**
* 意见反馈提交
*/
feedbackCommit = (obj = {}) => this.post('/v2/feedback/commit', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
feedbackCommit = (obj = {}) => this.post('/api/lms/v2/feedback/commit', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
}
......@@ -4,26 +4,26 @@ export default class GradeAPI extends BaseAPI {
/**
* 获取我的学分信息
*/
getCredit = () => this.get('/v2/education/credits', {})
getCredit = () => this.get('/api/lms/v2/education/credits', {})
/**
* 提交 重修课程
*/
submitRebuild = (obj = {}) => this.post('/v2/education/retake', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
submitRebuild = (obj = {}) => this.post('/api/lms/v2/education/retake', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
/**
* 获取意见列表
* type_id [int]
* page [int]
* pageSize [int]
*/
feedbackList = (obj = {}) => this.get('/v2/feedback/lists', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
feedbackList = (obj = {}) => this.get('/api/lms/v2/feedback/lists', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
/**
* 意见反馈回复
* feedback_id [int]
* contents [string]
*/
feedbackReply = (obj = {}) => this.post('/v2/feedback/reply', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
feedbackReply = (obj = {}) => this.post('/api/lms/v2/feedback/reply', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
/**
* 意见反馈提交
*/
feedbackCommit = (obj = {}) => this.post('/v2/feedback/commit', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
feedbackCommit = (obj = {}) => this.post('/api/lms/v2/feedback/commit', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
}
......@@ -3,32 +3,54 @@ import _ from 'lodash'
export default class OtherAPI extends BaseAPI {
/**
* 当前登录用户,检测是否该系统有权限
*/
getInfo = () => this.post('/user_center/get_user_info', {}, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
* 当前登录用户,检测是否该系统有权限
*/
getInfo = () => this.get('/api/lms/user/getinfo')
/**
* 获取我的消息信息
*/
getMyMsg = (obj) => this.get('/v2/education/message/my', obj, {})
getMyMsg = (obj) => this.get('/api/lms/v2/education/message/my', obj, {})
/**
* 标记已读未读
*/
setMyMsg = (rid) => this.post(`/v2/education/message/${rid}`, {})
getNavMsg = (rid) => this.get(`/v2/education/message/num?v=${new Date().getTime()}`, {})
setMyMsg = (rid) => this.post(`/api/lms/v2/education/message/${rid}`, {})
getNavMsg = (rid) =>
this.get(`/api/lms/v2/education/message/num?v=${new Date().getTime()}`, {})
/**
* 调用退出登录
*/
outLogin = () => this.post('/user_center/logout', {}, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
outLogin = () => this.get('/api/passport/rest/logout')
/**
* 文件提交
* @param {[object]} obj
*/
uploadFile = (obj = {}) => this.post('/util/upload-file', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
uploadFile = (obj = {}) =>
this.post('/api/usercenter/user/upload-image', obj, {
headers: { 'Content-Type': 'multipart/form-data' }
})
/**
* 个人信息 - 修改密码
* @param {[string]} obj.old_password 验证码
* @param {[string]} obj.new_password 新的密码
* @param {[string]} obj.service 这里 一直是定值 h5.ezijing.com
*/
updatePwd = (obj = {}) => this.post('/user_center/change_password', _.assignIn(obj, { service: 'h5.ezijing.com' }), { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
updatePwd = (obj = {}) =>
this.post(
'/api/usercenter/user/change-pwd-by-cookie',
_.assignIn(obj, { service: 'h5.ezijing.com' }),
{ headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }
)
/**
* 个人信息 - 上传头像
*/
updateUser = (obj = {}) =>
this.post('/api/usercenter/user/update-user', obj, {
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
})
}
......@@ -7,24 +7,24 @@ export default class PlayerAPI extends BaseAPI {
* @param {[string]} cur_semester_id -> sid
* @param {[string]} cur_video_id -> vid
*/
getChapterList = (cid, sid, vid) => this.get(`/v2/education/courses/${sid}/${cid}`, {})
getChapterList = (cid, sid, vid) => this.get(`/api/lms/v2/education/courses/${sid}/${cid}`, {})
/**
* 获取对应某个章节的详细信息
* @param {[string]} vid
*/
getCurrentChapterDetail = (vid) => this.post('/v2/education/video-streaming', { vid }, { headers: { 'Content-Type': 'application/json' } })
getCurrentChapterDetail = (vid) => this.post('/api/lms/v2/education/video-streaming', { vid }, { headers: { 'Content-Type': 'application/json' } })
/**
* 获取对应某个章节的详细信息
* @param {[string]} vid
*/
getCurrentChapterDetailAliyun = (vid) => this.post('/v2/education/aliyun-video-streaming', { vid }, { headers: { 'Content-Type': 'application/json' } })
getCurrentChapterDetailAliyun = (vid) => this.post('/api/lms/v2/education/aliyun-video-streaming', { vid }, { headers: { 'Content-Type': 'application/json' } })
/**
* 获取进度信息
* @param {[string]} vid
* @param {[string]} did
* @param {[string]} sid
*/
getProgress = (vid, did, sid) => this.get(`/v2/education/video/${sid}/${vid}/device`, { device_id: did })
getProgress = (vid, did, sid) => this.get(`/api/lms/v2/education/video/${sid}/${vid}/device`, { device_id: did })
/**
* 提交进度信息
* @param {[object]} obj
......@@ -37,66 +37,66 @@ export default class PlayerAPI extends BaseAPI {
_m: obj.mpt, // 当前播放最大时间
_c: obj.cpt // 当前播放位置
*/
updateProgress = (obj = {}) => this.get('/v2/analytics/upload-video', obj)
updateProgress = (obj = {}) => this.get('/api/lms/v2/analytics/upload-video', obj)
/**
* 获取试题信息
* @param {[string]} eid
* @param {[string]} cid
* @param {[string]} sid
*/
getExamDetail = (sid, cid, eid) => this.get(`/v2/education/homeworks/${sid}/${cid}/${eid}`, {})
getExamDetail = (sid, cid, eid) => this.get(`/api/lms/v2/education/homeworks/${sid}/${cid}/${eid}`, {})
/**
* 提交考试信息
* @param {[object]} param
*/
submitExamDetail = (param) => this.post('/v2/education/homeworks', param, { headers: { 'Content-Type': 'application/json' } })
submitExamDetail = (param) => this.post('/api/lms/v2/education/homeworks', param, { headers: { 'Content-Type': 'application/json' } })
/**
* 获取对应 作业或问题 回答
* @param {[string]} sid
* @param {[string]} cid
* @param {[string]} id resource_id
*/
getHomework = (sid, cid, id) => this.get(`/v2/education/homeworks/${sid}/${cid}/${id}`, {})
getHomework = (sid, cid, id) => this.get(`/api/lms/v2/education/homeworks/${sid}/${cid}/${id}`, {})
/**
* 文件提交
* @param {[object]} obj
*/
uploadFile = (obj = {}) => this.post('/util/upload-file', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
uploadFile = (obj = {}) => this.post('/api/lms/util/upload-file', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
/**
* 提交课程 作业或问题
*/
updateHomework = (obj = {}) => this.post('/v2/education/homeworks', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
updateHomework = (obj = {}) => this.post('/api/lms/v2/education/homeworks', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
/**
* 课程作业截止时间
*/
getHomeworkStopTime = (sid, cid, chapterId) => this.get(`/v2/education/homeworks/${sid}/${cid}/${chapterId}/deadline`, {})
getHomeworkStopTime = (sid, cid, chapterId) => this.get(`/api/lms/v2/education/homeworks/${sid}/${cid}/${chapterId}/deadline`, {})
/**
* 获取对应 大作业 回答
* @param {[string]} sid
* @param {[string]} cid
*/
getCourseHomework = (sid, cid) => this.get(`/v2/education/courses/${sid}/${cid}/essay`, {})
getCourseHomework = (sid, cid) => this.get(`/api/lms/v2/education/courses/${sid}/${cid}/essay`, {})
/**
* 提交课程 大作业
* @param {[string]} sid
* @param {[string]} cid
*/
updateCourseHomework = (sid, cid, obj = {}) => this.post(`/v2/education/courses/${sid}/${cid}/essay`, obj, { headers: { 'Content-Type': 'multipart/form-data' } })
updateCourseHomework = (sid, cid, obj = {}) => this.post(`/api/lms/v2/education/courses/${sid}/${cid}/essay`, obj, { headers: { 'Content-Type': 'multipart/form-data' } })
/**
* 提交 课程考核
* @param {[string]} obj.sid
* @param {[string]} obj.cid
* @param {[string]} obj.raw (base64)
*/
updateSurveyAnswer = (obj) => this.post('/v2/education/survey/answer', obj, { headers: { 'Content-Type': 'application/json' } })
updateSurveyAnswer = (obj) => this.post('/api/lms/v2/education/survey/answer', obj, { headers: { 'Content-Type': 'application/json' } })
/**
* 手机端 获取实时最新直播接口
*/
getNewLiveMsg = (obj = {}) => this.get('/v2/education/lives/latest', obj)
getNewLiveMsg = (obj = {}) => this.get('/api/lms/v2/education/lives/latest', obj)
/**
* 手机端 获取列表接口
*/
getLiveList = (obj = {}) => this.get('/v2/education/lives/courses', obj)
getLiveList = (obj = {}) => this.get('/api/lms/v2/education/lives/courses', obj)
/**
* 跨域接口请求 - 直接获取云课堂设置
*/
......@@ -106,21 +106,21 @@ export default class PlayerAPI extends BaseAPI {
* @param {[string]} course_id -> cid
* @param {[string]} semester_id -> sid
*/
getExamInfo = (cid, sid) => this.get(`/v2/education/${sid}/${cid}/examination`, {})
getExamInfo = (cid, sid) => this.get(`/api/lms/v2/education/${sid}/${cid}/examination`, {})
/**
* 获取考卷结果
* @param {[string]} course_id -> cid
* @param {[string]} semester_id -> sid
* @param {[string]} exam_id -> eid
*/
getExamAnswer = (cid, sid, eid, obj = {}) => this.get(`/v2/education/${sid}/${cid}/examination/${eid}/sheet`, obj)
getExamAnswer = (cid, sid, eid, obj = {}) => this.get(`/api/lms/v2/education/${sid}/${cid}/examination/${eid}/sheet`, obj)
/**
* 获取考试状态
* @param {[string]} course_id -> cid
* @param {[string]} semester_id -> sid
* @param {[string]} exam_id -> eid
*/
getExamStatus = (cid, sid, eid) => this.get(`/v2/education/${sid}/${cid}/examination/${eid}/status`, {})
getExamStatus = (cid, sid, eid) => this.get(`/api/lms/v2/education/${sid}/${cid}/examination/${eid}/status`, {})
/**
* 提交考卷
* @param {[string]} course_id -> cid
......@@ -128,5 +128,5 @@ export default class PlayerAPI extends BaseAPI {
* @param {[string]} exam_id -> eid
* @param {[object]} obj -> 提交对象类
*/
submitExam = (cid, sid, eid, obj = {}) => this.post(`/v2/education/${sid}/${cid}/examination/${eid}/sheet`, obj, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
submitExam = (cid, sid, eid, obj = {}) => this.post(`/api/lms/v2/education/${sid}/${cid}/examination/${eid}/sheet`, obj, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
}
......@@ -4,11 +4,11 @@ export default class ReportAPI extends BaseAPI {
/**
* 获取所有通过报告列表
*/
getReportList = () => this.get('/v2/education/symposium-report-all', {})
getReportList = () => this.get('/api/lms/v2/education/symposium-report-all', {})
/**
* 获取我的学术活动
*/
getReportActiveList = () => this.get('/v2/education/symposium/my', {})
getReportActiveList = () => this.get('/api/lms/v2/education/symposium/my', {})
/**
* 提交活动申请
* symposium_name 活动名称
......@@ -19,53 +19,53 @@ export default class ReportAPI extends BaseAPI {
* symposium_address 活动地点
* 返回 {'flag' : true, 'errors' : []}
*/
submitReportActive = (obj = {}) => this.post('/v2/education/symposium', obj, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
submitReportActive = (obj = {}) => this.post('/api/lms/v2/education/symposium', obj, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
/**
* 获取学术活动详情
*/
getReportActive = (rid) => this.get(`/v2/education/symposium/${rid}`, {})
getReportActive = (rid) => this.get(`/api/lms/v2/education/symposium/${rid}`, {})
/**
* 修改活动申请
* 参数同上
*/
updateReportActive = (rid, obj = {}) => this.post(`/v2/education/symposium/${rid}`, obj, { headers: { 'Content-Type': 'application/json' } })
updateReportActive = (rid, obj = {}) => this.post(`/api/lms/v2/education/symposium/${rid}`, obj, { headers: { 'Content-Type': 'application/json' } })
/**
* 删除活动申请
* 参数同上
*/
deleteReportActive = rid => this.delete(`/v2/education/symposium/${rid}`, {})
deleteReportActive = rid => this.delete(`/api/lms/v2/education/symposium/${rid}`, {})
/**
* 获取活动相关的学术报告
*/
getReportListAll = (rid) => this.get(`/v2/education/symposium/${rid}/report`, {})
getReportListAll = (rid) => this.get(`/api/lms/v2/education/symposium/${rid}/report`, {})
/**
* 提交学术报告
* report_name 报告名称
* report_description 报告描述
* file_url 文章URL
*/
submitReport = (rid, obj = {}) => this.post(`/v2/education/symposium/${rid}/report`, obj, { headers: { 'Content-Type': 'application/json' } })
submitReport = (rid, obj = {}) => this.post(`/api/lms/v2/education/symposium/${rid}/report`, obj, { headers: { 'Content-Type': 'application/json' } })
/**
* 获取学术报告详情
*/
getSubmitReport = (rid, reid) => this.get(`/v2/education/symposium/report/${reid}`, {})
getSubmitReport = (rid, reid) => this.get(`/api/lms/v2/education/symposium/report/${reid}`, {})
/**
* 更新学术报告
*/
updateSubmitReport = (rid, reid, obj = {}) => this.post(`/v2/education/symposium/${rid}/report/${reid}`, obj)
updateSubmitReport = (rid, reid, obj = {}) => this.post(`/api/lms/v2/education/symposium/${rid}/report/${reid}`, obj)
/**
* 删除学术报告
* 参数同上
*/
deleteSubmitReport = (rid, reid) => this.delete(`/v2/education/symposium/report/${reid}`, {})
deleteSubmitReport = (rid, reid) => this.delete(`/api/lms/v2/education/symposium/report/${reid}`, {})
/**
* 获取事务类型
*/
getAffairsType = () => this.get('/v2/lobby/affairs')
getAffairsType = () => this.get('/api/lms/v2/lobby/affairs')
/**
* 获取事务类型
*/
getAffairsData = (obj = {}) => this.get('/v2/lobby/processes', obj)
getAffairsData = (obj = {}) => this.get('/api/lms/v2/lobby/processes', obj)
/**
* 提交活动申请
* affair_id 活动名称
......@@ -77,13 +77,13 @@ export default class ReportAPI extends BaseAPI {
* symposium_lecturer
* 返回 {'flag' : true, 'errors' : []}
*/
submitLearning = (obj = {}) => this.post('/v2/lobby/processes', obj)
submitLearning = (obj = {}) => this.post('/api/lms/v2/lobby/processes', obj)
/* 删除事务 */
deleteAffairs = (reid) => this.delete(`/v2/lobby/processes/${reid}`, {})
deleteAffairs = (reid) => this.delete(`/api/lms/v2/lobby/processes/${reid}`, {})
/* 获取事务详情 */
getAffairsDetails = (rid) => this.get(`/v2/lobby/processes/${rid}`, {})
getAffairsDetails = (rid) => this.get(`/api/lms/v2/lobby/processes/${rid}`, {})
/* 修改事务 */
updateAffairs = (rid, obj = {}) => this.post(`/v2/lobby/processes/${rid}`, obj)
updateAffairs = (rid, obj = {}) => this.post(`/api/lms/v2/lobby/processes/${rid}`, obj)
/* 重修图片提交 */
uploadFile = (obj = {}) => this.post('/v2/lobby/tools/upload', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
uploadFile = (obj = {}) => this.post('/api/lms/v2/lobby/tools/upload', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
}
import cAction from '@action'
import { Message } from 'element-ui'
export default class Before {
constructor(opt) {
const UA = navigator.userAgent
......@@ -14,7 +12,7 @@ export default class Before {
'studentHelp',
'teacherHelp'
]
this.isMobile = /android|iphone|ipod/i.test(UA)
this.isMobile = /android|iphone|ipad|ipod/i.test(UA)
}
async update(to, from, next) {
......@@ -45,13 +43,14 @@ export default class Before {
if (window.G.UserInfo) return true
return cAction.Other.getInfo()
.then((res) => {
window.G.UserInfo = res
return true
})
.catch((res) => {
if (res.code !== 80201) {
Message({ type: 'error', message: res.message })
if (res.id) {
window.G.UserInfo = res
return true
} else {
return false
}
})
.catch(() => {
return false
})
}
......
......@@ -123,15 +123,14 @@ export default {
},
/* 退出登录 - 跳转方法 */
goOutLogin () {
cAction.Other.outLogin().then(response => {
if (response.status === 200) {
cAction.Other.outLogin()
.then(str => {
window.G.UserInfo = {}
this.$router.push({ path: '/login/index' })
} else {
/* 出错 */
}
}).catch(e => {
this.$message.error(e.message)
})
})
.catch(e => {
this.$message.error(e.message)
})
/* 清空一下记录,然后调整到登录页 */
// this.$router.push({ path: '/login/index' })
},
......@@ -207,6 +206,7 @@ export default {
width: 70px;
height: 70px;
border-radius: 50%;
object-fit: cover;
}
&:hover {
.set-pic {
......
......@@ -7,7 +7,7 @@ const httpRequest = new BaseAPI(webConf)
export const getDiscussList = (param) => {
const paramPath = param.path || ''
return httpRequest.get(
`/v2/qa/questions${paramPath}`,
`/api/lms/v2/qa/questions${paramPath}`,
param.dataJson
)
}
......@@ -17,7 +17,7 @@ export const getDiscussList = (param) => {
export const getCourseDiscussList = (param) => {
const paramPath = param.path || ''
return httpRequest.get(
`/v2/qa/questions/course${paramPath}`,
`/api/lms/v2/qa/questions/course${paramPath}`,
param.dataJson
)
}
......@@ -26,7 +26,7 @@ export const getCourseDiscussList = (param) => {
*/
export const deleteDiscuss = (qid) => {
return httpRequest.delete(
`/v2/qa/questions/${qid}`
`/api/lms/v2/qa/questions/${qid}`
)
}
......@@ -35,7 +35,7 @@ export const deleteDiscuss = (qid) => {
*/
export const getDiscussDetail = (qid) => {
return httpRequest.get(
`/v2/qa/questions/${qid}`
`/api/lms/v2/qa/questions/${qid}`
)
}
/**
......@@ -43,7 +43,7 @@ export const getDiscussDetail = (qid) => {
*/
export const deleteComment = (cid) => {
return httpRequest.delete(
`/v2/qa/comments/${cid}`
`/api/lms/v2/qa/comments/${cid}`
)
}
/**
......@@ -51,7 +51,7 @@ export const deleteComment = (cid) => {
*/
export const callbackComment = (param) => {
return httpRequest.post(
'/v2/qa/comments',
'/api/lms/v2/qa/comments',
param,
{ headers: { 'Content-Type': 'application/json' } }
)
......@@ -62,7 +62,7 @@ export const callbackComment = (param) => {
*/
export const answerQues = (param) => {
return httpRequest.post(
'/v2/qa/answers',
'/api/lms/v2/qa/answers',
param,
{ headers: { 'Content-Type': 'application/json' } }
)
......@@ -72,7 +72,7 @@ export const answerQues = (param) => {
*/
export const deleteAnswer = (aid) => {
return httpRequest.delete(
`/v2/qa/answers/${aid}`
`/api/lms/v2/qa/answers/${aid}`
)
}
/**
......@@ -80,7 +80,7 @@ export const deleteAnswer = (aid) => {
*/
export const unlike = (tagid) => {
return httpRequest.delete(
`/v2/qa/tags/${tagid}`
`/api/lms/v2/qa/tags/${tagid}`
)
}
/**
......@@ -88,7 +88,7 @@ export const unlike = (tagid) => {
*/
export const like = (param) => {
return httpRequest.post(
'/v2/qa/tags',
'/api/lms/v2/qa/tags',
param,
{ headers: { 'Content-Type': 'application/json' } }
)
......
......@@ -7,42 +7,42 @@ export default class LoginAPI extends BaseAPI {
* @param {[string]} obj.password 密码 md5加密
* @param {[string]} obj.service 传当前域名
*/
userLogin = (obj = {}) => this.post('/user_center/login', obj, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
userLogin = (obj = {}) => this.post('/api/passport/rest/login', obj, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
/**
* 调用退出登录
*/
outLogin = () => this.get('/user_center/logout', {}, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
outLogin = () => this.get('/api/passport/rest/logout', {}, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
/**
* 当前登录用户,检测是否该系统有权限
*/
getInfo = () => this.get('/user_center/get_user_info', {}, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
getInfo = () => this.get('/api/passport/account/get-user-info', {}, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
/**
* 发送验证码
* @param {[string]} obj.mobile 手机号
* @param {[string]} obj.service 传当前域名
*/
sendCode = (obj = {}) => this.post('/user_center/send_login_code', obj, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
sendCode = (obj = {}) => this.post('/api/usercenter/user/send-code', obj, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
/**
* 验证码登录
* @param {[string]} obj.mobile 手机号
* @param {[string]} obj.code 验证码
* @param {[string]} obj.service 传当前域名
*/
codeLogin = (obj = {}) => this.post('/user_center/code_login', obj, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
codeLogin = (obj = {}) => this.post('/api/passport/rest/login', obj, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
/**
* 发送重置密码验证码
* @param {[string]} obj.contact 手机号/邮箱
* @param {[string]} obj.source_type 值为 3
* @param {[string]} obj.service 传当前域名
*/
sendResetPwdCode = (obj = {}) => this.post('/user_center/send_reset_password_code', obj, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
sendResetPwdCode = (obj = {}) => this.post('/api/usercenter/user/send-code', obj, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
/**
* 重置密码验证码确认
* @param {[string]} obj.contact 手机号/邮箱
* @param {[string]} obj.code 验证码
* @param {[string]} obj.service 传当前域名
*/
validateCode = (obj = {}) => this.post('/user_center/validate_code', obj, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
validateCode = (obj = {}) => this.post('/api/passport/user_center/validate_code', obj, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
/**
* 重置密码
* @param {[string]} obj.contact 手机号/邮箱
......@@ -50,14 +50,14 @@ export default class LoginAPI extends BaseAPI {
* @param {[string]} obj.new_password 新的密码
* @param {[string]} obj.service 传当前域名
*/
resetPwd = (obj = {}) => this.post('/user_center/reset_password', obj, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
resetPwd = (obj = {}) => this.post('/api/usercenter/user/update-pwd', obj, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
/**
* 个人信息 - 修改密码
* @param {[string]} obj.old_password 验证码
* @param {[string]} obj.new_password 新的密码
* @param {[string]} obj.service 传当前域名
*/
updatePwd = (obj = {}) => this.post('/user_center/change_password', obj, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
updatePwd = (obj = {}) => this.post('/api/usercenter/user/change-pwd-by-cookie', obj, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
/**
* 清空所有cookies
*/
......
......@@ -110,9 +110,6 @@ export default {
this.$refs.setAccountform.validate((valid) => {
if (valid) {
Login.codeLogin({
/* 老版 */
mobile: this.setAccount.user,
code: this.setAccount.pwd,
/* 新版 */
account: this.setAccount.user,
password: this.setAccount.pwd,
......@@ -120,7 +117,7 @@ export default {
RememberMe: this.setAccount.isRemember ? 'true' : 'false',
service: window.location.origin
}).then(data => {
if (!data) { return }
if (data.code !== 0) { return }
if (data.url) {
/* 查询上次跳转信息,并跳转回去 */
if (this.query.rd) {
......
<template>
<div class="content-s">
<el-steps :active="stepActive" align-center>
<el-step :title="$t('LoginModule.ForgetLogin.step1')"></el-step>
<el-step :title="$t('LoginModule.ForgetLogin.step2')"></el-step>
<el-step :title="$t('LoginModule.ForgetLogin.step3')"></el-step>
</el-steps>
<div v-if="stepActive === 1" class="step1">
<el-form ref="form1" :model="accountSet" :rules="accountRules" @submit.native.prevent>
<el-row>
<el-col :xs="24" :sm="5" :md="6" :lg="6" :xl="8"><el-form-item></el-form-item></el-col>
<el-col :xs="24" :sm="9" :md="8" :lg="8" :xl="5">
<el-form-item prop="account">
<el-input v-model="accountSet.account" type="text" :placeholder="$t('LoginModule.ForgetLogin.inputStr')" @keyup.enter.native="onSubmitForm1"></el-input>
<div class="step3">
<el-form ref="form3" label-width="100px" :model="accountSet" :rules="accountRules" label-position="top">
<el-row type="flex" class="row-bg" justify="center">
<el-col :xs="24" :md="10">
<el-form-item prop="account" :label="$t('LoginModule.NormalLogin.account')">
<el-input v-model="accountSet.account" type="text" :placeholder="$t('LoginModule.ForgetLogin.inputStr')"></el-input>
</el-form-item>
</el-col>
<el-col :xs="24" :sm="5" :md="4" :lg="4" :xl="3">
<el-form-item>
<el-button style="width: 100%;" type="primary" @click="onSubmitForm1">{{$t('LoginModule.ForgetLogin.sendCode')}}</el-button>
</el-form-item>
</el-col>
<el-col :xs="24" :sm="5" :md="6" :lg="6" :xl="8"><el-form-item></el-form-item></el-col>
</el-row>
</el-form>
<slot name="go-back"></slot>
</div>
<div v-if="stepActive === 2" class="step2">
<div class="txt-title">
{{$t('LoginModule.ForgetLogin.codeStr')}}{{accountSet.account}}
</div>
<el-form ref="form2" :model="accountSet" :rules="accountRules" @submit.native.prevent>
<el-row>
<el-col :xs="24" :sm="1" :md="2" :lg="4" :xl="4"><el-form-item></el-form-item></el-col>
<el-col :xs="24" :sm="16" :md="14" :lg="11" :xl="11">
<el-form-item label-width="120px" prop="code" :label="(accountSet.type ? $t('LoginModule.ForgetLogin.mailCode') : $t('LoginModule.ForgetLogin.iphoneCode'))">
<el-input v-model="accountSet.code" type="text" :placeholder="$t('LoginModule.ForgetLogin.input4Code')"></el-input>
</el-form-item>
</el-col>
<el-col :xs="24" :sm="6" :md="6" :lg="5" :xl="5">
<el-form-item>
<el-button style="width: 100%;" type="primary" :disabled="isSendCode" @click="sendCode">{{sendBtnText}}</el-button>
<el-form-item prop="code" :label="(accountSet.type ? $t('LoginModule.ForgetLogin.mailCode') : $t('LoginModule.ForgetLogin.iphoneCode'))">
<el-input v-model="accountSet.code" type="text" :placeholder="$t('LoginModule.ForgetLogin.input4Code')">
<el-button slot="append" type="primary" @click="sendCode">{{sendBtnText}}</el-button>
</el-input>
</el-form-item>
</el-col>
<el-col :xs="24" :sm="1" :md="2" :lg="4" :xl="4"><el-form-item></el-form-item></el-col>
</el-row>
</el-form>
<div class="operate">
<el-row>
<el-col :span="12">
<el-button @click="goPrevStep">{{$t('LoginModule.ForgetLogin.prev')}}</el-button>
</el-col>
<el-col :span="12" style="text-align: right;">
<el-button @click="onSubmitForm2">{{$t('LoginModule.ForgetLogin.next')}}</el-button>
</el-col>
</el-row>
</div>
</div>
<div v-if="stepActive === 3" class="step3">
<el-form ref="form3" :model="accountSet" :rules="accountRules" label-position="left">
<el-row>
<el-col :xs="24" :sm="3" :md="5" :lg="6" :xl="6"><el-form-item></el-form-item></el-col>
<el-col :xs="24" :sm="18" :md="14" :lg="12" :xl="12">
<el-form-item label-width="120px" prop="newpwd" :label="$t('LoginModule.ForgetLogin.newPwd')">
<el-form-item prop="newpwd" :label="$t('LoginModule.ForgetLogin.newPwd')">
<el-input v-model="accountSet.newpwd" type="password" :placeholder="$t('LoginModule.ForgetLogin.placeholder')"></el-input>
</el-form-item>
<el-form-item label-width="120px" prop="repwd" :label="$t('LoginModule.ForgetLogin.repeatNewPwd')">
<el-form-item prop="repwd" :label="$t('LoginModule.ForgetLogin.repeatNewPwd')">
<el-input v-model="accountSet.repwd" type="password" :placeholder="$t('LoginModule.ForgetLogin.repeatPlaceholder')"></el-input>
</el-form-item>
<el-form-item>
<el-button style="width: 100%;" type="primary" @click="onSubmitForm3">{{$t('LoginModule.ForgetLogin.finish')}}</el-button>
<el-button style="width: 100%;" type="primary" @click="onSubmitForm">{{$t('LoginModule.ForgetLogin.finish')}}</el-button>
</el-form-item>
</el-col>
<el-col :xs="24" :sm="3" :md="5" :lg="6" :xl="6"><el-form-item></el-form-item></el-col>
</el-row>
</el-form>
<slot name="go-back"></slot>
</div>
<el-dialog
title=""
......@@ -136,7 +88,6 @@ export default {
}
}
return {
stepActive: 1,
isSendCode: false, // 是否已发送验证码
timeInterval: null, // 定时器,倒计时
sendBtnText: this.$t('LoginModule.ForgetLogin.sendCode'), // 按钮 文字
......@@ -168,36 +119,11 @@ export default {
},
beforeDestroy () { /* 清空倒计时 */ this.clearTime() },
methods: {
/* 上一步 */
goPrevStep () {
this.stepActive -= 1
/* 清空 第一步 填写内容 */
this.accountSet.account = ''
/* 清空倒计时 */
this.clearTime()
},
/* 第一步 提交 */
onSubmitForm1 () {
this.$refs.form1.validate((valid) => {
if (valid) {
/* 跳到第二步 */
this.stepActive = 2
/* 跳到第二步 并 发送验证码 */
this.sendCode()
} else {
this.$message.error(this.$t('LoginModule.ForgetLogin.checkRightStr'))
return false
}
})
},
/* 发送验证码 */
sendCode () {
if (!this.isSendCode) {
Login.sendResetPwdCode({
contact: this.accountSet.account,
source_type: 3
}).then(res => {
if (res.status === 200) {
Login.sendResetPwdCode({ account: this.accountSet.account }).then(res => {
if (res.code === 0) {
/* 发送验证码不管是否成功,都开始倒计时 */
let time = 60
this.isSendCode = true
......@@ -228,37 +154,17 @@ export default {
this.sendBtnText = this.$t('LoginModule.ForgetLogin.sendCode')
clearInterval(this.timeInterval)
},
/* 第二步 提交 */
onSubmitForm2 () {
this.$refs.form2.validate((valid) => {
if (valid) {
Login.validateCode({
contact: this.accountSet.account,
code: this.accountSet.code
}).then(data => {
if (data.status === 200) {
/* 跳到第三步 */
this.stepActive = 3
} else {
return new Error(JSON.stringify(data))
}
})
} else {
this.$message.error(this.$t('LoginModule.Others.formCheckStr'))
return false
}
})
},
/* 第三步 提交 */
onSubmitForm3 () {
onSubmitForm () {
this.$refs.form3.validate((valid) => {
if (valid) {
Login.resetPwd({
contact: this.accountSet.account,
account: this.accountSet.account,
code: this.accountSet.code,
new_password: this.accountSet.repwd
password: this.accountSet.newpwd,
passwordR: this.accountSet.repwd
}).then(data => {
if (data.status === 200) {
if (data.code === 0) {
this.centerDialogVisible = true
} else {
return new Error(JSON.stringify(data))
......@@ -285,19 +191,19 @@ export default {
.content-s {
position: absolute;
left: 50%;
top: 55%;
padding: 40px 0;
width: 80%;
max-width: 1200px;
top: 22%;
padding: 20px 0;
width: calc(100% - 20px);
max-width: 1000px;
box-shadow: 0px 3px 10px rgba(0, 0, 0, 0.3);
transform: translateX(-50%);
background: #fff;
}
/* forget 登录 */
.step1 { font-size: 16px; width: 90%; margin: 20px auto 0 auto; }
.step2 { font-size: 16px; width: 71%; margin: 20px auto 0 auto; }
.step2 .txt-title { margin-bottom: 0.3rem; color: #999; text-align: center; }
.step2 .operate { margin-top: 0.2rem; }
.step3 { font-size: 16px; width: 80%; margin: 20px auto 0 auto; }
.step3 { font-size: 16px; margin: 10px 20px 0; text-align: left;}
::v-deep .el-form-item__label{ line-height:1; }
</style>
......@@ -66,16 +66,20 @@ export default {
if (valid) {
Login.userLogin({
/* 老版登录 */
login_name: this.setAccount.user,
password: md5('uokoaduw' + this.setAccount.pwd.split('').reverse().join('') + 'auhgniq'),
// login_name: this.setAccount.user,
// password: md5('uokoaduw' + this.setAccount.pwd.split('').reverse().join('') + 'auhgniq'),
/* 新版登录 */
account: this.setAccount.user,
// password: this.setAccount.pwd,
password: this.setAccount.pwd,
type: 1,
RememberMe: this.setAccount.isRemember ? 'true' : 'false',
service: window.location.origin
}).then(res => {
if (!res) { return }
if (res.code !== 0) { return }
if (this.attr.url) {
window.location.href = this.attr.url
return
}
if (res.url) {
/* 查询上次跳转信息,并跳转回去 */
if (this.query.rd) {
......
......@@ -8,7 +8,9 @@ const httpRequest = new BaseAPI(webConf)
* @param {string} courseId 课程ID
*/
export function getCourse(semesterId, courseId) {
return httpRequest.get(`/v2/education/courses/${semesterId}/${courseId}`)
return httpRequest.get(
`/api/lms/v2/education/courses/${semesterId}/${courseId}`
)
}
/**
......@@ -17,7 +19,7 @@ export function getCourse(semesterId, courseId) {
*/
export function getChapterVideo(vid) {
return httpRequest.post(
'/v2/education/video-streaming',
'/api/lms/v2/education/video-streaming',
{ vid },
{ headers: { 'Content-Type': 'application/json' } }
)
......@@ -29,7 +31,7 @@ export function getChapterVideo(vid) {
*/
export function getChapterVideoAliyun(vid) {
return httpRequest.post(
'/v2/education/aliyun-video-streaming',
'/api/lms/v2/education/aliyun-video-streaming',
{ vid },
{ headers: { 'Content-Type': 'application/json' } }
)
......@@ -43,7 +45,7 @@ export function getChapterVideoAliyun(vid) {
*/
export function getChapterVideoProgress(semesterId, resourseId, params) {
return httpRequest.get(
`/v2/education/video/${semesterId}/${resourseId}/device`,
`/api/lms/v2/education/video/${semesterId}/${resourseId}/device`,
params
)
}
......@@ -53,7 +55,7 @@ export function getChapterVideoProgress(semesterId, resourseId, params) {
* @param {Object} params
*/
export function updateChapterVideoProgress(params) {
return httpRequest.get('/v2/analytics/upload-video', params)
return httpRequest.get('/api/lms/v2/analytics/upload-video', params)
}
/**
......@@ -64,7 +66,7 @@ export function updateChapterVideoProgress(params) {
*/
export function getChapterHomework(semesterId, courseId, resourseId) {
return httpRequest.get(
`/v2/education/homeworks/${semesterId}/${courseId}/${resourseId}`
`/api/lms/v2/education/homeworks/${semesterId}/${courseId}/${resourseId}`
)
}
......@@ -76,7 +78,7 @@ export function getChapterHomework(semesterId, courseId, resourseId) {
*/
export function getChapterHomeworkDeadline(semesterId, courseId, chapterId) {
return httpRequest.get(
`/v2/education/homeworks/${semesterId}/${courseId}/${chapterId}/deadline`
`/api/lms/v2/education/homeworks/${semesterId}/${courseId}/${chapterId}/deadline`
)
}
......@@ -84,7 +86,7 @@ export function getChapterHomeworkDeadline(semesterId, courseId, chapterId) {
* 提交考试
*/
export function sbumitChapterHomework(params) {
return httpRequest.post('/v2/education/homeworks', params, {
return httpRequest.post('/api/lms/v2/education/homeworks', params, {
headers: { 'Content-Type': 'application/json' }
})
}
......@@ -93,7 +95,7 @@ export function sbumitChapterHomework(params) {
* 上传文件
*/
export function uploadFile(data) {
return httpRequest.post('/util/upload-file', data, {
return httpRequest.post('/api/lms/util/upload-file', data, {
headers: { 'Content-Type': 'multipart/form-data' }
})
}
......@@ -105,7 +107,7 @@ export function uploadFile(data) {
*/
export function getCourseWork(semesterId, courseId) {
return httpRequest.get(
`/v2/education/courses/${semesterId}/${courseId}/essay`
`/api/lms/v2/education/courses/${semesterId}/${courseId}/essay`
)
}
......@@ -116,7 +118,7 @@ export function getCourseWork(semesterId, courseId) {
*/
export function updateCourseWork(semesterId, courseId, data) {
return httpRequest.post(
`/v2/education/courses/${semesterId}/${courseId}/essay`,
`/api/lms/v2/education/courses/${semesterId}/${courseId}/essay`,
data,
{ headers: { 'Content-Type': 'multipart/form-data' } }
)
......@@ -128,7 +130,9 @@ export function updateCourseWork(semesterId, courseId, data) {
* @param {string} courseId 课程ID
*/
export function getCourseExam(semesterId, courseId) {
return httpRequest.get(`/v2/education/${semesterId}/${courseId}/examination`)
return httpRequest.get(
`/api/lms/v2/education/${semesterId}/${courseId}/examination`
)
}
/**
......@@ -139,7 +143,7 @@ export function getCourseExam(semesterId, courseId) {
*/
export function getCourseExamStatus(semesterId, courseId, examId) {
return httpRequest.get(
`/v2/education/${semesterId}/${courseId}/examination/${examId}/status`
`/api/lms/v2/education/${semesterId}/${courseId}/examination/${examId}/status`
)
}
......@@ -151,7 +155,7 @@ export function getCourseExamStatus(semesterId, courseId, examId) {
*/
export function submitCourseExam(semesterId, courseId, examId, data) {
return httpRequest.post(
`/v2/education/${semesterId}/${courseId}/examination/${examId}/sheet`,
`/api/lms/v2/education/${semesterId}/${courseId}/examination/${examId}/sheet`,
data,
{ headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }
)
......@@ -165,7 +169,7 @@ export function submitCourseExam(semesterId, courseId, examId, data) {
*/
export function getCourseExamResult(semesterId, courseId, examId, params) {
return httpRequest.get(
`/v2/education/${semesterId}/${courseId}/examination/${examId}/sheet`,
`/api/lms/v2/education/${semesterId}/${courseId}/examination/${examId}/sheet`,
params
)
}
......@@ -231,7 +231,7 @@ export default {
const user = window.G.UserInfo
const params = {
sid: user.student_info.id,
uid: user.uid,
uid: user.id,
d: Cookies.get('_idt'),
i: Cookies.get('_idt'),
c: this.cid, // 课程ID
......
......@@ -68,16 +68,16 @@ export default {
actionName: 'Other',
functionName: 'updatePwd',
data: {
old_password: md5('uokoaduw' + this.accountSetPwd.oldPwd.split('').reverse().join('') + 'auhgniq'),
new_password: this.accountSetPwd.newPwdAgain
// old_password: md5('uokoaduw' + this.accountSetPwd.oldPwd.split('').reverse().join('') + 'auhgniq'),
old_password: this.accountSetPwd.oldPwd,
password: this.accountSetPwd.newPwd,
passwordR: this.accountSetPwd.newPwdAgain
},
thenCallback: data => {
if (data.status === 200) {
if (data.code === 0) {
/* 重置密码 */
this.$refs.setpwdform.resetFields()
this.$message.success('密码修改成功')
} else {
this.$message.error(data.message)
}
},
catchCallback: () => {},
......
......@@ -43,7 +43,6 @@ export default {
components: {},
data() {
const Gu = window.G.UserInfo
console.log(Gu)
return {
imgUrl: Gu.avatar || '',
user: {
......@@ -70,29 +69,6 @@ export default {
this.file.lastModifiedDate = file.raw.lastModifiedDate
this.file.size = file.raw.size
this.file.avatar = file.raw
// try {
// /* 这个必然是IE */
// let stream = new ActiveXObject('ADODB.Stream') // eslint-disable-line
// stream.type = 1
// stream.open()
// // console.log(this.$refs.upFile.$el.children[0].children[1].files[0])
// debugger
// // stream.loadFromFile(filename)
// // text = stream.readText(adReadAll)
// // stream.close()
// } catch (e) {
// let reader = new FileReader() // eslint-disable-line
// reader.readAsBinaryString(this.$refs.upFile.$el.children[0].children[1].files[0]) // 这个读法是异步的
// reader.onloadend = () => {
// // 这个事件在读取结束后,无论成功或者失败都会触发
// if (reader.error) {
// /* 文件读取失败 */
// this.$message.error('文件读取失败,请重试')
// } else {
// this.file.avatar = reader.result
// }
// }
// }
},
uploadFile() {
if (!/\.(jpg|jpeg|gif|png|bmp)$/gi.test(this.file.name)) {
......@@ -106,11 +82,10 @@ export default {
spinner: '',
background: 'rgba(255, 255, 255, 0.9)'
})
action.Other.uploadFile(this.file)
action.Other.uploadFile({ image: this.file.avatar })
.then(data => {
this.imgUrl = data.avatar
window.G.UserInfo.avatar = data.avatar
this.filesArr.pop()
this.imgUrl = data.url
this.updateUser()
})
.catch(() => {
this.filesArr.pop()
......@@ -118,6 +93,13 @@ export default {
.finally(() => {
loading.close()
})
},
updateUser() {
action.Other.updateUser({
SsoBasicUser: { info: { avatar: this.imgUrl } }
}).then(data => {
window.G.UserInfo.avatar = this.imgUrl
})
}
}
}
......@@ -137,12 +119,9 @@ export default {
border-radius: 50%;
overflow: hidden;
img {
position: absolute;
top: 50%;
left: 50%;
width: 100%;
height: 100%;
transform: translate(-50%, -50%);
object-fit: cover;
}
}
.info {
......
......@@ -286,7 +286,7 @@ export default {
const _userInfo = window.G.UserInfo
cAction.Player.updateProgress({
sid: (_userInfo && _userInfo.student_info && _userInfo.student_info.id) || '',
uid: (_userInfo && _userInfo.uid) || '',
uid: (_userInfo && _userInfo.id) || '',
d: cTool.other.getIdt(),
i: cTool.other.getIdt(),
c: this.cid,
......
# 查到当前目录就可以了,不用再往下查找
root = true
# 对所有文件制定规范
[*]
charset = utf-8 # 字符编码
end_of_line = lf # 从左往右写
indent_size = 2 # tab键长度2个空格
indent_style = space
insert_final_newline = true # 保存自动加上一个空行
trim_trailing_whitespace = true # 每行最后空格去掉
{
"extends": "standard",
"plugins": [
"html"
],
"parser": "babel-eslint",
"rules": {
"no-new": "off",
"no-debugger": "off"
},
"globals": {
"window": false,
"$": false,
"webConf": false
}
}
.DS_Store
node_modules
npm-debug.log
server-dist
node-dist
dist
dist.zip
# code protect - prevent submit code below
.vscode
PC-server-1.0.3 / 2019-10-22
==================
* 追加 视频错误信息采集、本地JS报错信息采集。
PC-server-1.0.2 / 2019-10-15
==================
* 修改 目录文件查询,增加文件大小
PC-server-1.0.1 / 2019-10-08
==================
* 追加 服务端 采集 客户端 上报的 视频播放错误。
PC-server-1.0.0 / 2019-08-26
==================
* 拆分 分离 服务端。
# 根据项目框架 - 记录新增模块 与 修改
* adm-zip - npm 模块安装
* form-data - npm 模块安装
* axios - npm 模块安装
* promise.prototype.finally - npm 模块安装
* 修改 package.json 中 端口号
* 修改 package.json 中 项目名
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"name": "nodejs",
"version": "1.0.0",
"description": "ecollage - 学习系统",
"main": "index.js",
"scripts": {
"lint": "eslint --ext .js server/",
"lint:fix": "eslint --fix --ext .js server/",
"deploy:test": "cross-env NODE_ENV=test SERVER_PORT=3402 pm2 start ./server/distRun.js -i 1 -n elearning-collage -o upload_tmp/pm2_elearning-collage.stdout.log -e upload_tmp/pm2_elearning-collage.stderr.log --log-date-format 'YYYY-MM-DD HH:mm Z'",
"deploy": "cross-env NODE_ENV=production SERVER_PORT=3402 pm2 start ./server/distRun.js -i 2 -n elearning-collage -o /data/logs/pm3/elearning-collage/pm2_elearning-collage.stdout.log -e /data/logs/pm3/elearning-collage/pm2_elearning-collage.stderr.log --log-date-format 'YYYY-MM-DD HH:mm Z'",
"reload": "pm2 reload elearning-collage"
},
"author": "ZYX",
"license": "ISC",
"eslintIgnore": [
"build/"
],
"devDependencies": {
"babel-core": "^6.26.3",
"babel-eslint": "^8.2.6",
"eslint": "^4.19.1",
"eslint-config-standard": "^11.0.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-node": "^6.0.1",
"eslint-plugin-promise": "^3.8.0",
"eslint-plugin-standard": "^3.1.0"
},
"dependencies": {
"@god/node-com": "^1.1.4",
"adm-zip": "^0.4.13",
"axios": "^0.19.0",
"body-parser": "^1.18.3",
"child_process": "^1.0.2",
"connect-history-api-fallback": "^1.6.0",
"cors": "^2.8.5",
"express": "^4.16.4",
"form-data": "^2.5.0",
"multer": "^1.4.1",
"promise.prototype.finally": "^3.1.1",
"cross-env": "^5.2.0"
}
}
const state = process.env.NODE_ENV
let conf = {}
if (state === 'test') {
conf.agentApiUrl = 'https://api2.ezijing.com/'
conf.apiKey = 'TM4Nmspf52Nr3ZeSeAkyzbsHh7vIer8D'
conf.host = 'lms-api2.ezijing.com'
// conf.host = 'docker-lms-api.ezijing.com'
} else if (state === 'production') {
conf.agentApiUrl = 'https://zapi.ezijing.com/'
conf.apiKey = 'TM4Nmspf52Nr3ZeSeAkyzbsHh7vIer8D'
conf.host = 'lms-api.ezijing.com'
}
global.app = null
module.exports = conf
const fs = require('fs')
const path = require('path')
const _cpro = require('child_process')
const com = require('@god/node-com')
const md5 = com.Tool.MD5
/**
* 目录结构操作,删除查询
* 0: delete, 删除;
* 1: list, 查询;
* 2: create, 创建;
* 3: readfile, 文件;
* 4: searchinfo, 直接根据姓名,搜索对应目录,并返回该目录下,info.txt文件中 所有内容
* 5: searchlogvideo, 根据姓名,搜索参数(video目录+vid)所有该人员所有观看记录
* 9: get-md5, 获取md5字符串, 鉴权使用;
*/
const dirOperate = (req, res) => {
let operate = req.body.operate || ''
let timestamp = Math.floor(new Date().getTime() / 100000000) + '00000000'
let md5Str = md5('ezijing.com' + timestamp)
if (operate === '9') { res.status(200).json({ 'timestamp': timestamp, 'MD5-auth': md5Str }); return }
let auth = req.headers.auth || ''
if (auth === md5Str) {
_executeOperate(req, res)
} else {
res.status(200).json({ 'msg': '没有权限 访问该接口' })
}
}
/**
* 根据 对应参数,执行
* @param {*} req 请求参数
* @param {*} res 返回参数
*/
const _executeOperate = (req, res) => {
let dir = req.body.dir || ''
let operate = req.body.operate || ''
let json = {}
json.dirPath = dir
json.arrJson = {}
if (operate === '2') {
_createDir(dir, (str) => {
json.arrJson.msg = str
res.status(200).json(json)
})
return
}
fs.stat(dir, (error, stats) => {
if (error) {
json.arrJson.msg = '当前目录,或文件不存在'
/* 返回数据 */
res.status(200).json(json)
} else {
if (operate === '0') { /* 删除 */
_deleteDir(dir, stats, (str) => {
json.arrJson.msg = str
res.status(200).json(json)
})
} else if (operate === '1') { /* 查询 */
_checkDir(dir, json, () => {
res.status(200).json(json)
})
} else if (operate === '3') { /* 读取文件内容 */
_readFile(dir, (data) => {
res.status(200).send(data)
})
} else if (operate === '4') { /* 根据人名查询学生 基本信息 */
let name = req.body.name
_searchInfo(dir, name, (data) => {
res.status(200).send(data)
})
} else if (operate === '5') { /* 搜索 视频记录行为 日志 */
let name = req.body.name
let opt = req.body.opt
_searchLogVideo(dir, name, opt, (data) => {
res.status(200).send(data)
})
} else {
res.status(200).json({ 'msg': 'operate 参数错误' })
}
}
})
}
/**
* 参数 0(删除),执行方法
* @param {string} dir 请求参数中,传过来的路径字符串
* @param {object} stats 判断该路径,对应的属性状态
* @param {function} callfunc 回调函数
*/
const _deleteDir = (dir, stats, callfunc) => {
if (stats.isFile()) {
fs.unlink(dir, () => {
callfunc('文件删除成功')
})
} else if (stats.isDirectory()) {
com.Tool.Directory.rmdir(dir, () => {
callfunc('目录删除成功')
})
}
}
/**
* 参数 1(查询),执行方法
* @param {string} dir 请求参数中,传过来的路径字符串
* @param {object} json 接口返回,整个json对象,传过来进行修改
* @param {function} callfunc 回调函数
*/
const _checkDir = (dir, json, callfunc) => {
let pa = fs.readdirSync(dir)
let dirStr = 'dir'
let dirCount = 0
let fileStr = 'file'
let fileCount = 0
for (let j = 0; j < pa.length; j++) {
let elem = pa[j]
let stat = fs.statSync(path.resolve(dir, elem))
if (stat.isFile()) {
json.arrJson[fileStr + (fileCount++)] = elem + ';size:' + stat.size
}
if (stat.isDirectory()) {
json.arrJson[dirStr + (dirCount++)] = elem
}
}
/* 统计总个数 */
json.count = pa.length
callfunc()
}
/**
* 参数 2(创建),执行方法
* @param {string} dir 请求参数中,传过来的路径字符串
* @param {function} callfunc 回调函数
*/
const _createDir = (dir, callfunc) => {
com.Tool.Directory.mkdir(dir, () => {
callfunc('目录创建成功')
})
}
/**
* 参数 3(读文件),执行方法
* @param {string} dir 请求参数中,传过来的路径字符串,必须是文件,否则出错
* @param {function} callfunc 回调函数
*/
const _readFile = (dir, callfunc) => {
callfunc(fs.readFileSync(dir))
}
/**
* 参数 4(搜索),执行方法
* @param {string} dir 请求参数中,传过来的路径字符串,必须是文件,否则出错
* @param {string} name 请求参数中,增加一个name字段,用这个字段匹配相关目录
* @param {function} callfunc 回调函数
*/
const _searchInfo = (dir, name, callfunc) => {
let pa = fs.readdirSync(dir)
let reg = new RegExp(name, 'gi')
let _path = ''
for (let j = 0; j < pa.length; j++) {
let elem = pa[j]
if (reg.test(elem)) {
_path = path.resolve(dir, elem)
break
}
}
if (_path) {
callfunc(fs.readFileSync(path.resolve(_path, 'info.txt')))
} else {
callfunc('没有该学生或文件解析出错')
}
}
/**
* 参数 5(视频学习行为查询),执行方法
* @param {string} dir 请求参数中,传过来的路径字符串,必须是文件,否则出错
* @param {string} name 请求参数中,增加一个name字段,用这个字段匹配相关目录
* @param {string} opt 请求参数中,逗号隔开,第一个为 video: 视频行为记录信息;第二个为 vid: 视频id
* @param {function} callfunc 回调函数
*/
const _searchLogVideo = (dir, name, opt, callfunc) => {
let pa = fs.readdirSync(dir)
let reg = new RegExp(name, 'gi')
let _path = ''
for (let j = 0; j < pa.length; j++) {
let elem = pa[j]
if (reg.test(elem)) {
_path = path.resolve(dir, elem)
break
}
}
if (!_path) {
callfunc('没有该学生或文件解析出错')
} else {
let _arr = opt.split(',')
let _videoPath = path.resolve(_path, _arr[0])
/* 对路径进行处理,保证shell可识别 */
_videoPath = _videoPath.replace(/ /gi, '\\ ')
let _catStr = 'cat *.log'
let _grepStr = "grep '" + _arr[1] + "'"
let _sortStr = 'sort -t ' + String.fromCharCode(0x001) + ' -k1,2nr'
let _grepOptStr = _arr[2] ? (" | grep -o '" + [_arr[1] + '', '[0-9]\\+', '[0-9]\\+', '[0-9]\\+'].join(String.fromCharCode(0x001)) + "'") : ''
_cpro.exec('cd ' + _videoPath + ' && ' + _catStr + ' | ' + _grepStr + ' | ' + _sortStr + _grepOptStr, (err, stdout, stderr) => {
if (err) {
console.log(err)
callfunc(err)
return
}
if (stdout) {
callfunc(stdout)
} else {
callfunc('查无此项,请检查vid或其他参数')
}
})
/* 再增加一个 日志查询 记录 执行时间等 */
}
}
module.exports = {
dirOperate: dirOperate
}
const fs = require('fs')
const conf = require('../config')
const com = require('@god/node-com')
const axios = require('axios')
const AdmZip = require('adm-zip')
/* 支持 finally函数 */
require('promise.prototype.finally').shim()
/* 通过API统一过拦截器,接口代理转发请求 */
const agentProcessor = () => {
/* 目录在服务器,启动时,直接创建号 */
let _totalDir = '001' // 默认表示,存储从第一学期开始
com.Tool.Directory.mkdir('upload_tmp/' + _totalDir)
return (req, res) => {
/* 获取 日志必须 返回 + 视频行为日志信息 */
const _logJson = com.Log.EzijingVideo.setLogVideo(req, {
_totalDir
})
let headers = req.headers
let options = {}
/* 删除一些 不必要属性 */
let pwdBase64 = headers['pmd5'] || ''
delete headers['pmd5'] // pwd base64
try {
options = {
timeout: 60 * 1000,
url: req.params[0], // .replace(/tenant\//gi, '')
baseURL: conf.agentApiUrl,
method: req.method,
data: req.body,
params: req.query,
maxContentLength: Infinity,
maxBodyLength: Infinity
}
options.url = options.url.replace(/tenant\//gi, '')
headers['apikey'] = conf.apiKey
if (/user_center/gi.test(options.url)) {
headers['Host'] = 'sso.ezijing.com'
headers['host'] = 'sso.ezijing.com'
} else {
// headers['Host'] = 'lms-api.ezijing.com'
// headers['host'] = 'lms-api.ezijing.com'
headers['Host'] = conf.host
headers['host'] = conf.host
}
/* 测试 */
// if (/\/essay/gi.test(options.url) && /post/gi.test(req.method)) {
// console.time('essay')
// options.baseURL = 'http://192.168.10.199:8081/'
// options.url = options.url.replace(/tenant\//gi, '')
// console.log(options.baseURL + options.url)
// }
headers['accept'] = '*/*'
delete headers['accept-language']
com.Tool.ReqType.toUrlEncoded(req, options)
let _fileName = com.Tool.ReqType.toFormData(req, options)
/* 获取cookie,解析SUP,设置token */
headers['ticket'] = com.Tool.Cookie.getTicketByCAS('_SUP', req) // _SUP获取
headers['token'] = headers['ticket']
axios.defaults.headers = headers
axios.defaults.withCredentials = true
/* 处理特殊请求,在域名为e-learing2时生效 */
// let _stoken = com.Tool.Cookie.getCookie('_SUP', req)
// if (_stoken) {
// headers['stoken'] = _stoken
// }
/* 重新转发请求 */
let _reqTime = 0
let _status = 0
axios(options)
.then((data) => {
/* 记录 请求处理时长 + 请求状态 */
_reqTime =
new Date().getTime() - _logJson._nodeServerCurrentTime + 'ms'
_status = 200
// /* 兼容老版本,登录接口 清除_SUP; 退出登录 清除_SUP */
/* 重新修改,改为只能服务端 设置 cookie */
if (
/user_center\/login/gi.test(options.url) ||
/user_center\/code_login/gi.test(options.url)
) {
com.Tool.Cookie.setTicketByCAS(
'_SUP',
'.ezijing.com',
data.data.ticket,
res
)
com.Tool.Cookie.setCookie('_AUTH', '.ezijing.com', pwdBase64, res)
}
if (/user_center\/logout/gi.test(options.url)) {
res.clearCookie('_SUP', { path: '/', domain: '.ezijing.com' })
res.clearCookie('_AUTH', { path: '/', domain: '.ezijing.com' })
res.clearCookie('TGC', { path: '/', domain: '.ezijing.com' })
res.clearCookie('CAS_USER_ID', { path: '/', domain: '.ezijing.com' })
}
/* 如果是大作业提价,先docx解析,解析不出来则报错 */
if (
/util\/upload-file/gi.test(options.url) &&
req.body.special &&
req.body.special === 'course-work'
) {
let _strContent = ''
let contentXml = null
try {
let zip = new AdmZip(_fileName[0]) // filePath为文件路径
contentXml = zip.readAsText('word/document.xml') // 将document.xml读取为text内容;
_strContent = contentXml.replace(/<[/]{0,1}\w[^>]*>/gi, '')
// contentXml.match(/<w:t[^>]*?>[\s\S]*?<\/w:t>/ig).forEach((item) => {
// _strContent += item.slice(5, -6) // 不能换行,应该是 解析某些换行规则会比较慢
// })
data.data.dataStr = Buffer.from(_strContent, 'utf8').toString(
'base64'
)
} catch (e) {
res.status(500).json({
message:
'文档上传出错,错误原因:请不要直接修改后缀“.doc”为“.docx”或者正文内容必须大于400字',
errMsg: 'err',
code: 500
})
return
}
}
/* getInfo 时,则写入 用户基本信息 */
if (/user_center\/get_user_info/gi.test(options.url)) {
/* check-access接口 */
// headers['Host'] = 'lms-api.ezijing.com'
// headers['host'] = 'lms-api.ezijing.com'
headers['Host'] = conf.host
headers['host'] = conf.host
axios.defaults.headers = headers
axios({
timeout: 30 * 1000,
url: 'user/check-access',
baseURL: conf.agentApiUrl,
method: 'GET',
data: {},
params: ''
})
.then((_data) => {
if (_data.data.id) {
data.data['auth_key'] = headers['token']
data.data['id'] = headers['uid']
data.data.student_info = _data.data
let _name =
(data.data.student_info &&
data.data.student_info.personal_name) ||
data.data.nickname
let _email =
(data.data.student_info && data.data.student_info.email) ||
data.data.email
com.Log.EzijingVideo.writeBasicInfo(req, _logJson, {
_name, // 用于重新 定位学生目录
_email, // 用于重新 定位学生目录
_totalDir // 用于重新 定位学生目录
})
res.status(200).send(data.data)
} else {
res.status(403).send({
name: 'Unauthorized',
message: '非学习系统用户,请联系管理员',
code: 0,
status: 401
})
}
})
.catch((e) => {
try {
res.status(e.response.status).send(e.response.data)
} catch (e) {
res.status(500).send({
name: 'undefined',
message: '接口请求异常',
code: 0,
status: 500
})
}
})
} else {
res.status(200).send(data.data)
}
})
.catch((e) => {
/* 记录 请求处理时长 + 请求状态 */
_reqTime =
new Date().getTime() - _logJson._nodeServerCurrentTime + 'ms'
_status = (e.response && e.response.status) || 500
/* 未登录,则全部清空 _SUP */
if (e.response && e.response.status === 403) {
res.clearCookie('_SUP', { path: '/', domain: '.ezijing.com' })
res.clearCookie('_AUTH', { path: '/', domain: '.ezijing.com' })
}
/* 返回执行代码出错 或者 服务器请求错误 */
if (e.response && e.response.data) {
/* 如果未登录 强制 弹出到 登录页 */
// setPorxyHeader(e.response, res)
res.status(e.response.status).json(e.response.data)
console.error(
_logJson._uuid +
String.fromCharCode(0x001) +
JSON.stringify(options) +
String.fromCharCode(0x001) +
JSON.stringify(axios.defaults.headers) +
String.fromCharCode(0x001) +
JSON.stringify(e.response.data)
)
} else {
res.status(500).json({
message: '系统错误,请稍后重试或联系管理员',
errMsg: 'Error Proxy Request or BackData Excute Error',
code: 500
})
console.error(_logJson._uuid, e)
}
})
.finally(() => {
/* 请求结束,删除服务器端 缓存文件 */
if (_fileName.length) {
for (let i = 0; i < _fileName.length; i++) {
fs.unlinkSync(_fileName[i])
}
}
/* 视频行为日志 写入 */
com.Log.EzijingVideo.writeLogVideo(_logJson, {
_reqTime,
_status
})
})
} catch (e) {
res.status(500).json({
message: '系统错误,请稍后重试或联系管理员',
errMsg: 'Network Server Excute Error',
code: 500
})
console.error(_logJson._uuid, e)
}
}
}
module.exports = {
agentProcessor: agentProcessor
}
差异被折叠。
差异被折叠。
差异被折叠。
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论