Files
learning-system-mobile/pages/my/myShares.vue
2022-05-30 23:03:25 +08:00

944 lines
23 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<view>
<page-title :showBack="true">我的分享</page-title>
<view class="top-tab">
<view class="top-bar-center">
<view class="top-bar-tab" @click="clicktab(1)" :class="{ active: conType == 1 }">课程</view>
<view class="top-bar-tab" @click="clicktab(2)" :class="{ active: conType == 2 }">文章</view>
<view class="top-bar-tab" @click="clicktab(4)" :class="{ active: conType == 4 }">问答</view>
</view>
</view>
<view class="top-content-options">
<!-- 是否已查看 -->
<view style="margin-right: 20upx;">
<!-- <u-picker :show="statusSelectShow" @cancel="statusSelectShow = false" @confirm="chooseStatus" :columns="selectData" keyName="label"></u-picker> -->
<text class="textbtn" @click="statusSelectShow = !statusSelectShow">状态</text>
</view>
<!--课程-->
<view class="input-search">
<u-search
v-model="query.keyword"
placeholder="标题搜索"
@search="findData(true)"
@clear="findData(true)"
:clearabled="true"
:showAction="false"
shape="square"
bgColor="#ffffff"
>
<!-- <template slot="suffix">
<u-icon @click="findData(true)" name="search"></u-icon>
</template> -->
</u-search>
</view>
</view>
<view class="sea-show" v-show="statusSelectShow">
<text @click="chooseStatus(null)" :class="[isRead == null?'sea-active':'','sea-index' ]">全部</text>
<text @click="chooseStatus(true)" :class="[isRead == true?'sea-active':'','sea-index' ]">已查看</text>
<text @click="chooseStatus(false)" :class="[isRead == false?'sea-active':'','sea-index' ]">未查看</text>
</view>
<view v-if="conType == 1">
<view v-for="(item, idx) in courseList" :key="idx" class="course_box">
<view class="course" @click="toCourseDetail(item)">
<view class="course-img"><course-image :course="item" width="262upx" height="147upx"></course-image></view>
<view class="course-content">
<view class="coursetit-sl"><span class="common" :class="contentTypeFilter(item.contentType).class">{{ contentTypeFilter(item.contentType).text }}</span><span style="font-weight: bold; margin-top: 10rpx;" v-html="$keywordActiveShow(item.title,query.keyword)"></span></view>
<view class="course-con_source">分享日期{{ item.time }}</view>
<view class="course-author">
我分享给{{ item.toAname }}
</view>
</view>
</view>
<view class="rowbtn-right">
<view class="rowbtn rowbtn-info" v-if="!item.isRead">
<!-- ../../static/images/icon/noread.png -->
<u-icon name="eye-off" color="#767676" labelColor="#767676" label="未查看" size="16" labelSize="12"></u-icon>
</view>
<view class="rowbtn rowbtn-info" v-else>
<!-- ../../static/images/icon/isread.png -->
<u-icon name="eye-fill" color="#767676" labelColor="#767676" label="已查看" size="16" labelSize="12"></u-icon>
</view>
<view class="rowbtn rowbtn-primary" v-if="!item.isRead" @click="withdraw(item)">
<!-- ../../static/images/icon/withdraw.png -->
<u-icon name="reload" color="#3E7FFF" labelColor="#3E7FFF" label="撤回" size="16" labelSize="12"></u-icon>
</view>
</view>
<!-- <text class="isread" v-if="!item.isRead"> -->
<!-- <image style="height: 26rpx;" src="../../static/images/icon/noread.png" mode=""></image>
未查看</text> -->
<!-- </text> -->
<!-- <text class="isread" v-else>
<image style="margin-top: -5rpx;" src="../../static/images/icon/isread.png" mode=""></image>
已查看</text> -->
<!-- <text class="with" @click="withdraw(item)" v-if="!item.isRead" >
<image style="margin-left: 15rpx;" src="../../static/images/icon/withdraw.png" mode=""></image>
撤回</text> -->
<!-- <view><interact-bar :data="item" :shares="false" :views="false"></interact-bar></view> -->
</view>
</view>
<view v-if="conType == 2">
<view class="article_one" v-for="(item, idx) in articleList" :key="idx" >
<view>
<!-- <view class="art_type">
<text v-if="item.isRead">
[已查看]
</text>
<text v-else>
[未查看]
</text>
</view> -->
<view @click="toArticleDetail(item)" class="articla_tit" >
<text v-if="item.isRead" style="color:#3e7fff">[已查看]</text>
<text v-else style="color:#FF3E3E">[未查看]</text>
<text v-html="$keywordActiveShow(item.title,query.keyword)"></text>
</view>
<text class="articla_text" @click="toArticleDetail(item)" v-html="$keywordActiveShow(item.summary,query.keyword)"></text>
<author-info :avatar="item.avatar" :name="item.sysCreateBy" :info="item.orgInfo" :sex="item.sex"></author-info>
<view class="artical_text_bottom">
<view class="" style="margin-top: 18upx;">
<text style="font-size: 26rpx;color: #9d9d9d;">{{item.time}}</text>
<text style="font-size: 26rpx;color: #666666;margin-right: 35upx;">我分享给{{item.toAname}}</text>
</view>
<view class="rowbtn-right">
<view class="rowbtn rowbtn-primary" v-if="!item.isRead" @click="withdraw(item)">
<!-- ../../static/images/icon/withdraw.png -->
<u-icon name="reload" color="#3E7FFF" labelColor="#3E7FFF" label="撤回" size="16" labelSize="12"></u-icon>
</view>
</view>
</view>
<!-- <view style="margin-top: 8px;"><interact-bar :data="item" :shares="false"></interact-bar></view> -->
<!-- <text class="isread" v-if="item.isRead">
<image style="height: 26rpx;" src="../../static/images/icon/noread.png" mode=""></image>
未查看</text>
<text class="isread" v-else>
<image style="margin-top: -5rpx;" src="../../static/images/icon/isread.png" mode=""></image>
已查看</text> -->
<!-- <text class="with" @click="withdraw(item)" v-if="!item.isRead">
<image style="margin-left: 15rpx;" src="../../static/images/icon/withdraw.png" mode=""></image>
撤回</text> -->
</view>
</view>
</view>
<view v-if="conType == 4">
<view v-for="(item, idx) in qaList" :key="idx" class="qa" >
<view class="qa-body" @click="toQaDetail(item.question)">
<text v-if="item.question.isResolve" style="color:#08A890">[已解决]</text>
<text v-else style="color:#588afc">
[待解决]
</text>
<text v-html="$keywordActiveShow(item.question.title,query.keyword)"></text>
</view>
<view class="qa-bottom" @click="toQaDetail(item.question)" v-html="$keywordActiveShow(item.question.content,query.keyword)"></view>
<author-info :avatar="item.avatar" :name="item.question.sysCreateBy" :info="item.orgInfo" :sex="item.sex"></author-info>
<view class="qa-answers" style=" " v-if="item.question.isResolve">
<!-- <text></text> -->
<!-- <view class="answer-one">
</view> -->
<view class="answer-two" @click="toQaDetail(item.question)" style="word-break:break-all;
width: 100%;
overflow: hidden;
text-overflow: ellipsis;
-webkit-box-orient: vertical;
display: -webkit-box;-webkit-line-clamp: 2;
line-height: 35rpx;
overflow: hidden;text-overflow: ellipsis;
font-size: 32rpx;
">
<text style="color: #FFB30F;">最佳回答:</text>{{ item.question.bestAnswer }}
</view>
<!-- <text class="answers_text"></text> -->
</view>
<text @click="toQaDetail(item.question)" class="qa-text">{{item.time}}</text>
<text style="font-size: 26rpx;color: #666666" @click="toQaDetail(item.question)">我分享给{{item.toAname}}</text>
<!-- <view class="qa-bar"><interact-bar :data="item.question" :praises="false" :views="false"></interact-bar></view> -->
<!-- <view class="">
<text class="isread" v-if="item.isRead">
<image style="height: 26rpx;" src="../../static/images/icon/noread.png" mode=""></image>
已查看</text>
<text class="isread" v-else>
<image style="margin-top: -5rpx;" src="../../static/images/icon/isread.png" mode=""></image>
未查看</text>
<text class="with" @click="withdraw(item)" v-if="!item.isRead">
<image style="margin-left: 15rpx;" src="../../static/images/icon/withdraw.png" mode=""></image>
撤回</text>
</view> -->
<view class="rowbtn-right">
<view class="rowbtn rowbtn-info" v-if="item.isRead">
<u-icon name="eye-off" color="#767676" labelColor="#767676" label="已查看" size="16" labelSize="12"></u-icon>
</view>
<view class="rowbtn rowbtn-info" v-else>
<u-icon name="eye-fill" color="#767676" labelColor="#767676" label="未查看" size="16" labelSize="12"></u-icon>
</view>
<view class="rowbtn rowbtn-primary" v-if="!item.isRead" @click="withdraw(item)">
<u-icon name="reload" color="#3E7FFF" labelColor="#3E7FFF" label="撤回" size="16" labelSize="12"></u-icon>
</view>
</view>
</view>
</view>
<view v-show="count>query.pageSize"><uni-load-more :status="loadStatus"></uni-load-more></view>
</view>
</template>
<script>
import { mapState, mapActions } from 'vuex';
import apiShares from '@/api/modules/shares.js';
import apiUser from '@/api/system/user.js';
export default {
computed: mapState(['resourceTab']),
data() {
return {
isRead:null,
statusBtn: '全部',
selectData: [
[
{ label: '全部', value: null },
{ label: '已查看', value: true },
{ label: '未查看', value: false },
]
],
statusSelectShow: false,
conType: 1,
query:{
pageIndex: 1,
pageSize: 4,
keyword:'',
isRead:null
},
courseList:[],
articleList:[],
qaList:[],
count:0,
loadStatus: 'more', //more,loading,noMore, 应该划分出三个
};
},
onLoad: function(options) {
this.findData(true);
},
onPullDownRefresh() {
this.onReachBottom();
},
async onReachBottom() {
if(this.conType==1){
if(this.courseList.length<this.count){
this.loadStatus='loading';
this.query.pageIndex++;
await this.findData(false);
this.loadStatus='more';
}else{
this.loadStatus='noMore';
}
}
if(this.conType==2){
if(this.articleList.length<this.count){
this.loadStatus='loading';
this.query.pageIndex++;
await this.findData(false);
this.loadStatus='more';
}else{
this.loadStatus='noMore';
}
}
if(this.conType==4){
if(this.qaList.length<this.count){
this.loadStatus='loading';
this.query.pageIndex++;
await this.findData(false);
this.loadStatus='more';
}else{
this.loadStatus='noMore';
}
}
},
methods: {
//点击切换类别时请求数据
clicktab(val) {
this.conType=val;
this.query.pageIndex=1;
this.query.keyword='';
this.isRead = null;
this.query.isRead = null;
this.statusBtn = '全部'
this.findData(true);
},
//查找数据
findData(flag) {
let $this = this;
//是否重置列表
if (flag) {
if(this.conType==1){
this.courseList=[]
}
if(this.conType==2){
this.articleList=[]
}
if(this.conType==4){
this.qaList=[]
}
}
this.query.isRead = this.isRead;
//生成查询条件
uni.showLoading({ title: '加载中...' });
//查询条件
const conList = {
1: 'mycourselist',
2: 'myarticlelist',
4: 'myqalist'
};
// console.log(this.query,'dydyyy')
apiShares[conList[this.conType]](this.query).then(rs => {
if (rs.status == 200) {
this.count=rs.result.count
if(this.conType==1){
rs.result.list.forEach(item=>{
$this.courseList.push(item)
})
}
if(this.conType==2){
let userIds = [];
rs.result.list.forEach(item=>{
item.avatar=''
item.orgInfo='';
item.sex=null;
userIds.push(item.sysCreateAid);
$this.articleList.push(item)
})
$this.loadUserInfos(rs.result.list,userIds);
}
if(this.conType==4){
let userIds = [];
rs.result.list.forEach(item=>{
item.avatar=''
item.orgInfo='';
item.sex=null;
userIds.push(item.question.sysCreateAid);
$this.qaList.push(item)
})
$this.loadUserInfos(rs.result.list,userIds);
}
}else{
uni.showToast({
title: "获取数据失败",
icon:'none'
});
}
});
setTimeout(function() {
uni.hideLoading();
}, 100);
},
withdraw(item){
apiShares.deleteshares(item.id).then(res=>{
if(res.status == 200){
uni.showToast({
icon:'success',
title:"撤回成功"
})
setTimeout(()=>{
this.findData(true);
},1000)
// console.log('撤回成功')
// setTimeout(function() {
// uni.showToast()
// }, 1000);
// if (this.conType == 1) {
// this.findData(true);
// }
// if (this.conType == 2) {
// this.findData(true);
// }
// if (this.conType == 4) {
// this.findData(true);
// }
}else{
uni.showToast({
icon:'none',
title:"撤回失败"
})
}
})
},
loadUserInfos(list, userIds) {
let $this = this;
const noReapetIds = [...new Set(userIds)];
apiUser.getByIds(noReapetIds).then(res => {
if (res.status == 200) {
if(this.conType==2){
list.forEach(item => {
res.result.some(author => {
if (author.aid == item.sysCreateAid) {
if (author.avatar != '') {
item.avatar = $this.$config.fileUrl + author.avatar;
//实际上根本没有拿到fileUrl
}else{
item.avatar=''
}
item.sex = author.sex
item.orgInfo = author.orgInfo;
return true;
}
return false;
});
});
}else{
list.forEach(item => {
res.result.some(author => {
if (author.aid == item.question.sysCreateAid) {
if (author.avatar != '') {
item.avatar = $this.$config.fileUrl + author.avatar;
//实际上根本没有拿到fileUrl
}else{
item.avatar=''
}
item.sex = author.sex
item.orgInfo = author.orgInfo;
return true;
}
return false;
});
});
}
}
});
},
toCourseDetail(citem) {
if (citem.contentType == 10) {
uni.navigateTo({
url: '/pages/resource/microDetail?id=' + citem.objId
});
} else if (citem.contentType == 20 || citem.contentType == 21) {
uni.navigateTo({
url: '/pages/resource/courseDetail?id=' + citem.objId
});
}
},
toArticleDetail(item) {
uni.navigateTo({
url: '/pages/resource/articeDetail?id=' + item.objId
});
},
toQaDetail(item) {
uni.navigateTo({
url: '/pages/resource/qaDetail?id=' + item.id
});
},
chooseStatus(e) {
// this.statusSelectShow = false;
// this.statusBtn = e.value[0].label;
this.isRead = e;
//console.log(this.isRead)
this.findData(true);
},
contentTypeFilter(value) {
let obj = {};
switch (value) {
case '10': {
obj.class = 'uc-course-type2';
obj.text = '录播';
break;
}
case '21': {
obj.class = 'uc-course-type2';
obj.text = '直播';
break;
}
case '20': {
obj.class = 'uc-course-type2';
obj.text = '录播';
break;
}
case '30': {
obj.class = 'uc-course-type2';
obj.text = '面授';
break;
}
case '90': {
obj.class = 'uc-course-type2';
obj.text = '混合';
break;
}
}
return obj;
},
}
}
</script>
<style lang="scss" scoped>
.rowbtn-right{
margin-top: 10upx;
display: flex;
justify-content: flex-end;
}
.rowbtn{
padding: 5px 8px 0px 8px;
height: 20px;
border-radius: 10upx;
margin-left: 20upx;
}
.rowbtn-primary{
background-color: #ebf3fe;
}
.rowbtn-info{
background-color: #f7f7f7;
}
.sea-show{
padding: 20rpx;
padding-left: 28upx;
padding-bottom: 10upx;
.sea-active{
border: 1rpx solid #679cfc !important;
color: #679cfc;
}
.sea-index{
font-size: 26rpx;
padding: 6rpx 16rpx;
border: 1rpx solid #ccc;
border-radius: 20rpx;
margin-right: 16rpx;
background-color: #fff;
}
}
.coursetit-sl{
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
word-break:break-all;
-webkit-line-clamp: 1;
line-height: 45rpx;
-webkit-box-orient: vertical;
}
.with{
color: #666;
font-size: 24rpx;
line-height: 35rpx;
image{
width: 26rpx;
height: 26rpx;
margin-right: 10rpx;
padding-top: 10rpx;
vertical-align: top;
}
}
.isread{
color: #666;
font-size: 24rpx;
line-height: 35rpx;
image{
width: 30rpx;
height: 30rpx;
margin-right: 10rpx;
padding-top: 10rpx;
vertical-align: top;
}
}
.textbtn {
background-color: #ffffff;
padding: 18upx 20upx;
color: #4f4f4f;
border-radius: 8upx;
font-size: 28upx;
}
.top-content-options{
height: 34px;
display: flex;
align-items: center;
line-height: 34px;
padding: 20upx 0upx 0upx 28upx;
.input-search {
height: 34px;
padding-right: 10px;
flex: 1;
// padding: 28upx 20upx;
.u-input {
background: #ffffff;
}
}
}
/deep/.filter .btn-box > uni-view {
border: solid 0.5px #ffb30f;
}
/deep/.filter .btn-box .submit {
background-color: #ffb30f;
}
/deep/.filter .btn-box > uni-view {
border: solid 0.5px #ffb30f;
}
/deep/.filter .btn-box .reset {
color: #ffb30f;
}
/deep/.filter .menu-box .box .labels .on {
border-color: #ffb30f;
background-color: #ffb30f;
}
/deep/.filter .menu-box .box .labels > uni-view {
width: 125px;
padding-left: 5px;
padding-right: 5px;
}
/deep/.sub-menu-list .sub-menu > .menu-name > .iconfont {
color: #ffb30f;
}
/deep/.sub-menu-list.alone .sub-menu {
border-bottom: 0;
}
/deep/.nav .first-menu.on {
color: #ffb30f;
}
/deep/.sub-menu-list.alone .sub-menu.on {
color: #ffb30f;
}
/deep/.u-tabs__wrapper__nav {
display: flex;
justify-content: space-around;
}
.top-tab {
height: 50px;
// background: linear-gradient(to bottom, #6BA0FC, #6297FD);
display: flex;
justify-content: space-between;
line-height: 60px;
color: #373737;
.top-bar-center {
display: flex;
font-size: 30upx;
// margin-left: 40upx;
.top-bar-tab {
margin: 0upx 50upx;
}
.active {
border-bottom: 2px solid #588afc;
// color: #5282eb;
font-size: 35upx;
font-weight: bold;
}
}
.top-tab-left {
display: flex;
justify-content: space-around;
width: 100%;
text-align: center;
}
.top-tab-line {
width: 50px;
height: 3px;
background: #ffffff;
margin-top: -5px;
}
}
.input-search{
height: 34px;
.u-input{
background: #ffffff;
}
// /deep/.u-icon{
// span{
// font-size: 50upx;
// color: #588afc;
// }
// }
// /deep/.uni-input-placeholder{
// color: #588afc!important;
// }
}
.course_box {
// margin-bottom: 10px;
margin-top: 14upx;
background-color: #ffffff;
padding: 19upx 40upx;
.course {
display: flex;
justify-content: flex-start;
/deep/ .course-img {
display: flex;
justify-content: space-around;
width: 120px;
height: 70px;
margin-right: 20upx;
margin-top: 9rpx;
margin-left: 10rpx;
margin-bottom: 20rpx;
uni-image{
border-radius:8px;
}
}
.course-content {
display: flex;
flex-direction: column;
justify-content: space-between;
margin-left: 10upx;
.course-con_source{
font-size: 28upx;
color: #444444;
margin-top: 10rpx;
padding-bottom: 10rpx;
}
.course-author {
font-size: 26upx;
color: #666;
}
.common{
padding: 4upx 15upx;
border-radius: 2px;
font-size: 24upx;
color: #fff;
margin-right: 20upx;
}
.uc-course-type1{
background: #588afc;
}
.uc-course-type2{
background: #ffb30f;
}
}
}
}
.article-center {
width: 90%;
margin-left: 5%;
margin-right: 5%;
}
.article {
background: #f8fbfd;
}
.art_type{
// float: left;
}
.articla_tit {
padding-bottom: 15rpx;
overflow: hidden;
font-weight: bold;
text-overflow:ellipsis;
white-space: nowrap;
font-size: 30rpx;
// float: left;
}
.articla_text {
word-break:break-all;
font-size: 28rpx;
color: #454545;
display: -webkit-box;
line-height: 40rpx;
overflow: hidden;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
margin-bottom: 10rpx;
}
.article_one {
// padding-top: 10px;
margin-top: 20rpx;
background-color: #fff;
padding: 19upx 38upx;
.answers_text {
// font-size: 14px;
// color: #797979;
// display: -webkit-box;
overflow: hidden;
width: 80%;
// line-height: 25upx;
// -webkit-box-orient: vertical;
// -webkit-line-clamp: 2;
}
.artical_text_bottom{
display: flex;
justify-content: space-between;
margin-top: 10rpx;
text{
margin-right: 10px;
}
}
}
.qa {
// margin-top: 19rpx;
// padding: 10px;
padding: 19upx 39upx;
box-shadow: #f7f7f7 0px 6px 5px;
border-radius: 4px;
background: #ffffff;
margin-top: 20upx;
padding-bottom: 15rpx;
padding-top: 0;
.qa-header {
height: 26px;
line-height: 25px;
display: flex;
justify-content: space-between;
.qa-user {
display: flex;
img {
height: 25px;
width: 25px;
margin-right: 5px;
}
}
}
.qa-body {
line-height: 40px;
overflow: hidden;
text-overflow:ellipsis;
white-space: nowrap;
font-size: 30rpx;
font-weight: bold;
}
.qa-bottom {
font-size: 30rpx;
color: #454545;
display: -webkit-box;
overflow: hidden;
line-height: 45rpx;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
margin-bottom: 4rpx;
word-break:break-all;
}
.qa-answers {
display: flex;
overflow: hidden;
line-height: 20upx;
width: 100%;
// height: 70upx;
margin: 10upx 0upx;
padding: 10upx 0;
font-size: 30rpx;
color: #5b5b5b;
answer-one{
width: 50%;
}
answer-two{
flex: 1;
word-break:break-all;
overflow: hidden;
// display: -webkit-box;
// -webkit-box-orient: vertical;
// -webkit-line-clamp: 2;
display:inline-block;/*转为行内块元素*/
white-space: pre-wrap;/*处理元素内的空白,保留空白符序列,但是正常地进行换行*/
word-wrap: break-word;
}
}
.qa-text{
font-size: 26rpx;
color: #9d9d9d;
margin-right: 10px;
}
}
.details {
height: 127px;
border-bottom: 1px solid #e3e3e3;
}
.newest {
width: 60px;
height: 31px;
background: #ffffff;
font-size: 11px;
border-radius: 4px;
color: #505050;
text-align: center;
line-height: 31px;
margin-top: 2px;
margin-left: 9px;
}
.hottest {
background: #dfebf4;
color: #5ba2fc;
}
.big_top {
height: 37px;
}
.big_box_top {
display: flex;
height: 80upx;
padding: 30upx 0;
}
.big-box_center {
height: 173px;
margin-top: 9px;
display: flex;
justify-content: space-between;
flex-wrap: wrap;
}
.llef {
width: 168px;
height: 172px;
border-radius: 4px;
background: #ffffff;
box-shadow: #f1f6fe 0px 6px 5px;
}
.llef img {
width: 168px;
height: 96px;
}
</style>