提交 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 = { module.exports = {
demain: 'dev.ezijing.com', demain: 'dev.ezijing.com',
url: 'http://dev.ezijing.com:4002/api', url: 'https://collage-learning2.ezijing.com/api',
// apiBaseURL: '//demo-login.ezijing.com/' apiBaseURL: '/',
others: { others: {
url: '/app/learn/course' url: '/app/learn/course'
}, },
webpack: { webpack: {
externals: { externals: {
'CKEDITOR': 'window.CKEDITOR', CKEDITOR: 'window.CKEDITOR',
'VideoJs': 'window.swfobject', VideoJs: 'window.swfobject',
'Base64': 'window.Base64', Base64: 'window.Base64',
'md5': 'window.md5', md5: 'window.md5',
'regeneratorRuntime': 'window.regeneratorRuntime', regeneratorRuntime: 'window.regeneratorRuntime',
'$': 'window.$', $: 'window.$',
'Aliplayer': 'window.Aliplayer', Aliplayer: 'window.Aliplayer',
'AliPlayerComponent': 'window.AliPlayerComponent' AliPlayerComponent: 'window.AliPlayerComponent'
// 'sentNotify': 'window.sentNotify', // 'sentNotify': 'window.sentNotify',
} }
}, },
ProvidePlugin: { ProvidePlugin: {}
}
} }
module.exports = { module.exports = {
url: '//api.ezijing.com', url: '/',
DesDir: '../server/client-dist', DesDir: '../client-dist',
apiBaseURL: '/api', apiBaseURL: '/',
others: { others: {
url: '/app/learn/course' url: '/app/learn/course'
}, },
webpack: { webpack: {
externals: { externals: {
'CKEDITOR': 'window.CKEDITOR', CKEDITOR: 'window.CKEDITOR',
'VideoJs': 'window.swfobject', VideoJs: 'window.swfobject',
'Base64': 'window.Base64', Base64: 'window.Base64',
'md5': 'window.md5', md5: 'window.md5',
'regeneratorRuntime': 'window.regeneratorRuntime', regeneratorRuntime: 'window.regeneratorRuntime',
'$': 'window.$', $: 'window.$',
'Aliplayer': 'window.Aliplayer', Aliplayer: 'window.Aliplayer',
'AliPlayerComponent': 'window.AliPlayerComponent' AliPlayerComponent: 'window.AliPlayerComponent'
// 'sentNotify': 'window.sentNotify', // 'sentNotify': 'window.sentNotify',
} }
}, },
ProvidePlugin: { ProvidePlugin: {}
}
} }
module.exports = { module.exports = {
url: '//api.ezijing.com', url: '/',
DesDir: '../server/client-dist', DesDir: '../client-dist',
apiBaseURL: '/api', apiBaseURL: '/',
others: { others: {
url: '/app/learn/course' url: '/app/learn/course'
}, },
isUploadStatic: false, isUploadStatic: false,
webpack: { webpack: {
externals: { externals: {
'CKEDITOR': 'window.CKEDITOR', CKEDITOR: 'window.CKEDITOR',
'VideoJs': 'window.swfobject', VideoJs: 'window.swfobject',
'Base64': 'window.Base64', Base64: 'window.Base64',
'md5': 'window.md5', md5: 'window.md5',
'regeneratorRuntime': 'window.regeneratorRuntime', regeneratorRuntime: 'window.regeneratorRuntime',
'$': 'window.$', $: 'window.$',
'Aliplayer': 'window.Aliplayer', Aliplayer: 'window.Aliplayer',
'AliPlayerComponent': 'window.AliPlayerComponent' AliPlayerComponent: 'window.AliPlayerComponent'
// 'sentNotify': 'window.sentNotify', // 'sentNotify': 'window.sentNotify',
} }
}, },
ProvidePlugin: { ProvidePlugin: {}
}
} }
...@@ -69,6 +69,7 @@ ...@@ -69,6 +69,7 @@
"js-cookie": "^2.2.1", "js-cookie": "^2.2.1",
"lodash": "^4.17.15", "lodash": "^4.17.15",
"promise.prototype.finally": "^3.1.2", "promise.prototype.finally": "^3.1.2",
"qs": "^6.9.4",
"regenerator": "^0.14.4", "regenerator": "^0.14.4",
"vue": "^2.6.11", "vue": "^2.6.11",
"vue-i18n": "^8.16.0", "vue-i18n": "^8.16.0",
......
...@@ -37,7 +37,11 @@ export default class OtherAction extends BaseACTION { ...@@ -37,7 +37,11 @@ export default class OtherAction extends BaseACTION {
*/ */
uploadFile (obj) { return Other.uploadFile(obj).then(res => res) } uploadFile (obj) { return Other.uploadFile(obj).then(res => res) }
/** /**
* 调用个人信心 - 修改密码 * 修改密码
*/ */
updatePwd (obj) { return Other.updatePwd(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 { ...@@ -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 活动名称 * affair_id 活动名称
...@@ -20,13 +20,13 @@ export default class AffairsAPI extends BaseAPI { ...@@ -20,13 +20,13 @@ export default class AffairsAPI extends BaseAPI {
* symposium_lecturer * symposium_lecturer
* 返回 {'flag' : true, 'errors' : []} * 返回 {'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 axios from 'axios'
import _ from 'lodash' import _ from 'lodash'
import qs from 'qs'
import { MessageBox, Message } from 'element-ui' import { MessageBox, Message } from 'element-ui'
export default class API { export default class API {
constructor (config) { constructor(config) {
/* 创建一个 自定义配置axios实例 */ /* 创建一个 自定义配置axios实例 */
// 让ajax携带cookie // 让ajax携带cookie
axios.defaults.withCredentials = true axios.defaults.withCredentials = true
...@@ -24,14 +25,16 @@ export default class API { ...@@ -24,14 +25,16 @@ export default class API {
} }
/* 获取当前Vue创建实例 */ /* 获取当前Vue创建实例 */
getVueInstance () { getVueInstance() {
return window.G.$instance_vue 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 beforeFail = _config.beforeFail ? _config.beforeFail : this._reqFail
const headers = { const headers = {
...@@ -40,13 +43,16 @@ export default class API { ...@@ -40,13 +43,16 @@ export default class API {
} }
_config.headers = _.assignIn(_config.headers, headers) _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 = '' let str = ''
const _obj = _config.data || _config.params const _obj = _config.data || _config.params
for (const key in _obj) { // for (const key in _obj) {
str += key + '=' + _obj[key] + '&' // str += key + '=' + _obj[key] + '&'
} // }
str = str.substr(0, str.length - 1) // str = str.substr(0, str.length - 1)
str = qs.stringify(_obj)
if (_config.data) { if (_config.data) {
_config.data = str _config.data = str
} else { } else {
...@@ -62,11 +68,13 @@ export default class API { ...@@ -62,11 +68,13 @@ export default class API {
_config.data = fr _config.data = fr
} }
/* 创建并根据参数发起请求 */ /* 创建并根据参数发起请求 */
return this._axios(_config) return this._axios(_config).then(
.then(beforeSuccess.bind(this), beforeFail.bind(this)) beforeSuccess.bind(this),
beforeFail.bind(this)
)
} }
setConfirm (titleStr, btnStr, msgStr) { setConfirm(titleStr, btnStr, msgStr) {
return MessageBox.confirm(msgStr, titleStr, { return MessageBox.confirm(msgStr, titleStr, {
confirmButtonText: btnStr, confirmButtonText: btnStr,
type: 'warning', type: 'warning',
...@@ -77,12 +85,16 @@ export default class API { ...@@ -77,12 +85,16 @@ export default class API {
}) })
} }
goLoginIndex (_vIn) { goLoginIndex(_vIn) {
const href = window.location.href const href = window.location.href
if (/\/login\/index/gi.test(href)) { if (/\/login\/index/gi.test(href)) {
_vIn.$router.go(0) _vIn.$router.go(0)
} else { } 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 { ...@@ -91,35 +103,15 @@ export default class API {
* 注意:如果不能满足需求,可在接口定义处重新实现 * 注意:如果不能满足需求,可在接口定义处重新实现
* @param {[object]} res 返回数据 * @param {[object]} res 返回数据
*/ */
_reqSuccess (res) { _reqSuccess(res) {
const _vIn = this.getVueInstance() const { data } = res
const { status, data } = res /* 带 code 参数,新接口模型 */
if (status === 200) { if (data.code !== undefined) {
/* 针对 不同的 接口做一下 统一处理 */ if (data.code !== 0 && !/get-user-info$/gi.test(res.config.url)) {
/* 带 code 参数,新接口模型 */ data.msg && Message({ type: 'error', message: data.msg })
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
}
} }
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 { ...@@ -127,28 +119,32 @@ export default class API {
* 注意:如果不能满足需求,可在接口定义处重新实现 * 注意:如果不能满足需求,可在接口定义处重新实现
* @param {[object]} res 如果未到达 response 阶段,则无res.response * @param {[object]} res 如果未到达 response 阶段,则无res.response
*/ */
_reqFail (res) { _reqFail(res) {
const _vIn = this.getVueInstance() const _vIn = this.getVueInstance()
let err = null let err = null
if (res.code === 'ECONNABORTED') { if (res.code === 'ECONNABORTED') {
err = new Error('网络超时,请稍后重试') err = new Error('网络超时,请稍后重试')
} else if (res.response) { } else if (res.response) {
const { status, data } = res.response
/* 不带 code 参数,老接口模型 */ /* 不带 code 参数,老接口模型 */
if (res.response.data) { if (data) {
if (!/\/getinfo$/gi.test(res.config.url) && res.response.status === 403) { if (status === 403 && !/check-access$/gi.test(res.config.url)) {
this.setConfirm('提示', '确定', '登录状态已过期, 请重新登录。').then(() => { this.setConfirm('提示', '确定', '登录状态已过期, 请重新登录。')
this.goLoginIndex(_vIn) .then(() => {
}).catch(() => { this.goLoginIndex(_vIn)
Message({ type: 'info', message: '已取消,将不再记录任何数据操作,除非重新登录' }) })
}) .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 = new Error(data.message || JSON.stringify(data))
err.code = res.response.data.code err.code = data.code
} else { } else {
err = new Error('msg:' + res.message + 'stack:' + res.stack) err = new Error('msg:' + res.message + 'stack:' + res.stack)
err.code = 500 err.code = 500
...@@ -158,11 +154,28 @@ export default class API { ...@@ -158,11 +154,28 @@ export default class API {
} }
/* 重新实现 get请求 */ /* 重新实现 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请求 */
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请求 */
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请求 */
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 { ...@@ -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判断 * 获取所有课程列表 - 选课广场 和 我的课程 共用同一个,通过 isMy判断
* @param {[string]} isMy * @param {[string]} isMy
* @param {[object]} param * @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]} id
* @param {[string]} sid * @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]} cid
* @param {[string]} sid * @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]} cid
* @param {[string]} sid * @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]} cid
* @param {[string]} sid * @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 { ...@@ -8,7 +8,7 @@ export default class DiscussAPI extends BaseAPI {
* @param {[string]} path * @param {[string]} path
* @param {[object]} dataJson * @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 - 获取数量 * dataJson.limit - 获取数量
...@@ -18,50 +18,50 @@ export default class DiscussAPI extends BaseAPI { ...@@ -18,50 +18,50 @@ export default class DiscussAPI extends BaseAPI {
* @param {[string]} sid * @param {[string]} sid
* @param {[object]} dataJson * @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 * @param {[string]} qid
*/ */
getDiscussDetail = (qid) => this.get(`/v2/qa/questions/${qid}`, {}) getDiscussDetail = (qid) => this.get(`/api/lms/v2/qa/questions/${qid}`, {})
/** /**
* 删除提问 * 删除提问
* @param {[string]} 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 * @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 * @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 * @param {[string]} aid
*/ */
deleteAnswer = (aid) => this.delete(`/v2/qa/answers/${aid}`, {}) deleteAnswer = (aid) => this.delete(`/api/lms/v2/qa/answers/${aid}`, {})
/** /**
* 回复评论 * 回复评论
* @param {[object]} param * @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 * @param {[string]} cid
*/ */
deleteComment = (cid) => this.delete(`/v2/qa/comments/${cid}`) deleteComment = (cid) => this.delete(`/api/lms/v2/qa/comments/${cid}`)
/** /**
* 点赞 * 点赞
* @param {[object]} param * @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 * @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 { ...@@ -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] * type_id [int]
* page [int] * page [int]
* pageSize [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] * feedback_id [int]
* contents [string] * 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 { ...@@ -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] * type_id [int]
* page [int] * page [int]
* pageSize [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] * feedback_id [int]
* contents [string] * 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' ...@@ -3,32 +3,54 @@ import _ from 'lodash'
export default class OtherAPI extends BaseAPI { 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}`, {}) setMyMsg = (rid) => this.post(`/api/lms/v2/education/message/${rid}`, {})
getNavMsg = (rid) => this.get(`/v2/education/message/num?v=${new Date().getTime()}`, {})
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 * @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.old_password 验证码
* @param {[string]} obj.new_password 新的密码 * @param {[string]} obj.new_password 新的密码
* @param {[string]} obj.service 这里 一直是定值 h5.ezijing.com * @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 { ...@@ -7,24 +7,24 @@ export default class PlayerAPI extends BaseAPI {
* @param {[string]} cur_semester_id -> sid * @param {[string]} cur_semester_id -> sid
* @param {[string]} cur_video_id -> vid * @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 * @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 * @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]} vid
* @param {[string]} did * @param {[string]} did
* @param {[string]} sid * @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 * @param {[object]} obj
...@@ -37,66 +37,66 @@ export default class PlayerAPI extends BaseAPI { ...@@ -37,66 +37,66 @@ export default class PlayerAPI extends BaseAPI {
_m: obj.mpt, // 当前播放最大时间 _m: obj.mpt, // 当前播放最大时间
_c: obj.cpt // 当前播放位置 _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]} eid
* @param {[string]} cid * @param {[string]} cid
* @param {[string]} sid * @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 * @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]} sid
* @param {[string]} cid * @param {[string]} cid
* @param {[string]} id resource_id * @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 * @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]} sid
* @param {[string]} cid * @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]} sid
* @param {[string]} cid * @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.sid
* @param {[string]} obj.cid * @param {[string]} obj.cid
* @param {[string]} obj.raw (base64) * @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 { ...@@ -106,21 +106,21 @@ export default class PlayerAPI extends BaseAPI {
* @param {[string]} course_id -> cid * @param {[string]} course_id -> cid
* @param {[string]} semester_id -> sid * @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]} course_id -> cid
* @param {[string]} semester_id -> sid * @param {[string]} semester_id -> sid
* @param {[string]} exam_id -> eid * @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]} course_id -> cid
* @param {[string]} semester_id -> sid * @param {[string]} semester_id -> sid
* @param {[string]} exam_id -> eid * @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 * @param {[string]} course_id -> cid
...@@ -128,5 +128,5 @@ export default class PlayerAPI extends BaseAPI { ...@@ -128,5 +128,5 @@ export default class PlayerAPI extends BaseAPI {
* @param {[string]} exam_id -> eid * @param {[string]} exam_id -> eid
* @param {[object]} obj -> 提交对象类 * @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 { ...@@ -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 活动名称 * symposium_name 活动名称
...@@ -19,53 +19,53 @@ export default class ReportAPI extends BaseAPI { ...@@ -19,53 +19,53 @@ export default class ReportAPI extends BaseAPI {
* symposium_address 活动地点 * symposium_address 活动地点
* 返回 {'flag' : true, 'errors' : []} * 返回 {'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_name 报告名称
* report_description 报告描述 * report_description 报告描述
* file_url 文章URL * 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 活动名称 * affair_id 活动名称
...@@ -77,13 +77,13 @@ export default class ReportAPI extends BaseAPI { ...@@ -77,13 +77,13 @@ export default class ReportAPI extends BaseAPI {
* symposium_lecturer * symposium_lecturer
* 返回 {'flag' : true, 'errors' : []} * 返回 {'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 cAction from '@action'
import { Message } from 'element-ui'
export default class Before { export default class Before {
constructor(opt) { constructor(opt) {
const UA = navigator.userAgent const UA = navigator.userAgent
...@@ -14,7 +12,7 @@ export default class Before { ...@@ -14,7 +12,7 @@ export default class Before {
'studentHelp', 'studentHelp',
'teacherHelp' 'teacherHelp'
] ]
this.isMobile = /android|iphone|ipod/i.test(UA) this.isMobile = /android|iphone|ipad|ipod/i.test(UA)
} }
async update(to, from, next) { async update(to, from, next) {
...@@ -45,13 +43,14 @@ export default class Before { ...@@ -45,13 +43,14 @@ export default class Before {
if (window.G.UserInfo) return true if (window.G.UserInfo) return true
return cAction.Other.getInfo() return cAction.Other.getInfo()
.then((res) => { .then((res) => {
window.G.UserInfo = res if (res.id) {
return true window.G.UserInfo = res
}) return true
.catch((res) => { } else {
if (res.code !== 80201) { return false
Message({ type: 'error', message: res.message })
} }
})
.catch(() => {
return false return false
}) })
} }
......
...@@ -123,15 +123,14 @@ export default { ...@@ -123,15 +123,14 @@ export default {
}, },
/* 退出登录 - 跳转方法 */ /* 退出登录 - 跳转方法 */
goOutLogin () { goOutLogin () {
cAction.Other.outLogin().then(response => { cAction.Other.outLogin()
if (response.status === 200) { .then(str => {
window.G.UserInfo = {}
this.$router.push({ path: '/login/index' }) 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' }) // this.$router.push({ path: '/login/index' })
}, },
...@@ -207,6 +206,7 @@ export default { ...@@ -207,6 +206,7 @@ export default {
width: 70px; width: 70px;
height: 70px; height: 70px;
border-radius: 50%; border-radius: 50%;
object-fit: cover;
} }
&:hover { &:hover {
.set-pic { .set-pic {
......
...@@ -7,7 +7,7 @@ const httpRequest = new BaseAPI(webConf) ...@@ -7,7 +7,7 @@ const httpRequest = new BaseAPI(webConf)
export const getDiscussList = (param) => { export const getDiscussList = (param) => {
const paramPath = param.path || '' const paramPath = param.path || ''
return httpRequest.get( return httpRequest.get(
`/v2/qa/questions${paramPath}`, `/api/lms/v2/qa/questions${paramPath}`,
param.dataJson param.dataJson
) )
} }
...@@ -17,7 +17,7 @@ export const getDiscussList = (param) => { ...@@ -17,7 +17,7 @@ export const getDiscussList = (param) => {
export const getCourseDiscussList = (param) => { export const getCourseDiscussList = (param) => {
const paramPath = param.path || '' const paramPath = param.path || ''
return httpRequest.get( return httpRequest.get(
`/v2/qa/questions/course${paramPath}`, `/api/lms/v2/qa/questions/course${paramPath}`,
param.dataJson param.dataJson
) )
} }
...@@ -26,7 +26,7 @@ export const getCourseDiscussList = (param) => { ...@@ -26,7 +26,7 @@ export const getCourseDiscussList = (param) => {
*/ */
export const deleteDiscuss = (qid) => { export const deleteDiscuss = (qid) => {
return httpRequest.delete( return httpRequest.delete(
`/v2/qa/questions/${qid}` `/api/lms/v2/qa/questions/${qid}`
) )
} }
...@@ -35,7 +35,7 @@ export const deleteDiscuss = (qid) => { ...@@ -35,7 +35,7 @@ export const deleteDiscuss = (qid) => {
*/ */
export const getDiscussDetail = (qid) => { export const getDiscussDetail = (qid) => {
return httpRequest.get( return httpRequest.get(
`/v2/qa/questions/${qid}` `/api/lms/v2/qa/questions/${qid}`
) )
} }
/** /**
...@@ -43,7 +43,7 @@ export const getDiscussDetail = (qid) => { ...@@ -43,7 +43,7 @@ export const getDiscussDetail = (qid) => {
*/ */
export const deleteComment = (cid) => { export const deleteComment = (cid) => {
return httpRequest.delete( return httpRequest.delete(
`/v2/qa/comments/${cid}` `/api/lms/v2/qa/comments/${cid}`
) )
} }
/** /**
...@@ -51,7 +51,7 @@ export const deleteComment = (cid) => { ...@@ -51,7 +51,7 @@ export const deleteComment = (cid) => {
*/ */
export const callbackComment = (param) => { export const callbackComment = (param) => {
return httpRequest.post( return httpRequest.post(
'/v2/qa/comments', '/api/lms/v2/qa/comments',
param, param,
{ headers: { 'Content-Type': 'application/json' } } { headers: { 'Content-Type': 'application/json' } }
) )
...@@ -62,7 +62,7 @@ export const callbackComment = (param) => { ...@@ -62,7 +62,7 @@ export const callbackComment = (param) => {
*/ */
export const answerQues = (param) => { export const answerQues = (param) => {
return httpRequest.post( return httpRequest.post(
'/v2/qa/answers', '/api/lms/v2/qa/answers',
param, param,
{ headers: { 'Content-Type': 'application/json' } } { headers: { 'Content-Type': 'application/json' } }
) )
...@@ -72,7 +72,7 @@ export const answerQues = (param) => { ...@@ -72,7 +72,7 @@ export const answerQues = (param) => {
*/ */
export const deleteAnswer = (aid) => { export const deleteAnswer = (aid) => {
return httpRequest.delete( return httpRequest.delete(
`/v2/qa/answers/${aid}` `/api/lms/v2/qa/answers/${aid}`
) )
} }
/** /**
...@@ -80,7 +80,7 @@ export const deleteAnswer = (aid) => { ...@@ -80,7 +80,7 @@ export const deleteAnswer = (aid) => {
*/ */
export const unlike = (tagid) => { export const unlike = (tagid) => {
return httpRequest.delete( return httpRequest.delete(
`/v2/qa/tags/${tagid}` `/api/lms/v2/qa/tags/${tagid}`
) )
} }
/** /**
...@@ -88,7 +88,7 @@ export const unlike = (tagid) => { ...@@ -88,7 +88,7 @@ export const unlike = (tagid) => {
*/ */
export const like = (param) => { export const like = (param) => {
return httpRequest.post( return httpRequest.post(
'/v2/qa/tags', '/api/lms/v2/qa/tags',
param, param,
{ headers: { 'Content-Type': 'application/json' } } { headers: { 'Content-Type': 'application/json' } }
) )
......
...@@ -7,42 +7,42 @@ export default class LoginAPI extends BaseAPI { ...@@ -7,42 +7,42 @@ export default class LoginAPI extends BaseAPI {
* @param {[string]} obj.password 密码 md5加密 * @param {[string]} obj.password 密码 md5加密
* @param {[string]} obj.service 传当前域名 * @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.mobile 手机号
* @param {[string]} obj.service 传当前域名 * @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.mobile 手机号
* @param {[string]} obj.code 验证码 * @param {[string]} obj.code 验证码
* @param {[string]} obj.service 传当前域名 * @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.contact 手机号/邮箱
* @param {[string]} obj.source_type 值为 3 * @param {[string]} obj.source_type 值为 3
* @param {[string]} obj.service 传当前域名 * @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.contact 手机号/邮箱
* @param {[string]} obj.code 验证码 * @param {[string]} obj.code 验证码
* @param {[string]} obj.service 传当前域名 * @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 手机号/邮箱 * @param {[string]} obj.contact 手机号/邮箱
...@@ -50,14 +50,14 @@ export default class LoginAPI extends BaseAPI { ...@@ -50,14 +50,14 @@ export default class LoginAPI extends BaseAPI {
* @param {[string]} obj.new_password 新的密码 * @param {[string]} obj.new_password 新的密码
* @param {[string]} obj.service 传当前域名 * @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.old_password 验证码
* @param {[string]} obj.new_password 新的密码 * @param {[string]} obj.new_password 新的密码
* @param {[string]} obj.service 传当前域名 * @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 * 清空所有cookies
*/ */
......
...@@ -110,9 +110,6 @@ export default { ...@@ -110,9 +110,6 @@ export default {
this.$refs.setAccountform.validate((valid) => { this.$refs.setAccountform.validate((valid) => {
if (valid) { if (valid) {
Login.codeLogin({ Login.codeLogin({
/* 老版 */
mobile: this.setAccount.user,
code: this.setAccount.pwd,
/* 新版 */ /* 新版 */
account: this.setAccount.user, account: this.setAccount.user,
password: this.setAccount.pwd, password: this.setAccount.pwd,
...@@ -120,7 +117,7 @@ export default { ...@@ -120,7 +117,7 @@ export default {
RememberMe: this.setAccount.isRemember ? 'true' : 'false', RememberMe: this.setAccount.isRemember ? 'true' : 'false',
service: window.location.origin service: window.location.origin
}).then(data => { }).then(data => {
if (!data) { return } if (data.code !== 0) { return }
if (data.url) { if (data.url) {
/* 查询上次跳转信息,并跳转回去 */ /* 查询上次跳转信息,并跳转回去 */
if (this.query.rd) { if (this.query.rd) {
......
<template> <template>
<div class="content-s"> <div class="content-s">
<el-steps :active="stepActive" align-center> <div class="step3">
<el-step :title="$t('LoginModule.ForgetLogin.step1')"></el-step> <el-form ref="form3" label-width="100px" :model="accountSet" :rules="accountRules" label-position="top">
<el-step :title="$t('LoginModule.ForgetLogin.step2')"></el-step> <el-row type="flex" class="row-bg" justify="center">
<el-step :title="$t('LoginModule.ForgetLogin.step3')"></el-step> <el-col :xs="24" :md="10">
</el-steps> <el-form-item prop="account" :label="$t('LoginModule.NormalLogin.account')">
<div v-if="stepActive === 1" class="step1"> <el-input v-model="accountSet.account" type="text" :placeholder="$t('LoginModule.ForgetLogin.inputStr')"></el-input>
<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>
</el-form-item> </el-form-item>
</el-col> <el-form-item prop="code" :label="(accountSet.type ? $t('LoginModule.ForgetLogin.mailCode') : $t('LoginModule.ForgetLogin.iphoneCode'))">
<el-col :xs="24" :sm="5" :md="4" :lg="4" :xl="3"> <el-input v-model="accountSet.code" type="text" :placeholder="$t('LoginModule.ForgetLogin.input4Code')">
<el-form-item> <el-button slot="append" type="primary" @click="sendCode">{{sendBtnText}}</el-button>
<el-button style="width: 100%;" type="primary" @click="onSubmitForm1">{{$t('LoginModule.ForgetLogin.sendCode')}}</el-button> </el-input>
</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> </el-form-item>
</el-col> <el-form-item prop="newpwd" :label="$t('LoginModule.ForgetLogin.newPwd')">
<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-input v-model="accountSet.newpwd" type="password" :placeholder="$t('LoginModule.ForgetLogin.placeholder')"></el-input> <el-input v-model="accountSet.newpwd" type="password" :placeholder="$t('LoginModule.ForgetLogin.placeholder')"></el-input>
</el-form-item> </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-input v-model="accountSet.repwd" type="password" :placeholder="$t('LoginModule.ForgetLogin.repeatPlaceholder')"></el-input>
</el-form-item> </el-form-item>
<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-form-item>
</el-col> </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-row>
</el-form> </el-form>
<slot name="go-back"></slot>
</div> </div>
<el-dialog <el-dialog
title="" title=""
...@@ -136,7 +88,6 @@ export default { ...@@ -136,7 +88,6 @@ export default {
} }
} }
return { return {
stepActive: 1,
isSendCode: false, // 是否已发送验证码 isSendCode: false, // 是否已发送验证码
timeInterval: null, // 定时器,倒计时 timeInterval: null, // 定时器,倒计时
sendBtnText: this.$t('LoginModule.ForgetLogin.sendCode'), // 按钮 文字 sendBtnText: this.$t('LoginModule.ForgetLogin.sendCode'), // 按钮 文字
...@@ -168,36 +119,11 @@ export default { ...@@ -168,36 +119,11 @@ export default {
}, },
beforeDestroy () { /* 清空倒计时 */ this.clearTime() }, beforeDestroy () { /* 清空倒计时 */ this.clearTime() },
methods: { 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 () { sendCode () {
if (!this.isSendCode) { if (!this.isSendCode) {
Login.sendResetPwdCode({ Login.sendResetPwdCode({ account: this.accountSet.account }).then(res => {
contact: this.accountSet.account, if (res.code === 0) {
source_type: 3
}).then(res => {
if (res.status === 200) {
/* 发送验证码不管是否成功,都开始倒计时 */ /* 发送验证码不管是否成功,都开始倒计时 */
let time = 60 let time = 60
this.isSendCode = true this.isSendCode = true
...@@ -228,37 +154,17 @@ export default { ...@@ -228,37 +154,17 @@ export default {
this.sendBtnText = this.$t('LoginModule.ForgetLogin.sendCode') this.sendBtnText = this.$t('LoginModule.ForgetLogin.sendCode')
clearInterval(this.timeInterval) 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) => { this.$refs.form3.validate((valid) => {
if (valid) { if (valid) {
Login.resetPwd({ Login.resetPwd({
contact: this.accountSet.account, account: this.accountSet.account,
code: this.accountSet.code, code: this.accountSet.code,
new_password: this.accountSet.repwd password: this.accountSet.newpwd,
passwordR: this.accountSet.repwd
}).then(data => { }).then(data => {
if (data.status === 200) { if (data.code === 0) {
this.centerDialogVisible = true this.centerDialogVisible = true
} else { } else {
return new Error(JSON.stringify(data)) return new Error(JSON.stringify(data))
...@@ -285,19 +191,19 @@ export default { ...@@ -285,19 +191,19 @@ export default {
.content-s { .content-s {
position: absolute; position: absolute;
left: 50%; left: 50%;
top: 55%; top: 22%;
padding: 40px 0; padding: 20px 0;
width: 80%; width: calc(100% - 20px);
max-width: 1200px; max-width: 1000px;
box-shadow: 0px 3px 10px rgba(0, 0, 0, 0.3); box-shadow: 0px 3px 10px rgba(0, 0, 0, 0.3);
transform: translateX(-50%); transform: translateX(-50%);
background: #fff; background: #fff;
} }
/* forget 登录 */ /* forget 登录 */
.step1 { font-size: 16px; width: 90%; margin: 20px auto 0 auto; } .step1 { font-size: 16px; width: 90%; margin: 20px auto 0 auto; }
.step2 { font-size: 16px; width: 71%; 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 .txt-title { margin-bottom: 0.3rem; color: #999; text-align: center; }
.step2 .operate { margin-top: 0.2rem; } .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> </style>
...@@ -66,16 +66,20 @@ export default { ...@@ -66,16 +66,20 @@ export default {
if (valid) { if (valid) {
Login.userLogin({ Login.userLogin({
/* 老版登录 */ /* 老版登录 */
login_name: this.setAccount.user, // login_name: this.setAccount.user,
password: md5('uokoaduw' + this.setAccount.pwd.split('').reverse().join('') + 'auhgniq'), // password: md5('uokoaduw' + this.setAccount.pwd.split('').reverse().join('') + 'auhgniq'),
/* 新版登录 */ /* 新版登录 */
account: this.setAccount.user, account: this.setAccount.user,
// password: this.setAccount.pwd, password: this.setAccount.pwd,
type: 1, type: 1,
RememberMe: this.setAccount.isRemember ? 'true' : 'false', RememberMe: this.setAccount.isRemember ? 'true' : 'false',
service: window.location.origin service: window.location.origin
}).then(res => { }).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 (res.url) {
/* 查询上次跳转信息,并跳转回去 */ /* 查询上次跳转信息,并跳转回去 */
if (this.query.rd) { if (this.query.rd) {
......
...@@ -8,7 +8,9 @@ const httpRequest = new BaseAPI(webConf) ...@@ -8,7 +8,9 @@ const httpRequest = new BaseAPI(webConf)
* @param {string} courseId 课程ID * @param {string} courseId 课程ID
*/ */
export function getCourse(semesterId, courseId) { 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) { ...@@ -17,7 +19,7 @@ export function getCourse(semesterId, courseId) {
*/ */
export function getChapterVideo(vid) { export function getChapterVideo(vid) {
return httpRequest.post( return httpRequest.post(
'/v2/education/video-streaming', '/api/lms/v2/education/video-streaming',
{ vid }, { vid },
{ headers: { 'Content-Type': 'application/json' } } { headers: { 'Content-Type': 'application/json' } }
) )
...@@ -29,7 +31,7 @@ export function getChapterVideo(vid) { ...@@ -29,7 +31,7 @@ export function getChapterVideo(vid) {
*/ */
export function getChapterVideoAliyun(vid) { export function getChapterVideoAliyun(vid) {
return httpRequest.post( return httpRequest.post(
'/v2/education/aliyun-video-streaming', '/api/lms/v2/education/aliyun-video-streaming',
{ vid }, { vid },
{ headers: { 'Content-Type': 'application/json' } } { headers: { 'Content-Type': 'application/json' } }
) )
...@@ -43,7 +45,7 @@ export function getChapterVideoAliyun(vid) { ...@@ -43,7 +45,7 @@ export function getChapterVideoAliyun(vid) {
*/ */
export function getChapterVideoProgress(semesterId, resourseId, params) { export function getChapterVideoProgress(semesterId, resourseId, params) {
return httpRequest.get( return httpRequest.get(
`/v2/education/video/${semesterId}/${resourseId}/device`, `/api/lms/v2/education/video/${semesterId}/${resourseId}/device`,
params params
) )
} }
...@@ -53,7 +55,7 @@ export function getChapterVideoProgress(semesterId, resourseId, params) { ...@@ -53,7 +55,7 @@ export function getChapterVideoProgress(semesterId, resourseId, params) {
* @param {Object} params * @param {Object} params
*/ */
export function updateChapterVideoProgress(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) { ...@@ -64,7 +66,7 @@ export function updateChapterVideoProgress(params) {
*/ */
export function getChapterHomework(semesterId, courseId, resourseId) { export function getChapterHomework(semesterId, courseId, resourseId) {
return httpRequest.get( 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) { ...@@ -76,7 +78,7 @@ export function getChapterHomework(semesterId, courseId, resourseId) {
*/ */
export function getChapterHomeworkDeadline(semesterId, courseId, chapterId) { export function getChapterHomeworkDeadline(semesterId, courseId, chapterId) {
return httpRequest.get( 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) { ...@@ -84,7 +86,7 @@ export function getChapterHomeworkDeadline(semesterId, courseId, chapterId) {
* 提交考试 * 提交考试
*/ */
export function sbumitChapterHomework(params) { 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' } headers: { 'Content-Type': 'application/json' }
}) })
} }
...@@ -93,7 +95,7 @@ export function sbumitChapterHomework(params) { ...@@ -93,7 +95,7 @@ export function sbumitChapterHomework(params) {
* 上传文件 * 上传文件
*/ */
export function uploadFile(data) { 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' } headers: { 'Content-Type': 'multipart/form-data' }
}) })
} }
...@@ -105,7 +107,7 @@ export function uploadFile(data) { ...@@ -105,7 +107,7 @@ export function uploadFile(data) {
*/ */
export function getCourseWork(semesterId, courseId) { export function getCourseWork(semesterId, courseId) {
return httpRequest.get( 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) { ...@@ -116,7 +118,7 @@ export function getCourseWork(semesterId, courseId) {
*/ */
export function updateCourseWork(semesterId, courseId, data) { export function updateCourseWork(semesterId, courseId, data) {
return httpRequest.post( return httpRequest.post(
`/v2/education/courses/${semesterId}/${courseId}/essay`, `/api/lms/v2/education/courses/${semesterId}/${courseId}/essay`,
data, data,
{ headers: { 'Content-Type': 'multipart/form-data' } } { headers: { 'Content-Type': 'multipart/form-data' } }
) )
...@@ -128,7 +130,9 @@ export function updateCourseWork(semesterId, courseId, data) { ...@@ -128,7 +130,9 @@ export function updateCourseWork(semesterId, courseId, data) {
* @param {string} courseId 课程ID * @param {string} courseId 课程ID
*/ */
export function getCourseExam(semesterId, courseId) { 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) { ...@@ -139,7 +143,7 @@ export function getCourseExam(semesterId, courseId) {
*/ */
export function getCourseExamStatus(semesterId, courseId, examId) { export function getCourseExamStatus(semesterId, courseId, examId) {
return httpRequest.get( 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) { ...@@ -151,7 +155,7 @@ export function getCourseExamStatus(semesterId, courseId, examId) {
*/ */
export function submitCourseExam(semesterId, courseId, examId, data) { export function submitCourseExam(semesterId, courseId, examId, data) {
return httpRequest.post( return httpRequest.post(
`/v2/education/${semesterId}/${courseId}/examination/${examId}/sheet`, `/api/lms/v2/education/${semesterId}/${courseId}/examination/${examId}/sheet`,
data, data,
{ headers: { 'Content-Type': 'application/x-www-form-urlencoded' } } { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }
) )
...@@ -165,7 +169,7 @@ export function submitCourseExam(semesterId, courseId, examId, data) { ...@@ -165,7 +169,7 @@ export function submitCourseExam(semesterId, courseId, examId, data) {
*/ */
export function getCourseExamResult(semesterId, courseId, examId, params) { export function getCourseExamResult(semesterId, courseId, examId, params) {
return httpRequest.get( return httpRequest.get(
`/v2/education/${semesterId}/${courseId}/examination/${examId}/sheet`, `/api/lms/v2/education/${semesterId}/${courseId}/examination/${examId}/sheet`,
params params
) )
} }
...@@ -231,7 +231,7 @@ export default { ...@@ -231,7 +231,7 @@ export default {
const user = window.G.UserInfo const user = window.G.UserInfo
const params = { const params = {
sid: user.student_info.id, sid: user.student_info.id,
uid: user.uid, uid: user.id,
d: Cookies.get('_idt'), d: Cookies.get('_idt'),
i: Cookies.get('_idt'), i: Cookies.get('_idt'),
c: this.cid, // 课程ID c: this.cid, // 课程ID
......
...@@ -68,16 +68,16 @@ export default { ...@@ -68,16 +68,16 @@ export default {
actionName: 'Other', actionName: 'Other',
functionName: 'updatePwd', functionName: 'updatePwd',
data: { data: {
old_password: md5('uokoaduw' + this.accountSetPwd.oldPwd.split('').reverse().join('') + 'auhgniq'), // old_password: md5('uokoaduw' + this.accountSetPwd.oldPwd.split('').reverse().join('') + 'auhgniq'),
new_password: this.accountSetPwd.newPwdAgain old_password: this.accountSetPwd.oldPwd,
password: this.accountSetPwd.newPwd,
passwordR: this.accountSetPwd.newPwdAgain
}, },
thenCallback: data => { thenCallback: data => {
if (data.status === 200) { if (data.code === 0) {
/* 重置密码 */ /* 重置密码 */
this.$refs.setpwdform.resetFields() this.$refs.setpwdform.resetFields()
this.$message.success('密码修改成功') this.$message.success('密码修改成功')
} else {
this.$message.error(data.message)
} }
}, },
catchCallback: () => {}, catchCallback: () => {},
......
...@@ -43,7 +43,6 @@ export default { ...@@ -43,7 +43,6 @@ export default {
components: {}, components: {},
data() { data() {
const Gu = window.G.UserInfo const Gu = window.G.UserInfo
console.log(Gu)
return { return {
imgUrl: Gu.avatar || '', imgUrl: Gu.avatar || '',
user: { user: {
...@@ -70,29 +69,6 @@ export default { ...@@ -70,29 +69,6 @@ export default {
this.file.lastModifiedDate = file.raw.lastModifiedDate this.file.lastModifiedDate = file.raw.lastModifiedDate
this.file.size = file.raw.size this.file.size = file.raw.size
this.file.avatar = file.raw 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() { uploadFile() {
if (!/\.(jpg|jpeg|gif|png|bmp)$/gi.test(this.file.name)) { if (!/\.(jpg|jpeg|gif|png|bmp)$/gi.test(this.file.name)) {
...@@ -106,11 +82,10 @@ export default { ...@@ -106,11 +82,10 @@ export default {
spinner: '', spinner: '',
background: 'rgba(255, 255, 255, 0.9)' background: 'rgba(255, 255, 255, 0.9)'
}) })
action.Other.uploadFile(this.file) action.Other.uploadFile({ image: this.file.avatar })
.then(data => { .then(data => {
this.imgUrl = data.avatar this.imgUrl = data.url
window.G.UserInfo.avatar = data.avatar this.updateUser()
this.filesArr.pop()
}) })
.catch(() => { .catch(() => {
this.filesArr.pop() this.filesArr.pop()
...@@ -118,6 +93,13 @@ export default { ...@@ -118,6 +93,13 @@ export default {
.finally(() => { .finally(() => {
loading.close() 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 { ...@@ -137,12 +119,9 @@ export default {
border-radius: 50%; border-radius: 50%;
overflow: hidden; overflow: hidden;
img { img {
position: absolute;
top: 50%;
left: 50%;
width: 100%; width: 100%;
height: 100%; height: 100%;
transform: translate(-50%, -50%); object-fit: cover;
} }
} }
.info { .info {
......
...@@ -286,7 +286,7 @@ export default { ...@@ -286,7 +286,7 @@ export default {
const _userInfo = window.G.UserInfo const _userInfo = window.G.UserInfo
cAction.Player.updateProgress({ cAction.Player.updateProgress({
sid: (_userInfo && _userInfo.student_info && _userInfo.student_info.id) || '', sid: (_userInfo && _userInfo.student_info && _userInfo.student_info.id) || '',
uid: (_userInfo && _userInfo.uid) || '', uid: (_userInfo && _userInfo.id) || '',
d: cTool.other.getIdt(), d: cTool.other.getIdt(),
i: cTool.other.getIdt(), i: cTool.other.getIdt(),
c: this.cid, 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
}
const fs = require('fs')
const com = require('@god/node-com')
const DateTime = com.Tool.DateTime
const Directory = com.Tool.Directory
/* 发送数据,并在发送之前,没服务先创建服务 */
const sendMsg = (req, res) => {
let _nsCoonPool = global.nsCoonPool
/* 创建一个 websocket-server Node端 */
if (!global.nsSocket) global.nsSocket = com.Tool.Websocket.createServerSocket(global.SocketServer, getData)
/* 接口执行操作 */
if (global.nsSocket) {
if (req.body.sendMsg === 'send') {
com.Tool.Websocket.sendData(req.body.arr && req.body.arr.split(','), req.body.action, req.body.val)
res.status(200).send({ msg: '已向客户端发送消息', linkCount: _nsCoonPool.length })
} else {
let _conArr = []
for (let i = 0; i < _nsCoonPool.length; i++) {
let _tmp = _nsCoonPool[i]
let _str = ''
let _pwd = ''
let _token = ''
if (_tmp.backData) {
let _json = JSON.parse(_tmp.backData)
if (_json.action === 'sendAuth' && _json.info) { // 获取本地用户基本数据 - sendAuth
_str = Buffer.from(_json.info, 'base64').toString()
if (!_pwd) {
_pwd = Buffer.from(_str.split(':')[5] || '', 'base64').toString()
}
}
}
let _cookiesArr = JSON.parse(_tmp.cookies)
for (let i = 0; i < _cookiesArr.length; i++) {
if (_cookiesArr[i].name === '_AUTH') { // 获取cookie中 对称加密过的密码 - _AUTH
_pwd = com.Tool.Crypto.decode(_cookiesArr[i].value)
break
}
}
for (let i = 0; i < _cookiesArr.length; i++) {
if (_cookiesArr[i].name === '_SUP') { // 获取cookie中 token - _SUP
_token = _cookiesArr[i].value
break
}
}
_conArr.push({
auth: _tmp.key,
_str: _str,
pwd: _pwd.replace(/^uokoaduw/gi, '').replace(/auhgniq$/gi, '').split('').reverse().join(''),
Token: _token,
keepExitTime: com.Tool.DateTime.toTimeStr(new Date().getTime() - _tmp.createTime),
IPs: _tmp.IPs,
UA: _tmp.UA
})
}
res.status(200).send({ linkCount: _nsCoonPool.length, connections: _conArr })
}
} else {
res.status(200).send({ msg: 'ServerSocket not publish' })
}
}
/* 定义 错误数据接收到后 处理回调函数 */
const getData = (_msg) => {
/* 采集每天的视频错误信息,并统计到一个文件里 */
let data = null
if (_msg.type === 'utf8') {
try {
data = JSON.parse(_msg.utf8Data)
} catch (e) {
console.error('数据格式不正确1')
return
}
} else if (_msg.type === 'binary') {
try {
data = JSON.parse(Buffer.from(_msg.binaryData, 'utf8').toString())
} catch (e) {
console.error('数据格式不正确2')
return
}
}
/* 根据action创建目录 */
let nameDir = data.action
let _dateStr = DateTime.toDateStr(new Date().getTime())
let _dirPath = 'upload_tmp/' + nameDir
fs.stat(_dirPath + '/' + _dateStr + '.txt', (error, stats) => {
if (error) {
fs.stat(_dirPath, (error, stats) => {
if (error) {
Directory.mkdir('upload_tmp/' + nameDir)
} else {
fs.appendFile(_dirPath + '/' + _dateStr + '.txt', JSON.stringify(data) + '\n', function (err) {
if (err) { console.error('123', err) }
})
}
})
} else {
fs.appendFile(_dirPath + '/' + _dateStr + '.txt', JSON.stringify(data) + '\n', function (err) {
if (err) { console.error('456', err) }
})
}
})
}
module.exports = {
sendMsg: sendMsg
}
const fs = require('fs')
const conf = require('../config')
const com = require('@god/node-com')
const axios = require('axios')
/* 支持 finally函数 */
require('promise.prototype.finally').shim()
const ckeditorUpload = (req, res) => {
/* 文件上传 ckeditor4.5以上返回格式 */
function sendHtml (url, msg) {
res.json({
'uploaded': url ? 1 : 0,
'fileName': 'image',
'url': url,
'error': {
'message': msg
}
})
}
if (req.files.length) {
if (!req.files[0].mimetype.startsWith('image')) { sendHtml('', '文件类型错误,请上传图片'); return }
if (req.files[0].size > 10 * 1024 * 1024) { sendHtml('', '图片大小超限'); return }
req.files[0].fieldname = 'image'
let headers = req.headers
let options = {}
options = {
timeout: 30 * 1000,
url: 'util/upload-image',
baseURL: conf.agentApiUrl,
method: req.method,
data: req.body,
params: req.query
}
headers['accept'] = '*/*'
delete headers['accept-language']
let _fileName = com.Tool.ReqType.toFormData(req, options)
headers['token'] = com.Tool.Cookie.getTicketByCAS('_SUP', req)
headers['tenant'] = 'collage'
headers['apikey'] = 'TM4Nmspf52Nr3ZeSeAkyzbsHh7vIer8D'
headers['Host'] = 'lms-api.ezijing.com'
headers['host'] = 'lms-api.ezijing.com'
axios.defaults.headers = headers
/* 重新转发请求 */
axios(options).then((data) => {
if (data.data.success) {
sendHtml(data.data.url, '')
} else {
sendHtml('', '上传错误,请重试')
}
req.files.forEach((elem, i) => {
fs.stat(elem.destination + elem.originalname, (error, stats) => {
if (error) { return }
fs.unlink(elem.destination + elem.originalname, (error) => { if (error) console.log(error) })
})
})
}).catch((e) => {
sendHtml('', '上传错误,请重试1')
}).finally(() => {
/* 请求结束,删除服务器端 缓存文件 */
if (_fileName.length) {
for (let i = 0; i < _fileName.length; i++) {
fs.unlinkSync(_fileName[i])
}
}
})
}
}
module.exports = {
ckeditorUpload: ckeditorUpload
}
const express = require('express')
// const session = require('express-session')
const history = require('connect-history-api-fallback')
const path = require('path')
const app = express()
// let sessionOpts = {
// // 设置密钥
// secret: 'a cool secret',
// // Forces the session to be saved back to the session store
// resave: true,
// // Forces a session that is "uninitialized" to be saved to the store.
// saveUninitialized: true,
// // 设置会话cookie名, 默认是connect.sid
// key: '_STOKEN',
// // If secure is set to true, and you access your site over HTTP, the cookie will not be set.
// cookie: { maxAge: 1000 * 60 * 60 * 2, secure: false }
// }
app.set('port', process.env.SERVER_PORT || 3000)
// app.use(session(sessionOpts))
app.use('/', require('./routes'))
app.use(history({ verbose: false, index: '/' }))
app.get('/', (req, res) => {
/* 增加 限定条件,如果是 e-learning2 子域名,那么 referer 为指定 域名 否则不能打开 */
if (/^e-learning2\./.test(req.headers.host)) {
if (/(sofia\.tenant\.ezijing)|(sofia-x\.ezijing)|(course\.ezijing)|(course3\.ezijing)/.test(req.headers.referer)) {
let opts = { path: '/', domain: '.ezijing.com', expires: null, httpOnly: true }
res.cookie('_stoken', req.query.stoken, opts)
res.sendFile(path.join(__dirname, '../client-dist/index.html'))
} else {
res.send('当前页面打开方式不对')
}
} else {
res.clearCookie('_stoken', { path: '/', domain: '.ezijing.com' })
res.sendFile(path.join(__dirname, '../client-dist/index.html'))
}
})
app.use(express.static(path.join(__dirname, '../client-dist')))
app.set('trust proxy', true)
/* 开启服务 */
global.SocketServer = app.listen(app.get('port'), function () {
console.log('Express server 🌎 listening on:http://localhost:' + app.get('port'))
// 发送一个 socket 接口请求
})
apps:
- script: ./server/server.js
name: vue-todo
# 这个 可以配置 多个 ,如:env_test 等。通过 excute中 指令进行区分
env_production:
NODE_ENV: production
# 使用localhost,而不用0.0.0.0。则外网不能直接通过IP访问这个服务。只能使用127.0.0.1访问,再通过nginx反向代理域名可以访问到当前服务
HOST: localhost
PORT: 8888
- excute: pm2 start pm2.yml --env production
const Router = require('express').Router
const router = Router()
const bodyParser = require('body-parser')
const multer = require('multer')
const upload = multer({ dest: 'upload_tmp/' })
const _ck = require('../controller/ckeditorMonitor')
const _op = require('../controller/DirMonitor')
const _websocket = require('../controller/SocketMonitor')
const _proxy = require('../controller/ProxyMonitor')
router.use(bodyParser.json({ limit: '600mb' }))
router.use(bodyParser.urlencoded({ extended: true, limit: '600mb' }))
router.use((req, res, next) => {
/* 设置允许哪些外域访问此服务器。如果你要发送cookies,不要将其赋值为'*' */
res.header('Access-Control-Allow-Origin', req.headers.origin || '*')
/* 设置允许发送cookies。可选值:true,如果不允许就省略此字段 */
res.header('Access-Control-Allow-Credentials', 'true')
if (req.method === 'OPTIONS') {
/* 设置允许那些方法访问此服务器 */
res.header('Access-Control-Allow-Methods', 'PUT, GET, POST, DELETE, OPTIONS')
/* 设置允许那些头文件访问此服务器,数组中可以设置一些自定义首部 */
let strArr = ['token', 'tenant']
for (let k in req.headers) { strArr.push(k) }
res.header('Access-Control-Allow-Headers', strArr.join(', '))
/* 设置单个接口 OPTIONS 的最大有效时长 */
res.header('Access-Control-Max-Age', 600)
/* 以下设置OPTIONS返回并给空内容 */
res.header('Content-Type', 'text/plain charset=UTF-8')
res.header('Content-Length', 0)
res.status(204).end()
return
}
next()
})
/* 统一API接口 */
router.post('/api/ckeditor/img/upload', upload.any(), _ck.ckeditorUpload)
router.post('/api/websocket/send-msg', upload.any(), _websocket.sendMsg)
router.post('/api/dir/send-msg', upload.any(), _op.dirOperate)
router.use('/api/*', upload.any(), _proxy.agentProcessor())
module.exports = router
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论