mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-mobile.git
synced 2025-12-11 03:46:47 +08:00
我的任务对接
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/** 管理端接口 **/
|
/** 管理端接口 **/
|
||||||
import ajax from '../unionAjax.js';
|
import ajax from './manageAjax.js';
|
||||||
const baseURL ="/manageApi";
|
const baseURL ="/manageApi";
|
||||||
|
|
||||||
/**用户的待办任务数量*/
|
/**用户的待办任务数量*/
|
||||||
|
|||||||
158
api/manage/manageAjax.js
Normal file
158
api/manage/manageAjax.js
Normal file
@@ -0,0 +1,158 @@
|
|||||||
|
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')){
|
||||||
|
// //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.code==1000){
|
||||||
|
//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){
|
||||||
|
//console.log(rs.data,'rs.data')
|
||||||
|
if(rs.data.code==1000){
|
||||||
|
removeToken();
|
||||||
|
toLogin(reUrl);
|
||||||
|
}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,4 +1,5 @@
|
|||||||
import config from '@/config/index.js'
|
import config from '@/config/index.js'
|
||||||
|
import {toLogin} from '@/utils/tologin.js'
|
||||||
import {getToken,removeToken} from '@/utils/token.js'
|
import {getToken,removeToken} from '@/utils/token.js'
|
||||||
import qs from 'qs'
|
import qs from 'qs'
|
||||||
|
|
||||||
@@ -36,21 +37,7 @@ const formRequest=function(method,url,data){
|
|||||||
if(rs.data.status==6001){
|
if(rs.data.status==6001){
|
||||||
//uni.removeStorageSync('userInfo');
|
//uni.removeStorageSync('userInfo');
|
||||||
removeToken();
|
removeToken();
|
||||||
let loginPath=config.loginPath;
|
toLogin(reUrl);
|
||||||
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{
|
}else{
|
||||||
resolve(rs.data);
|
resolve(rs.data);
|
||||||
}
|
}
|
||||||
@@ -86,21 +73,7 @@ const jsonRequest=function(method,url,data){
|
|||||||
if(rs.statusCode==200){
|
if(rs.statusCode==200){
|
||||||
if(rs.data.status==6001){
|
if(rs.data.status==6001){
|
||||||
removeToken();
|
removeToken();
|
||||||
let loginPath=config.loginPath;
|
toLogin(reUrl);
|
||||||
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{
|
}else{
|
||||||
resolve(rs.data);
|
resolve(rs.data);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,8 +81,16 @@
|
|||||||
"^/systemapi" : ""
|
"^/systemapi" : ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/manageApi" : {
|
||||||
|
"target" : "https://u-pre.boe.com",
|
||||||
|
"changeOrigin" : true,
|
||||||
|
"secure" : false,
|
||||||
|
"pathRewrite" : {
|
||||||
|
"^/manageApi" : "/manageApi"
|
||||||
|
}
|
||||||
|
},
|
||||||
"/uboeApi" : {
|
"/uboeApi" : {
|
||||||
"target" : "http://u-pre.boe.com",
|
"target" : "https://u-pre.boe.com",
|
||||||
"changeOrigin" : true,
|
"changeOrigin" : true,
|
||||||
"secure" : false,
|
"secure" : false,
|
||||||
"pathRewrite" : {
|
"pathRewrite" : {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
"pages": [
|
"pages": [
|
||||||
{"path" : "pages/login/loading","style" : { "navigationBarTitleText": "正在加载","enablePullDownRefresh": false}},
|
{"path" : "pages/login/loading","style" : { "navigationBarTitleText": "正在加载","enablePullDownRefresh": false}},
|
||||||
{"path" : "pages/index/index","style": {"navigationBarTitleText": "首页","app-plus":{"titleNView":false}}},
|
{"path" : "pages/index/index","style": {"navigationBarTitleText": "首页","app-plus":{"titleNView":false}}},
|
||||||
|
{"path" : "pages/forward","style": {"navigationBarTitleText": "正在打开","app-plus":{"titleNView":false}}},
|
||||||
{"path" : "pages/resource/index","style": {"navigationBarTitleText": "资源","enablePullDownRefresh": false,"onReachBottomDistance": 50 }},
|
{"path" : "pages/resource/index","style": {"navigationBarTitleText": "资源","enablePullDownRefresh": false,"onReachBottomDistance": 50 }},
|
||||||
{"path" : "pages/resource/search","style": {"navigationBarTitleText": "资源搜索"}},
|
{"path" : "pages/resource/search","style": {"navigationBarTitleText": "资源搜索"}},
|
||||||
{"path" : "pages/resource/articeDetail","style": {"navigationBarTitleText": "文章详细"}},
|
{"path" : "pages/resource/articeDetail","style": {"navigationBarTitleText": "文章详细"}},
|
||||||
|
|||||||
47
pages/forward.vue
Normal file
47
pages/forward.vue
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<template>
|
||||||
|
<!-- 学习任务详情 -->
|
||||||
|
<view class="loaddetail-box">
|
||||||
|
<!-- <page-title :showBack="true">详细信息</page-title> -->
|
||||||
|
<web-view v-if="innerUrl!=''" :src="innerUrl" style="width: 100%;height: 100%;"></web-view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data (){
|
||||||
|
return{
|
||||||
|
innerUrl:'',
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onLoad(options) {
|
||||||
|
console.log(options,'options')
|
||||||
|
let params=options.params;
|
||||||
|
let to=options.to;
|
||||||
|
let urlPre=window.location.protocol+'//'+window.location.host;
|
||||||
|
this.innerUrl=urlPre+to
|
||||||
|
if(params){
|
||||||
|
this.innerUrl=this.innerUrl+'?'+params;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted(){
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
body{
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
uni-page-body{
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
.loaddetail-box{
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
@@ -260,6 +260,7 @@
|
|||||||
import apicourseStudy from "../../api/modules/courseStudy.js"
|
import apicourseStudy from "../../api/modules/courseStudy.js"
|
||||||
import apiCoursePortal from '@/api/modules/coursePortal.js'
|
import apiCoursePortal from '@/api/modules/coursePortal.js'
|
||||||
import apiBoeCourse from '@/api/boe/course.js';
|
import apiBoeCourse from '@/api/boe/course.js';
|
||||||
|
import apiManage from '@/api/manage/manage.js';
|
||||||
import { formatDate } from '@/utils/tools.js';
|
import { formatDate } from '@/utils/tools.js';
|
||||||
import apiUser from '@/api/system/user.js'
|
import apiUser from '@/api/system/user.js'
|
||||||
import { mapGetters } from 'vuex'
|
import { mapGetters } from 'vuex'
|
||||||
@@ -413,7 +414,7 @@
|
|||||||
let $this = this;
|
let $this = this;
|
||||||
if (this.tabIndex == 0) {
|
if (this.tabIndex == 0) {
|
||||||
if (this.taskHasMore) {
|
if (this.taskHasMore) {
|
||||||
this.taskPageSize++;
|
this.taskPageIndex++;
|
||||||
this.loadBoeData(false);
|
this.loadBoeData(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -585,10 +586,20 @@
|
|||||||
},
|
},
|
||||||
// 学习任务跳转详情
|
// 学习任务跳转详情
|
||||||
loaddetail(task) {
|
loaddetail(task) {
|
||||||
|
// uni.navigateTo({
|
||||||
|
// url: '/pages/study/loaddetail?id=' + task.cmtask_id
|
||||||
|
// });
|
||||||
|
let taskUrl='';
|
||||||
|
if(task.cmtask_type==1){ //学习路径图
|
||||||
|
let params=encodeURIComponent('routerId='+task.cmtask_id);
|
||||||
|
taskUrl='/pages/forward?to=/student-h5/pathdetails¶ms='+params;
|
||||||
|
}else if(task.cmtask_type==2){ //学习项目
|
||||||
|
let params=encodeURIComponent('projectId='+task.cmtask_id);
|
||||||
|
taskUrl='/pages/forward?to=/student-h5/projectdetails¶ms='+params;
|
||||||
|
}
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: '/pages/study/loaddetail?id=' + task.cmtask_id
|
url: taskUrl
|
||||||
});
|
});
|
||||||
// window.open(`/loaddetail?id=${task.cmtask_id}`)
|
|
||||||
},
|
},
|
||||||
|
|
||||||
loadBoeData(flag) {
|
loadBoeData(flag) {
|
||||||
@@ -605,29 +616,58 @@
|
|||||||
if (this.cmtask_name) {
|
if (this.cmtask_name) {
|
||||||
params.cmtask_name = this.keyWord;
|
params.cmtask_name = this.keyWord;
|
||||||
}
|
}
|
||||||
apiBoeCourse.cmtaskList(params).then(res => {
|
|
||||||
this.taskCount = res.result.count;
|
apiManage.userTaskList(params).then(res => {
|
||||||
res.result.list.forEach(item => {
|
if(res.code==200){
|
||||||
let time = this.formatDate(item.created_at * 1000);
|
this.taskCount = parseInt(res.data.total);
|
||||||
item.created_at = time.split(' ')[0];
|
this.couresList.push(...res.data.records);
|
||||||
});
|
if (this.taskCount > this.taskPageIndex * this.taskPageSize) {
|
||||||
this.couresList.push(...res.result.list);
|
this.taskHasMore = true;
|
||||||
if (this.taskCount > this.taskPageIndex * this.taskPageSize) {
|
} else {
|
||||||
this.taskHasMore = true;
|
this.taskHasMore = false;
|
||||||
} else {
|
}
|
||||||
this.taskHasMore = false;
|
if (this.isOne) {
|
||||||
|
this.value = this.taskCount;
|
||||||
|
}
|
||||||
|
if (this.isOne && res.result.records.length == 0) {
|
||||||
|
this.tabIndex = 1;
|
||||||
|
}
|
||||||
|
this.isOne = false;
|
||||||
|
}else{
|
||||||
|
uni.showToast({
|
||||||
|
title: '获取任务失败',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (this.isOne) {
|
|
||||||
this.value = res.result.count;
|
|
||||||
}
|
|
||||||
if (this.isOne && res.result.list.length == 0) {
|
|
||||||
this.tabIndex = 1;
|
|
||||||
}
|
|
||||||
this.isOne = false;
|
|
||||||
|
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// apiBoeCourse.cmtaskList(params).then(res => {
|
||||||
|
// this.taskCount = res.result.count;
|
||||||
|
// res.result.list.forEach(item => {
|
||||||
|
// let time = this.formatDate(item.created_at * 1000);
|
||||||
|
// item.created_at = time.split(' ')[0];
|
||||||
|
// });
|
||||||
|
// this.couresList.push(...res.result.list);
|
||||||
|
// if (this.taskCount > this.taskPageIndex * this.taskPageSize) {
|
||||||
|
// this.taskHasMore = true;
|
||||||
|
// } else {
|
||||||
|
// this.taskHasMore = false;
|
||||||
|
// }
|
||||||
|
// if (this.isOne) {
|
||||||
|
// this.value = res.result.count;
|
||||||
|
// }
|
||||||
|
// if (this.isOne && res.result.list.length == 0) {
|
||||||
|
// this.tabIndex = 1;
|
||||||
|
// }
|
||||||
|
// this.isOne = false;
|
||||||
|
|
||||||
|
// }).catch(err => {
|
||||||
|
|
||||||
|
// })
|
||||||
},
|
},
|
||||||
loadUserInfos(list, userIds) {
|
loadUserInfos(list, userIds) {
|
||||||
const noReapetIds = [...new Set(userIds)];
|
const noReapetIds = [...new Set(userIds)];
|
||||||
|
|||||||
Reference in New Issue
Block a user