demingshangjia/pages/user/content.vue

183 lines
3.3 KiB
Vue
Raw Normal View History

2020-06-13 17:36:24 +08:00
<template>
<view class="content">
<view class="tab-swiper">
2020-07-30 09:41:08 +08:00
<u-tabs-swiper
ref="uTabs"
:list="list"
:current="current"
@change="tabsChange"
active-color="#FF780F"
inactive-color="#333333"
font-size="30"
gutter="317"
height="98"
:show-bar="false"
swiperWidth="750"
:is-scroll="false"
></u-tabs-swiper>
2020-06-13 17:36:24 +08:00
</view>
2020-07-30 10:12:27 +08:00
<view class="box">
<view v-for="(item, index) in newlist" :key="index"><ContentItem :info="item" :type="type" @del="del"></ContentItem></view>
</view>
2020-06-13 17:36:24 +08:00
<u-popup v-model="show" mode="center">
<view class="close-popup">
2020-07-30 10:12:27 +08:00
<view class="tips">{{msg}}</view>
2020-06-13 17:36:24 +08:00
<view class="btn">
2020-07-30 09:41:08 +08:00
<view class="cancel" @click="show = false">取消</view>
2020-07-30 10:12:27 +08:00
<view class="confirm" @click="delarticle">确定</view>
2020-06-13 17:36:24 +08:00
</view>
</view>
</u-popup>
2020-07-30 10:12:27 +08:00
<u-toast ref="uToast" />
2020-06-13 17:36:24 +08:00
</view>
</template>
<script>
2020-07-30 09:41:08 +08:00
import ContentItem from '@/components/content-item/index';
2020-06-13 17:36:24 +08:00
export default {
data() {
return {
show: false,
current: 0,
swiperCurrent: 0,
2020-07-30 09:41:08 +08:00
list: [
{
name: '图文'
},
{
name: '视频'
}
],
type: 1,
num: 1,
2020-07-30 10:12:27 +08:00
newlist: [],
delid:null,
msg:""
2020-07-30 09:41:08 +08:00
};
2020-06-13 17:36:24 +08:00
},
components: {
ContentItem
},
2020-07-29 20:35:33 +08:00
onLoad() {
2020-07-30 09:41:08 +08:00
this.getlist();
2020-07-29 20:35:33 +08:00
},
onReachBottom() {
2020-07-30 09:41:08 +08:00
this.num++;
this.getlist();
2020-07-29 20:35:33 +08:00
},
2020-06-13 17:36:24 +08:00
methods: {
2020-07-30 09:41:08 +08:00
getlist() {
2020-07-29 20:35:33 +08:00
let that = this;
2020-07-30 10:12:27 +08:00
this.$u.api.articlelist({
type: that.type,
page: that.num
2020-07-30 19:49:12 +08:00
}).then(res => {
2020-07-30 10:12:27 +08:00
if (res.errCode != 0) {
this.$refs.uToast.show({
title: res.message,
type: 'error'
});
} else {
let arr = res.data.articleList;
for (let index in arr) {
that.newlist.push(arr[index]);
2020-07-29 20:35:33 +08:00
}
2020-07-30 10:12:27 +08:00
}
});
2020-07-29 20:35:33 +08:00
},
del(e) {
2020-07-30 10:12:27 +08:00
// 提示是否删除弹窗
if(this.type==1){
this.msg="确定要删除该图文吗?"
}else{
this.msg="确定要删除该视频吗?"
}
2020-07-30 09:41:08 +08:00
this.show = true;
2020-07-30 10:12:27 +08:00
this.delid = e
},
// 删除文章
delarticle(){
let that = this;
that.show = false;
this.$u.api.delarticle({
article_id: that.delid
2020-07-30 19:49:12 +08:00
}).then(res => {
2020-07-30 10:12:27 +08:00
console.log(res)
if (res.errCode != 0) {
this.$refs.uToast.show({
title: res.message,
type: 'error'
});
} else {
this.$refs.uToast.show({
title: res.message,
type: 'success'
});
// 删除后更新页面
2020-07-30 19:49:12 +08:00
this.delid = null
2020-07-30 10:12:27 +08:00
this.newlist = [];
that.num=1
that.getlist()
}
});
2020-06-13 17:36:24 +08:00
},
tabsChange(index) {
2020-07-30 10:12:27 +08:00
this.current = index;
2020-07-30 09:41:08 +08:00
this.type = index + 1;
this.num = 0;
this.newlist = [];
this.getlist();
}
}
2020-06-13 17:36:24 +08:00
};
</script>
<style lang="scss" scoped>
2020-07-30 09:41:08 +08:00
.tab-swiper {
width: 100%;
position: fixed;
top: 0;
2020-07-30 10:12:27 +08:00
margin-bottom: 20rpx;
z-index: 1000;
2020-07-30 09:41:08 +08:00
}
2020-06-13 17:36:24 +08:00
.content {
min-height: calc(100vh - var(--window-top));
2020-07-30 09:41:08 +08:00
background-color: #ececec;
2020-06-13 17:36:24 +08:00
display: flex;
flex-direction: column;
> uni-swiper {
flex: 1;
}
2020-07-30 10:12:27 +08:00
.box{
padding-top: 120rpx;
}
2020-06-13 17:36:24 +08:00
.close-popup {
2020-07-30 09:41:08 +08:00
background: rgba(255, 255, 255, 1);
2020-06-13 17:36:24 +08:00
border-radius: 10rpx;
.tips {
width: 420rpx;
font-size: 28rpx;
2020-07-30 09:41:08 +08:00
color: rgba(102, 102, 102, 1);
2020-06-13 17:36:24 +08:00
text-align: center;
padding: 38rpx 0;
}
.btn {
width: 420rpx;
2020-07-30 09:41:08 +08:00
border-top: 2rpx #ececec solid;
2020-06-13 17:36:24 +08:00
display: flex;
> view {
font-size: 26rpx;
flex: 1;
line-height: 98rpx;
text-align: center;
}
.cancel {
color: #333333;
2020-07-30 09:41:08 +08:00
border-right: 2rpx #ececec solid;
2020-06-13 17:36:24 +08:00
}
.confirm {
2020-07-30 09:41:08 +08:00
color: #ff780f;
2020-06-13 17:36:24 +08:00
}
}
}
}
2020-07-30 09:41:08 +08:00
</style>