267 lines
5.4 KiB
Vue
267 lines
5.4 KiB
Vue
<template>
|
|
<view class="page">
|
|
<view class="" style="padding: 10rpx;">
|
|
<u-subsection
|
|
:list="list"
|
|
font-size="20"
|
|
:current="current"
|
|
mode="subsection"
|
|
@change="sectionChange">
|
|
</u-subsection>
|
|
</view>
|
|
|
|
<u-popup :show="show" @close="close" @open="open">
|
|
<view class="popup-page">
|
|
<view class="">
|
|
<uni-list>
|
|
<uni-list-item
|
|
@click="editItem(selectIndex)"
|
|
:show-extra-icon="true"
|
|
:extra-icon="iconList.edit"
|
|
clickable="true"
|
|
title="文章编辑" />
|
|
</uni-list>
|
|
<uni-list>
|
|
<uni-list-item
|
|
@click="settingItem(selectIndex)"
|
|
:show-extra-icon="true"
|
|
:extra-icon="iconList.setting"
|
|
clickable="true"
|
|
title="文章设置" />
|
|
</uni-list>
|
|
<uni-list>
|
|
<uni-list-item
|
|
@click="deleteItem(selectIndex)"
|
|
:show-extra-icon="true"
|
|
:extra-icon="iconList.delete"
|
|
clickable="true"
|
|
title="删除" />
|
|
</uni-list>
|
|
</view>
|
|
<view class="close-button" @click="close()">
|
|
取消
|
|
</view>
|
|
</view>
|
|
|
|
</u-popup>
|
|
|
|
<view class="" v-if="current === 1">
|
|
<view class="container" style="display: flex;flex-wrap: wrap;">
|
|
<view class=""
|
|
style="box-sizing: border-box;width: 50%;border-radius: 12rpx;" v-for="(item, index) in cms_list">
|
|
<uni-card margin="5" spacing="0" @click="editItem(index)">
|
|
<cloud-image
|
|
width="100%"
|
|
height="200rpx"
|
|
mode="scaleToFill"
|
|
:src="Array.isArray(item.thumbnail) && item.thumbnail.length > 0?item.thumbnail[0]:''">
|
|
</cloud-image>
|
|
<text class="uni-body">
|
|
{{ item.title }}
|
|
</text>
|
|
<view
|
|
slot="actions"
|
|
class="card-actions">
|
|
|
|
<view
|
|
class="card-actions-item">
|
|
<text
|
|
class="card-actions-item-text">
|
|
阅读量 {{ item.view_count }}
|
|
</text>
|
|
</view>
|
|
<view
|
|
class="card-actions-item"
|
|
@click.stop="selectMore(index)">
|
|
<uni-icons type="more-filled" size="18" color="#999"></uni-icons>
|
|
</view>
|
|
</view>
|
|
</uni-card>
|
|
</view>
|
|
</view>
|
|
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import cloudImage from "@/components/cloud-image.vue"
|
|
import uSubsection from "@/uni_modules/uview-ui/components/u-subsection/u-subsection.vue"
|
|
import uPopup from "@/uni_modules/uview-ui/components/u-popup/u-popup.vue"
|
|
|
|
const uniIdCo = uniCloud.importObject("uni-id-co")
|
|
import {
|
|
store,
|
|
mutations
|
|
} from '@/pages3/uni_modules/uni-id-pages/common/store.js'
|
|
|
|
export default {
|
|
data() {
|
|
return {
|
|
list: ['动态', '作品', '相册', '收藏'],
|
|
current: 1,
|
|
show: false,
|
|
iconList: {
|
|
delete : {
|
|
color: '#f55',
|
|
size: '22',
|
|
type: 'closeempty'
|
|
},
|
|
setting: {
|
|
color: '#888',
|
|
size: '22',
|
|
type: 'gear-filled'
|
|
},
|
|
edit: {
|
|
color: '#888',
|
|
size: '22',
|
|
type: 'compose'
|
|
}
|
|
},
|
|
cms_list: [],
|
|
selectIndex: 0,
|
|
};
|
|
},
|
|
computed: {
|
|
userInfo() {
|
|
return store.userInfo
|
|
},
|
|
realNameStatus() {
|
|
if (!this.userInfo.realNameAuth) {
|
|
return 0
|
|
}
|
|
|
|
return this.userInfo.realNameAuth.authStatus
|
|
},
|
|
},
|
|
components:{
|
|
uSubsection,
|
|
cloudImage,
|
|
uPopup
|
|
},
|
|
async onLoad() {
|
|
console.log(this.userInfo);
|
|
let res = await uniCloud.importObject("uni-cms-articles")
|
|
.get_cms_articles_for_userId({user_id: this.userInfo._id});
|
|
console.log(res);
|
|
this.cms_list = res.data;
|
|
},
|
|
methods:{
|
|
sectionChange(index) {
|
|
console.log(index)
|
|
this.current = index;
|
|
},
|
|
selectMore(index) {
|
|
console.log(index)
|
|
this.show = true;
|
|
this.selectIndex = index;
|
|
},
|
|
close() {
|
|
this.show = false;
|
|
},
|
|
open() {
|
|
this.show = true;
|
|
},
|
|
onClick(e) {
|
|
console.log(e)
|
|
|
|
},
|
|
async deleteItem(index) {
|
|
console.log(index)
|
|
console.log(this.cms_list[index]);
|
|
let res = await uniCloud.importObject("uni-cms-articles").del_cms_articles({id: this.cms_list[index]._id});
|
|
console.log(res)
|
|
if (res.code === 200) {
|
|
this.cms_list.splice(index, 1)
|
|
}
|
|
this.close()
|
|
},
|
|
async editItem(index) {
|
|
console.log(index);
|
|
let cms = this.cms_list[index];
|
|
console.log(cms);
|
|
uni.setStorageSync("cms", cms);
|
|
await this.toCmsEdit(cms.id);
|
|
},
|
|
async toCmsEdit(id) {
|
|
uni.navigateTo({
|
|
url: "/pages2/editCms/editCms?id=" + id
|
|
});
|
|
},
|
|
settingItem(index) {
|
|
console.log("setting")
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
.page {
|
|
padding: 20rpx;
|
|
}
|
|
|
|
.container {
|
|
overflow: hidden;
|
|
}
|
|
|
|
.custom-cover {
|
|
flex: 1;
|
|
flex-direction: row;
|
|
position: relative;
|
|
}
|
|
|
|
.cover-content {
|
|
position: absolute;
|
|
bottom: 0;
|
|
left: 0;
|
|
right: 0;
|
|
height: 40px;
|
|
background-color: rgba($color: #000000, $alpha: 0.4);
|
|
display: flex;
|
|
flex-direction: row;
|
|
align-items: center;
|
|
padding-left: 15px;
|
|
font-size: 14px;
|
|
color: #fff;
|
|
}
|
|
|
|
.card-actions {
|
|
display: flex;
|
|
flex-direction: row;
|
|
justify-content: space-around;
|
|
align-items: center;
|
|
height: 45px;
|
|
border-top: 1px #eee solid;
|
|
}
|
|
.card-actions-item {
|
|
display: flex;
|
|
flex-direction: row;
|
|
align-items: center;
|
|
}
|
|
.card-actions-item-text {
|
|
font-size: 12px;
|
|
color: #666;
|
|
margin-left: 5px;
|
|
}
|
|
.cover-image {
|
|
flex: 1;
|
|
height: 150px;
|
|
}
|
|
.no-border {
|
|
border-width: 0;
|
|
}
|
|
.close-button {
|
|
background-color: #fff;
|
|
text-align: center;
|
|
border: 3rpx solid #fff;
|
|
height: 50rpx;
|
|
width: 100%;
|
|
padding: 5rpx;
|
|
margin-top: 20rpx;
|
|
margin-bottom: 10rpx;
|
|
}
|
|
.popup-page {
|
|
background-color: #eee;
|
|
}
|
|
</style>
|