YingXingAI/pages/my/ReleaseList/ReleaseList.vue

478 lines
13 KiB
Vue

<template>
<view>
<u-navbar :title="titleList[type]" ></u-navbar>
<view class="list">
<scroll-view
scroll-y="true"
style="height: calc(100vh - 0.5rem); width: 100%"
@scrolltolower="onreachBottom"
>
<information v-if="releaseList.length" @onDelCollet="onDelCollet" @onStar="onStar" @onSign="onSign" @onDelete="onDelete" :list="releaseList" :type="type" :isDel="isDel" :bottom="true" route="3" :flag='flag' :schoolId='this.schoolId' :borderRadius="true"></information>
<view v-if="!releaseList.length" style="margin-top:20vh;">
<!-- <u-empty text="暂无数据111" mode="list"></u-empty> -->
<no-data ></no-data>
</view>
</scroll-view>
<u-toast ref="uToast" />
<!-- <view class="xyList">
<view class="flex-col list">
<view
class="flex-col list-item_1"
:key="i"
v-for="(item, i) in releaseList"
>
<view class="flex-row group_11">
<image
src="https://codefun-proj-user-res-1256085488.cos.ap-guangzhou.myqcloud.com/6216dee45a7e3f031061d0f1/624409975b22cf00110eafb0/16486275577001633329.png"
class="image_9"
/>
<view class="flex-col items-start group_23">
<text class="text_10">{{item.schoolName}}</text>
<text class="text_11">{{item.time}}</text>
</view>
</view>
<text class="text_12"
>{{item.title}}</text
>
<text class="text_13">
{{item.content}}
</text>
<view class="equal-division flex-col">
<view class="flex-row">
<image
src="https://codefun-proj-user-res-1256085488.cos.ap-guangzhou.myqcloud.com/6216dee45a7e3f031061d0f1/624409975b22cf00110eafb0/16486275577025201928.png"
class="image_10"
/>
<image
src="https://codefun-proj-user-res-1256085488.cos.ap-guangzhou.myqcloud.com/6216dee45a7e3f031061d0f1/624409975b22cf00110eafb0/16486275577046447275.png"
class="image_10 image_13"
/>
<image
src="https://codefun-proj-user-res-1256085488.cos.ap-guangzhou.myqcloud.com/6216dee45a7e3f031061d0f1/624409975b22cf00110eafb0/16486275577048644458.png"
class="image_10 image_15"
/>
</view>
<view class="flex-row tool">
<view class="flex-row group_8">
<image
src="/static/common/img/16486275583591942621.png"
class="image_12"
/>
<text class="text_17">686</text>
</view>
<view class="flex-row group_9">
<image
src="/static/common/img/16486275582930866915.png"
class="image_14"
/>
<text class="text_18">996</text>
</view>
<view class="justify-between group_10">
<image
src="/static/common/img/16486275583636337201.png"
class="image_16"
/>
<text class="text_19">100</text>
</view>
</view>
</view>
</view>
</view>
</view> -->
</view>
<u-toast ref="uToast" />
</view>
</template>
<script>
import information from "../../../components/Information.vue";
import NoData from '@/components/NoData.vue';
export default {
data() {
return {
releaseList:[],
pageSize:10,
pageIndex:1,
schoolId:"",
type:0,
total1:0,
total2:0,
total3:0,
isNolink:false,
flag:'',
isDel:false,
titleList:['学校资讯','我的发布','我的收藏']
}
},
components: {
information: information,
NoData,
},
onLoad(e){
// setTimeout(()=>{
if(e.type == 1 ){
this.type = 1
this.isDel = true
// this.myPublishs()
}else if(e.type == 2){
this.flag = 'Collection'
this.isNolink = true
this.type = 2
// this.myCollection()
uni.setNavigationBarTitle({
title:'我的收藏'
})
}else{
this.type = 0
this.isDel = true
// this.mySchoolZx()
uni.setNavigationBarTitle({
title:'学校资讯'
})
}
// },100)
},
onShow(){
this.releaseList=[]
this.getschoolId()
},
methods:{
//获取学校id
getschoolId(){
this.$u.apiList.GetUserSchool().then(res=>{
console.log(res,'res--')
// 学生时
if([0,2].includes(this.vuex_user.userType)){
this.schoolId = res.items.schoolId
}
// 教师时
if(this.vuex_user.userType === 1){
this.schoolId = res.jzgItems.schoolId
}
// this.schoolId = res.items.schoolId
// this.schoolId = res.selectSchoolId
if(this.type==1){
this.myPublishs()
}else if(this.type==2){
this.myCollection()
}else{
this.mySchoolZx()
}
})
},
//我的发布
myPublishs(){
const data = {
userId:this.vuex_user.id,
schoolId:this.schoolId,
pageIndex:this.pageIndex,
pageSize:this.pageSize
}
this.$u.apiList.Publishs(data).then((res)=>{
this.total1 = res.total
if(this.releaseList.length==0){
this.releaseList = res.items
}else if(this.releaseList.length>0){
this.releaseList=this.releaseList.concat(res.items)
}
})
},
//我的收藏
myCollection(){
const data = {
userId:this.vuex_user.id,
schoolId:this.schoolId,
pageIndex:this.pageIndex,
pageSize:this.pageSize
}
this.$u.apiList.Collection(data).then((res)=>{
this.total2 = res.length
if(this.releaseList.length==0){
this.releaseList = res
}else if(this.releaseList.length>0){
this.releaseList = this.releaseList.concat(res)
}
})
},
//学校资讯
mySchoolZx(){
const data = {
PageIndex:this.pageIndex,
PageSize:this.pageSize
}
this.$u.api.MyAlumnRange(data).then((res)=>{
this.total3 = res.total
if(this.releaseList.length==0){
this.releaseList = res.items
}else if(this.releaseList.length<res.total){
this.releaseList=this.releaseList.concat(res.items)
}else{
}
})
},
onStar(val){
const data = {
id : val.id,
type:val.type
}
this.$u.apiList.LikeCollect(data)
.then((res)=>{
if(val.isCllect){
val.isCllect = false
val.collectCount -= 1
this.$refs.uToast.show({
title: '取消收藏成功',
type: 'success',
})
}else{
val.isCllect = true
val.collectCount += 1
this.$refs.uToast.show({
title: '收藏成功',
type: 'success',
})
}
})
.catch((err)=>{
this.$refs.uToast.show({
title: '收藏失败',
type: 'error',
})
})
},
onSign(v){
// return
uni.setStorage({
key: 'Tag',
data: v+',1',
success: function () {
;
}
});
uni.switchTab({
url:'../../AlumniCircle/alumnus/alumnus',
params:{current:1,v:v}
})
},
onreachBottom(){
let num = this.pageIndex * this.pageSize
if(this.total1 > num){
this.pageIndex++;
this.myPublishs()
}else if(this.total2 > num){
this.pageIndex++;
this.myCollection()
}else if(this.total3 > num){
this.pageIndex++;
this.mySchoolZx()
}
},
//删除我的发布
onDelete(val){
const data={
type:1,
id :val.id
}
if(this.type==0){
data.type = 3
}
uni.showModal({
// title: '提示',
content: '确定删除此内容?',
success: (res) => {
if (res.confirm) {
this.$u.apiList.DelateArticle(data).then(res=>{
console.log('res======',res);
this.$refs.uToast.show({
title: '删除成功',
type: 'success',
})
this.releaseList = this.releaseList.filter(i=>{
return val.id!=i.id
})
// this.myPublishs()
})
.catch(err=>{
console.log(err,'11111111111');
this.$refs.uToast.show({
title: '删除失败',
type: 'error',
})
})
} else if (res.cancel) {
// console.log('用户点击取消');
}
}
});
},
//删除收藏
onDelCollet(val){
const data = {
userId:this.vuex_user.id,
collectId:val
}
uni.showModal({
// title: '提示',
content: '确定删除收藏?',
success: (res) => {
if (res.confirm) {
this.$u.apiList.CancleCollect(data).then(res=>{
this.releaseList = this.releaseList.filter(i=>{
return i.collectId != val
})
this.$refs.uToast.show({
title: '删除成功',
type: 'success',
})
})
.catch(err=>{
this.$refs.uToast.show({
title: '删除失败',
type: 'error',
})
})
} else if (res.cancel) {
// console.log('用户点击取消');
}
}
});
},
//返回上一级
router(){
uni.switchTab({
url: '../../my/my/my'
});
}
},
}
</script>
<style lang="scss" scoped>
.xyList {
.list {
margin-top: 0.055rem;
padding-bottom: 0.06rem;
.list-item_1 {
padding: 0.19rem 0 0.07rem;
background-color: rgb(255, 255, 255);
margin-bottom: 0.1rem;
.group_11 {
padding: 0 0.16rem;
.image_9 {
margin-bottom: 0.015rem;
width: 0.3rem;
height: 0.3rem;
}
.group_23 {
margin-left: 0.065rem;
margin-top: 0.02rem;
flex: 1 1 auto;
.text_10 {
color: rgb(2, 2, 2);
font-size: 0.14rem;
line-height: 0.13rem;
}
.text_11 {
margin-top: 0.055rem;
color: rgb(184, 184, 184);
font-size: 0.12rem;
line-height: 0.12rem;
}
}
}
.text_12 {
margin-top: 0.17rem;
align-self: center;
color: rgb(55, 59, 72);
font-size: 0.18rem;
line-height: 0.17rem;
}
.text_13 {
margin: 0.12rem 0.15rem 0 0.17rem;
color: rgb(73, 76, 87);
font-size: 0.15rem;
line-height: 0.24rem;
}
.equal-division {
margin-top: 0.035rem;
padding: 0.05rem 0.15rem;
.tool {
margin-top: 0.3rem;
.group_8 {
padding-left: 0.26rem;
padding-right: 0.24rem;
flex: 1 1 1.11rem;
.image_12 {
width: 0.22rem;
height: 0.21rem;
}
.text_17 {
margin-left: 0.08rem;
align-self: center;
color: rgb(180, 182, 189);
font-size: 0.14rem;
line-height: 0.11rem;
}
}
.group_9 {
margin-left: 0.055rem;
padding: 0 0.24rem;
flex: 1 1 1.11rem;
.image_14 {
width: 0.18rem;
height: 0.2rem;
}
.text_18 {
margin-left: 0.08rem;
align-self: center;
color: rgb(180, 182, 189);
font-size: 0.14rem;
line-height: 0.11rem;
}
}
.group_10 {
margin-left: 0.05rem;
padding: 0 0.23rem;
flex: 1 1 1.11rem;
width: 1.12rem;
.image_16 {
margin-left: 0.07rem;
width: 0.2rem;
height: 0.2rem;
}
.text_19 {
align-self: center;
color: rgb(180, 182, 189);
font-size: 0.14rem;
line-height: 0.11rem;
}
}
}
.image_10 {
flex: 1 1 1.11rem;
width: 1.11rem;
height: 1.11rem;
}
.image_13 {
margin-left: 0.055rem;
}
.image_15 {
margin-left: 0.05rem;
}
}
}
}
}
</style>