mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-mobile.git
synced 2025-12-09 02:46:46 +08:00
Merge branch 'master' of codeup.aliyun.com:6265f483e4166464dc2f9c14/boeu/mobile
This commit is contained in:
8
App.vue
8
App.vue
@@ -20,7 +20,13 @@
|
||||
});
|
||||
//获取或加载一次用户信息
|
||||
//console.log('App Launch');
|
||||
this.$store.dispatch('GetUserInfo');
|
||||
//登录页面不需要,此页面用于本地测试
|
||||
//console.log(location.href,'location.href');
|
||||
var href=location.href;
|
||||
if(href.indexOf('/pages/login/login')==-1){
|
||||
this.$store.dispatch('GetUserInfo');
|
||||
}
|
||||
|
||||
},
|
||||
mounted() {
|
||||
},
|
||||
|
||||
65
api/ajax.js
65
api/ajax.js
@@ -1,9 +1,11 @@
|
||||
import config from '@/config/index.js'
|
||||
import {toLogin} from '@/utils/tologin.js'
|
||||
import {getToken,removeToken} from '@/utils/token.js'
|
||||
import qs from 'qs'
|
||||
|
||||
const ReLoginUrl="/login";
|
||||
|
||||
|
||||
const formatUrl=function(url){
|
||||
return url;
|
||||
// if(url.startsWith('http') || url.startsWith('https')){
|
||||
@@ -32,24 +34,28 @@ const formRequest=function(method,url,data){
|
||||
dataType: 'json',
|
||||
header: headers,
|
||||
success:function(rs,statusCode){
|
||||
//toLogin();
|
||||
if(rs.statusCode==200){
|
||||
if(rs.data.status==401 || rs.data.status==402){
|
||||
removeToken();
|
||||
let loginPath=config.loginPath;
|
||||
if(loginPath.startsWith('http')){
|
||||
// #ifdef APP-PLUS
|
||||
plus.runtime.openURL(loginPath) //这里默认使用外部浏览器打开而不是内部web-view组件打开
|
||||
// #endif
|
||||
// #ifdef H5
|
||||
//window.open(loginPath)
|
||||
let returnUrl=window.location.protocol+'//'+window.location.host+config.context;
|
||||
location.href=config.loginPath+"?returnUrl="+encodeURIComponent(returnUrl+'/pages/login/loading');
|
||||
// #endif
|
||||
}else{
|
||||
uni.redirectTo({
|
||||
url:loginPath
|
||||
})
|
||||
}
|
||||
toLogin(reUrl);
|
||||
// let loginPath=config.loginPath;
|
||||
// if(loginPath.startsWith('http')){
|
||||
// // #ifdef APP-PLUS
|
||||
// plus.runtime.openURL(loginPath) //这里默认使用外部浏览器打开而不是内部web-view组件打开
|
||||
// // #endif
|
||||
// // #ifdef H5
|
||||
// //window.open(loginPath)
|
||||
// toLogin();
|
||||
// //let returnUrl=window.location.protocol+'//'+window.location.host+config.context;
|
||||
// //location.href=config.loginPath+"?returnUrl="+encodeURIComponent(returnUrl+'/pages/login/loading');
|
||||
// // #endif
|
||||
// }else{
|
||||
|
||||
// uni.redirectTo({
|
||||
// url:loginPath
|
||||
// })
|
||||
// }
|
||||
}else{
|
||||
resolve(rs.data);
|
||||
}
|
||||
@@ -86,20 +92,21 @@ const jsonRequest=function(method,url,data){
|
||||
if(rs.statusCode==200){
|
||||
if(rs.data.status==401 || rs.data.status==402){
|
||||
removeToken();
|
||||
let loginPath=config.loginPath;
|
||||
if(loginPath.startsWith('http')){
|
||||
// #ifdef APP-PLUS
|
||||
plus.runtime.openURL(loginPath) //这里默认使用外部浏览器打开而不是内部web-view组件打开
|
||||
// #endif
|
||||
// #ifdef H5
|
||||
let returnUrl=window.location.protocol+'//'+window.location.host+config.context;
|
||||
location.href=config.loginPath+"?returnUrl="+encodeURIComponent(returnUrl+'/pages/login/loading');
|
||||
// #endif
|
||||
}else{
|
||||
uni.redirectTo({
|
||||
url:loginPath
|
||||
})
|
||||
}
|
||||
toLogin(reUrl);
|
||||
// let loginPath=config.loginPath;
|
||||
// if(loginPath.startsWith('http')){
|
||||
// // #ifdef APP-PLUS
|
||||
// plus.runtime.openURL(loginPath) //这里默认使用外部浏览器打开而不是内部web-view组件打开
|
||||
// // #endif
|
||||
// // #ifdef H5
|
||||
// let returnUrl=window.location.protocol+'//'+window.location.host+config.context;
|
||||
// location.href=config.loginPath+"?returnUrl="+encodeURIComponent(returnUrl+'/pages/login/loading');
|
||||
// // #endif
|
||||
// }else{
|
||||
// uni.redirectTo({
|
||||
// url:loginPath
|
||||
// })
|
||||
// }
|
||||
}else{
|
||||
resolve(rs.data);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import config from '@/config/index.js'
|
||||
import {toLogin} from '@/utils/tologin.js'
|
||||
import {getToken,removeToken} from '@/utils/token.js'
|
||||
import qs from 'qs'
|
||||
|
||||
@@ -35,21 +36,22 @@ const formRequest=function(method,url,data){
|
||||
if(rs.data.status==6001){
|
||||
//uni.removeStorageSync('userInfo');
|
||||
removeToken();
|
||||
let loginPath=config.loginPath;
|
||||
if(loginPath.startsWith('http')){
|
||||
// #ifdef APP-PLUS
|
||||
plus.runtime.openURL(loginPath) //这里默认使用外部浏览器打开而不是内部web-view组件打开
|
||||
// #endif
|
||||
// #ifdef H5
|
||||
//window.open(loginPath)
|
||||
let returnUrl=window.location.protocol+'//'+window.location.host+config.context;
|
||||
location.href=config.loginPath+"?returnUrl="+encodeURIComponent(returnUrl+'/pages/login/loading');
|
||||
// #endif
|
||||
}else{
|
||||
uni.redirectTo({
|
||||
url:loginPath
|
||||
})
|
||||
}
|
||||
toLogin(reUrl);
|
||||
// let loginPath=config.loginPath;
|
||||
// if(loginPath.startsWith('http')){
|
||||
// // #ifdef APP-PLUS
|
||||
// plus.runtime.openURL(loginPath) //这里默认使用外部浏览器打开而不是内部web-view组件打开
|
||||
// // #endif
|
||||
// // #ifdef H5
|
||||
// //window.open(loginPath)
|
||||
// let returnUrl=window.location.protocol+'//'+window.location.host+config.context;
|
||||
// location.href=config.loginPath+"?returnUrl="+encodeURIComponent(returnUrl+'/pages/login/loading');
|
||||
// // #endif
|
||||
// }else{
|
||||
// uni.redirectTo({
|
||||
// url:loginPath
|
||||
// })
|
||||
// }
|
||||
}else{
|
||||
resolve(rs.data);
|
||||
}
|
||||
@@ -85,21 +87,22 @@ const jsonRequest=function(method,url,data){
|
||||
if(rs.statusCode==200){
|
||||
if(rs.data.status==6001){
|
||||
removeToken();
|
||||
let loginPath=config.loginPath;
|
||||
if(loginPath.startsWith('http')){
|
||||
// #ifdef APP-PLUS
|
||||
plus.runtime.openURL(loginPath) //这里默认使用外部浏览器打开而不是内部web-view组件打开
|
||||
// #endif
|
||||
// #ifdef H5
|
||||
//window.open(loginPath)
|
||||
let returnUrl=window.location.protocol+'//'+window.location.host+config.context;
|
||||
location.href=config.loginPath+"?returnUrl="+encodeURIComponent(returnUrl+'/pages/login/loading');
|
||||
// #endif
|
||||
}else{
|
||||
uni.redirectTo({
|
||||
url:loginPath
|
||||
})
|
||||
}
|
||||
toLogin(reUrl);
|
||||
// let loginPath=config.loginPath;
|
||||
// if(loginPath.startsWith('http')){
|
||||
// // #ifdef APP-PLUS
|
||||
// plus.runtime.openURL(loginPath) //这里默认使用外部浏览器打开而不是内部web-view组件打开
|
||||
// // #endif
|
||||
// // #ifdef H5
|
||||
// //window.open(loginPath)
|
||||
// let returnUrl=window.location.protocol+'//'+window.location.host+config.context;
|
||||
// location.href=config.loginPath+"?returnUrl="+encodeURIComponent(returnUrl+'/pages/login/loading');
|
||||
// // #endif
|
||||
// }else{
|
||||
// uni.redirectTo({
|
||||
// url:loginPath
|
||||
// })
|
||||
// }
|
||||
}else{
|
||||
resolve(rs.data);
|
||||
}
|
||||
|
||||
@@ -55,6 +55,11 @@ const modifyPassword = function(data) {
|
||||
return ajax.postJson('/user/resetPassword',data);
|
||||
}
|
||||
|
||||
/**获取加入的受众的id集合*/
|
||||
const getInAudienceIds = function() {
|
||||
return ajax.post(baseURL,'/audience/audienceByUser',{});
|
||||
}
|
||||
|
||||
export default {
|
||||
userParentOrg,
|
||||
findOrgsByKeyword,
|
||||
@@ -63,5 +68,6 @@ export default {
|
||||
getUserInfoById,
|
||||
getUserCrowds,
|
||||
getOrgHrbpInfo,
|
||||
modifyPassword
|
||||
modifyPassword,
|
||||
getInAudienceIds
|
||||
}
|
||||
|
||||
27
api/manage/manage.js
Normal file
27
api/manage/manage.js
Normal file
@@ -0,0 +1,27 @@
|
||||
/** 管理端接口 **/
|
||||
import ajax from '../unionAjax.js';
|
||||
const baseURL ="/manageApi";
|
||||
|
||||
/**用户的待办任务数量*/
|
||||
const getTaskNum = function(){
|
||||
return ajax.get(baseURL+'/todoTask/queryTodoTaskCounts');
|
||||
}
|
||||
|
||||
/**用户的待办任务数量
|
||||
{
|
||||
"pageNo":1,
|
||||
"pageSize":10,
|
||||
"cmtask_name":"",任务名称
|
||||
"cmtask_code":"",任务Id
|
||||
"cmtask_status":"",状态
|
||||
"cmtask_id":"965341999643234304" 学员id,当前人的
|
||||
}
|
||||
*/
|
||||
const userTaskList = function(data){
|
||||
return ajax.postJson(baseURL+'/todoTask/queryTodoTaskDetail',data);
|
||||
}
|
||||
|
||||
export default {
|
||||
getTaskNum,
|
||||
userTaskList
|
||||
}
|
||||
170
api/unionAjax.js
Normal file
170
api/unionAjax.js
Normal file
@@ -0,0 +1,170 @@
|
||||
import config from '@/config/index.js'
|
||||
import {getToken,removeToken} from '@/utils/token.js'
|
||||
import qs from 'qs'
|
||||
|
||||
const ReLoginUrl="/login";
|
||||
|
||||
const formatUrl=function(url){
|
||||
return url;
|
||||
// if(url.startsWith('http') || url.startsWith('https')){
|
||||
// //console.log(url,"我拿到的url值,我想知道下面有啥方法")
|
||||
// return url;
|
||||
// }else{
|
||||
// return config.oldApiBaseUrl+url
|
||||
// }
|
||||
}
|
||||
const formRequest=function(method,url,data){
|
||||
let token=getToken();
|
||||
if(!token){
|
||||
token='';
|
||||
}
|
||||
let headers={
|
||||
'content-type':'application/x-www-form-urlencoded',
|
||||
'token':token
|
||||
}
|
||||
let reUrl=formatUrl(url);
|
||||
return new Promise(function(resolve, reject){
|
||||
uni.request({
|
||||
url: reUrl,
|
||||
method,
|
||||
data: data,
|
||||
xhrFields: {withCredentials: true},
|
||||
dataType: 'json',
|
||||
header: headers,
|
||||
success:function(rs,statusCode){
|
||||
if(rs.statusCode==200){
|
||||
if(rs.data.status==6001){
|
||||
//uni.removeStorageSync('userInfo');
|
||||
removeToken();
|
||||
let loginPath=config.loginPath;
|
||||
if(loginPath.startsWith('http')){
|
||||
// #ifdef APP-PLUS
|
||||
plus.runtime.openURL(loginPath) //这里默认使用外部浏览器打开而不是内部web-view组件打开
|
||||
// #endif
|
||||
// #ifdef H5
|
||||
//window.open(loginPath)
|
||||
let returnUrl=window.location.protocol+'//'+window.location.host+config.context;
|
||||
location.href=config.loginPath+"?returnUrl="+encodeURIComponent(returnUrl+'/pages/login/loading');
|
||||
// #endif
|
||||
}else{
|
||||
uni.redirectTo({
|
||||
url:loginPath
|
||||
})
|
||||
}
|
||||
}else{
|
||||
resolve(rs.data);
|
||||
}
|
||||
}else{
|
||||
reject("API请求错误");
|
||||
}
|
||||
},
|
||||
fail:function(err){
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
const jsonRequest=function(method,url,data){
|
||||
let token=getToken();
|
||||
if(!token){
|
||||
token='';
|
||||
}
|
||||
let headers={
|
||||
'token':token
|
||||
}
|
||||
let reUrl=formatUrl(url);
|
||||
return new Promise(function(resolve, reject){
|
||||
uni.request({
|
||||
url: reUrl,
|
||||
method,
|
||||
data: data,
|
||||
xhrFields: {withCredentials: true},
|
||||
dataType: 'json',
|
||||
header: headers,
|
||||
success:function(rs,statusCode){
|
||||
if(rs.statusCode==200){
|
||||
if(rs.data.status==6001){
|
||||
removeToken();
|
||||
let loginPath=config.loginPath;
|
||||
if(loginPath.startsWith('http')){
|
||||
// #ifdef APP-PLUS
|
||||
plus.runtime.openURL(loginPath) //这里默认使用外部浏览器打开而不是内部web-view组件打开
|
||||
// #endif
|
||||
// #ifdef H5
|
||||
//window.open(loginPath)
|
||||
let returnUrl=window.location.protocol+'//'+window.location.host+config.context;
|
||||
location.href=config.loginPath+"?returnUrl="+encodeURIComponent(returnUrl+'/pages/login/loading');
|
||||
// #endif
|
||||
}else{
|
||||
uni.redirectTo({
|
||||
url:loginPath
|
||||
})
|
||||
}
|
||||
}else{
|
||||
resolve(rs.data);
|
||||
}
|
||||
}else{
|
||||
reject("API请求错误");
|
||||
}
|
||||
},
|
||||
fail:function(err){
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
//get请求
|
||||
const get=function(url){
|
||||
return formRequest('GET',url,'');
|
||||
}
|
||||
//post请求
|
||||
const post=function(url,data){
|
||||
if(data){
|
||||
data=qs.stringify(data);
|
||||
}
|
||||
return formRequest('POST',url,data);
|
||||
}
|
||||
//postJson请求
|
||||
const postJson=function(url,json){
|
||||
return jsonRequest('POST',url,json);
|
||||
}
|
||||
//put请求
|
||||
const put=function(url,data){
|
||||
if(data){
|
||||
data=qs.stringify(data);
|
||||
}
|
||||
return formRequest('PUT',url,data);
|
||||
}
|
||||
//putJson请求
|
||||
const putJson=function(url,json){
|
||||
return jsonRequest('PUT',url,json);
|
||||
}
|
||||
//patch请求
|
||||
const patch=function(url,data){
|
||||
if(data){
|
||||
data=qs.stringify(data);
|
||||
}
|
||||
return formRequest('PATCH',url,data);
|
||||
}
|
||||
//patchJson请求
|
||||
const patchJson=function(url,json){
|
||||
return jsonRequest('PATCH',url,json);
|
||||
}
|
||||
//delete请求
|
||||
const del=function(url,data){
|
||||
if(data){
|
||||
data=qs.stringify(data);
|
||||
}
|
||||
return formRequest('DELETE',url,data);
|
||||
}
|
||||
export default {
|
||||
get,
|
||||
post,
|
||||
postJson,
|
||||
put,
|
||||
putJson,
|
||||
patch,
|
||||
patchJson,
|
||||
del
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
/**系统的一些全局配置变量*/
|
||||
let apiBaseUrl = '';
|
||||
let oldApiBaseUrl ='/uboeApi';
|
||||
let manageApiBaseUrl ='/manageApi';
|
||||
let statApiBaseUrl='/statApi';
|
||||
let socialApiBaseUrl='/socialApi';
|
||||
let loginPath='/pages/login/login';
|
||||
@@ -18,7 +19,7 @@ if(process.env.NODE_ENV === 'development'){
|
||||
statApiBaseUrl='/statApi';
|
||||
socialApiBaseUrl='/socialApi';
|
||||
fileUrl = 'http://127.0.0.1:9090/cdn/upload';
|
||||
loginPath='/pages/login/login';
|
||||
loginPath='/mobile/pages/login/login';
|
||||
scormPlayer='http://localhost:9083/scorm-player';
|
||||
}else if(process.env.ENV_TYPE === 'preview'){
|
||||
// 预发布环境,当前配置未使用上
|
||||
@@ -53,6 +54,7 @@ if(process.env.NODE_ENV === 'development'){
|
||||
export default {
|
||||
apiBaseUrl:apiBaseUrl,
|
||||
oldApiBaseUrl:oldApiBaseUrl,
|
||||
manageApiBaseUrl:manageApiBaseUrl,
|
||||
statApiBaseUrl:statApiBaseUrl,
|
||||
socialApiBaseUrl:socialApiBaseUrl,
|
||||
context:context,
|
||||
|
||||
@@ -74,7 +74,7 @@
|
||||
"https" : false,
|
||||
"proxy" : {
|
||||
"/systemapi" : {
|
||||
"target" : "http://192.168.0.11:9090",
|
||||
"target" : "http://127.0.0.1:9090",
|
||||
"changeOrigin" : true,
|
||||
"secure" : false,
|
||||
"pathRewrite" : {
|
||||
@@ -91,7 +91,7 @@
|
||||
},
|
||||
"/statApi" : {
|
||||
// 目标代理服务器地址
|
||||
"target" : "http://192.168.0.11:9080",
|
||||
"target" : "http://127.0.0.1:9080",
|
||||
"changeOrigin" : true,
|
||||
"logLevel" : "debug",
|
||||
"secure" : false,
|
||||
@@ -101,7 +101,7 @@
|
||||
},
|
||||
"/socialApi" : {
|
||||
// 目标代理服务器地址
|
||||
"target" : "http://192.168.0.11:9081",
|
||||
"target" : "http://127.0.0.1:9081",
|
||||
"changeOrigin" : true,
|
||||
"logLevel" : "debug",
|
||||
"secure" : false,
|
||||
|
||||
@@ -15,27 +15,41 @@
|
||||
},
|
||||
onLoad(options) {
|
||||
this.toUrl=options.returnUrl;
|
||||
if(this.toUrl){
|
||||
if(this.toUrl=='/'){
|
||||
this.toUrl='';
|
||||
}
|
||||
var pvArray=Object.keys(options);
|
||||
var params='';
|
||||
pvArray.forEach(pv=>{
|
||||
if(pv!='returnUrl'){
|
||||
params+='&'+pv+'='+options[pv];
|
||||
}
|
||||
});
|
||||
this.toUrl=this.toUrl+params;
|
||||
}
|
||||
console.log(this.toUrl,'options.returnUrl');
|
||||
},
|
||||
mounted() {
|
||||
let token=getToken();
|
||||
let $this=this;
|
||||
let urlPre=window.location.protocol+'//'+window.location.host+this.$config.context;
|
||||
//console.log(token,'得到token');
|
||||
if(!token){
|
||||
console.log('未获得token,转向登录');
|
||||
//this.$router.push({ path: process.env.VUE_APP_LOGIN_URL })
|
||||
// #ifdef APP-PLUS
|
||||
plus.runtime.openURL(this.$config.loginPath) //这里默认使用外部浏览器打开而不是内部web-view组件打开
|
||||
// #endif
|
||||
// #ifdef H5
|
||||
//console.log('this.$config.loginPath',this.$config.loginPath);
|
||||
if(this.$config.loginPath.startsWith('http')){
|
||||
let returnUrl=window.location.protocol+'//'+window.location.host+this.$config.context;
|
||||
location.href=this.$config.loginPath+"?returnUrl="+encodeURIComponent(returnUrl+'/pages/login/loading');
|
||||
}else{
|
||||
location.href=this.$config.loginPath;
|
||||
}
|
||||
|
||||
// #endif
|
||||
//this.$router.push({ path: process.env.VUE_APP_LOGIN_URL })
|
||||
// #ifdef APP-PLUS
|
||||
plus.runtime.openURL(this.$config.loginPath) //这里默认使用外部浏览器打开而不是内部web-view组件打开
|
||||
// #endif
|
||||
// #ifdef H5
|
||||
//console.log('this.toUrl',this.toUrl);
|
||||
//console.log('this.$config.loginPath',this.$config.loginPath);
|
||||
if(this.toUrl){
|
||||
location.href=this.$config.loginPath+"?returnUrl="+encodeURIComponent(urlPre+'/pages/login/loading?returnUrl='+encodeURIComponent(this.toUrl));
|
||||
}else{
|
||||
location.href=this.$config.loginPath+"?returnUrl="+encodeURIComponent(urlPre+'/pages/login/loading');
|
||||
}
|
||||
// #endif
|
||||
}else{
|
||||
apiLogin.boeLogin(token).then(rs=>{
|
||||
if(rs.status==200){
|
||||
@@ -49,7 +63,9 @@
|
||||
// })
|
||||
uni.setStorageSync("boe_new_login",1);//记录新登录
|
||||
let openUrl=$this.toUrl;
|
||||
//http://localhost:8081/mobile/pages/login/loading?returnUrl=/pages/study/courseStudy?id=1028700304503054336
|
||||
if(openUrl){
|
||||
//如果openUrl的页面不存在,或不对,就会出现跳转不动的问题,这个情况
|
||||
if(openUrl.startsWith('http')){
|
||||
location.href=openUrl
|
||||
}else{
|
||||
@@ -74,8 +90,11 @@
|
||||
plus.runtime.openURL(this.$config.loginPath) //这里默认使用外部浏览器打开而不是内部web-view组件打开
|
||||
// #endif
|
||||
// #ifdef H5
|
||||
location.href=this.$config.loginPath;
|
||||
//window.open(this.$config.loginPath)
|
||||
if(this.toUrl){
|
||||
location.href=this.$config.loginPath+"?returnUrl="+encodeURIComponent(urlPre+'/pages/login/loading?returnUrl='+encodeURIComponent(this.toUrl));
|
||||
}else{
|
||||
location.href=this.$config.loginPath+"?returnUrl="+encodeURIComponent(urlPre+'/pages/login/loading');
|
||||
}
|
||||
// #endif
|
||||
}
|
||||
}).catch(err=>{
|
||||
|
||||
@@ -33,14 +33,31 @@
|
||||
loginName: '',//10181457
|
||||
password: '',//666666
|
||||
loading:false,
|
||||
redirect: undefined
|
||||
redirect: ''
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
console.log(options,'options');
|
||||
var pvArray=Object.keys(options);
|
||||
this.redirect=options.returnUrl;
|
||||
var params='';
|
||||
pvArray.forEach(pv=>{
|
||||
if(pv!='returnUrl'){
|
||||
params+='&'+pv+'='+options[pv];
|
||||
}
|
||||
console.log(pv,'=',options[pv]);
|
||||
});
|
||||
//if(params){
|
||||
console.log(this.redirect+params)
|
||||
//}
|
||||
|
||||
|
||||
},
|
||||
mounted() {
|
||||
//对cookies进行操作,这里是写
|
||||
//document.cookie = "mytest=qweqwe131231; path=/; max-age=" + 30*24*60*60;
|
||||
console.log('process.env.NODE_ENV',process.env.NODE_ENV);
|
||||
console.log('process.env.ENV_TYPE',process.env.ENV_TYPE);
|
||||
//console.log('process.env.NODE_ENV',process.env.NODE_ENV);
|
||||
//console.log('process.env.ENV_TYPE',process.env.ENV_TYPE);
|
||||
},
|
||||
methods: {
|
||||
submitLogin(){
|
||||
@@ -63,9 +80,14 @@
|
||||
// uni.switchTab({
|
||||
// url:'/pages/index/index'
|
||||
// })
|
||||
uni.switchTab({
|
||||
url:'/pages/index/index'
|
||||
})
|
||||
if($this.redirect){
|
||||
location.href=$this.redirect;
|
||||
}else{
|
||||
uni.switchTab({
|
||||
url:'/pages/index/index'
|
||||
})
|
||||
}
|
||||
|
||||
});
|
||||
}else{
|
||||
console.log(rs.error);
|
||||
|
||||
@@ -84,7 +84,7 @@
|
||||
</view>
|
||||
<div v-if="curContent.contentType == 50" style="min-height: 500px;">
|
||||
<!--因为web-view 动态切换地址不好用,所以这里先使用iframe-->
|
||||
<iframe v-if="scormUrl" :src="scormUrl" frameborder="0" scrolling="no" border="0px" style="width:100%;height:500px;border:0px;"></iframe>
|
||||
<iframe id="iframe-scorm" v-if="scormUrl" :src="scormUrl" @load="iframeScormLoad()" frameborder="0" scrolling="no" border="0px" style="width:100%;min-height:500px;border:0px;"></iframe>
|
||||
</div>
|
||||
<view v-if="curContent.contentType==52">
|
||||
<!--外连接-->
|
||||
@@ -577,6 +577,26 @@
|
||||
window.clearTimeout(this.handleTimeout);
|
||||
}
|
||||
},
|
||||
iframeScormLoad(){
|
||||
setTimeout(function(){
|
||||
var scormIframe=document.getElementById('iframe-scorm');
|
||||
if (scormIframe) {
|
||||
let iframeWin = scormIframe.contentWindow;
|
||||
let iframeDoc = scormIframe.contentDocument || scormIframe.document;
|
||||
|
||||
let cHeight = Math.max(iframeDoc.body.clientHeight,iframeDoc.documentElement.clientHeight);
|
||||
let sHeight = Math.max(iframeDoc.body. scrollHeight,iframeDoc.documentElement.scrollHeight);
|
||||
let winHeight = iframeWin.document.documentElement.scrollHeight || iframeWin.document.body.scrollHeight;
|
||||
|
||||
let lheight = Math.max(cHeight, sHeight);
|
||||
let finalHeight = Math.max(lheight, winHeight );
|
||||
|
||||
scormIframe.height =finalHeight;
|
||||
console.log('scormIframe.height',scormIframe.height);
|
||||
}
|
||||
},1500);
|
||||
|
||||
},
|
||||
loadMyScore(){
|
||||
apiCourseGrade.score({courseId:this.courseId}).then(rs=>{
|
||||
if(rs.status==200){
|
||||
@@ -918,13 +938,20 @@
|
||||
if(con.contentType>20){
|
||||
let $this=this;
|
||||
//用户的学习时长,音视频课程学习,单独的处理,不再追加学习时长
|
||||
this.isAppendTime = false;
|
||||
this.appendStudyOtherHandle = setTimeout(function() {
|
||||
this.isAppendTime = false;
|
||||
this.appendStudyOtherHandle = setTimeout(function() {
|
||||
$this.appendStudyOtherTime();
|
||||
}, 1000*60*2); //非音视频课程学习,2分钟后记录,因为一次记录是60秒
|
||||
//this.appendStudyTime();
|
||||
}, 1000*60*2); //非音视频课程学习,2分钟后记录,因为一次记录是60秒
|
||||
//this.appendStudyTime();
|
||||
//非视频,音频的5秒后学习完成
|
||||
this.handleTimeout = setTimeout(function(){$this.saveStudyInfo();},5000);//5秒后记录学习完成
|
||||
if(con.contentType!=50){
|
||||
this.handleTimeout = setTimeout(function(){$this.saveStudyInfo();},5000);//5秒后记录学习完成
|
||||
}else{
|
||||
//scorm课件不记录完成情况,由播放回调记录完成情况
|
||||
//当前先保存学习记录,未学习状态
|
||||
this.saveScormStudy();
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
followUser(tea){
|
||||
@@ -1522,6 +1549,34 @@
|
||||
})
|
||||
}
|
||||
},
|
||||
saveScormStudy() {
|
||||
//只记录SCORM课件的学习
|
||||
if(this.curContent.contentType!=50){
|
||||
return;
|
||||
}
|
||||
if(this.curContent.status==9){
|
||||
//已学习完的,不用再添加
|
||||
return;
|
||||
}
|
||||
let params ={
|
||||
studyId: this.studyId,//学习id,
|
||||
courseId: this.courseId,//课程id,
|
||||
contentId: this.curContent.id,//内容id,
|
||||
contentType: this.curContent.contentType,
|
||||
contentName: this.curContent.contentName,//内容名称
|
||||
progress: 1,
|
||||
status: 2,
|
||||
contentTotal:this.totalContent
|
||||
}
|
||||
apiCourseStudy.studyContent(params).then(res=>{
|
||||
if(res.status == 200) {
|
||||
this.curContent.status=2;//完成
|
||||
this.curContent.studyItemId=res.result;//学习记录id
|
||||
}else{
|
||||
console.log('记录学习失败:'+res.message+','+res.error);
|
||||
}
|
||||
})
|
||||
},
|
||||
//还需要记录播放时间
|
||||
saveStudyInfo() { //记录课件学习信息
|
||||
if(this.curContent.contentType>=60){
|
||||
|
||||
33
utils/tologin.js
Normal file
33
utils/tologin.js
Normal file
@@ -0,0 +1,33 @@
|
||||
import config from '@/config/index.js'
|
||||
|
||||
export function toLogin(ajaxUrl) {
|
||||
let pageUrl=location.href;
|
||||
console.log(pageUrl,'pageUrl');
|
||||
let urlPre=window.location.protocol+'//'+window.location.host;
|
||||
console.log(urlPre,'urlPre');
|
||||
let urlContext=config.context;
|
||||
console.log(urlContext,'urlContext');
|
||||
let returnPage=pageUrl.substring((urlPre+urlContext).length);
|
||||
console.log(returnPage,'returnPage');
|
||||
console.log(config.loginPath+"?returnUrl="+urlPre+urlContext+'/pages/login/loading?returnUrl='+returnPage,'生成的url');
|
||||
|
||||
if(ajaxUrl && ajaxUrl.indexOf('/xboe/portal/init')>-1){
|
||||
return;
|
||||
}
|
||||
//http://localhost:8081/mobile/pages/study/courseStudy?id=1028700304503054336
|
||||
if(pageUrl.indexOf('returnUrl')>-1){
|
||||
console.log(pageUrl,'to pageUrl')
|
||||
//location.href=config.loginPath+"?returnUrl="+pageUrl;
|
||||
// uni.redirectTo({
|
||||
// url:config.loginPath
|
||||
// })
|
||||
}else{
|
||||
if(process.env.NODE_ENV === 'development'){
|
||||
location.href=config.loginPath+"?returnUrl="+encodeURIComponent(returnPage);
|
||||
}else{
|
||||
location.href=config.loginPath+"?returnUrl="+encodeURIComponent(urlPre+urlContext+'/pages/login/loading?returnUrl='+encodeURIComponent(returnPage));
|
||||
}
|
||||
//location.href=config.loginPath
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import config from '../config/index.js'
|
||||
import {toLogin} from '@/utils/tologin.js'
|
||||
import {getToken,removeToken} from '@/utils/token.js'
|
||||
import qs from 'qs'
|
||||
|
||||
@@ -34,21 +35,22 @@ const formRequest=function(method,url,data){
|
||||
if(rs.statusCode==200){
|
||||
if(rs.data.status==401 || rs.data.status==402){
|
||||
removeToken();
|
||||
let loginPath=config.loginPath;
|
||||
if(loginPath.startsWith('http')){
|
||||
// #ifdef APP-PLUS
|
||||
plus.runtime.openURL(loginPath) //这里默认使用外部浏览器打开而不是内部web-view组件打开
|
||||
// #endif
|
||||
// #ifdef H5
|
||||
//window.open(loginPath)
|
||||
let returnUrl=window.location.protocol+'//'+window.location.host+config.context;
|
||||
location.href=config.loginPath+"?returnUrl="+encodeURIComponent(returnUrl+'/pages/login/loading');
|
||||
// #endif
|
||||
}else{
|
||||
uni.redirectTo({
|
||||
url:loginPath
|
||||
})
|
||||
}
|
||||
toLogin(reUrl);
|
||||
// let loginPath=config.loginPath;
|
||||
// if(loginPath.startsWith('http')){
|
||||
// // #ifdef APP-PLUS
|
||||
// plus.runtime.openURL(loginPath) //这里默认使用外部浏览器打开而不是内部web-view组件打开
|
||||
// // #endif
|
||||
// // #ifdef H5
|
||||
// //window.open(loginPath)
|
||||
// let returnUrl=window.location.protocol+'//'+window.location.host+config.context;
|
||||
// location.href=config.loginPath+"?returnUrl="+encodeURIComponent(returnUrl+'/pages/login/loading');
|
||||
// // #endif
|
||||
// }else{
|
||||
// uni.redirectTo({
|
||||
// url:loginPath
|
||||
// })
|
||||
// }
|
||||
}else{
|
||||
resolve(rs.data);
|
||||
}
|
||||
@@ -85,21 +87,22 @@ const jsonRequest=function(method,url,data){
|
||||
if(rs.statusCode==200){
|
||||
if(rs.data.status==401 || rs.data.status==402){
|
||||
removeToken();
|
||||
let loginPath=config.loginPath;
|
||||
if(loginPath.startsWith('http')){
|
||||
// #ifdef APP-PLUS
|
||||
plus.runtime.openURL(loginPath) //这里默认使用外部浏览器打开而不是内部web-view组件打开
|
||||
// #endif
|
||||
// #ifdef H5
|
||||
//window.open(loginPath)
|
||||
let returnUrl=window.location.protocol+'//'+window.location.host+config.context;
|
||||
location.href=config.loginPath+"?returnUrl="+encodeURIComponent(returnUrl+'/pages/login/loading');
|
||||
// #endif
|
||||
}else{
|
||||
uni.redirectTo({
|
||||
url:loginPath
|
||||
})
|
||||
}
|
||||
toLogin(reUrl);
|
||||
// let loginPath=config.loginPath;
|
||||
// if(loginPath.startsWith('http')){
|
||||
// // #ifdef APP-PLUS
|
||||
// plus.runtime.openURL(loginPath) //这里默认使用外部浏览器打开而不是内部web-view组件打开
|
||||
// // #endif
|
||||
// // #ifdef H5
|
||||
// //window.open(loginPath)
|
||||
// let returnUrl=window.location.protocol+'//'+window.location.host+config.context;
|
||||
// location.href=config.loginPath+"?returnUrl="+encodeURIComponent(returnUrl+'/pages/login/loading');
|
||||
// // #endif
|
||||
// }else{
|
||||
// uni.redirectTo({
|
||||
// url:loginPath
|
||||
// })
|
||||
// }
|
||||
}else{
|
||||
resolve(rs.data);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user