1
0
şunun yansıması https://github.com/ialley-workshop-open/uni-halo.git eşitlendi 2026-06-12 13:19:31 +08:00

修改:优化列表动画效果

Bu işleme şunda yer alıyor:
小莫唐尼
2023-06-08 21:23:21 +08:00
ebeveyn 21d723d260
işleme f838da43d8
21 değiştirilmiş dosya ile 4725 ekleme ve 4865 silme
+25 -3
Dosyayı Görüntüle
@@ -18,15 +18,31 @@ export default {
return { return {
author: HaloConfig.author, author: HaloConfig.author,
_isWechat: true, _isWechat: true,
haloAdConfig: HaloAdConfig haloAdConfig: HaloAdConfig,
_aniWaitIndex: 0, // 动画索引
}; };
}, },
computed: { computed: {
// 获取全局应用设置 // 获取全局应用设置
globalAppSettings() { globalAppSettings() {
return uni.$tm.vx.getters().getSettings; return uni.$tm.vx.getters().getSettings;
},
// 计算动画索引
calcAniWait() {
return (index) => {
if ((index + 1) % 10 == 0) {
this._aniWaitIndex = 1;
} else {
this._aniWaitIndex += 1;
}
console.log('this._aniWaitIndex', this._aniWaitIndex);
return this._aniWaitIndex * 50
}
} }
}, },
onLoad() {
this.fnResetSetAniWaitIndex()
},
created() { created() {
// #ifdef MP-WEIXIN // #ifdef MP-WEIXIN
this._isWechat = true; this._isWechat = true;
@@ -36,7 +52,9 @@ export default {
this._isWechat = false; this._isWechat = false;
// #endif // #endif
}, },
onShow() {
this.fnResetSetAniWaitIndex()
},
methods: { methods: {
/** /**
* 设置页面标题 * 设置页面标题
@@ -60,8 +78,12 @@ export default {
console.log('err', err); console.log('err', err);
}, },
}); });
},
// 初始化动画索引值(需要在每个页面调用)
fnResetSetAniWaitIndex() {
this._aniWaitIndex = 0
} }
}, },
}); });
}, },
}; };
-1
Dosyayı Görüntüle
@@ -106,7 +106,6 @@
} }
}, },
created() { created() {
console.log('cache-image', this.url);
this.imgStyle = { this.imgStyle = {
width: this.width, width: this.width,
height: this.height, height: this.height,
+189 -199
Dosyayı Görüntüle
@@ -12,23 +12,7 @@
</view> </view>
<block v-else> <block v-else>
<tm-sliderNav :list="categoryList" bg-color="white" color="light-blue" rang-key="name" @change="fnOnCategoryChange"></tm-sliderNav> <tm-sliderNav :list="categoryList" bg-color="white" color="light-blue" rang-key="name" @change="fnOnCategoryChange"></tm-sliderNav>
<scroll-view <scroll-view class="right-content pt-12 pb-12" :scroll-y="true" :scroll-top="scrollTop" :scroll-with-animation="true" :refresher-enabled="true" :refresher-triggered="triggered" :refresher-threshold="60" refresher-background="#fafafa" @refresherrefresh="fnGetData(true)" @scrolltolower="fnGetData(false)" @scroll="fnOnScroll" @touchmove.stop @touchstart="fnOnTouchStart" @touchend="fnOnTouchEnd" @touchcancel="fnOnTouchEnd">
class="right-content pt-12 pb-12"
:scroll-y="true"
:scroll-top="scrollTop"
:scroll-with-animation="true"
:refresher-enabled="true"
:refresher-triggered="triggered"
:refresher-threshold="60"
refresher-background="#fafafa"
@refresherrefresh="fnGetData(true)"
@scrolltolower="fnGetData(false)"
@scroll="fnOnScroll"
@touchmove.stop
@touchstart="fnOnTouchStart"
@touchend="fnOnTouchEnd"
@touchcancel="fnOnTouchEnd"
>
<view v-if="dataList.length == 0" class="article-empty flex flex-center"> <view v-if="dataList.length == 0" class="article-empty flex flex-center">
<tm-empty icon="icon-shiliangzhinengduixiang-" label="该分类下暂无文章~"></tm-empty> <tm-empty icon="icon-shiliangzhinengduixiang-" label="该分类下暂无文章~"></tm-empty>
</view> </view>
@@ -36,7 +20,7 @@
<block v-else> <block v-else>
<block v-for="(article, index) in dataList" :key="article.createTime"> <block v-for="(article, index) in dataList" :key="article.createTime">
<!-- 文章卡片 --> <!-- 文章卡片 -->
<tm-translate animation-name="fadeUp" :wait="(index + 1) * 50"> <tm-translate animation-name="fadeUp" :wait="calcAniWait(index)">
<article-min-card :article="article" @on-click="fnToArticleDetail"></article-min-card> <article-min-card :article="article" @on-click="fnToArticleDetail"></article-min-card>
</tm-translate> </tm-translate>
</block> </block>
@@ -50,195 +34,201 @@
</template> </template>
<script> <script>
import throttle from '@/utils/throttle.js'; import throttle from '@/utils/throttle.js';
import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue'; import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue';
import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue'; import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue';
import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue'; import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue';
import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue'; import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue';
import tmFlowLayout from '@/tm-vuetify/components/tm-flowLayout/tm-flowLayout.vue'; import tmFlowLayout from '@/tm-vuetify/components/tm-flowLayout/tm-flowLayout.vue';
import tmSliderNav from '@/tm-vuetify/components/tm-sliderNav/tm-sliderNav.vue'; import tmSliderNav from '@/tm-vuetify/components/tm-sliderNav/tm-sliderNav.vue';
import ArticleMinCard from '@/components/article-min-card/article-min-card.vue'; import ArticleMinCard from '@/components/article-min-card/article-min-card.vue';
export default { export default {
components: { components: {
tmSkeleton, tmSkeleton,
tmTranslate, tmTranslate,
tmFlotbutton, tmFlotbutton,
tmEmpty, tmEmpty,
tmFlowLayout, tmFlowLayout,
tmSliderNav, tmSliderNav,
ArticleMinCard ArticleMinCard
}, },
data() { data() {
return { return {
loading: 'loading', loading: 'loading',
queryParams: { queryParams: {
size: 10, size: 10,
page: 0, page: 0,
slug: '' slug: ''
}, },
categoryList: [], categoryList: [],
result: null, result: null,
dataList: [], dataList: [],
isLoadMore: false, isLoadMore: false,
loadMoreText: '', loadMoreText: '',
scrollTop: 0, scrollTop: 0,
tempScrollTop: 0, tempScrollTop: 0,
scrollTimeout: null, scrollTimeout: null,
triggered: false triggered: false
}; };
}, },
onLoad() { onLoad() {
this.fnSetPageTitle('文章分类'); this.fnSetPageTitle('文章分类');
this.fnGetAllCategory(); this.fnGetAllCategory();
}, },
onPullDownRefresh() { onPullDownRefresh() {
this.queryParams.page = 0; this.queryParams.page = 0;
this.isLoadMore = false; this.isLoadMore = false;
this.fnGetData();
},
onReachBottom(e) {
if (this.result.hasNext) {
this.queryParams.page += 1;
this.isLoadMore = true;
this.fnGetData(false);
} else {
uni.showToast({
icon: 'none',
title: '没有更多数据了'
});
}
},
methods: {
fnOnCategoryChange(e) {
this.queryParams.slug = this.categoryList[e].slug;
this.fnToTopScroll();
this.dataList = [];
this.fnGetData(); this.fnGetData();
}, },
onReachBottom(e) {
fnGetAllCategory() { if (this.result.hasNext) {
this.loading = 'loading'; this.queryParams.page += 1;
uni.showLoading({ this.isLoadMore = true;
mask: true, this.fnGetData(false);
title: '加载中...'
});
this.$httpApi
.getCategoryList({ more: true })
.then(res => {
this.categoryList = res.data;
if (res.data.length != 0) {
this.queryParams.slug = res.data[0].slug;
this.triggered = false;
this.loading = 'success';
this.fnGetData(true, false);
}
})
.catch(err => {
console.error(err);
this.loading = 'error';
})
.finally(() => {
uni.hideLoading();
uni.stopPullDownRefresh();
});
},
fnGetData(isPulldownRefresh = true, triggered = true) {
if (!isPulldownRefresh) {
if (this.result.hasNext) {
this.queryParams.page += 1;
} else {
return uni.showToast({
icon: 'none',
title: '没有更多数据了'
});
}
} else { } else {
this.queryParams.page = 0; uni.showToast({
if (triggered) { icon: 'none',
this.triggered = true; title: '没有更多数据了'
}
}
this.$httpApi
.getCategoryPostList(this.queryParams.slug, this.queryParams)
.then(res => {
this.result = res.data;
if (!isPulldownRefresh) {
this.dataList = this.dataList.concat(res.data.content);
} else {
this.dataList = res.data.content;
}
this.loadMoreText = res.data.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~';
})
.catch(err => {
this.loadMoreText = '加载失败!';
})
.finally(() => {
this.triggered = false;
}); });
}
}, },
//跳转文章详情 methods: {
fnToArticleDetail(article) { fnOnCategoryChange(e) {
uni.navigateTo({ this.fnResetSetAniWaitIndex();
url: '/pagesA/article-detail/article-detail?articleId=' + article.id, this.queryParams.slug = this.categoryList[e].slug;
animationType: 'slide-in-right' this.fnToTopScroll();
}); this.dataList = [];
}, this.fnGetData();
fnOnScroll(e) { },
this.tempScrollTop = e.detail.scrollTop;
}, fnGetAllCategory() {
fnToTopScroll() { this.loading = 'loading';
uni.pageScrollTo({ uni.showLoading({
scrollTop: 0, mask: true,
duration: 500 title: '加载中...'
}); });
this.scrollTop = 0; this.$httpApi
this.tempScrollTop = 0; .getCategoryList({ more: true })
}, .then(res => {
fnOnTouchStart() { this.categoryList = res.data;
clearTimeout(this.scrollTimeout); if (res.data.length != 0) {
}, this.queryParams.slug = res.data[0].slug;
fnOnTouchEnd() { this.triggered = false;
this.scrollTimeout = setTimeout(() => { this.loading = 'success';
this.scrollTop = this.tempScrollTop; this.fnGetData(true, false);
}, 500); }
})
.catch(err => {
console.error(err);
this.loading = 'error';
})
.finally(() => {
uni.hideLoading();
uni.stopPullDownRefresh();
});
},
fnGetData(isPulldownRefresh = true, triggered = true) {
if (!isPulldownRefresh) {
if (this.result.hasNext) {
this.queryParams.page += 1;
} else {
return uni.showToast({
icon: 'none',
title: '没有更多数据了'
});
}
} else {
this.queryParams.page = 0;
if (triggered) {
this.triggered = true;
}
}
this.$httpApi
.getCategoryPostList(this.queryParams.slug, this.queryParams)
.then(res => {
this.result = res.data;
if (!isPulldownRefresh) {
this.dataList = this.dataList.concat(res.data.content);
} else {
this.dataList = res.data.content;
}
this.loadMoreText = res.data.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~';
})
.catch(err => {
this.loadMoreText = '加载失败!';
})
.finally(() => {
this.triggered = false;
});
},
//跳转文章详情
fnToArticleDetail(article) {
uni.navigateTo({
url: '/pagesA/article-detail/article-detail?articleId=' + article.id,
animationType: 'slide-in-right'
});
},
fnOnScroll(e) {
this.tempScrollTop = e.detail.scrollTop;
},
fnToTopScroll() {
uni.pageScrollTo({
scrollTop: 0,
duration: 500
});
this.scrollTop = 0;
this.tempScrollTop = 0;
},
fnOnTouchStart() {
clearTimeout(this.scrollTimeout);
},
fnOnTouchEnd() {
this.scrollTimeout = setTimeout(() => {
this.scrollTop = this.tempScrollTop;
}, 500);
}
} }
} };
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.app-page { .app-page {
width: 100vw; width: 100vw;
min-height: 100vh; min-height: 100vh;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
background-color: #fff; background-color: #fff;
} }
.content {
height: 100vh; .content {
background-color: #fafafa; height: 100vh;
} background-color: #fafafa;
.category-empty { }
width: 100%;
height: 70vh; .category-empty {
} width: 100%;
.article-empty { height: 70vh;
width: 100%; }
height: 70vh;
} .article-empty {
.right-content { width: 100%;
// width: calc(100vw - 144rpx); height: 70vh;
width: calc(100vw - 190rpx); }
height: 100vh;
background-color: #fff; .right-content {
white-space: nowrap; // width: calc(100vw - 144rpx);
background-color: #fafafa; width: calc(100vw - 190rpx);
} height: 100vh;
.loading-wrap { background-color: #fff;
padding: 24rpx; white-space: nowrap;
} background-color: #fafafa;
</style> }
.loading-wrap {
padding: 24rpx;
}
</style>
+204 -200
Dosyayı Görüntüle
@@ -74,7 +74,7 @@
</tm-flowLayout> </tm-flowLayout>
<block v-else> <block v-else>
<block v-for="(item, index) in dataList" :key="index"> <block v-for="(item, index) in dataList" :key="index">
<tm-translate animation-name="fadeUp" :wait="(index + 1) * 50"> <tm-translate animation-name="fadeUp" :wait="calcAniWait(index)">
<view class="round-3 shadow-2 overflow white mb-24"> <view class="round-3 shadow-2 overflow white mb-24">
<tm-images :previmage="false" :src="item.image" @click="fnPreview(item)"></tm-images> <tm-images :previmage="false" :src="item.image" @click="fnPreview(item)"></tm-images>
<view class="pa-24 text-size-m"> <view class="pa-24 text-size-m">
@@ -107,221 +107,225 @@
</template> </template>
<script> <script>
import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue'; import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue';
import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue'; import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue';
import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue'; import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue';
import tmTags from '@/tm-vuetify/components/tm-tags/tm-tags.vue'; import tmTags from '@/tm-vuetify/components/tm-tags/tm-tags.vue';
import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue'; import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue';
import tmIcons from '@/tm-vuetify/components/tm-icons/tm-icons.vue'; import tmIcons from '@/tm-vuetify/components/tm-icons/tm-icons.vue';
import tmImages from '@/tm-vuetify/components/tm-images/tm-images.vue'; import tmImages from '@/tm-vuetify/components/tm-images/tm-images.vue';
import tmFlowLayout from '@/tm-vuetify/components/tm-flowLayout/tm-flowLayout.vue'; import tmFlowLayout from '@/tm-vuetify/components/tm-flowLayout/tm-flowLayout.vue';
import tmTabs from '@/tm-vuetify/components/tm-tabs/tm-tabs.vue'; import tmTabs from '@/tm-vuetify/components/tm-tabs/tm-tabs.vue';
export default { export default {
components: { components: {
tmSkeleton, tmSkeleton,
tmTranslate, tmTranslate,
tmFlotbutton, tmFlotbutton,
tmTags, tmTags,
tmEmpty, tmEmpty,
tmIcons, tmIcons,
tmImages, tmImages,
tmFlowLayout, tmFlowLayout,
tmTabs tmTabs
}, },
data() { data() {
return { return {
isBlackTheme: false, isBlackTheme: false,
loading: 'loading', loading: 'loading',
category: { category: {
activeIndex: 0, activeIndex: 0,
activeValue: '', activeValue: '',
list: [] list: []
}, },
queryParams: { queryParams: {
size: 10, size: 10,
page: 0, page: 0,
team: null, team: null,
keyword: '' keyword: ''
}, },
cache: { cache: {
dataList: [], dataList: [],
total: 0 total: 0
}, },
isLoadMore: false, isLoadMore: false,
loadMoreText: '', loadMoreText: '',
result: {}, result: {},
dataList: [] dataList: []
}; };
}, },
filters: { filters: {
filterTakeTime(val) { filterTakeTime(val) {
return uni.$tm.dayjs(val).format('DD/MM/YYYY'); return uni.$tm.dayjs(val).format('DD/MM/YYYY');
}
},
watch: {
globalAppSettings: {
deep: true,
handler() {
// this.isLoadMore = false;
// this.queryParams.page = 0;
// this.dataList = [];
// this.cache.list = [];
// this.cache.total = 0;
} }
} },
}, watch: {
onLoad() { globalAppSettings: {
this.fnSetPageTitle('个人图库'); deep: true,
this.fnGetCategory(); handler() {
}, // this.isLoadMore = false;
created() { // this.queryParams.page = 0;
this.fnGetData(); // this.dataList = [];
}, // this.cache.list = [];
onPullDownRefresh() { // this.cache.total = 0;
this.isLoadMore = false; }
this.queryParams.page = 0; }
this.fnGetData(); },
}, onLoad() {
onReachBottom(e) { this.fnSetPageTitle('个人图库');
if (this.result.hasNext) { this.fnGetCategory();
this.queryParams.page += 1; },
this.isLoadMore = true; created() {
this.fnGetData(); this.fnGetData();
} else { },
uni.showToast({ onPullDownRefresh() {
icon: 'none', this.isLoadMore = false;
title: '没有更多数据了'
});
}
},
methods: {
fnOnCategoryChange(index) {
this.dataList = [];
if (index == 0) {
this.queryParams.team = null;
} else {
this.queryParams.team = this.category.list[index];
}
this.queryParams.page = 0; this.queryParams.page = 0;
this.fnToTopPage();
this.fnGetData(); this.fnGetData();
}, },
fnGetCategory() { onReachBottom(e) {
this.$httpApi.getPhotoTeams().then(res => { if (this.result.hasNext) {
this.category.list = ['全部', ...res.data]; this.queryParams.page += 1;
}); this.isLoadMore = true;
}, this.fnGetData();
fnGetData() { } else {
uni.showLoading({ uni.showToast({
mask: true, icon: 'none',
title: '加载中...' title: '没有更多数据了'
}); });
// 设置状态为加载中
if (!this.isLoadMore) {
this.loading = 'loading';
} }
this.loadMoreText = ''; },
this.$httpApi methods: {
.getPhotoListByPage(this.queryParams) fnOnCategoryChange(index) {
.then(res => { this.fnResetSetAniWaitIndex();
if (res.status == 200) { this.dataList = [];
this.loading = 'success'; if (index == 0) {
this.result = res.data; this.queryParams.team = null;
if (res.data.content.length != 0) { } else {
const _list = res.data.content.map((item, index) => { this.queryParams.team = this.category.list[index];
item['image'] = this.$utils.checkImageUrl(item.thumbnail); }
item['model'] = 'text'; this.queryParams.page = 0;
item['takeTime'] = this.$tm.dayjs(item['takeTime']).format('DD/MM/YYYY'); this.fnToTopPage();
return item; this.fnGetData();
}); },
this.fnCacheDataList(_list); fnGetCategory() {
if (this.globalAppSettings.gallery.useWaterfull) { this.$httpApi.getPhotoTeams().then(res => {
this.dataList = _list; this.category.list = ['全部', ...res.data];
this.$nextTick(() => { });
this.$refs.wafll.pushData(_list); },
fnGetData() {
uni.showLoading({
mask: true,
title: '加载中...'
});
// 设置状态为加载中
if (!this.isLoadMore) {
this.loading = 'loading';
}
this.loadMoreText = '';
this.$httpApi
.getPhotoListByPage(this.queryParams)
.then(res => {
if (res.status == 200) {
this.loading = 'success';
this.result = res.data;
if (res.data.content.length != 0) {
const _list = res.data.content.map((item, index) => {
item['image'] = this.$utils.checkImageUrl(item.thumbnail);
item['model'] = 'text';
item['takeTime'] = this.$tm.dayjs(item['takeTime']).format('DD/MM/YYYY');
return item;
}); });
} else { this.fnCacheDataList(_list);
this.dataList = this.dataList.concat(_list); if (this.globalAppSettings.gallery.useWaterfull) {
this.dataList = _list;
this.$nextTick(() => {
this.$refs.wafll.pushData(_list);
});
} else {
this.dataList = this.dataList.concat(_list);
}
} }
this.loadMoreText = res.data.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~';
} else {
this.loading = 'error';
this.waterfall.loading = 'finish';
this.loadMoreText = '';
} }
this.loadMoreText = res.data.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~'; })
} else { .catch(err => {
console.error(err);
this.loading = 'error'; this.loading = 'error';
this.waterfall.loading = 'finish'; this.waterfall.loading = 'finish';
this.loadMoreText = ''; this.loadMoreText = '加载失败,请下拉刷新!';
} })
}) .finally(() => {
.catch(err => { setTimeout(() => {
console.error(err); uni.hideLoading();
this.loading = 'error'; uni.stopPullDownRefresh();
this.waterfall.loading = 'finish'; }, 500);
this.loadMoreText = '加载失败,请下拉刷新!'; });
}) },
.finally(() => { // 缓存数据
setTimeout(() => { fnCacheDataList(dataList) {
uni.hideLoading(); if (this.queryParams.page == 0) {
uni.stopPullDownRefresh(); this.cache.dataList = dataList;
}, 500); } else {
}); this.cache.dataList = [...this.cache.dataList, ...dataList];
}, }
// 缓存数据 },
fnCacheDataList(dataList) {
if (this.queryParams.page == 0) {
this.cache.dataList = dataList;
} else {
this.cache.dataList = [...this.cache.dataList, ...dataList];
}
},
// 瀑布流组件点击事件 // 瀑布流组件点击事件
fnOnClick(data) { fnOnClick(data) {
console.log('点击数据', data); console.log('点击数据', data);
}, },
// 预览 // 预览
fnPreview(item) { fnPreview(item) {
const index = this.cache.dataList.findIndex(x => x.id == item.id); const index = this.cache.dataList.findIndex(x => x.id == item.id);
uni.previewImage({ uni.previewImage({
current: index, current: index,
urls: this.cache.dataList.map(x => x.image), urls: this.cache.dataList.map(x => x.image),
indicator: 'number', indicator: 'number',
loop: true loop: true
}); });
}
} }
} };
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.app-page { .app-page {
width: 100vw; width: 100vw;
min-height: 100vh; min-height: 100vh;
display: flex;
flex-direction: column;
padding-bottom: 24rpx;
background-color: #fafafa;
&.is-balck {
background-color: #212121;
}
}
.content {
box-sizing: border-box;
padding: 0 24rpx;
padding-top: 24rpx;
.content-empty {
height: 60vh;
display: flex; display: flex;
align-items: center; flex-direction: column;
justify-content: center; padding-bottom: 24rpx;
background-color: #fafafa;
&.is-balck {
background-color: #212121;
}
} }
}
.loading-wrap { .content {
box-sizing: border-box; box-sizing: border-box;
padding: 24rpx; padding: 0 24rpx;
} padding-top: 24rpx;
.card {
box-shadow: 0rpx 4rpx 24rpx rgba(0, 0, 0, 0.03); .content-empty {
} height: 60vh;
</style> display: flex;
align-items: center;
justify-content: center;
}
}
.loading-wrap {
box-sizing: border-box;
padding: 24rpx;
}
.card {
box-shadow: 0rpx 4rpx 24rpx rgba(0, 0, 0, 0.03);
}
</style>
+356 -349
Dosyayı Görüntüle
@@ -22,13 +22,7 @@
<view class="bg-white pb-24"> <view class="bg-white pb-24">
<!-- 轮播图+广告 --> <!-- 轮播图+广告 -->
<view class="banner bg-white ml-24 mr-24 mt-12 round-3" v-if="bannerList.length != 0"> <view class="banner bg-white ml-24 mr-24 mt-12 round-3" v-if="bannerList.length != 0">
<e-swiper <e-swiper :dotPosition="globalAppSettings.banner.dotPosition" :autoplay="true" :useDot="globalAppSettings.banner.useDot" :list="bannerList" @on-click="fnOnBannerClick"></e-swiper>
:dotPosition="globalAppSettings.banner.dotPosition"
:autoplay="true"
:useDot="globalAppSettings.banner.useDot"
:list="bannerList"
@on-click="fnOnBannerClick"
></e-swiper>
</view> </view>
<!-- 快捷导航 --> <!-- 快捷导航 -->
<!-- <view v-if="useQuickNav" class="quick-nav flex-between round-3 flex mt-12 ml-12 mr-12 pa-24"> <!-- <view v-if="useQuickNav" class="quick-nav flex-between round-3 flex mt-12 ml-12 mr-12 pa-24">
@@ -73,7 +67,7 @@
<block v-else> <block v-else>
<view :class="globalAppSettings.layout.home"> <view :class="globalAppSettings.layout.home">
<block v-for="(article, index) in articleList" :key="article.createTime"> <block v-for="(article, index) in articleList" :key="article.createTime">
<tm-translate class="ani-item" animation-name="fadeUp" :wait="(index + 1) * 50"> <tm-translate class="ani-item" animation-name="fadeUp" :wait="calcAniWait(index)">
<article-card from="home" :article="article" @on-click="fnToArticleDetail"></article-card> <article-card from="home" :article="article" @on-click="fnToArticleDetail"></article-card>
<!-- 广告区域 --> <!-- 广告区域 -->
<view v-if="haloAdConfig.home.use && (index + 1) % haloAdConfig.frequency == 0" class="ad-wrap ma-24"> <view v-if="haloAdConfig.home.use && (index + 1) % haloAdConfig.frequency == 0" class="ad-wrap ma-24">
@@ -96,367 +90,380 @@
</template> </template>
<script> <script>
import tmMenubars from '@/tm-vuetify/components/tm-menubars/tm-menubars.vue'; import tmMenubars from '@/tm-vuetify/components/tm-menubars/tm-menubars.vue';
import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue'; import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue';
import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue'; import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue';
import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue'; import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue';
import tmIcons from '@/tm-vuetify/components/tm-icons/tm-icons.vue'; import tmIcons from '@/tm-vuetify/components/tm-icons/tm-icons.vue';
import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue'; import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue';
import eSwiper from '@/components/e-swiper/e-swiper.vue'; import eSwiper from '@/components/e-swiper/e-swiper.vue';
export default { export default {
components: { components: {
tmMenubars, tmMenubars,
tmSkeleton, tmSkeleton,
tmTranslate, tmTranslate,
tmFlotbutton, tmFlotbutton,
tmIcons, tmIcons,
tmEmpty, tmEmpty,
eSwiper eSwiper
},
data() {
return {
loading: 'loading',
queryParams: {
size: 10,
page: 0
},
result: {},
isLoadMore: false,
loadMoreText: '加载中...',
bannerCurrent: 0,
bannerList: [],
noticeList: [],
articleList: [],
categoryList: [],
useQuickNav: false,
quickNavList: []
};
},
computed: {
bloggerInfo() {
let blogger = this.$tm.vx.getters().getBlogger;
blogger.avatar = this.$utils.checkAvatarUrl(blogger.avatar, true);
return blogger;
}
},
onLoad() {
this.fnSetPageTitle();
this.useQuickNav = this.$haloConfig.quickNav.use;
},
created() {
this.fnQuery();
},
onPullDownRefresh() {
this.isLoadMore = false;
this.queryParams.page = 0;
this.fnQuery();
},
onReachBottom(e) {
if (this.result.hasNext) {
this.queryParams.page += 1;
this.isLoadMore = true;
this.fnGetArticleList();
} else {
uni.showToast({
icon: 'none',
title: '没有更多数据了'
});
}
},
methods: {
fnQuery() {
this.fnGetBanner();
this.fnGetArticleList();
this.fnGetCategoryList();
this.fnGetQuickNavList();
}, },
fnGetQuickNavList() { data() {
this.useQuickNav = this.$haloConfig.quickNav.use; return {
if (!this.$haloConfig.quickNav.use) return; loading: 'loading',
const _quickNavList = this.$haloConfig.quickNav.list; queryParams: {
this.quickNavList = _quickNavList.map(item => { size: 10,
return item; page: 0
}); },
}, result: {},
fnGetCategoryList() { isLoadMore: false,
this.$httpApi loadMoreText: '加载中...',
.getCategoryList({ more: true }) bannerCurrent: 0,
.then(res => { bannerList: [],
this.categoryList = res.data.sort((a, b) => { noticeList: [],
return b.postCount - a.postCount; articleList: [],
}); categoryList: [],
useQuickNav: false,
setTimeout(() => { quickNavList: []
this.loading = 'success';
}, 500);
})
.catch(err => {
console.error(err);
this.loading = 'error';
})
.finally(() => {
setTimeout(() => {
uni.hideLoading();
uni.stopPullDownRefresh();
}, 500);
});
},
// 获取轮播图
fnGetBanner() {
const _this = this;
const _format = function(list, type) {
return list.map((item, index) => {
switch (type) {
case 'list':
return {
id: index,
nickname: _this.bloggerInfo.nickname,
avatar: _this.bloggerInfo.avatar,
address: item.href || '',
title: item.title,
image: _this.$utils.checkImageUrl(item.thumbnail)
};
case 'article':
return {
mp4: '',
id: item.id,
nickname: _this.bloggerInfo.nickname,
avatar: _this.bloggerInfo.avatar,
address: '',
createTime: uni.$tm.dayjs(item.createTime).fromNow(),
title: item.title,
src: _this.$utils.checkImageUrl(item.thumbnail),
image: _this.$utils.checkImageUrl(item.thumbnail)
};
case 'banner':
return {
id: '',
src: item
};
}
});
}; };
switch (this.$haloConfig.banner.type) { },
case 'list': // 手动配置的banner
this.bannerList = _format(this.$haloConfig.banner.list, 'list'); computed: {
break; bloggerInfo() {
case 'article': // 来自热门文章的封面 let blogger = this.$tm.vx.getters().getBlogger;
this.$httpApi.getPostList({ page: 0, size: 6, sort: 'topPriority,visits,desc' }).then(res => { blogger.avatar = this.$utils.checkAvatarUrl(blogger.avatar, true);
this.bannerList = _format(res.data.content, 'article'); return blogger;
if (this.bannerList.length == 0) { },
this.bannerList = _format(this.$haloConfig.banner.list, 'list');
},
onLoad() {
this.fnSetPageTitle();
this.useQuickNav = this.$haloConfig.quickNav.use;
},
created() {
this.fnQuery();
},
onPullDownRefresh() {
this.isLoadMore = false;
this.queryParams.page = 0;
this.fnQuery();
},
onReachBottom(e) {
if (this.result.hasNext) {
this.queryParams.page += 1;
this.isLoadMore = true;
this.fnGetArticleList();
} else {
uni.showToast({
icon: 'none',
title: '没有更多数据了'
});
}
},
methods: {
fnQuery() {
this.fnGetBanner();
this.fnGetArticleList();
this.fnGetCategoryList();
this.fnGetQuickNavList();
},
fnGetQuickNavList() {
this.useQuickNav = this.$haloConfig.quickNav.use;
if (!this.$haloConfig.quickNav.use) return;
const _quickNavList = this.$haloConfig.quickNav.list;
this.quickNavList = _quickNavList.map(item => {
return item;
});
},
fnGetCategoryList() {
this.$httpApi
.getCategoryList({ more: true })
.then(res => {
this.categoryList = res.data.sort((a, b) => {
return b.postCount - a.postCount;
});
setTimeout(() => {
this.loading = 'success';
}, 500);
})
.catch(err => {
console.error(err);
this.loading = 'error';
})
.finally(() => {
setTimeout(() => {
uni.hideLoading();
uni.stopPullDownRefresh();
}, 500);
});
},
// 获取轮播图
fnGetBanner() {
const _this = this;
const _format = function(list, type) {
return list.map((item, index) => {
switch (type) {
case 'list':
return {
id: index,
nickname: _this.bloggerInfo.nickname,
avatar: _this.bloggerInfo.avatar,
address: item.href || '',
title: item.title,
image: _this.$utils.checkImageUrl(item.thumbnail)
};
case 'article':
return {
mp4: '',
id: item.id,
nickname: _this.bloggerInfo.nickname,
avatar: _this.bloggerInfo.avatar,
address: '',
createTime: uni.$tm.dayjs(item.createTime).fromNow(),
title: item.title,
src: _this.$utils.checkImageUrl(item.thumbnail),
image: _this.$utils.checkImageUrl(item.thumbnail)
};
case 'banner':
return {
id: '',
src: item
};
} }
}); });
break; };
case 'banner': // 来自后台配置的banner(暂未开放) switch (this.$haloConfig.banner.type) {
this.bannerList = _format([], 'banner'); case 'list': // 手动配置的banner
break; this.bannerList = _format(this.$haloConfig.banner.list, 'list');
} break;
}, case 'article': // 来自热门文章的封面
fnOnBannerChange(e) { this.$httpApi.getPostList({ page: 0, size: 6, sort: 'topPriority,visits,desc' }).then(res => {
this.bannerCurrent = e.current; this.bannerList = _format(res.data.content, 'article');
}, if (this.bannerList.length == 0) {
fnOnBannerClick(item) { this.bannerList = _format(this.$haloConfig.banner.list, 'list');
if (item.id == '') return; }
this.fnToArticleDetail(item); });
}, break;
// 文章列表 case 'banner': // 来自后台配置的banner(暂未开放)
fnGetArticleList() { this.bannerList = _format([], 'banner');
uni.showLoading({ break;
mask: true, }
title: '加载中...' },
}); fnOnBannerChange(e) {
// 设置状态为加载中 this.bannerCurrent = e.current;
if (!this.isLoadMore) { },
this.loading = 'loading'; fnOnBannerClick(item) {
} if (item.id == '') return;
this.loadMoreText = '加载中...'; this.fnToArticleDetail(item);
this.$httpApi },
.getPostList(this.queryParams) // 文章列表
.then(res => { fnGetArticleList() {
this.loading = 'success'; uni.showLoading({
this.loadMoreText = res.data.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~'; mask: true,
this.result = res.data; title: '加载中...'
if (this.isLoadMore) {
this.articleList = this.articleList.concat(res.data.content);
} else {
this.articleList = res.data.content;
}
this.loading = 'success';
})
.catch(err => {
this.loading = 'error';
this.loadMoreText = '加载失败,请下拉刷新!';
uni.$tm.toast(err.message || '数据加载失败!');
})
.finally(() => {
uni.hideLoading();
uni.stopPullDownRefresh();
}); });
}, // 设置状态为加载中
if (!this.isLoadMore) {
this.loading = 'loading';
}
this.loadMoreText = '加载中...';
this.$httpApi
.getPostList(this.queryParams)
.then(res => {
this.loading = 'success';
this.loadMoreText = res.data.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~';
this.result = res.data;
if (this.isLoadMore) {
this.articleList = this.articleList.concat(res.data.content);
} else {
this.articleList = res.data.content;
}
this.loading = 'success';
})
.catch(err => {
this.loading = 'error';
this.loadMoreText = '加载失败,请下拉刷新!';
uni.$tm.toast(err.message || '数据加载失败!');
})
.finally(() => {
uni.hideLoading();
uni.stopPullDownRefresh();
});
},
//跳转文章详情 //跳转文章详情
fnToArticleDetail(article) { fnToArticleDetail(article) {
uni.navigateTo({ uni.navigateTo({
url: '/pagesA/article-detail/article-detail?articleId=' + article.id, url: '/pagesA/article-detail/article-detail?articleId=' + article.id,
animationType: 'slide-in-right' animationType: 'slide-in-right'
}); });
}, },
// 快捷导航页面跳转 // 快捷导航页面跳转
fnToNavPage(item) { fnToNavPage(item) {
switch (item.type) { switch (item.type) {
case 'tabbar': case 'tabbar':
uni.switchTab({ uni.switchTab({
url: item.path url: item.path
}); });
break; break;
case 'page': case 'page':
uni.navigateTo({ uni.navigateTo({
url: item.path url: item.path
}); });
break; break;
}
},
// 分类页面
fnToCategoryPage() {
uni.switchTab({
url: '/pages/tabbar/category/category'
});
},
// 所有的文章列表页面
fnToArticlesPage() {
uni.navigateTo({
url: '/pagesA/articles/articles'
});
},
// 根据slug查询分类下的文章
fnToCategoryBy(category) {
uni.navigateTo({
url: `/pagesA/category-detail/category-detail?slug=${category.slug}&name=${category.name}`
});
},
fnChangeMode() {
const isBlackTheme = this.$tm.vx.state().tmVuetify.black;
this.$tm.theme.setBlack(!isBlackTheme);
uni.setNavigationBarColor({
backgroundColor: !isBlackTheme ? '#0a0a0a' : '#ffffff',
frontColor: !isBlackTheme ? '#ffffff' : '#0a0a0a'
});
},
fnToSearch() {
uni.navigateTo({
url: '/pagesA/articles/articles'
});
} }
},
// 分类页面
fnToCategoryPage() {
uni.switchTab({
url: '/pages/tabbar/category/category'
});
},
// 所有的文章列表页面
fnToArticlesPage() {
uni.navigateTo({
url: '/pagesA/articles/articles'
});
},
// 根据slug查询分类下的文章
fnToCategoryBy(category) {
uni.navigateTo({
url: `/pagesA/category-detail/category-detail?slug=${category.slug}&name=${category.name}`
});
},
fnChangeMode() {
const isBlackTheme = this.$tm.vx.state().tmVuetify.black;
this.$tm.theme.setBlack(!isBlackTheme);
uni.setNavigationBarColor({
backgroundColor: !isBlackTheme ? '#0a0a0a' : '#ffffff',
frontColor: !isBlackTheme ? '#ffffff' : '#0a0a0a'
});
},
fnToSearch() {
uni.navigateTo({
url: '/pagesA/articles/articles'
});
} }
} };
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.app-page { .app-page {
width: 100vw; width: 100vw;
min-height: 100vh; min-height: 100vh;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
// background-color: #ffffff; // background-color: #ffffff;
.logo { .logo {
width: 60rpx; width: 60rpx;
height: 60rpx; height: 60rpx;
box-sizing: border-box;
}
::v-deep {
.tm-menubars .body .body_wk .left {
min-width: initial;
}
}
}
.loading-wrap {
padding: 24rpx;
}
.search-input {
background-color: #f5f5f5;
align-items: center;
/* #ifdef MP-WEIXIN */
margin-right: 24rpx;
/* #endif */
&_icon {}
&_text {}
}
.show-more {
width: 42rpx;
height: 42rpx;
box-sizing: border-box; box-sizing: border-box;
box-shadow: 0rpx 0rpx 24rpx rgba(0, 0, 0, 0.03);
} }
::v-deep { .banner {
.tm-menubars .body .body_wk .left { overflow: hidden;
min-width: initial;
}
} }
}
.loading-wrap {
padding: 24rpx;
}
.search-input {
background-color: #f5f5f5;
align-items: center;
/* #ifdef MP-WEIXIN */
margin-right: 24rpx;
/* #endif */
&_icon {
}
&_text {
}
}
.show-more {
width: 42rpx;
height: 42rpx;
box-sizing: border-box;
box-shadow: 0rpx 0rpx 24rpx rgba(0, 0, 0, 0.03);
}
.banner {
overflow: hidden;
}
.quick-nav {
background-color: #fff;
box-sizing: border-box;
// box-shadow: 0rpx 2rpx 24rpx rgba(0, 0, 0, 0.03);
.name {
color: var(--main-text-color);
}
}
.category {
width: 94vw;
display: flex;
height: 200rpx;
white-space: nowrap;
margin: 0 24rpx;
.content {
display: inline-block;
padding-left: 24rpx;
&:first-child {
padding-left: 0;
}
}
.cate-empty {
height: inherit;
}
}
.page-item { .quick-nav {
&_title { background-color: #fff;
position: relative; box-sizing: border-box;
padding-left: 24rpx;
font-size: 32rpx; // box-shadow: 0rpx 2rpx 24rpx rgba(0, 0, 0, 0.03);
z-index: 1; .name {
color: var(--main-text-color); color: var(--main-text-color);
&:before {
content: '';
position: absolute;
left: 0rpx;
top: 8rpx;
width: 8rpx;
height: 30rpx;
background-color: rgba(33, 150, 243, 1);
border-radius: 6rpx;
z-index: 0;
} }
} }
}
.h_row_col2 { .category {
display: flex; width: 94vw;
flex-wrap: wrap; display: flex;
box-sizing: border-box; height: 200rpx;
padding: 0 12rpx; white-space: nowrap;
.ani-item { margin: 0 24rpx;
width: 50%;
.content {
display: inline-block;
padding-left: 24rpx;
&:first-child {
padding-left: 0;
}
}
.cate-empty {
height: inherit;
}
} }
}
</style> .page-item {
&_title {
position: relative;
padding-left: 24rpx;
font-size: 32rpx;
z-index: 1;
color: var(--main-text-color);
&:before {
content: '';
position: absolute;
left: 0rpx;
top: 8rpx;
width: 8rpx;
height: 30rpx;
background-color: rgba(33, 150, 243, 1);
border-radius: 6rpx;
z-index: 0;
}
}
}
.h_row_col2 {
display: flex;
flex-wrap: wrap;
box-sizing: border-box;
padding: 0 12rpx;
.ani-item {
width: 50%;
}
}
</style>
+249 -275
Dosyayı Görüntüle
@@ -16,22 +16,11 @@
<!-- 如果只有一个分组使用列表的形式 result.length == 1 --> <!-- 如果只有一个分组使用列表的形式 result.length == 1 -->
<view v-else-if="result.length == 1" class="flex flex-col pb-24"> <view v-else-if="result.length == 1" class="flex flex-col pb-24">
<block v-for="(link, index) in result[0].children" :key="index"> <block v-for="(link, index) in result[0].children" :key="index">
<tm-translate animation-name="fadeUp" :wait="(index + 1) * 50"> <tm-translate animation-name="fadeUp" :wait="calcAniWait(index)">
<!-- 色彩版本 --> <!-- 色彩版本 -->
<view <view v-if="!globalAppSettings.links.useSimple" class="info flex pt-24 pb-24 pl-12 pr-12" :class="{ 'border-b-1': index != result[0].children.length - 1 }" @click="fnOnLinkEvent(link)">
v-if="!globalAppSettings.links.useSimple"
class="info flex pt-24 pb-24 pl-12 pr-12"
:class="{ 'border-b-1': index != result[0].children.length - 1 }"
@click="fnOnLinkEvent(link)"
>
<view class="link-logo"> <view class="link-logo">
<cache-image <cache-image class="link-logo_img" radius="12rpx" :url="link.logo" :fileMd5="link.logo" mode="aspectFill"></cache-image>
class="link-logo_img"
radius="12rpx"
:url="link.logo"
:fileMd5="link.logo"
mode="aspectFill"
></cache-image>
</view> </view>
<view class="flex flex-col pl-30 info-detail"> <view class="flex flex-col pl-30 info-detail">
<view class="link-card_name text-size-l text-weight-b text-red">{{ link.name }}</view> <view class="link-card_name text-size-l text-weight-b text-red">{{ link.name }}</view>
@@ -67,28 +56,17 @@
<!-- 如果大于一个分组使用联系人的索引形式 result.length > 1 --> <!-- 如果大于一个分组使用联系人的索引形式 result.length > 1 -->
<block v-else> <block v-else>
<block v-for="(team, index) in result" :key="index"> <block v-for="(team, index) in result" :key="index">
<tm-translate animation-name="fadeUp" :wait="(index + 1) * 50"> <tm-translate animation-name="fadeUp" :wait="calcAniWait(index)">
<view class="grey-lighten-4 text text-size-s text-weight-b px-32 py-12">{{ team.title }}</view> <view class="grey-lighten-4 text text-size-s text-weight-b px-32 py-12">{{ team.title }}</view>
<block v-for="(link, linkIndex) in team.children" :key="link.id"> <block v-for="(link, linkIndex) in team.children" :key="link.id">
<tm-translate animation-name="fadeUp" :wait="(linkIndex + 1) * 50"> <tm-translate animation-name="fadeUp" :wait="calcAniWait(linkIndex)">
<!-- 色彩版本 --> <!-- 色彩版本 -->
<view <view v-if="!globalAppSettings.links.useSimple" class="info flex pt-24 pb-24 pl-12 pr-12" :class="{
v-if="!globalAppSettings.links.useSimple"
class="info flex pt-24 pb-24 pl-12 pr-12"
:class="{
'border-b-1': 'border-b-1':
linkIndex != team.children.length - 1 || index == result.length - 1 linkIndex != team.children.length - 1 || index == result.length - 1
}" }" @click="fnOnLinkEvent(link)">
@click="fnOnLinkEvent(link)"
>
<view class="link-logo"> <view class="link-logo">
<cache-image <cache-image class="link-logo_img" radius="12rpx" :url="link.logo" :fileMd5="link.logo" mode="aspectFill"></cache-image>
class="link-logo_img"
radius="12rpx"
:url="link.logo"
:fileMd5="link.logo"
mode="aspectFill"
></cache-image>
</view> </view>
<view class="flex flex-col pl-30 info-detail"> <view class="flex flex-col pl-30 info-detail">
<view class="link-card_name text-size-l text-weight-b text-red"> <view class="link-card_name text-size-l text-weight-b text-red">
@@ -98,12 +76,7 @@
<tm-tags color="bg-gradient-amber-accent" :shadow="0" size="s" model="fill"> <tm-tags color="bg-gradient-amber-accent" :shadow="0" size="s" model="fill">
ID{{ link.id }} ID{{ link.id }}
</tm-tags> </tm-tags>
<tm-tags <tm-tags color=" bg-gradient-light-blue-lighten" :shadow="0" size="s" model="fill">
color=" bg-gradient-light-blue-lighten"
:shadow="0"
size="s"
model="fill"
>
{{ link.team || '暂未分组' }} {{ link.team || '暂未分组' }}
</tm-tags> </tm-tags>
</view> </view>
@@ -113,11 +86,7 @@
</view> </view>
</view> </view>
<!-- 简洁版本 --> <!-- 简洁版本 -->
<view <view v-else class="link-card flex ml-24 mr-24 pt-24 pb-24" @click="fnOnLinkEvent(link)">
v-else
class="link-card flex ml-24 mr-24 pt-24 pb-24"
@click="fnOnLinkEvent(link)"
>
<image class="logo shadow-6" :src="link.logo" mode="aspectFill"></image> <image class="logo shadow-6" :src="link.logo" mode="aspectFill"></image>
<view class="info pl-24"> <view class="info pl-24">
<view class="name text-size-g">{{ link.name }}</view> <view class="name text-size-g">{{ link.name }}</view>
@@ -137,13 +106,7 @@
</block> </block>
<!-- 返回顶部 --> <!-- 返回顶部 -->
<tm-flotbutton <tm-flotbutton v-if="linkTotal > 10" color="light-blue" @click="fnToTopPage" size="m" icon="icon-angle-up"></tm-flotbutton>
v-if="linkTotal > 10"
color="light-blue"
@click="fnToTopPage"
size="m"
icon="icon-angle-up"
></tm-flotbutton>
<!-- 详情弹窗 --> <!-- 详情弹窗 -->
<tm-poup v-model="detail.show" :width="640" height="auto" position="center" :round="6"> <tm-poup v-model="detail.show" :width="640" height="auto" position="center" :round="6">
@@ -175,12 +138,7 @@
<!-- 博客预览图 --> <!-- 博客预览图 -->
<view class="mt-24"> <view class="mt-24">
<tm-images <tm-images :width="568" :round="2" :src="caclSiteThumbnail(detail.data.url)" mode="aspectFill"></tm-images>
:width="568"
:round="2"
:src="caclSiteThumbnail(detail.data.url)"
mode="aspectFill"
></tm-images>
</view> </view>
</view> </view>
</tm-poup> </tm-poup>
@@ -189,243 +147,259 @@
</template> </template>
<script> <script>
import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue'; import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue';
import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue'; import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue';
import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue'; import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue';
import tmTags from '@/tm-vuetify/components/tm-tags/tm-tags.vue'; import tmTags from '@/tm-vuetify/components/tm-tags/tm-tags.vue';
import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue'; import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue';
import tmImages from '@/tm-vuetify/components/tm-images/tm-images.vue'; import tmImages from '@/tm-vuetify/components/tm-images/tm-images.vue';
import tmPoup from '@/tm-vuetify/components/tm-poup/tm-poup.vue'; import tmPoup from '@/tm-vuetify/components/tm-poup/tm-poup.vue';
import { GetRandomNumberByRange } from '@/utils/random.js'; import { GetRandomNumberByRange } from '@/utils/random.js';
export default { export default {
components: { components: {
tmSkeleton, tmSkeleton,
tmTranslate, tmTranslate,
tmFlotbutton, tmFlotbutton,
tmTags, tmTags,
tmEmpty, tmEmpty,
tmImages, tmImages,
tmPoup tmPoup
},
data() {
return {
loading: 'loading',
queryParams: {
size: 10,
page: 0,
sort: ''
},
result: [],
detail: {
show: false,
data: {}
},
linkTotal: 0
};
},
computed: {
caclSiteThumbnail(val) {
return val => {
if (!val) return '';
if (val.charAt(val.length - 1) != '/') {
val = val + '/';
}
return 'https://image.thum.io/get/width/1000/crop/800/' + val;
};
}
},
onLoad() {
this.fnSetPageTitle('朋友圈');
},
created() {
this.fnGetData();
},
onPullDownRefresh() {
this.fnGetData();
},
methods: {
fnRandomColor() {
const _r = GetRandomNumberByRange(0, this.$haloConfig.colors.length - 1);
return this.$haloConfig.colors[_r];
}, },
fnGetData() { data() {
this.linkTotal = 0; return {
this.loading = 'loading'; loading: 'loading',
uni.showLoading({ queryParams: {
mask: true, size: 10,
title: '加载中...' page: 0,
}); sort: ''
this.$httpApi
.getLinkListByTeam()
.then(res => {
if (res.status == 200) {
console.log('请求结果:');
console.log(res);
// 处理数据
const _result = res.data.map(item => {
const _team = item.team || '未分组';
const _links = item.links.map(link => {
this.linkTotal += 1;
link.logo = this.$utils.checkAvatarUrl(link.logo);
return link;
});
return {
title: _team,
children: _links
};
});
this.result = _result.reverse();
setTimeout(() => {
this.loading = 'success';
}, 500);
} else {
this.loading = 'error';
}
})
.catch(err => {
console.error(err);
this.loading = 'error';
})
.finally(() => {
setTimeout(() => {
uni.hideLoading();
uni.stopPullDownRefresh();
}, 500);
});
},
fnOnLinkEvent(link) {
this.detail.data = link;
this.detail.show = true;
},
fnCopyLink(link) {
uni.setClipboardData({
data: `${link.name}:${link.url}`,
showToast: false,
success: () => {
uni.showToast({
icon: 'none',
title: '链接复制成功!'
});
}, },
fail: () => { result: [],
uni.showToast({ detail: {
icon: 'none', show: false,
title: '复制失败!' data: {}
},
linkTotal: 0
};
},
computed: {
caclSiteThumbnail(val) {
return val => {
if (!val) return '';
if (val.charAt(val.length - 1) != '/') {
val = val + '/';
}
return 'https://image.thum.io/get/width/1000/crop/800/' + val;
};
}
},
onLoad() {
this.fnSetPageTitle('朋友圈');
},
created() {
this.fnGetData();
},
onPullDownRefresh() {
this.fnGetData();
},
methods: {
fnRandomColor() {
const _r = GetRandomNumberByRange(0, this.$haloConfig.colors.length - 1);
return this.$haloConfig.colors[_r];
},
fnGetData() {
this.linkTotal = 0;
this.loading = 'loading';
uni.showLoading({
mask: true,
title: '加载中...'
});
this.$httpApi
.getLinkListByTeam()
.then(res => {
if (res.status == 200) {
console.log('请求结果:');
console.log(res);
// 处理数据
const _result = res.data.map(item => {
const _team = item.team || '未分组';
const _links = item.links.map(link => {
this.linkTotal += 1;
link.logo = this.$utils.checkAvatarUrl(link.logo);
return link;
});
return {
title: _team,
children: _links
};
});
this.result = _result.reverse();
setTimeout(() => {
this.loading = 'success';
}, 500);
} else {
this.loading = 'error';
}
})
.catch(err => {
console.error(err);
this.loading = 'error';
})
.finally(() => {
setTimeout(() => {
uni.hideLoading();
uni.stopPullDownRefresh();
}, 500);
}); });
} },
});
fnOnLinkEvent(link) {
this.detail.data = link;
this.detail.show = true;
},
fnCopyLink(link) {
uni.setClipboardData({
data: `${link.name}:${link.url}`,
showToast: false,
success: () => {
uni.showToast({
icon: 'none',
title: '链接复制成功!'
});
},
fail: () => {
uni.showToast({
icon: 'none',
title: '复制失败!'
});
}
});
}
} }
} };
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.app-page { .app-page {
width: 100vw; width: 100vw;
min-height: 100vh; min-height: 100vh;
display: flex;
flex-direction: column;
background-color: #fafafd;
}
.loading-wrap {
padding: 24rpx;
min-height: 100vh;
}
.content {
padding: 0 24rpx;
padding-top: 24rpx;
.content-empty {
height: 60vh;
display: flex; display: flex;
align-items: center; flex-direction: column;
justify-content: center; background-color: #fafafd;
} }
}
.link-card { .loading-wrap {
border-bottom: 2rpx solid #f5f5f5; padding: 24rpx;
background-color: #ffffff; min-height: 100vh;
&.one { }
border: 0;
box-shadow: 0rpx 2rpx 24rpx 0rpx rgba(0, 0, 0, 0.03); .content {
.logo { padding: 0 24rpx;
box-shadow: 0rpx 2rpx 12rpx rgba(0, 0, 0, 0.1); padding-top: 24rpx;
.content-empty {
height: 60vh;
display: flex;
align-items: center;
justify-content: center;
} }
} }
.logo {
// width: 126rpx; .link-card {
// height: 126rpx; border-bottom: 2rpx solid #f5f5f5;
width: 80rpx; background-color: #ffffff;
height: 80rpx;
border-radius: 12rpx; &.one {
border: 6rpx solid #ffffff; border: 0;
box-shadow: none; box-shadow: 0rpx 2rpx 24rpx 0rpx rgba(0, 0, 0, 0.03);
.logo {
box-shadow: 0rpx 2rpx 12rpx rgba(0, 0, 0, 0.1);
}
}
.logo {
// width: 126rpx;
// height: 126rpx;
width: 80rpx;
height: 80rpx;
border-radius: 12rpx;
border: 6rpx solid #ffffff;
box-shadow: none;
}
.info {
width: 0;
flex-grow: 1;
.name {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
color: #303133;
font-size: 30rpx;
font-weight: bold;
}
.desc {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
color: #303133;
font-size: 28rpx;
}
}
} }
.info { .link-card_name {
// color: #303133;
// color: #0080fe;
}
.link-card_desc {
font-size: 24rpx;
line-height: 1.6;
color: #303133;
}
.link-logo {
width: 140rpx;
height: 140rpx;
&_img {
width: 100%;
height: 100%;
}
}
.poup-logo {
width: 140rpx;
height: 140rpx;
border-radius: 50%;
&_img {
width: 100%;
height: 100%;
border-radius: 50%;
}
}
.info-detail {
width: 0; width: 0;
flex-grow: 1; flex-grow: 1;
.name { justify-content: center;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
color: #303133;
font-size: 30rpx;
font-weight: bold;
}
.desc {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
color: #303133;
font-size: 28rpx;
}
} }
}
.link-card_name { .poup-desc {
// color: #303133; font-size: 28rpx;
// color: #0080fe; line-height: 1.6;
} color: #555 !important;
.link-card_desc { }
font-size: 24rpx;
line-height: 1.6; .preview-site {
color: #303133;
}
.link-logo {
width: 140rpx;
height: 140rpx;
&_img {
width: 100%; width: 100%;
height: 100%; height: 300rpx;
} }
} </style>
.poup-logo {
width: 140rpx;
height: 140rpx;
border-radius: 50%;
&_img {
width: 100%;
height: 100%;
border-radius: 50%;
}
}
.info-detail {
width: 0;
flex-grow: 1;
justify-content: center;
}
.poup-desc {
font-size: 28rpx;
line-height: 1.6;
color: #555 !important;
}
.preview-site {
width: 100%;
height: 300rpx;
}
</style>
+271 -244
Dosyayı Görüntüle
@@ -18,16 +18,8 @@
<block v-for="(item, index) in dataList" :key="index"> <block v-for="(item, index) in dataList" :key="index">
<view class="tm-timeline-item tm-timeline-item--leftDir"> <view class="tm-timeline-item tm-timeline-item--leftDir">
<view style="width: 160rpx;"> <view style="width: 160rpx;">
<view <view :style="{ width: '24rpx', height: '24rpx' }" :class="[black_tmeme ? 'bk' : '']" class="flex-center rounded tm-timeline-jidian border-white-a-2 grey-lighten-2 light-blue shadow-primary-4"></view>
:style="{ width: '24rpx', height: '24rpx' }" <view :style="{ marginTop: '-24rpx' }" :class="[index !== dataList.length - 1 ? 'tm-timeline-item-boder' : '', black_tmeme ? 'bk' : '']" class="grey-lighten-2"></view>
:class="[black_tmeme ? 'bk' : '']"
class="flex-center rounded tm-timeline-jidian border-white-a-2 grey-lighten-2 light-blue shadow-primary-4"
></view>
<view
:style="{ marginTop: '-24rpx' }"
:class="[index !== dataList.length - 1 ? 'tm-timeline-item-boder' : '', black_tmeme ? 'bk' : '']"
class="grey-lighten-2"
></view>
</view> </view>
<view class="tm-timeline-item-content relative"> <view class="tm-timeline-item-content relative">
<view class="tm-timeline-item-left"> <view class="tm-timeline-item-left">
@@ -38,7 +30,7 @@
</view> </view>
<block v-if="item.posts.length != 0"> <block v-if="item.posts.length != 0">
<block v-for="(post, postIndex) in item.posts" :key="post.id"> <block v-for="(post, postIndex) in item.posts" :key="post.id">
<tm-translate animation-name="fadeUp" :wait="(postIndex + 1) * 50"> <tm-translate animation-name="fadeUp" :wait="calcAniWait(postIndex)">
<view class="flex post shadow-3 pa-24 mb-24" :class="[globalAppSettings.layout.cardType]" @click="fnToArticleDetail(post)"> <view class="flex post shadow-3 pa-24 mb-24" :class="[globalAppSettings.layout.cardType]" @click="fnToArticleDetail(post)">
<image class="post-thumbnail" :src="$utils.checkThumbnailUrl(post.thumbnail)" mode="aspectFill"></image> <image class="post-thumbnail" :src="$utils.checkThumbnailUrl(post.thumbnail)" mode="aspectFill"></image>
<view class="post-info pl-20"> <view class="post-info pl-20">
@@ -67,274 +59,309 @@
</template> </template>
<script> <script>
import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue'; import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue';
import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue'; import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue';
import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue'; import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue';
import tmTabs from '@/tm-vuetify/components/tm-tabs/tm-tabs.vue'; import tmTabs from '@/tm-vuetify/components/tm-tabs/tm-tabs.vue';
import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue'; import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue';
export default { export default {
components: { components: {
tmSkeleton, tmSkeleton,
tmTranslate, tmTranslate,
tmFlotbutton, tmFlotbutton,
tmTabs, tmTabs,
tmEmpty tmEmpty
},
data() {
return {
loading: 'loading',
tab: {
activeIndex: 0,
list: ['按月份查看', '按年份查看']
},
queryParams: {
size: 10,
page: 0
},
result: null,
dataList: [],
api: 'getMonthArchives'
};
},
computed: {
black_tmeme: function() {
return this.$tm.vx.state().tmVuetify.black;
}, },
color_tmeme: function() { data() {
return this.$tm.vx.state().tmVuetify.color; return {
} loading: 'loading',
}, tab: {
created() { activeIndex: 0,
this.fnGetData(); list: ['按月份查看', '按年份查看']
}, },
onPullDownRefresh() { queryParams: {
this.fnGetData(); size: 10,
this.queryParams.page = 0; page: 0
}, },
result: null,
methods: { dataList: [],
fnOnTabChange(index) { api: 'getMonthArchives'
// todo: };
const _api = ['getMonthArchives', 'getYearArchives']; },
this.api = _api[index]; computed: {
this.queryParams.page = 0; black_tmeme: function() {
return this.$tm.vx.state().tmVuetify.black;
},
color_tmeme: function() {
return this.$tm.vx.state().tmVuetify.color;
}
},
created() {
this.fnGetData(); this.fnGetData();
}, },
fnGetData() { onPullDownRefresh() {
this.loading = 'loading'; this.fnGetData();
uni.showLoading({ this.queryParams.page = 0;
mask: true,
title: '加载中...'
});
this.$httpApi[this.api](this.queryParams)
.then(res => {
this.result = res.data;
this.dataList = res.data;
setTimeout(() => {
this.loading = 'success';
}, 500);
})
.catch(err => {
console.error(err);
this.loading = 'error';
})
.finally(() => {
setTimeout(() => {
uni.hideLoading();
uni.stopPullDownRefresh();
}, 500);
});
}, },
//跳转文章详情
fnToArticleDetail(article) { methods: {
uni.navigateTo({ fnOnTabChange(index) {
url: '/pagesA/article-detail/article-detail?articleId=' + article.id, this.fnResetSetAniWaitIndex();
animationType: 'slide-in-right' const _api = ['getMonthArchives', 'getYearArchives'];
}); this.api = _api[index];
this.queryParams.page = 0;
this.fnGetData();
},
fnGetData() {
this.loading = 'loading';
uni.showLoading({
mask: true,
title: '加载中...'
});
this.$httpApi[this.api](this.queryParams)
.then(res => {
this.result = res.data;
this.dataList = res.data;
setTimeout(() => {
this.loading = 'success';
}, 500);
})
.catch(err => {
console.error(err);
this.loading = 'error';
})
.finally(() => {
setTimeout(() => {
uni.hideLoading();
uni.stopPullDownRefresh();
}, 500);
});
},
//跳转文章详情
fnToArticleDetail(article) {
uni.navigateTo({
url: '/pagesA/article-detail/article-detail?articleId=' + article.id,
animationType: 'slide-in-right'
});
}
} }
} };
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.app-page { .app-page {
width: 100vw; width: 100vw;
min-height: 100vh; min-height: 100vh;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
background-color: #fafafd; background-color: #fafafd;
} }
.loading-wrap {
padding: 24rpx; .loading-wrap {
} padding: 24rpx;
.list-empty { }
width: 100vw;
height: 100vh; .list-empty {
} width: 100vw;
.statistics { height: 100vh;
background-color: #ffffff; }
}
.e-timeline { .statistics {
::v-deep { background-color: #ffffff;
.tm-timeline-item > view:first-child { }
width: 110rpx !important;
} .e-timeline {
.tm-timeline-item-left { ::v-deep {
max-width: 580rpx !important; .tm-timeline-item>view:first-child {
width: 100% !important; width: 110rpx !important;
}
.tm-timeline-item-left {
max-width: 580rpx !important;
width: 100% !important;
}
} }
} }
}
.tm-timeline { .tm-timeline {
.tm-timeline-item { .tm-timeline-item {
.tm-timeline-item-left,
.tm-timeline-item-right {
width: 200rpx;
flex-shrink: 0;
}
.tm-timeline-item-content {
display: flex;
justify-content: center;
align-items: flex-start;
align-content: flex-start;
}
.tm-timeline-jidian {
margin: auto;
}
&.tm-timeline-item--leftDir {
display: flex;
flex-flow: row;
&.endright {
justify-content: flex-end;
}
.tm-timeline-item-left, .tm-timeline-item-left,
.tm-timeline-item-right { .tm-timeline-item-right {
width: auto; width: 200rpx;
max-width: 400rpx; flex-shrink: 0;
}
.tm-timeline-item-boder {
height: 100%;
width: 1px;
margin: auto;
}
.tm-timeline-jidian {
position: relative;
margin: auto;
z-index: 2;
} }
.tm-timeline-item-content { .tm-timeline-item-content {
display: flex; display: flex;
justify-content: flex-start; justify-content: center;
align-items: flex-start; align-items: flex-start;
align-content: flex-start; align-content: flex-start;
} }
}
}
}
.post { .tm-timeline-jidian {
width: 560rpx; margin: auto;
border-radius: 12rpx; }
background-color: #fff;
&.lr_image_text { &.tm-timeline-item--leftDir {
} display: flex;
&.lr_text_image { flex-flow: row;
.post-thumbnail {
order: 2; &.endright {
} justify-content: flex-end;
.post-info { }
order: 1;
padding-left: 0; .tm-timeline-item-left,
padding-right: 24rpx; .tm-timeline-item-right {
width: auto;
max-width: 400rpx;
}
.tm-timeline-item-boder {
height: 100%;
width: 1px;
margin: auto;
}
.tm-timeline-jidian {
position: relative;
margin: auto;
z-index: 2;
}
.tm-timeline-item-content {
display: flex;
justify-content: flex-start;
align-items: flex-start;
align-content: flex-start;
}
}
} }
} }
&.tb_image_text {
flex-direction: column; .post {
.post-thumbnail { width: 560rpx;
width: 100%; border-radius: 12rpx;
height: 220rpx; background-color: #fff;
&.lr_image_text {}
&.lr_text_image {
.post-thumbnail {
order: 2;
}
.post-info {
order: 1;
padding-left: 0;
padding-right: 24rpx;
}
} }
.post-info {
width: 100%; &.tb_image_text {
padding-left: 0; flex-direction: column;
&_title {
.post-thumbnail {
width: 100%;
height: 220rpx;
}
.post-info {
width: 100%;
padding-left: 0;
&_title {
margin-top: 12rpx;
}
&_time {
.iconfont {
display: none;
}
.time-label {
display: inline-block;
}
}
}
}
&.tb_text_image {
flex-direction: column;
.post-thumbnail {
order: 2;
width: 100%;
height: 220rpx;
margin-top: 12rpx; margin-top: 12rpx;
} }
&_time {
.iconfont {
display: none;
}
.time-label {
display: inline-block;
}
}
}
}
&.tb_text_image {
flex-direction: column;
.post-thumbnail {
order: 2;
width: 100%;
height: 220rpx;
margin-top: 12rpx;
}
.post-info {
order: 1;
width: 100%;
padding-left: 0;
&_time { .post-info {
.iconfont { order: 1;
display: none; width: 100%;
} padding-left: 0;
.time-label {
display: inline-block; &_time {
.iconfont {
display: none;
}
.time-label {
display: inline-block;
}
} }
} }
} }
}
&.only_text { &.only_text {
.post-info { .post-info {
padding: 6rpx; padding: 6rpx;
&_time {
margin-top: 20rpx; &_time {
.iconfont { margin-top: 20rpx;
display: none;
} .iconfont {
.time-label { display: none;
display: inline-block; }
.time-label {
display: inline-block;
}
} }
} }
}
.post-thumbnail { .post-thumbnail {
display: none; display: none;
}
} }
} }
}
.post-thumbnail { .post-thumbnail {
border-radius: 6rpx; border-radius: 6rpx;
width: 200rpx; width: 200rpx;
height: 170rpx; height: 170rpx;
}
.post-info {
width: 0;
flex-grow: 1;
&_title {
color: #303133;
font-size: 28rpx;
font-weight: bold;
} }
&_summary {
display: -webkit-box; .post-info {
line-height: 1.6; width: 0;
} flex-grow: 1;
&_time {
.time-label { &_title {
display: none; color: #303133;
font-size: 28rpx;
font-weight: bold;
}
&_summary {
display: -webkit-box;
line-height: 1.6;
}
&_time {
.time-label {
display: none;
}
} }
} }
} </style>
</style>
+141 -138
Dosyayı Görüntüle
@@ -23,7 +23,7 @@
<block v-else> <block v-else>
<block v-for="(article, index) in dataList" :key="article.id"> <block v-for="(article, index) in dataList" :key="article.id">
<!-- 文章卡片 --> <!-- 文章卡片 -->
<tm-translate animation-name="fadeUp" :wait="(index + 1) * 50"> <tm-translate animation-name="fadeUp" :wait="calcAniWait(index)">
<article-card :article="article" @on-click="fnToArticleDetail"></article-card> <article-card :article="article" @on-click="fnToArticleDetail"></article-card>
<!-- 广告区域 --> <!-- 广告区域 -->
<view v-if="haloAdConfig.articles.use && (index + 1) % haloAdConfig.frequency == 0" class="ad-wrap ma-24"> <view v-if="haloAdConfig.articles.use && (index + 1) % haloAdConfig.frequency == 0" class="ad-wrap ma-24">
@@ -45,159 +45,162 @@
</template> </template>
<script> <script>
import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue'; import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue';
import tmSearch from '@/tm-vuetify/components/tm-search/tm-search.vue'; import tmSearch from '@/tm-vuetify/components/tm-search/tm-search.vue';
import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue'; import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue';
import tmTabs from '@/tm-vuetify/components/tm-tabs/tm-tabs.vue'; import tmTabs from '@/tm-vuetify/components/tm-tabs/tm-tabs.vue';
import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue'; import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue';
import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue'; import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue';
export default { export default {
components: { components: {
tmSkeleton, tmSkeleton,
tmSearch, tmSearch,
tmTranslate, tmTranslate,
tmTabs, tmTabs,
tmFlotbutton, tmFlotbutton,
tmEmpty tmEmpty
}, },
data() { data() {
return { return {
isBlackTheme: false, isBlackTheme: false,
loading: 'loading', loading: 'loading',
tab: { tab: {
activeIndex: 0, activeIndex: 0,
list: ['全部', '最新文章', '热门文章', '最近更新', '最多点赞'] list: ['全部', '最新文章', '热门文章', '最近更新', '最多点赞']
}, },
queryParams: { queryParams: {
size: 10, size: 10,
page: 0, page: 0,
sort: 'topPriority,createTime,desc', sort: 'topPriority,createTime,desc',
keyword: '' keyword: ''
}, },
cache: { cache: {
dataList: [], dataList: [],
total: 0 total: 0
}, },
isLoadMore: false, isLoadMore: false,
loadMoreText: '加载中...', loadMoreText: '加载中...',
result: {}, result: {},
dataList: [] dataList: []
};
},
onLoad() {
this.fnSetPageTitle('文章列表');
},
created() {
this.fnGetData();
},
onPullDownRefresh() {
this.isLoadMore = false;
this.queryParams.page = 0;
this.fnGetData();
},
onReachBottom(e) {
if (this.result.hasNext) {
this.queryParams.page += 1;
this.isLoadMore = true;
this.fnGetData();
} else {
uni.showToast({
icon: 'none',
title: '没有更多数据了'
});
}
},
methods: {
fnOnTabChange(index) {
this.dataList = [];
const _sorts = {
0: '',
1: 'topPriority,createTime,desc',
2: 'topPriority,visits,desc',
3: 'topPriority,updateTime,desc',
4: 'topPriority,likes,desc'
}; };
this.queryParams.sort = _sorts[index]; },
this.queryParams.page = 0; onLoad() {
this.dataList = []; this.fnSetPageTitle('文章列表');
this.fnToTopPage(); },
created() {
this.fnGetData(); this.fnGetData();
}, },
fnOnSearch() { onPullDownRefresh() {
this.queryParams.page = 0;
this.isLoadMore = false; this.isLoadMore = false;
this.queryParams.page = 0;
this.fnGetData(); this.fnGetData();
}, },
fnGetData() {
uni.showLoading({
mask: true,
title: '加载中...'
});
// 设置状态为加载中
if (!this.isLoadMore) {
this.loading = 'loading';
}
this.loadMoreText = '加载中...';
this.$httpApi
.getPostList(this.queryParams)
.then(res => {
console.log('请求结果:');
console.log(res);
this.loading = 'success'; onReachBottom(e) {
this.loadMoreText = res.data.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~'; if (this.result.hasNext) {
// 处理数据 this.queryParams.page += 1;
this.result = res.data; this.isLoadMore = true;
if (this.isLoadMore) { this.fnGetData();
this.dataList = this.dataList.concat(res.data.content); } else {
} else { uni.showToast({
this.dataList = res.data.content; icon: 'none',
} title: '没有更多数据了'
})
.catch(err => {
console.error(err);
this.loading = 'error';
this.loadMoreText = '加载失败,请下拉刷新!';
})
.finally(() => {
setTimeout(() => {
uni.hideLoading();
uni.stopPullDownRefresh();
}, 800);
}); });
}
}, },
methods: {
fnOnTabChange(index) {
this.fnResetSetAniWaitIndex();
this.dataList = [];
const _sorts = {
0: '',
1: 'topPriority,createTime,desc',
2: 'topPriority,visits,desc',
3: 'topPriority,updateTime,desc',
4: 'topPriority,likes,desc'
};
this.queryParams.sort = _sorts[index];
this.queryParams.page = 0;
this.dataList = [];
this.fnToTopPage();
this.fnGetData();
},
fnOnSearch() {
this.fnResetSetAniWaitIndex();
this.queryParams.page = 0;
this.isLoadMore = false;
this.fnGetData();
},
fnGetData() {
uni.showLoading({
mask: true,
title: '加载中...'
});
// 设置状态为加载中
if (!this.isLoadMore) {
this.loading = 'loading';
}
this.loadMoreText = '加载中...';
this.$httpApi
.getPostList(this.queryParams)
.then(res => {
console.log('请求结果:');
console.log(res);
//跳转文章详情 this.loading = 'success';
fnToArticleDetail(article) { this.loadMoreText = res.data.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~';
uni.navigateTo({ // 处理数据
url: '/pagesA/article-detail/article-detail?articleId=' + article.id, this.result = res.data;
animationType: 'slide-in-right' if (this.isLoadMore) {
}); this.dataList = this.dataList.concat(res.data.content);
} else {
this.dataList = res.data.content;
}
})
.catch(err => {
console.error(err);
this.loading = 'error';
this.loadMoreText = '加载失败,请下拉刷新!';
})
.finally(() => {
setTimeout(() => {
uni.hideLoading();
uni.stopPullDownRefresh();
}, 800);
});
},
//跳转文章详情
fnToArticleDetail(article) {
uni.navigateTo({
url: '/pagesA/article-detail/article-detail?articleId=' + article.id,
animationType: 'slide-in-right'
});
}
} }
} };
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.app-page { .app-page {
width: 100vw; width: 100vw;
min-height: 100vh; min-height: 100vh;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
padding-bottom: 24rpx; padding-bottom: 24rpx;
background-color: #fafafd; background-color: #fafafd;
&.is-balck { &.is-balck {
background-color: #212121; background-color: #212121;
}
} }
}
.content {
padding-top: 24rpx;
.content-empty { .content {
height: 60vh; padding-top: 24rpx;
.content-empty {
height: 60vh;
}
} }
} </style>
</style>
+118 -116
Dosyayı Görüntüle
@@ -11,7 +11,7 @@
<block v-else> <block v-else>
<block v-for="(article, index) in dataList" :key="article.createTime"> <block v-for="(article, index) in dataList" :key="article.createTime">
<!-- 文章卡片 --> <!-- 文章卡片 -->
<tm-translate animation-name="fadeUp" :wait="(index + 1) * 50"><article-card :article="article" @on-click="fnToArticleDetail"></article-card></tm-translate> <tm-translate animation-name="fadeUp" :wait="calcAniWait(index)"><article-card :article="article" @on-click="fnToArticleDetail"></article-card></tm-translate>
</block> </block>
<view class="load-text">{{ loadMoreText }}</view> <view class="load-text">{{ loadMoreText }}</view>
</block> </block>
@@ -22,123 +22,125 @@
</template> </template>
<script> <script>
import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue'; import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue';
import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue'; import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue';
import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue'; import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue';
import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue'; import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue';
import ArticleCard from '@/components/article-card/article-card.vue'; import ArticleCard from '@/components/article-card/article-card.vue';
export default { export default {
components: { components: {
tmSkeleton, tmSkeleton,
tmTranslate, tmTranslate,
tmFlotbutton, tmFlotbutton,
tmEmpty, tmEmpty,
ArticleCard ArticleCard
},
data() {
return {
loading: 'loading',
queryParams: {
size: 10,
page: 0
},
slug: '',
pageTitle: '加载中...',
result: null,
dataList: [],
isLoadMore: false,
loadMoreText: ''
};
},
onLoad(e) {
this.slug = e.slug;
this.pageTitle = e.name;
this.fnGetData();
},
onPullDownRefresh() {
this.isLoadMore = false;
this.queryParams.page = 0;
this.fnGetData();
},
onReachBottom(e) {
if (this.result.hasNext) {
this.queryParams.page += 1;
this.isLoadMore = true;
this.fnGetData();
} else {
uni.showToast({
icon: 'none',
title: '没有更多数据了'
});
}
},
methods: {
fnGetData() {
uni.showLoading({
mask: true,
title: '加载中...'
});
// 设置状态为加载中
if (!this.isLoadMore) {
this.loading = 'loading';
}
this.loadMoreText = '加载中...';
this.$httpApi
.getCategoryPostList(this.slug, this.queryParams)
.then(res => {
this.fnSetPageTitle(`分类:${this.pageTitle} (共${res.data.total}篇)`);
this.result = res.data;
if (this.isLoadMore) {
this.dataList = this.dataList.concat(res.data.content);
} else {
this.dataList = res.data.content;
}
this.loadMoreText = res.data.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~';
setTimeout(() => {
this.loading = 'success';
}, 500);
})
.catch(err => {
console.error(err);
this.loading = 'error';
this.loadMoreText = '加载失败,请下拉刷新!';
})
.finally(() => {
setTimeout(() => {
uni.hideLoading();
uni.stopPullDownRefresh();
}, 500);
});
}, },
//跳转文章详情 data() {
fnToArticleDetail(article) { return {
uni.navigateTo({ loading: 'loading',
url: '/pagesA/article-detail/article-detail?articleId=' + article.id, queryParams: {
animationType: 'slide-in-right' size: 10,
}); page: 0
},
slug: '',
pageTitle: '加载中...',
result: null,
dataList: [],
isLoadMore: false,
loadMoreText: ''
};
},
onLoad(e) {
this.slug = e.slug;
this.pageTitle = e.name;
this.fnGetData();
},
onPullDownRefresh() {
this.isLoadMore = false;
this.queryParams.page = 0;
this.fnGetData();
},
onReachBottom(e) {
if (this.result.hasNext) {
this.queryParams.page += 1;
this.isLoadMore = true;
this.fnGetData();
} else {
uni.showToast({
icon: 'none',
title: '没有更多数据了'
});
}
},
methods: {
fnGetData() {
uni.showLoading({
mask: true,
title: '加载中...'
});
// 设置状态为加载中
if (!this.isLoadMore) {
this.loading = 'loading';
}
this.loadMoreText = '加载中...';
this.$httpApi
.getCategoryPostList(this.slug, this.queryParams)
.then(res => {
this.fnSetPageTitle(`分类:${this.pageTitle} (共${res.data.total}篇)`);
this.result = res.data;
if (this.isLoadMore) {
this.dataList = this.dataList.concat(res.data.content);
} else {
this.dataList = res.data.content;
}
this.loadMoreText = res.data.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~';
setTimeout(() => {
this.loading = 'success';
}, 500);
})
.catch(err => {
console.error(err);
this.loading = 'error';
this.loadMoreText = '加载失败,请下拉刷新!';
})
.finally(() => {
setTimeout(() => {
uni.hideLoading();
uni.stopPullDownRefresh();
}, 500);
});
},
//跳转文章详情
fnToArticleDetail(article) {
uni.navigateTo({
url: '/pagesA/article-detail/article-detail?articleId=' + article.id,
animationType: 'slide-in-right'
});
}
} }
} };
};
</script> </script>
<style lang="scss"> <style lang="scss">
.app-page { .app-page {
width: 100vw; width: 100vw;
min-height: 100vh; min-height: 100vh;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
padding: 24rpx 0; padding: 24rpx 0;
background-color: #fafafd; background-color: #fafafd;
} }
.loading-wrap {
padding: 0 24rpx; .loading-wrap {
min-height: 100vh; padding: 0 24rpx;
} min-height: 100vh;
.empty { }
height: 60vh;
display: flex; .empty {
align-items: center; height: 60vh;
justify-content: center; display: flex;
} align-items: center;
</style> justify-content: center;
}
</style>
+97 -96
Dosyayı Görüntüle
@@ -13,7 +13,7 @@
</view> </view>
<block v-else> <block v-else>
<block v-for="(journal, index) in dataList" :key="index"> <block v-for="(journal, index) in dataList" :key="index">
<tm-translate animation-name="fadeUp" :wait="(index + 1) * 50"> <tm-translate animation-name="fadeUp" :wait="calcAniWait(index)">
<!-- 日记卡片 --> <!-- 日记卡片 -->
<journal-card :journal="journal" :useLike="true"></journal-card> <journal-card :journal="journal" :useLike="true"></journal-card>
</tm-translate> </tm-translate>
@@ -27,107 +27,108 @@
</template> </template>
<script> <script>
import MarkdownConfig from '@/common/markdown/markdown.config.js'; import MarkdownConfig from '@/common/markdown/markdown.config.js';
import mpHtml from '@/components/mp-html/components/mp-html/mp-html.vue'; import mpHtml from '@/components/mp-html/components/mp-html/mp-html.vue';
import journalCard from '@/components/journal-card/journal-card.vue'; import journalCard from '@/components/journal-card/journal-card.vue';
import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue'; import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue';
import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue'; import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue';
import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue'; import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue';
import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue'; import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue';
export default { export default {
components: { mpHtml, tmSkeleton, tmEmpty, tmTranslate, tmFlotbutton, journalCard }, components: { mpHtml, tmSkeleton, tmEmpty, tmTranslate, tmFlotbutton, journalCard },
data() { data() {
return { return {
loading: 'loading', loading: 'loading',
markdownConfig: MarkdownConfig, markdownConfig: MarkdownConfig,
queryParams: { queryParams: {
size: 10, size: 10,
page: 0 page: 0
}, },
result: null, result: null,
dataList: [], dataList: [],
isLoadMore: false, isLoadMore: false,
loadMoreText: '加载中...' loadMoreText: '加载中...'
}; };
}, },
onLoad() { onLoad() {
this.fnSetPageTitle('个人日记'); this.fnSetPageTitle('个人日记');
}, },
created() { created() {
this.fnGetData();
},
onPullDownRefresh() {
this.isLoadMore = false;
this.queryParams.page = 0;
this.fnGetData();
},
onReachBottom(e) {
if (this.result.hasNext) {
this.queryParams.page += 1;
this.isLoadMore = true;
this.fnGetData(); this.fnGetData();
} else { },
uni.showToast({ onPullDownRefresh() {
icon: 'none', this.isLoadMore = false;
title: '没有更多数据了' this.queryParams.page = 0;
}); this.fnGetData();
} },
}, onReachBottom(e) {
methods: { if (this.result.hasNext) {
fnGetData() { this.queryParams.page += 1;
uni.showLoading({ this.isLoadMore = true;
mask: true, this.fnGetData();
title: '加载中...' } else {
}); uni.showToast({
// 设置状态为加载中 icon: 'none',
if (!this.isLoadMore) { title: '没有更多数据了'
this.loading = 'loading';
}
this.loadMoreText = '加载中...';
this.$httpApi
.getJournals(this.queryParams)
.then(res => {
this.loading = 'success';
this.loadMoreText = res.data.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~';
// 处理数据
this.result = res.data;
if (this.isLoadMore) {
this.dataList = this.dataList.concat(res.data.content);
} else {
this.dataList = res.data.content;
}
this.loading = 'success';
})
.catch(err => {
console.error(err);
this.loading = 'error';
this.loadMoreText = '加载失败,请下拉刷新!';
})
.finally(() => {
setTimeout(() => {
uni.hideLoading();
uni.stopPullDownRefresh();
}, 500);
}); });
}
},
methods: {
fnGetData() {
uni.showLoading({
mask: true,
title: '加载中...'
});
// 设置状态为加载中
if (!this.isLoadMore) {
this.loading = 'loading';
}
this.loadMoreText = '加载中...';
this.$httpApi
.getJournals(this.queryParams)
.then(res => {
this.loading = 'success';
this.loadMoreText = res.data.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~';
// 处理数据
this.result = res.data;
if (this.isLoadMore) {
this.dataList = this.dataList.concat(res.data.content);
} else {
this.dataList = res.data.content;
}
this.loading = 'success';
})
.catch(err => {
console.error(err);
this.loading = 'error';
this.loadMoreText = '加载失败,请下拉刷新!';
})
.finally(() => {
setTimeout(() => {
uni.hideLoading();
uni.stopPullDownRefresh();
}, 500);
});
}
} }
} };
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.app-page { .app-page {
width: 100vw; width: 100vw;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
} }
.loading-wrap {
} .loading-wrap {}
.app-page-content {
} .app-page-content {}
.content-empty {
height: 60vh; .content-empty {
} height: 60vh;
</style> }
</style>
+179 -193
Dosyayı Görüntüle
@@ -13,18 +13,9 @@
</view> </view>
<block v-else> <block v-else>
<block v-for="(item, index) in dataList" :key="index"> <block v-for="(item, index) in dataList" :key="index">
<tm-translate animation-name="fadeUp" :wait="(index + 1) * 50"> <tm-translate animation-name="fadeUp" :wait="calcAniWait(index)">
<!-- 列表项 --> <!-- 列表项 -->
<comment-item <comment-item class="mb-12" :isChild="false" :comment="item" :postId="sheetId" :useSolid="false" @on-copy="fnCopyContent" @on-comment="fnToComment" @on-detail="fnOnShowCommentDetail"></comment-item>
class="mb-12"
:isChild="false"
:comment="item"
:postId="sheetId"
:useSolid="false"
@on-copy="fnCopyContent"
@on-comment="fnToComment"
@on-detail="fnOnShowCommentDetail"
></comment-item>
</tm-translate> </tm-translate>
</block> </block>
<tm-flotbutton :offset="[16, 80]" @click="fnToTopPage" size="m" color="light-blue" icon="icon-angle-up"></tm-flotbutton> <tm-flotbutton :offset="[16, 80]" @click="fnToTopPage" size="m" color="light-blue" icon="icon-angle-up"></tm-flotbutton>
@@ -59,15 +50,7 @@
</view> </view>
<block v-else> <block v-else>
<comment-item <comment-item v-for="(comment, index) in commentDetail.list" :useSolid="false" :useActions="false" :key="index" :isChild="false" :comment="comment" :postId="sheetId"></comment-item>
v-for="(comment, index) in commentDetail.list"
:useSolid="false"
:useActions="false"
:key="index"
:isChild="false"
:comment="comment"
:postId="sheetId"
></comment-item>
</block> </block>
</block> </block>
</scroll-view> </scroll-view>
@@ -77,194 +60,197 @@
</template> </template>
<script> <script>
import AppKeys from '@/config/keys.js'; import AppKeys from '@/config/keys.js';
import SheetConfig from '@/config/sheets.config.js'; import SheetConfig from '@/config/sheets.config.js';
import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue'; import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue';
import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue'; import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue';
import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue'; import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue';
import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue'; import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue';
import tmPoup from '@/tm-vuetify/components/tm-poup/tm-poup.vue'; import tmPoup from '@/tm-vuetify/components/tm-poup/tm-poup.vue';
import tmButton from '@/tm-vuetify/components/tm-button/tm-button.vue'; import tmButton from '@/tm-vuetify/components/tm-button/tm-button.vue';
import commentItem from '@/components/comment-item/comment-item.vue'; import commentItem from '@/components/comment-item/comment-item.vue';
export default { export default {
components: { components: {
tmSkeleton, tmSkeleton,
tmFlotbutton, tmFlotbutton,
tmTranslate, tmTranslate,
tmEmpty, tmEmpty,
tmPoup, tmPoup,
tmButton, tmButton,
commentItem commentItem
}, },
data() { data() {
return { return {
loading: 'loading',
queryParams: {
size: 10,
page: 0
},
result: null,
dataList: [],
isLoadMore: false,
loadMoreText: '加载中...',
sheetId: SheetConfig[AppKeys.SHEET_LEAVING],
commentDetail: {
loading: 'loading', loading: 'loading',
show: false, queryParams: {
comment: {}, size: 10,
postId: undefined, page: 0
list: [] },
} result: null,
}; dataList: [],
}, isLoadMore: false,
loadMoreText: '加载中...',
sheetId: SheetConfig[AppKeys.SHEET_LEAVING],
commentDetail: {
loading: 'loading',
show: false,
comment: {},
postId: undefined,
list: []
}
};
},
onLoad() { onLoad() {
this.fnSetPageTitle('留言板'); this.fnSetPageTitle('留言板');
}, },
created() { created() {
this.fnGetData();
uni.$on('leaving_refresh', () => {
this.fnGetData(); this.fnGetData();
}); uni.$on('leaving_refresh', () => {
}, this.fnGetData();
onPullDownRefresh() { });
this.isLoadMore = false; },
this.queryParams.page = 0; onPullDownRefresh() {
this.fnGetData(); this.isLoadMore = false;
}, this.queryParams.page = 0;
onReachBottom(e) {
if (this.result.hasNext) {
this.queryParams.page += 1;
this.isLoadMore = true;
this.fnGetData(); this.fnGetData();
} else { },
uni.showToast({
icon: 'none',
title: '没有更多数据了'
});
}
},
methods: { onReachBottom(e) {
fnGetData() { if (this.result.hasNext) {
uni.showLoading({ this.queryParams.page += 1;
mask: true, this.isLoadMore = true;
title: '加载中...' this.fnGetData();
}); } else {
// 设置状态为加载中 uni.showToast({
if (!this.isLoadMore) { icon: 'none',
this.loading = 'loading'; title: '没有更多数据了'
});
} }
this.loadMoreText = '加载中...'; },
this.$httpApi
.getSheetsCommentsTreeBySheetId(this.sheetId, this.queryParams) methods: {
.then(res => { fnGetData() {
if (res.status == 200) { uni.showLoading({
this.loading = 'success'; mask: true,
// return; title: '加载中...'
this.loadMoreText = res.data.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~'; });
// 处理数据 // 设置状态为加载中
this.result = res.data; if (!this.isLoadMore) {
if (this.isLoadMore) { this.loading = 'loading';
this.dataList = this.dataList.concat(res.data.content); }
this.loadMoreText = '加载中...';
this.$httpApi
.getSheetsCommentsTreeBySheetId(this.sheetId, this.queryParams)
.then(res => {
if (res.status == 200) {
this.loading = 'success';
// return;
this.loadMoreText = res.data.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~';
// 处理数据
this.result = res.data;
if (this.isLoadMore) {
this.dataList = this.dataList.concat(res.data.content);
} else {
this.dataList = res.data.content;
}
} else { } else {
this.dataList = res.data.content; this.loading = 'error';
this.loadMoreText = '加载失败,请下拉刷新!';
} }
} else { })
.catch(err => {
console.error(err);
this.loading = 'error'; this.loading = 'error';
this.loadMoreText = '加载失败,请下拉刷新!'; this.loadMoreText = '加载失败,请下拉刷新!';
} })
}) .finally(() => {
.catch(err => { setTimeout(() => {
console.error(err); uni.hideLoading();
this.loading = 'error'; uni.stopPullDownRefresh();
this.loadMoreText = '加载失败,请下拉刷新!'; }, 500);
}) });
.finally(() => { },
setTimeout(() => { fnToComment(data) {
uni.hideLoading(); let _comment = {};
uni.stopPullDownRefresh(); if (data) {
}, 500); _comment = {
}); id: this.sheetId,
}, parentId: data.comment.id,
fnToComment(data) { title: data.comment.author,
let _comment = {}; from: 'sheets',
if (data) { formPage: 'leaving',
_comment = { type: 'user'
id: this.sheetId, };
parentId: data.comment.id, } else {
title: data.comment.author, _comment = {
from: 'sheets', id: this.sheetId,
formPage: 'leaving', parentId: 0,
type: 'user' title: '留言板留言',
}; from: 'sheets',
} else { formPage: 'leaving',
_comment = { type: 'post'
id: this.sheetId, };
parentId: 0, }
title: '留言板留言',
from: 'sheets',
formPage: 'leaving',
type: 'post'
};
}
uni.$tm.vx.commit('comment/setCommentInfo', _comment); uni.$tm.vx.commit('comment/setCommentInfo', _comment);
this.$Router.push({ this.$Router.push({
path: '/pagesA/comment/comment', path: '/pagesA/comment/comment',
query: _comment query: _comment
});
},
fnCopyContent(content) {
uni.$tm.u.setClipboardData(content);
uni.$tm.toast('内容已复制成功!');
},
fnOnShowCommentDetail(comment) {
this.commentDetail.comment = comment;
this.commentDetail.list = [];
this.commentDetail.show = true;
this.fnGetChildComments();
},
fnGetChildComments() {
this.commentDetail.loading = 'loading';
this.$httpApi
.getSheetsChildrenCommentList(this.sheetId, this.commentDetail.comment.id, {})
.then(res => {
if (res.status == 200) {
this.commentDetail.loading = 'success';
this.commentDetail.list = res.data;
} else {
this.commentDetail.loading = 'error';
}
})
.catch(err => {
this.commentDetail.loading = 'error';
}); });
},
fnCopyContent(content) {
uni.$tm.u.setClipboardData(content);
uni.$tm.toast('内容已复制成功!');
},
fnOnShowCommentDetail(comment) {
this.commentDetail.comment = comment;
this.commentDetail.list = [];
this.commentDetail.show = true;
this.fnGetChildComments();
},
fnGetChildComments() {
this.commentDetail.loading = 'loading';
this.$httpApi
.getSheetsChildrenCommentList(this.sheetId, this.commentDetail.comment.id, {})
.then(res => {
if (res.status == 200) {
this.commentDetail.loading = 'success';
this.commentDetail.list = res.data;
} else {
this.commentDetail.loading = 'error';
}
})
.catch(err => {
this.commentDetail.loading = 'error';
});
}
} }
} };
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.app-page { .app-page {
width: 100vw; width: 100vw;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
background-color: #fafafd; background-color: #fafafd;
} }
.app-page-content {
box-sizing: border-box; .app-page-content {
// box-shadow: 0rpx 0rpx 24rpx rgba(0, 0, 0, 0.05); box-sizing: border-box;
} // box-shadow: 0rpx 0rpx 24rpx rgba(0, 0, 0, 0.05);
.content-empty { }
width: 100%;
height: 60vh; .content-empty {
} width: 100%;
.loading-wrap { height: 60vh;
box-sizing: border-box; }
padding: 24rpx;
} .loading-wrap {
</style> box-sizing: border-box;
padding: 24rpx;
}
</style>
+118 -116
Dosyayı Görüntüle
@@ -11,7 +11,7 @@
<block v-else> <block v-else>
<block v-for="(article, index) in dataList" :key="article.createTime"> <block v-for="(article, index) in dataList" :key="article.createTime">
<!-- 文章卡片 --> <!-- 文章卡片 -->
<tm-translate animation-name="fadeUp" :wait="(index + 1) * 50"><article-card :article="article" @on-click="fnToArticleDetail"></article-card></tm-translate> <tm-translate animation-name="fadeUp" :wait="calcAniWait(index)"><article-card :article="article" @on-click="fnToArticleDetail"></article-card></tm-translate>
</block> </block>
<view class="load-text">{{ loadMoreText }}</view> <view class="load-text">{{ loadMoreText }}</view>
</block> </block>
@@ -22,123 +22,125 @@
</template> </template>
<script> <script>
import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue'; import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue';
import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue'; import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue';
import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue'; import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue';
import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue'; import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue';
import ArticleCard from '@/components/article-card/article-card.vue'; import ArticleCard from '@/components/article-card/article-card.vue';
export default { export default {
components: { components: {
tmSkeleton, tmSkeleton,
tmTranslate, tmTranslate,
tmFlotbutton, tmFlotbutton,
tmEmpty, tmEmpty,
ArticleCard ArticleCard
},
data() {
return {
loading: 'loading',
queryParams: {
size: 10,
page: 0
},
slug: '',
pageTitle: '加载中...',
result: null,
dataList: [],
isLoadMore: false,
loadMoreText: ''
};
},
onLoad(e) {
this.slug = e.slug;
this.pageTitle = e.name;
this.fnGetData();
},
onPullDownRefresh() {
this.isLoadMore = false;
this.queryParams.page = 0;
this.fnGetData();
},
onReachBottom(e) {
if (this.result.hasNext) {
this.queryParams.page += 1;
this.isLoadMore = true;
this.fnGetData();
} else {
uni.showToast({
icon: 'none',
title: '没有更多数据了'
});
}
},
methods: {
fnGetData() {
uni.showLoading({
mask: true,
title: '加载中...'
});
// 设置状态为加载中
if (!this.isLoadMore) {
this.loading = 'loading';
}
this.loadMoreText = '加载中...';
this.$httpApi
.getTagPostsList(this.slug, this.queryParams)
.then(res => {
this.fnSetPageTitle(`标签:${this.pageTitle} (共${res.data.total}篇)`);
this.result = res.data;
if (this.isLoadMore) {
this.dataList = this.dataList.concat(res.data.content);
} else {
this.dataList = res.data.content;
}
this.loadMoreText = res.data.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~';
setTimeout(() => {
this.loading = 'success';
}, 500);
})
.catch(err => {
console.error(err);
this.loading = 'error';
this.loadMoreText = '加载失败,请下拉刷新!';
})
.finally(() => {
setTimeout(() => {
uni.hideLoading();
uni.stopPullDownRefresh();
}, 500);
});
}, },
//跳转文章详情 data() {
fnToArticleDetail(article) { return {
uni.navigateTo({ loading: 'loading',
url: '/pagesA/article-detail/article-detail?articleId=' + article.id, queryParams: {
animationType: 'slide-in-right' size: 10,
}); page: 0
},
slug: '',
pageTitle: '加载中...',
result: null,
dataList: [],
isLoadMore: false,
loadMoreText: ''
};
},
onLoad(e) {
this.slug = e.slug;
this.pageTitle = e.name;
this.fnGetData();
},
onPullDownRefresh() {
this.isLoadMore = false;
this.queryParams.page = 0;
this.fnGetData();
},
onReachBottom(e) {
if (this.result.hasNext) {
this.queryParams.page += 1;
this.isLoadMore = true;
this.fnGetData();
} else {
uni.showToast({
icon: 'none',
title: '没有更多数据了'
});
}
},
methods: {
fnGetData() {
uni.showLoading({
mask: true,
title: '加载中...'
});
// 设置状态为加载中
if (!this.isLoadMore) {
this.loading = 'loading';
}
this.loadMoreText = '加载中...';
this.$httpApi
.getTagPostsList(this.slug, this.queryParams)
.then(res => {
this.fnSetPageTitle(`标签:${this.pageTitle} (共${res.data.total}篇)`);
this.result = res.data;
if (this.isLoadMore) {
this.dataList = this.dataList.concat(res.data.content);
} else {
this.dataList = res.data.content;
}
this.loadMoreText = res.data.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~';
setTimeout(() => {
this.loading = 'success';
}, 500);
})
.catch(err => {
console.error(err);
this.loading = 'error';
this.loadMoreText = '加载失败,请下拉刷新!';
})
.finally(() => {
setTimeout(() => {
uni.hideLoading();
uni.stopPullDownRefresh();
}, 500);
});
},
//跳转文章详情
fnToArticleDetail(article) {
uni.navigateTo({
url: '/pagesA/article-detail/article-detail?articleId=' + article.id,
animationType: 'slide-in-right'
});
}
} }
} };
};
</script> </script>
<style lang="scss"> <style lang="scss">
.app-page { .app-page {
width: 100vw; width: 100vw;
min-height: 100vh; min-height: 100vh;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
padding: 24rpx 0; padding: 24rpx 0;
background-color: #fafafd; background-color: #fafafd;
} }
.loading-wrap {
padding: 0 24rpx; .loading-wrap {
min-height: 100vh; padding: 0 24rpx;
} min-height: 100vh;
.empty { }
height: 60vh;
display: flex; .empty {
align-items: center; height: 60vh;
justify-content: center; display: flex;
} align-items: center;
</style> justify-content: center;
}
</style>
+279 -269
Dosyayı Görüntüle
@@ -29,7 +29,7 @@
</view> </view>
<block v-else> <block v-else>
<block v-for="(article, index) in dataList" :key="index"> <block v-for="(article, index) in dataList" :key="index">
<tm-translate animation-name="fadeUp" :wait="(index + 1) * 50"> <tm-translate animation-name="fadeUp" :wait="calcAniWait(index)">
<!-- 文章卡片 --> <!-- 文章卡片 -->
<view class="article-card mt-24 bg-white pa-24 round-3"> <view class="article-card mt-24 bg-white pa-24 round-3">
<view class="thumbnail round-2" @click="fnToArticleDetail(article)"> <view class="thumbnail round-2" @click="fnToArticleDetail(article)">
@@ -110,295 +110,305 @@
</template> </template>
<script> <script>
import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue'; import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue';
import tmSearch from '@/tm-vuetify/components/tm-search/tm-search.vue'; import tmSearch from '@/tm-vuetify/components/tm-search/tm-search.vue';
import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue'; import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue';
import tmTabs from '@/tm-vuetify/components/tm-tabs/tm-tabs.vue'; import tmTabs from '@/tm-vuetify/components/tm-tabs/tm-tabs.vue';
import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue'; import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue';
import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue'; import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue';
import tmTags from '@/tm-vuetify/components/tm-tags/tm-tags.vue'; import tmTags from '@/tm-vuetify/components/tm-tags/tm-tags.vue';
import tmButton from '@/tm-vuetify/components/tm-button/tm-button.vue'; import tmButton from '@/tm-vuetify/components/tm-button/tm-button.vue';
import tmPickers from '@/tm-vuetify/components/tm-pickers/tm-pickers.vue'; import tmPickers from '@/tm-vuetify/components/tm-pickers/tm-pickers.vue';
export default { export default {
components: { components: {
tmSkeleton, tmSkeleton,
tmSearch, tmSearch,
tmTranslate, tmTranslate,
tmTabs, tmTabs,
tmFlotbutton, tmFlotbutton,
tmEmpty, tmEmpty,
tmTags, tmTags,
tmButton, tmButton,
tmPickers tmPickers
}, },
data() { data() {
return { return {
isBlackTheme: false, isBlackTheme: false,
loading: 'loading',
tab: {
activeIndex: 0,
list: ['全部', '已发布', '私密', '草稿', '回收站']
},
queryParams: {
size: 10,
page: 0,
status: '',
keyword: '',
categoryId: undefined
},
cache: {
dataList: [],
total: 0
},
isLoadMore: false,
loadMoreText: '加载中...',
result: {},
dataList: [],
category: {
loading: 'loading', loading: 'loading',
show: false, tab: {
list: [], activeIndex: 0,
selected: [0] list: ['全部', '已发布', '私密', '草稿', '回收站']
} },
}; queryParams: {
}, size: 10,
onLoad() { page: 0,
this.fnSetPageTitle('文章管理'); status: '',
this.fnGetCategoryList(); keyword: '',
}, categoryId: undefined
created() { },
this.fnGetData(); cache: {
uni.$on('refresh-article-list', () => { dataList: [],
this.isLoadMore = false; total: 0
this.queryParams.page = 0; },
this.fnGetData(); isLoadMore: false,
}); loadMoreText: '加载中...',
}, result: {},
onPullDownRefresh() { dataList: [],
this.isLoadMore = false; category: {
this.queryParams.page = 0; loading: 'loading',
this.fnGetData(); show: false,
}, list: [],
selected: [0]
onReachBottom(e) { }
if (this.result.hasNext) {
this.queryParams.page += 1;
this.isLoadMore = true;
this.fnGetData();
} else {
uni.showToast({
icon: 'none',
title: '没有更多数据了'
});
}
},
methods: {
fnOnTabChange(index) {
this.dataList = [];
const _status = {
0: '',
1: 'PUBLISHED',
2: 'INTIMATE',
3: 'DRAFT',
4: 'RECYCLE'
}; };
this.queryParams.status = _status[index]; },
this.queryParams.page = 0; onLoad() {
this.fnToTopPage(); this.fnSetPageTitle('文章管理');
this.fnGetCategoryList();
},
created() {
this.fnGetData(); this.fnGetData();
uni.$on('refresh-article-list', () => {
this.isLoadMore = false;
this.queryParams.page = 0;
this.fnGetData();
});
}, },
// 获取分类列表 onPullDownRefresh() {
fnGetCategoryList() {
this.category.loading = 'loading';
this.$httpApi.admin
.getCategoryList()
.then(res => {
if (res.status == 200) {
let _list = res.data;
_list.unshift({ id: undefined, name: '全部' });
this.category.list = _list;
this.category.loading = 'success';
} else {
this.category.loading = 'error';
}
})
.catch(err => {
this.category.loading = 'error';
});
},
// 显示分类选择
fnOnCategoryConfirm(e) {
this.category.selected = [e[0].index];
this.queryParams.categoryId = e[0].data.id;
},
fnOnSearch() {
this.queryParams.page = 0;
this.isLoadMore = false; this.isLoadMore = false;
this.fnToTopPage(); this.queryParams.page = 0;
this.fnGetData(); this.fnGetData();
}, },
fnGetData() {
uni.showLoading({
mask: true,
title: '加载中...'
});
// 设置状态为加载中
if (!this.isLoadMore) {
this.loading = 'loading';
}
this.loadMoreText = '加载中...';
this.$httpApi.admin
.getPostsByPage(this.queryParams)
.then(res => {
console.log('请求结果:');
console.log(res);
if (res.status == 200) {
// 处理数据
this.result = res.data;
const _dataList = res.data.content.map(item => {
item.hasThumbnail = item.thumbnail != '';
if (item.thumbnail) {
item.thumbnail = this.$utils.checkThumbnailUrl(item.thumbnail);
}
return item;
});
if (this.isLoadMore) {
this.dataList = this.dataList.concat(_dataList);
} else {
this.dataList = _dataList;
}
this.loading = 'success'; onReachBottom(e) {
this.loadMoreText = res.data.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~'; if (this.result.hasNext) {
} else { this.queryParams.page += 1;
this.loading = 'error'; this.isLoadMore = true;
this.loadMoreText = '呜呜,加载失败了~'; this.fnGetData();
} } else {
}) uni.showToast({
.catch(err => { icon: 'none',
console.error(err); title: '没有更多数据了'
this.loading = 'error';
this.loadMoreText = '加载失败,请下拉刷新!';
})
.finally(() => {
setTimeout(() => {
uni.hideLoading();
uni.stopPullDownRefresh();
}, 800);
}); });
}
}, },
methods: {
// 跳转文章详情(预览) fnOnTabChange(index) {
fnToArticleDetail(article) { this.dataList = [];
uni.navigateTo({ const _status = {
url: '/pagesA/article-detail/article-detail?articleId=' + article.id, 0: '',
animationType: 'slide-in-right' 1: 'PUBLISHED',
}); 2: 'INTIMATE',
}, 3: 'DRAFT',
// 新增 4: 'RECYCLE'
fnOnAddArticle() { };
this.$Router.push({ path: '/pagesB/articles/article-edit', query: {} }); this.queryParams.status = _status[index];
}, this.queryParams.page = 0;
// 文章编辑 this.fnToTopPage();
fnOnEditArticle(article) { this.fnGetData();
this.$Router.push({ path: '/pagesB/articles/article-edit', query: { postsId: article.id } }); },
}, // 获取分类列表
// 设置文章信息 fnGetCategoryList() {
fnOnSetArticle(article, index) { this.category.loading = 'loading';
this.$Router.push({ path: '/pagesB/articles/article-setting', query: { postsId: article.id, postTitle: article.title, isEdit: 1, from: 'list' } }); this.$httpApi.admin
}, .getCategoryList()
// 删除文章 .then(res => {
fnOnDelArticle(article, index) { if (res.status == 200) {
uni.$eShowModal({ let _list = res.data;
title: '提示', _list.unshift({ id: undefined, name: '全部' });
content: '是否确定要删除该文章?', this.category.list = _list;
showCancel: true, this.category.loading = 'success';
cancelText: '否', } else {
cancelColor: '#999999', this.category.loading = 'error';
confirmText: '是', }
confirmColor: '#03a9f4' })
}) .catch(err => {
.then(res => { this.category.loading = 'error';
uni.showLoading({
mask: true,
title: '删除中...'
}); });
this.$httpApi.admin },
.deletePostsByIds([article.id]) // 显示分类选择
.then(res => { fnOnCategoryConfirm(e) {
if (res.status == 200) { this.fnResetSetAniWaitIndex();
uni.$tm.toast('文章已删除成功!'); this.category.selected = [e[0].index];
this.dataList.splice(index, 1); this.queryParams.categoryId = e[0].data.id;
},
fnOnSearch() {
this.fnResetSetAniWaitIndex();
this.queryParams.page = 0;
this.isLoadMore = false;
this.fnToTopPage();
this.fnGetData();
},
fnGetData() {
uni.showLoading({
mask: true,
title: '加载中...'
});
// 设置状态为加载中
if (!this.isLoadMore) {
this.loading = 'loading';
}
this.loadMoreText = '加载中...';
this.$httpApi.admin
.getPostsByPage(this.queryParams)
.then(res => {
console.log('请求结果:');
console.log(res);
if (res.status == 200) {
// 处理数据
this.result = res.data;
const _dataList = res.data.content.map(item => {
item.hasThumbnail = item.thumbnail != '';
if (item.thumbnail) {
item.thumbnail = this.$utils.checkThumbnailUrl(item.thumbnail);
}
return item;
});
if (this.isLoadMore) {
this.dataList = this.dataList.concat(_dataList);
} else { } else {
uni.$tm.toast('操作失败,请重试!'); this.dataList = _dataList;
} }
})
.catch(err => { this.loading = 'success';
uni.$tm.toast('操作失败,请重试!'); this.loadMoreText = res.data.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~';
} else {
this.loading = 'error';
this.loadMoreText = '呜呜,加载失败了~';
}
})
.catch(err => {
console.error(err);
this.loading = 'error';
this.loadMoreText = '加载失败,请下拉刷新!';
})
.finally(() => {
setTimeout(() => {
uni.hideLoading();
uni.stopPullDownRefresh();
}, 800);
});
},
// 跳转文章详情(预览)
fnToArticleDetail(article) {
uni.navigateTo({
url: '/pagesA/article-detail/article-detail?articleId=' + article.id,
animationType: 'slide-in-right'
});
},
// 新增
fnOnAddArticle() {
this.$Router.push({ path: '/pagesB/articles/article-edit', query: {} });
},
// 文章编辑
fnOnEditArticle(article) {
this.$Router.push({ path: '/pagesB/articles/article-edit', query: { postsId: article.id } });
},
// 设置文章信息
fnOnSetArticle(article, index) {
this.$Router.push({ path: '/pagesB/articles/article-setting', query: { postsId: article.id, postTitle: article.title, isEdit: 1, from: 'list' } });
},
// 删除文章
fnOnDelArticle(article, index) {
uni.$eShowModal({
title: '提示',
content: '是否确定要删除该文章?',
showCancel: true,
cancelText: '否',
cancelColor: '#999999',
confirmText: '是',
confirmColor: '#03a9f4'
})
.then(res => {
uni.showLoading({
mask: true,
title: '删除中...'
}); });
}) this.$httpApi.admin
.catch(err => {}); .deletePostsByIds([article.id])
.then(res => {
if (res.status == 200) {
uni.$tm.toast('文章已删除成功!');
this.dataList.splice(index, 1);
} else {
uni.$tm.toast('操作失败,请重试!');
}
})
.catch(err => {
uni.$tm.toast('操作失败,请重试!');
});
})
.catch(err => {});
}
} }
} };
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.app-page { .app-page {
width: 100vw; width: 100vw;
min-height: 100vh; min-height: 100vh;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
padding-bottom: 24rpx; padding-bottom: 24rpx;
background-color: #fafafd; background-color: #fafafd;
&.is-balck { &.is-balck {
background-color: #212121; background-color: #212121;
}
}
.app-page-content {
box-sizing: border-box;
.content-empty {
height: 60vh;
}
}
.article-card {
box-sizing: border-box;
box-shadow: 0rpx 2rpx 24rpx rgba(0, 0, 0, 0.05);
.thumbnail {
width: 100%;
height: 280rpx;
&-img {
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.03);
}
&-not {
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.03);
} }
} }
.title {
overflow: hidden; .app-page-content {
white-space: nowrap;
text-overflow: ellipsis;
word-wrap: break-word;
word-break: break-all;
}
.summary {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 3;
overflow: hidden;
word-wrap: break-word;
word-break: break-all;
}
.foot {
box-sizing: border-box; box-sizing: border-box;
border-top: 2rpx solid rgba(0, 0, 0, 0.03);
.content-empty {
height: 60vh;
}
} }
}
</style> .article-card {
box-sizing: border-box;
box-shadow: 0rpx 2rpx 24rpx rgba(0, 0, 0, 0.05);
.thumbnail {
width: 100%;
height: 280rpx;
&-img {
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.03);
}
&-not {
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.03);
}
}
.title {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
word-wrap: break-word;
word-break: break-all;
}
.summary {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 3;
overflow: hidden;
word-wrap: break-word;
word-break: break-all;
}
.foot {
box-sizing: border-box;
border-top: 2rpx solid rgba(0, 0, 0, 0.03);
}
}
</style>
Dosya farkı çok büyük olduğundan ihmal edildi Fark Yükle
+283 -308
Dosyayı Görüntüle
@@ -16,7 +16,7 @@
<view v-if="dataList.length == 0" class="content-empty flex flex-center"><tm-empty icon="icon-shiliangzhinengduixiang-" label="无数据"></tm-empty></view> <view v-if="dataList.length == 0" class="content-empty flex flex-center"><tm-empty icon="icon-shiliangzhinengduixiang-" label="无数据"></tm-empty></view>
<block v-else> <block v-else>
<block v-for="(category, index) in dataList" :key="index"> <block v-for="(category, index) in dataList" :key="index">
<tm-translate animation-name="fadeUp" :wait="(index + 1) * 50"> <tm-translate animation-name="fadeUp" :wait="calcAniWait(index)">
<view class="category-card flex round-3 bg-white pa-24 mb-24" @click="fnShowFormModal(category)"> <view class="category-card flex round-3 bg-white pa-24 mb-24" @click="fnShowFormModal(category)">
<text class="del-icon flex flex-center" @click.stop="fnDelete(category, index)">×</text> <text class="del-icon flex flex-center" @click.stop="fnDelete(category, index)">×</text>
<view class="left"> <view class="left">
@@ -52,49 +52,13 @@
<view class="poup-content"> <view class="poup-content">
<view class="poup-head text-align-center text-weight-b text-size-g ma-24">{{ form.id != undefined ? '编辑分类' : '新增分类' }}</view> <view class="poup-head text-align-center text-weight-b text-size-g ma-24">{{ form.id != undefined ? '编辑分类' : '新增分类' }}</view>
<scroll-view class="poup-body pa-24 pt-0" :scroll-y="true" @touchmove.stop> <scroll-view class="poup-body pa-24 pt-0" :scroll-y="true" @touchmove.stop>
<tm-input <tm-input required :adjust-position="true" :round="3" :borderBottom="false" title="名称" bg-color="grey-lighten-5" v-model="form.name" placeholder="请输入分类名称"></tm-input>
required
:adjust-position="true"
:round="3"
:borderBottom="false"
title="名称"
bg-color="grey-lighten-5"
v-model="form.name"
placeholder="请输入分类名称"
></tm-input>
<view class="pl-32 mb-24 input-tips text-grey text-size-s">填写提示页面上所显示的名称</view> <view class="pl-32 mb-24 input-tips text-grey text-size-s">填写提示页面上所显示的名称</view>
<tm-input <tm-input :borderBottom="false" :adjust-position="true" :round="3" title="别名" bg-color="grey-lighten-5" v-model="form.slug" placeholder="请输入分类别名"></tm-input>
:borderBottom="false"
:adjust-position="true"
:round="3"
title="别名"
bg-color="grey-lighten-5"
v-model="form.slug"
placeholder="请输入分类别名"
></tm-input>
<view class="pl-32 mb-24 input-tips text-grey text-size-s">填写提示一般为单个分类页面的标识最好为英文</view> <view class="pl-32 mb-24 input-tips text-grey text-size-s">填写提示一般为单个分类页面的标识最好为英文</view>
<tm-input <tm-input :borderBottom="false" :adjust-position="true" :round="3" title="密码" bg-color="grey-lighten-5" v-model="form.password" placeholder="请输入分类密码"></tm-input>
:borderBottom="false"
:adjust-position="true"
:round="3"
title="密码"
bg-color="grey-lighten-5"
v-model="form.password"
placeholder="请输入分类密码"
></tm-input>
<view class="pl-32 mb-24 input-tips text-grey text-size-s">填写提示分类的访问密码</view> <view class="pl-32 mb-24 input-tips text-grey text-size-s">填写提示分类的访问密码</view>
<tm-input <tm-input :borderBottom="false" :vertical="true" :adjust-position="true" inputType="textarea" :round="3" title="描述" :height="160" bg-color="grey-lighten-5" v-model="form.description" placeholder="请输入分类描述"></tm-input>
:borderBottom="false"
:vertical="true"
:adjust-position="true"
inputType="textarea"
:round="3"
title="描述"
:height="160"
bg-color="grey-lighten-5"
v-model="form.description"
placeholder="请输入分类描述"
></tm-input>
<view class="pl-32 mb-24 input-tips text-grey text-size-s">填写提示分类的描述信息</view> <view class="pl-32 mb-24 input-tips text-grey text-size-s">填写提示分类的描述信息</view>
<view class="ma-30 mt-12 pb-12"> <view class="ma-30 mt-12 pb-12">
<view class="mb-12"> <view class="mb-12">
@@ -122,207 +86,163 @@
</template> </template>
<script> <script>
import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue'; import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue';
import tmButton from '@/tm-vuetify/components/tm-button/tm-button.vue'; import tmButton from '@/tm-vuetify/components/tm-button/tm-button.vue';
import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue'; import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue';
import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue'; import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue';
import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue'; import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue';
import tmPoup from '@/tm-vuetify/components/tm-poup/tm-poup.vue'; import tmPoup from '@/tm-vuetify/components/tm-poup/tm-poup.vue';
import tmInput from '@/tm-vuetify/components/tm-input/tm-input.vue'; import tmInput from '@/tm-vuetify/components/tm-input/tm-input.vue';
import AttachmentSelect from '@/components/attachment-select/attachment-select.vue'; import AttachmentSelect from '@/components/attachment-select/attachment-select.vue';
export default { export default {
components: { components: {
tmSkeleton, tmSkeleton,
tmButton, tmButton,
tmEmpty, tmEmpty,
tmTranslate, tmTranslate,
tmFlotbutton, tmFlotbutton,
tmPoup, tmPoup,
tmInput, tmInput,
AttachmentSelect AttachmentSelect
},
data() {
return {
loading: 'loading',
queryParams: {
size: 10,
page: 0,
more: true
},
dataList: [],
poupShow: false,
attachmentsSelectShow: false,
form: {
description: undefined,
password: undefined,
createTime: undefined,
fullPath: undefined,
id: undefined,
name: '',
slug: undefined,
thumbnail: undefined,
showThumbnail: undefined
}
};
},
onLoad() {
this.fnSetPageTitle('分类管理');
},
created() {
this.fnGetData();
},
onPullDownRefresh() {
this.isLoadMore = false;
this.queryParams.page = 0;
this.fnGetData();
},
methods: {
fnGetData() {
uni.showLoading({
mask: true,
title: '加载中...'
});
// 设置状态为加载中
if (!this.isLoadMore) {
this.loading = 'loading';
}
this.loadMoreText = '加载中...';
this.$httpApi.admin
.getCategoryList(this.queryParams)
.then(res => {
console.log('getCategoryList');
console.log(res);
if (res.status == 200) {
this.loading = 'success';
this.dataList = res.data.map(item => {
if (item.thumbnail) {
item['showThumbnail'] = this.$utils.checkThumbnailUrl(item.thumbnail);
} else {
item['showThumbnail'] = '';
}
return item;
});
} else {
this.loading = 'error';
}
console.log(this.dataList);
})
.catch(err => {
console.error(err);
this.loading = 'error';
this.loadMoreText = '加载失败,请下拉刷新!';
})
.finally(() => {
setTimeout(() => {
uni.hideLoading();
uni.stopPullDownRefresh();
}, 800);
});
}, },
data() {
fnSelectColor() { return {
this.$refs.colorPicker.open(); loading: 'loading',
}, queryParams: {
size: 10,
fnOnConfirmSelectColor(e) { page: 0,
this.selectColor = e.rgba; more: true
this.$set(this.form, 'color', e.hex); },
}, dataList: [],
fnOnAttachmentsSelectClose() { poupShow: false,
this.attachmentsSelectShow = false; attachmentsSelectShow: false,
}, form: {
fnOnPoupChange(e) { description: undefined,
if (!e) { password: undefined,
this.fnResetForm(); createTime: undefined,
} fullPath: undefined,
}, id: undefined,
// 监听附件选择 name: '',
fnOnAttachmentsSelect(file) { slug: undefined,
this.form.thumbnail = file.path; thumbnail: undefined,
this.form.showThumbnail = this.$utils.checkThumbnailUrl(file.path); showThumbnail: undefined
this.attachmentsSelectShow = false;
},
fnShowFormModal(category) {
if (category) {
this.form = Object.assign({}, {}, category);
if (category.thumbnail) {
this.form.showThumbnail = this.$utils.checkThumbnailUrl(category.thumbnail);
} }
} else {
this.fnResetForm();
}
this.poupShow = true;
},
fnResetForm() {
this.form = {
color: undefined,
createTime: undefined,
fullPath: undefined,
id: undefined,
name: '',
slug: undefined,
thumbnail: undefined,
showThumbnail: undefined
}; };
}, },
fnSubmit() {
if (this.form.name.trim() == '') { onLoad() {
return uni.$tm.toast('分类名称未填写!'); this.fnSetPageTitle('分类管理');
}
if (this.form.id == undefined) {
this.$httpApi.admin
.createCategory(this.form)
.then(res => {
if (res.status == 200) {
uni.$tm.toast(`保存成功!`);
uni.startPullDownRefresh();
} else {
uni.$tm.toast('操作失败,请重试!');
}
})
.catch(err => {
uni.$tm.toast('操作失败,请重试!');
});
} else {
this.$httpApi.admin
.updateCategoryById(this.form.id, this.form)
.then(res => {
if (res.status == 200) {
uni.$tm.toast(`保存成功!`);
let updateIndex = this.dataList.findIndex(x => x.id == this.form.id);
this.$set(this.dataList, updateIndex, this.form);
} else {
uni.$tm.toast('操作失败,请重试!');
}
})
.catch(err => {
uni.$tm.toast('操作失败,请重试!');
});
}
}, },
// 删除 created() {
fnDelete(category) { this.fnGetData();
const _category = category || this.form; },
uni.$eShowModal({ onPullDownRefresh() {
title: '提示', this.isLoadMore = false;
content: `您是否要将 ${_category.name} 的分类删除?`, this.queryParams.page = 0;
showCancel: true, this.fnGetData();
cancelText: '否', },
cancelColor: '#999999',
confirmText: '是', methods: {
confirmColor: '#03a9f4' fnGetData() {
}) uni.showLoading({
.then(res => { mask: true,
title: '加载中...'
});
// 设置状态为加载中
if (!this.isLoadMore) {
this.loading = 'loading';
}
this.loadMoreText = '加载中...';
this.$httpApi.admin
.getCategoryList(this.queryParams)
.then(res => {
console.log('getCategoryList');
console.log(res);
if (res.status == 200) {
this.loading = 'success';
this.dataList = res.data.map(item => {
if (item.thumbnail) {
item['showThumbnail'] = this.$utils.checkThumbnailUrl(item.thumbnail);
} else {
item['showThumbnail'] = '';
}
return item;
});
} else {
this.loading = 'error';
}
console.log(this.dataList);
})
.catch(err => {
console.error(err);
this.loading = 'error';
this.loadMoreText = '加载失败,请下拉刷新!';
})
.finally(() => {
setTimeout(() => {
uni.hideLoading();
uni.stopPullDownRefresh();
}, 800);
});
},
fnSelectColor() {
this.$refs.colorPicker.open();
},
fnOnConfirmSelectColor(e) {
this.selectColor = e.rgba;
this.$set(this.form, 'color', e.hex);
},
fnOnAttachmentsSelectClose() {
this.attachmentsSelectShow = false;
},
fnOnPoupChange(e) {
if (!e) {
this.fnResetForm();
}
},
// 监听附件选择
fnOnAttachmentsSelect(file) {
this.form.thumbnail = file.path;
this.form.showThumbnail = this.$utils.checkThumbnailUrl(file.path);
this.attachmentsSelectShow = false;
},
fnShowFormModal(category) {
if (category) {
this.form = Object.assign({}, {}, category);
if (category.thumbnail) {
this.form.showThumbnail = this.$utils.checkThumbnailUrl(category.thumbnail);
}
} else {
this.fnResetForm();
}
this.poupShow = true;
},
fnResetForm() {
this.form = {
color: undefined,
createTime: undefined,
fullPath: undefined,
id: undefined,
name: '',
slug: undefined,
thumbnail: undefined,
showThumbnail: undefined
};
},
fnSubmit() {
if (this.form.name.trim() == '') {
return uni.$tm.toast('分类名称未填写!');
}
if (this.form.id == undefined) {
this.$httpApi.admin this.$httpApi.admin
.deleteCategoryById(_category.id) .createCategory(this.form)
.then(res => { .then(res => {
if (res.status == 200) { if (res.status == 200) {
uni.$tm.toast(`${_category.name} 分类已删除`); uni.$tm.toast(`保存成功`);
const delIndex = this.dataList.findIndex(x => x.id == _category.id); uni.startPullDownRefresh();
this.dataList.splice(delIndex, 1);
} else { } else {
uni.$tm.toast('操作失败,请重试!'); uni.$tm.toast('操作失败,请重试!');
} }
@@ -330,91 +250,146 @@ export default {
.catch(err => { .catch(err => {
uni.$tm.toast('操作失败,请重试!'); uni.$tm.toast('操作失败,请重试!');
}); });
}) } else {
.catch(err => {}); this.$httpApi.admin
.updateCategoryById(this.form.id, this.form)
.then(res => {
if (res.status == 200) {
uni.$tm.toast(`保存成功!`);
let updateIndex = this.dataList.findIndex(x => x.id == this.form.id);
this.$set(this.dataList, updateIndex, this.form);
} else {
uni.$tm.toast('操作失败,请重试!');
}
})
.catch(err => {
uni.$tm.toast('操作失败,请重试!');
});
}
},
// 删除
fnDelete(category) {
const _category = category || this.form;
uni.$eShowModal({
title: '提示',
content: `您是否要将 ${_category.name} 的分类删除?`,
showCancel: true,
cancelText: '否',
cancelColor: '#999999',
confirmText: '是',
confirmColor: '#03a9f4'
})
.then(res => {
this.$httpApi.admin
.deleteCategoryById(_category.id)
.then(res => {
if (res.status == 200) {
uni.$tm.toast(`${_category.name} 分类已删除!`);
const delIndex = this.dataList.findIndex(x => x.id == _category.id);
this.dataList.splice(delIndex, 1);
} else {
uni.$tm.toast('操作失败,请重试!');
}
})
.catch(err => {
uni.$tm.toast('操作失败,请重试!');
});
})
.catch(err => {});
}
} }
} };
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.app-page { .app-page {
width: 100vw; width: 100vw;
min-height: 100vh; min-height: 100vh;
}
.loading-wrap {
.loading-error {
height: 65vh;
} }
}
.content-empty {
width: 100%;
height: 60vh;
}
.poup-content { .loading-wrap {
overflow: hidden; .loading-error {
} height: 65vh;
.poup-body {
height: 71vh;
box-sizing: border-box;
touch-action: none;
}
.thumbnail {
width: 100%;
height: 260rpx;
}
.category-card {
position: relative;
box-sizing: border-box;
box-shadow: 0rpx 2rpx 24rpx rgba(0, 0, 0, 0.03);
.del-icon {
width: 46rpx;
height: 46rpx;
position: absolute;
right: 24rpx;
top: 24rpx;
border-radius: 50%;
box-sizing: border-box;
border: 4rpx solid #fff;
background-color: #ff8177;
box-shadow: 0rpx 0rpx 24rpx rgba(0, 0, 0, 0.05);
font-size: 32rpx;
color: #fff;
}
.left {
width: 200rpx;
height: 190rpx;
.cover {
width: 100%;
height: inherit;
background-color: #607d8b;
} }
} }
.right {
width: 0; .content-empty {
flex-grow: 1; width: 100%;
height: 60vh;
}
.poup-content {
overflow: hidden;
}
.poup-body {
height: 71vh;
box-sizing: border-box; box-sizing: border-box;
.color { touch-action: none;
}
.thumbnail {
width: 100%;
height: 260rpx;
}
.category-card {
position: relative;
box-sizing: border-box;
box-shadow: 0rpx 2rpx 24rpx rgba(0, 0, 0, 0.03);
.del-icon {
width: 46rpx;
height: 46rpx;
position: absolute;
right: 24rpx;
top: 24rpx;
border-radius: 50%;
box-sizing: border-box;
border: 4rpx solid #fff;
background-color: #ff8177;
box-shadow: 0rpx 0rpx 24rpx rgba(0, 0, 0, 0.05);
font-size: 32rpx;
color: #fff; color: #fff;
} }
}
}
.desc-box { .left {
box-sizing: border-box; width: 200rpx;
.label { height: 190rpx;
width: 86rpx;
.cover {
width: 100%;
height: inherit;
background-color: #607d8b;
}
}
.right {
width: 0;
flex-grow: 1;
box-sizing: border-box;
.color {
color: #fff;
}
}
} }
.value {
width: 0; .desc-box {
flex-grow: 1; box-sizing: border-box;
white-space: nowrap;
overflow: hidden; .label {
text-overflow: ellipsis; width: 86rpx;
word-wrap: break-word; }
word-break: break-all;
.value {
width: 0;
flex-grow: 1;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
word-wrap: break-word;
word-break: break-all;
}
} }
} </style>
</style>
+331 -334
Dosyayı Görüntüle
@@ -19,7 +19,7 @@
<view v-if="dataList.length == 0" class="content-empty flex flex-center"><tm-empty icon="icon-shiliangzhinengduixiang-" label="无数据"></tm-empty></view> <view v-if="dataList.length == 0" class="content-empty flex flex-center"><tm-empty icon="icon-shiliangzhinengduixiang-" label="无数据"></tm-empty></view>
<block v-else> <block v-else>
<block v-for="(comment, index) in dataList" :key="index"> <block v-for="(comment, index) in dataList" :key="index">
<tm-translate animation-name="fadeUp" :wait="(index + 1) * 50"> <tm-translate animation-name="fadeUp" :wait="calcAniWait(index)">
<view class="comment-card bg-white round-3 pt-24 pb-24"> <view class="comment-card bg-white round-3 pt-24 pb-24">
<view class="head flex flex-between pl-24 pr-24"> <view class="head flex flex-between pl-24 pr-24">
<view class="left flex flex-center"> <view class="left flex flex-center">
@@ -96,17 +96,7 @@
<view class="mb-24">评论内容</view> <view class="mb-24">评论内容</view>
<view class="pa-24 pt-12 pb-12 grey-lighten-5 text-grey round-3">{{ reply.data.content }}</view> <view class="pa-24 pt-12 pb-12 grey-lighten-5 text-grey round-3">{{ reply.data.content }}</view>
</view> </view>
<tm-input <tm-input :vertical="true" :borderBottom="false" input-type="textarea" title="我的回复" bg-color="grey-lighten-5" v-model="reply.form.content" :height="150" :focus="true" :adjustPosition="true"></tm-input>
:vertical="true"
:borderBottom="false"
input-type="textarea"
title="我的回复"
bg-color="grey-lighten-5"
v-model="reply.form.content"
:height="150"
:focus="true"
:adjustPosition="true"
></tm-input>
</scroll-view> </scroll-view>
<view class="btn-wrap flex flex-center"> <view class="btn-wrap flex flex-center">
<!-- 审核状态 --> <!-- 审核状态 -->
@@ -129,347 +119,354 @@
</template> </template>
<script> <script>
import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue'; import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue';
import tmButton from '@/tm-vuetify/components/tm-button/tm-button.vue'; import tmButton from '@/tm-vuetify/components/tm-button/tm-button.vue';
import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue'; import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue';
import tmTabs from '@/tm-vuetify/components/tm-tabs/tm-tabs.vue'; import tmTabs from '@/tm-vuetify/components/tm-tabs/tm-tabs.vue';
import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue'; import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue';
import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue'; import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue';
import tmTags from '@/tm-vuetify/components/tm-tags/tm-tags.vue'; import tmTags from '@/tm-vuetify/components/tm-tags/tm-tags.vue';
import tmPoup from '@/tm-vuetify/components/tm-poup/tm-poup.vue'; import tmPoup from '@/tm-vuetify/components/tm-poup/tm-poup.vue';
import tmInput from '@/tm-vuetify/components/tm-input/tm-input.vue'; import tmInput from '@/tm-vuetify/components/tm-input/tm-input.vue';
export default { export default {
components: { components: {
tmSkeleton, tmSkeleton,
tmButton, tmButton,
tmEmpty, tmEmpty,
tmTabs, tmTabs,
tmTranslate, tmTranslate,
tmFlotbutton, tmFlotbutton,
tmTags, tmTags,
tmPoup, tmPoup,
tmInput tmInput
},
data() {
return {
loading: 'loading',
tab: {
adtiveIndex: 0,
list: ['文章评论', '页面评论', '日记评论']
},
queryParams: {
size: 10,
page: 0
},
result: {},
dataList: [],
queryType: 'Posts',
isLoadMore: false,
loadMoreText: '加载中...',
reply: {
show: false,
data: {},
form: {
allowNotification: true,
author: '',
authorUrl: '',
content: '',
email: '',
parentId: 0,
postId: 0
}
}
};
},
computed: {
// 获取博主信息
bloggerInfo() {
return this.$tm.vx.getters().getBlogger;
}
},
onLoad() {
this.fnSetPageTitle('评论管理');
},
created() {
this.fnGetData();
},
onPullDownRefresh() {
this.isLoadMore = false;
this.queryParams.page = 0;
this.fnGetData();
},
onReachBottom(e) {
if (this.result.hasNext) {
this.queryParams.page += 1;
this.isLoadMore = true;
this.fnGetData();
} else {
uni.showToast({
icon: 'none',
title: '没有更多数据了'
});
}
},
methods: {
fnOnTabChange(index) {
this.fnResetReply();
this.dataList = [];
this.queryType = ['Posts', 'Sheets', 'Journals'][index];
this.fnToTopPage();
this.fnGetData();
}, },
data() {
fnGetData() { return {
uni.showLoading({ loading: 'loading',
mask: true, tab: {
title: '加载中...' adtiveIndex: 0,
}); list: ['文章评论', '页面评论', '日记评论']
// 设置状态为加载中 },
if (!this.isLoadMore) { queryParams: {
this.loading = 'loading'; size: 10,
} page: 0
this.loadMoreText = '加载中...'; },
this.$httpApi.admin[`get${this.queryType}Comments`](this.queryParams) result: {},
.then(res => { dataList: [],
console.log('请求结果:'); queryType: 'Posts',
console.log(res); isLoadMore: false,
loadMoreText: '加载中...',
this.loading = 'success'; reply: {
this.loadMoreText = res.data.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~'; show: false,
const _list = res.data.content.map(x => { data: {},
x.avatar = this.$utils.checkAvatarUrl(x.avatar, x.isAdmin); form: {
return x; allowNotification: true,
}); author: '',
// 处理数据 authorUrl: '',
this.result = res.data; content: '',
if (this.isLoadMore) { email: '',
this.dataList = this.dataList.concat(_list); parentId: 0,
} else { postId: 0
this.dataList = _list;
} }
})
.catch(err => {
console.error(err);
this.loading = 'error';
this.loadMoreText = '加载失败,请下拉刷新!';
})
.finally(() => {
setTimeout(() => {
uni.hideLoading();
uni.stopPullDownRefresh();
}, 800);
});
},
fnShowReplyModal(comment) {
this.reply.data = comment;
this.reply.form.parentId = comment.id;
switch (this.queryType) {
case 'Posts':
this.reply.form.postId = comment.post.id;
break;
case 'Sheets':
this.reply.form.postId = comment.sheet.id;
break;
case 'Journals':
this.reply.form.postId = comment.journal.id;
break;
}
this.reply.show = true;
},
fnResetReply() {
this.reply = {
show: false,
data: {},
form: {
allowNotification: true,
author: '',
authorUrl: '',
content: '',
email: '',
parentId: 0,
postId: 0
} }
}; };
}, },
// 审核通过 computed: {
fnReplyPass(comment) { // 获取博主信息
uni.$eShowModal({ bloggerInfo() {
title: '提示', return this.$tm.vx.getters().getBlogger;
content: `您是否要通过 ${comment.author} 的评论?`, }
showCancel: true,
cancelText: '否',
cancelColor: '#999999',
confirmText: '是',
confirmColor: '#03a9f4'
})
.then(res => {
this.$httpApi.admin[`update${this.queryType}CommentsStatus`](comment.id, 'PUBLISHED')
.then(res => {
if (res.status == 200) {
uni.$tm.toast(`操作成功!`);
comment.status = 'PUBLISHED';
// uni.startPullDownRefresh();
} else {
uni.$tm.toast('操作失败,请重试!');
}
})
.catch(err => {
uni.$tm.toast('操作失败,请重试!');
});
})
.catch(err => {});
}, },
// 回复评论 onLoad() {
fnReplySubmit() { this.fnSetPageTitle('评论管理');
this.reply.form.author = this.bloggerInfo.nickname; },
this.reply.form.authorUrl = this.$haloConfig.social.blog || this.$haloConfig.apiUrl; created() {
this.reply.form.email = this.bloggerInfo.email; this.fnGetData();
},
uni.showLoading({ onPullDownRefresh() {
title: '正在回复中...' this.isLoadMore = false;
}); this.queryParams.page = 0;
this.$httpApi.admin[`post${this.queryType}Comments`](this.reply.form) this.fnGetData();
.then(res => { },
if (res.status == 200) { onReachBottom(e) {
uni.$tm.toast('回复成功'); if (this.result.hasNext) {
this.fnResetReply(); this.queryParams.page += 1;
this.fnToTopPage(); this.isLoadMore = true;
uni.startPullDownRefresh(); this.fnGetData();
} else { } else {
uni.$tm.toast('回复失败,请重试!'); uni.showToast({
} icon: 'none',
}) title: '没有更多数据了'
.catch(err => {
uni.$tm.toast('回复失败,请重试!');
}); });
}
}, },
// 还原 methods: {
fnRestore(comment) { fnOnTabChange(index) {
uni.$eShowModal({ this.fnResetSetAniWaitIndex();
title: '提示', this.fnResetReply();
content: `您是否要将 ${comment.author} 的评论还原?`, this.dataList = [];
showCancel: true, this.queryType = ['Posts', 'Sheets', 'Journals'][index];
cancelText: '否', this.fnToTopPage();
cancelColor: '#999999', this.fnGetData();
confirmText: '是', },
confirmColor: '#03a9f4'
}) fnGetData() {
.then(res => { uni.showLoading({
this.$httpApi.admin[`update${this.queryType}CommentsStatus`](comment.id, 'PUBLISHED') mask: true,
.then(res => { title: '加载中...'
if (res.status == 200) { });
uni.$tm.toast(`已将 ${comment.author} 的评论还原!`); // 设置状态为加载中
// uni.startPullDownRefresh(); if (!this.isLoadMore) {
comment.status = 'PUBLISHED'; this.loading = 'loading';
} else { }
uni.$tm.toast('操作失败,请重试!'); this.loadMoreText = '加载中...';
} this.$httpApi.admin[`get${this.queryType}Comments`](this.queryParams)
}) .then(res => {
.catch(err => { console.log('请求结果:');
uni.$tm.toast('操作失败,请重试!'); console.log(res);
this.loading = 'success';
this.loadMoreText = res.data.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~';
const _list = res.data.content.map(x => {
x.avatar = this.$utils.checkAvatarUrl(x.avatar, x.isAdmin);
return x;
}); });
}) // 处理数据
.catch(err => {}); this.result = res.data;
}, if (this.isLoadMore) {
// 移到回收站 this.dataList = this.dataList.concat(_list);
fnRecycle(comment) { } else {
uni.$eShowModal({ this.dataList = _list;
title: '提示', }
content: `您是否要将 ${comment.author} 的评论移到回收站?`, })
showCancel: true, .catch(err => {
cancelText: '否', console.error(err);
cancelColor: '#999999', this.loading = 'error';
confirmText: '是', this.loadMoreText = '加载失败,请下拉刷新!';
confirmColor: '#03a9f4' })
}) .finally(() => {
.then(res => { setTimeout(() => {
this.$httpApi.admin[`update${this.queryType}CommentsStatus`](comment.id, 'RECYCLE') uni.hideLoading();
.then(res => { uni.stopPullDownRefresh();
if (res.status == 200) { }, 800);
uni.$tm.toast(`已将 ${comment.author} 的评论移到回收站!`); });
comment.status = 'RECYCLE'; },
// uni.startPullDownRefresh(); fnShowReplyModal(comment) {
} else { this.reply.data = comment;
this.reply.form.parentId = comment.id;
switch (this.queryType) {
case 'Posts':
this.reply.form.postId = comment.post.id;
break;
case 'Sheets':
this.reply.form.postId = comment.sheet.id;
break;
case 'Journals':
this.reply.form.postId = comment.journal.id;
break;
}
this.reply.show = true;
},
fnResetReply() {
this.reply = {
show: false,
data: {},
form: {
allowNotification: true,
author: '',
authorUrl: '',
content: '',
email: '',
parentId: 0,
postId: 0
}
};
},
// 审核通过
fnReplyPass(comment) {
uni.$eShowModal({
title: '提示',
content: `您是否要通过 ${comment.author} 的评论?`,
showCancel: true,
cancelText: '否',
cancelColor: '#999999',
confirmText: '是',
confirmColor: '#03a9f4'
})
.then(res => {
this.$httpApi.admin[`update${this.queryType}CommentsStatus`](comment.id, 'PUBLISHED')
.then(res => {
if (res.status == 200) {
uni.$tm.toast(`操作成功!`);
comment.status = 'PUBLISHED';
// uni.startPullDownRefresh();
} else {
uni.$tm.toast('操作失败,请重试!');
}
})
.catch(err => {
uni.$tm.toast('操作失败,请重试!'); uni.$tm.toast('操作失败,请重试!');
} });
}) })
.catch(err => { .catch(err => {});
uni.$tm.toast('操作失败,请重试!'); },
}); // 回复评论
}) fnReplySubmit() {
.catch(err => {}); this.reply.form.author = this.bloggerInfo.nickname;
}, this.reply.form.authorUrl = this.$haloConfig.social.blog || this.$haloConfig.apiUrl;
// 删除评论(永久删除) this.reply.form.email = this.bloggerInfo.email;
fnDelete(comment) {
uni.$eShowModal({ uni.showLoading({
title: '提示', title: '正在回复中...'
content: `您是否要将 ${comment.author} 的评论删除?`, });
showCancel: true, this.$httpApi.admin[`post${this.queryType}Comments`](this.reply.form)
cancelText: '否', .then(res => {
cancelColor: '#999999', if (res.status == 200) {
confirmText: '是', uni.$tm.toast('回复成功');
confirmColor: '#03a9f4' this.fnResetReply();
}) this.fnToTopPage();
.then(res => { uni.startPullDownRefresh();
this.$httpApi.admin[`delete${this.queryType}CommentsById`](comment.id) } else {
.then(res => { uni.$tm.toast('回复失败,请重试!');
if (res.status == 200) { }
uni.$tm.toast(`${comment.author} 的评论已删除!`); })
const delIndex = this.dataList.findIndex(x => x.id == comment.id); .catch(err => {
this.dataList.splice(delIndex, 1); uni.$tm.toast('回复失败,请重试!');
// uni.startPullDownRefresh(); });
} else { },
// 还原
fnRestore(comment) {
uni.$eShowModal({
title: '提示',
content: `您是否要将 ${comment.author} 的评论还原?`,
showCancel: true,
cancelText: '否',
cancelColor: '#999999',
confirmText: '是',
confirmColor: '#03a9f4'
})
.then(res => {
this.$httpApi.admin[`update${this.queryType}CommentsStatus`](comment.id, 'PUBLISHED')
.then(res => {
if (res.status == 200) {
uni.$tm.toast(`已将 ${comment.author} 的评论还原!`);
// uni.startPullDownRefresh();
comment.status = 'PUBLISHED';
} else {
uni.$tm.toast('操作失败,请重试!');
}
})
.catch(err => {
uni.$tm.toast('操作失败,请重试!'); uni.$tm.toast('操作失败,请重试!');
} });
}) })
.catch(err => { .catch(err => {});
uni.$tm.toast('操作失败,请重试!'); },
}); // 移到回收站
}) fnRecycle(comment) {
.catch(err => {}); uni.$eShowModal({
title: '提示',
content: `您是否要将 ${comment.author} 的评论移到回收站?`,
showCancel: true,
cancelText: '否',
cancelColor: '#999999',
confirmText: '是',
confirmColor: '#03a9f4'
})
.then(res => {
this.$httpApi.admin[`update${this.queryType}CommentsStatus`](comment.id, 'RECYCLE')
.then(res => {
if (res.status == 200) {
uni.$tm.toast(`已将 ${comment.author} 的评论移到回收站!`);
comment.status = 'RECYCLE';
// uni.startPullDownRefresh();
} else {
uni.$tm.toast('操作失败,请重试!');
}
})
.catch(err => {
uni.$tm.toast('操作失败,请重试!');
});
})
.catch(err => {});
},
// 删除评论(永久删除)
fnDelete(comment) {
uni.$eShowModal({
title: '提示',
content: `您是否要将 ${comment.author} 的评论删除?`,
showCancel: true,
cancelText: '否',
cancelColor: '#999999',
confirmText: '是',
confirmColor: '#03a9f4'
})
.then(res => {
this.$httpApi.admin[`delete${this.queryType}CommentsById`](comment.id)
.then(res => {
if (res.status == 200) {
uni.$tm.toast(`${comment.author} 的评论已删除!`);
const delIndex = this.dataList.findIndex(x => x.id == comment.id);
this.dataList.splice(delIndex, 1);
// uni.startPullDownRefresh();
} else {
uni.$tm.toast('操作失败,请重试!');
}
})
.catch(err => {
uni.$tm.toast('操作失败,请重试!');
});
})
.catch(err => {});
}
} }
} };
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.app-page { .app-page {
width: 100vw; width: 100vw;
min-height: 100vh; min-height: 100vh;
}
.loading-wrap {
padding: 24rpx;
.loading-error {
height: 65vh;
} }
}
.content-empty {
width: 100%;
height: 60vh;
}
.comment-card { .loading-wrap {
box-sizing: border-box; padding: 24rpx;
box-shadow: 0rpx 0rpx 24rpx rgba(0, 0, 0, 0.05);
margin-bottom: 24rpx;
.avatar { .loading-error {
width: 56rpx; height: 65vh;
height: 56rpx; }
}
.content-empty {
width: 100%;
height: 60vh;
}
.comment-card {
box-sizing: border-box; box-sizing: border-box;
border: 4rpx solid #fff; box-shadow: 0rpx 0rpx 24rpx rgba(0, 0, 0, 0.05);
box-shadow: 0rpx 0rpx 24rpx rgba(0, 0, 0, 0.15); margin-bottom: 24rpx;
.avatar {
width: 56rpx;
height: 56rpx;
box-sizing: border-box;
border: 4rpx solid #fff;
box-shadow: 0rpx 0rpx 24rpx rgba(0, 0, 0, 0.15);
}
.comment-content {
line-height: 1.6;
}
} }
.comment-content {
line-height: 1.6; .poup-content {
overflow: hidden;
} }
}
.poup-content { .poup-body {
overflow: hidden; height: 60vh;
} box-sizing: border-box;
.poup-body { }
height: 60vh; </style>
box-sizing: border-box;
}
</style>
+127 -132
Dosyayı Görüntüle
@@ -17,16 +17,8 @@
</view> </view>
<block v-else> <block v-else>
<block v-for="(journal, index) in dataList" :key="journal.id"> <block v-for="(journal, index) in dataList" :key="journal.id">
<tm-translate animation-name="fadeUp" :wait="(index + 1) * 50"> <tm-translate animation-name="fadeUp" :wait="calcAniWait(index)">
<journal-card <journal-card :isAdmin="true" :journal="journal" :useLike="false" :useEdit="true" :useDel="true" @on-del="fnOnJournalDel" @on-edit="fnOnJournalEdit"></journal-card>
:isAdmin="true"
:journal="journal"
:useLike="false"
:useEdit="true"
:useDel="true"
@on-del="fnOnJournalDel"
@on-edit="fnOnJournalEdit"
></journal-card>
</tm-translate> </tm-translate>
</block> </block>
<tm-flotbutton :offset="[16, 80]" @click="fnToTopPage" color="light-blue" size="m" icon="icon-angle-up"></tm-flotbutton> <tm-flotbutton :offset="[16, 80]" @click="fnToTopPage" color="light-blue" size="m" icon="icon-angle-up"></tm-flotbutton>
@@ -38,139 +30,142 @@
</template> </template>
<script> <script>
import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue'; import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue';
import tmButton from '@/tm-vuetify/components/tm-button/tm-button.vue'; import tmButton from '@/tm-vuetify/components/tm-button/tm-button.vue';
import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue'; import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue';
import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue'; import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue';
import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue'; import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue';
export default { export default {
components: { components: {
tmSkeleton, tmSkeleton,
tmButton, tmButton,
tmEmpty, tmEmpty,
tmTranslate, tmTranslate,
tmFlotbutton tmFlotbutton
}, },
data() { data() {
return { return {
loading: 'loading', loading: 'loading',
queryParams: { queryParams: {
size: 10, size: 10,
page: 0 page: 0
}, },
form: { form: {
status: true, status: true,
content: '', content: '',
keepRaw: true, keepRaw: true,
sourceContent: '', sourceContent: '',
type: 'PUBLIC' type: 'PUBLIC'
}, },
result: {}, result: {},
dataList: [], dataList: [],
isLoadMore: false, isLoadMore: false,
loadMoreText: '加载中...' loadMoreText: '加载中...'
}; };
}, },
onLoad() { onLoad() {
this.fnSetPageTitle('日记管理'); this.fnSetPageTitle('日记管理');
}, },
created() { created() {
this.fnGetData(); this.fnGetData();
uni.$on('journals_refresh', () => { uni.$on('journals_refresh', () => {
this.isLoadMore = false;
this.queryParams.page = 0;
this.fnGetData(false);
});
},
onPullDownRefresh() {
this.isLoadMore = false; this.isLoadMore = false;
this.queryParams.page = 0; this.queryParams.page = 0;
this.fnGetData(false);
});
},
onPullDownRefresh() {
this.isLoadMore = false;
this.queryParams.page = 0;
this.fnGetData();
},
onReachBottom(e) {
if (this.result.hasNext) {
this.queryParams.page += 1;
this.isLoadMore = true;
this.fnGetData(); this.fnGetData();
} else {
uni.showToast({
icon: 'none',
title: '没有更多数据了'
});
}
},
methods: {
// 调用编辑操作
fnOnToolBarEdit(e) {
this.$refs.article[e.currentTarget.dataset.method]();
}, },
fnGetData(useTip = true) { onReachBottom(e) {
if (useTip) { if (this.result.hasNext) {
uni.showLoading({ this.queryParams.page += 1;
mask: true, this.isLoadMore = true;
title: '加载中...' this.fnGetData();
} else {
uni.showToast({
icon: 'none',
title: '没有更多数据了'
}); });
} }
// 设置状态为加载中 },
if (!this.isLoadMore) { methods: {
this.loading = 'loading'; // 调用编辑操作
} fnOnToolBarEdit(e) {
this.loadMoreText = '加载中...'; this.$refs.article[e.currentTarget.dataset.method]();
this.$httpApi },
.getJournals(this.queryParams) fnGetData(useTip = true) {
.then(res => { if (useTip) {
this.loading = 'success'; uni.showLoading({
this.loadMoreText = res.data.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~'; mask: true,
// 处理数据 title: '加载中...'
this.result = res.data; });
if (this.isLoadMore) { }
this.dataList = this.dataList.concat(res.data.content); // 设置状态为加载中
} else { if (!this.isLoadMore) {
this.dataList = res.data.content; this.loading = 'loading';
} }
this.loading = 'success'; this.loadMoreText = '加载中...';
}) this.$httpApi
.catch(err => { .getJournals(this.queryParams)
console.error(err); .then(res => {
this.loading = 'error'; this.loading = 'success';
this.loadMoreText = '加载失败,请下拉刷新!'; this.loadMoreText = res.data.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~';
}) // 处理数据
.finally(() => { this.result = res.data;
setTimeout(() => { if (this.isLoadMore) {
uni.hideLoading(); this.dataList = this.dataList.concat(res.data.content);
uni.stopPullDownRefresh(); } else {
}, 500); this.dataList = res.data.content;
}
this.loading = 'success';
})
.catch(err => {
console.error(err);
this.loading = 'error';
this.loadMoreText = '加载失败,请下拉刷新!';
})
.finally(() => {
setTimeout(() => {
uni.hideLoading();
uni.stopPullDownRefresh();
}, 500);
});
},
fnOnJournalDel(journal) {
this.dataList.splice(this.dataList.findIndex(x => x.id == journal.id), 1);
},
fnOnJournalEdit(data) {
uni.$tm.vx.commit('journal/setJournalInfo', data);
this.$Router.push({
path: '/pagesB/journal/journal-edit',
query: data
}); });
}, }
fnOnJournalDel(journal) {
this.dataList.splice(this.dataList.findIndex(x => x.id == journal.id), 1);
},
fnOnJournalEdit(data) {
uni.$tm.vx.commit('journal/setJournalInfo', data);
this.$Router.push({
path: '/pagesB/journal/journal-edit',
query: data
});
} }
} };
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.app-page { .app-page {
width: 100vw; width: 100vw;
min-height: 100vh; min-height: 100vh;
}
.loading-wrap {
padding: 24rpx;
.loading-error {
height: 40vh;
} }
}
.edit-wrap { .loading-wrap {
box-sizing: border-box; padding: 24rpx;
box-shadow: 0rpx 4rpx 24rpx rgba(0, 0, 0, 0.05);
} .loading-error {
</style> height: 40vh;
}
}
.edit-wrap {
box-sizing: border-box;
box-shadow: 0rpx 4rpx 24rpx rgba(0, 0, 0, 0.05);
}
</style>
+286 -317
Dosyayı Görüntüle
@@ -23,10 +23,12 @@
<view v-if="filterList.lenght == 0" class="empty"><tm-empty icon="icon-wind-cry" label="无数据"></tm-empty></view> <view v-if="filterList.lenght == 0" class="empty"><tm-empty icon="icon-wind-cry" label="无数据"></tm-empty></view>
<block v-else> <block v-else>
<block v-for="(item, index) in filterList" :key="index"> <block v-for="(item, index) in filterList" :key="index">
<tm-translate animation-name="fadeUp" :wait="(index + 1) * 50"> <tm-translate animation-name="fadeUp" :wait="calcAniWait(index)">
<view class="link-card round-3 bg-white flex flex-col mt-24 ml-24 mr-24 pa-24"> <view class="link-card round-3 bg-white flex flex-col mt-24 ml-24 mr-24 pa-24">
<view class="head flex"> <view class="head flex">
<view class="left round-2 flex flex-col flex-center"><image class="logo round-2 " :src="item.logo" mode="aspectFill"></image></view> <view class="left round-2 flex flex-col flex-center">
<image class="logo round-2 " :src="item.logo" mode="aspectFill"></image>
</view>
<view class="right pl-24 text-size-m"> <view class="right pl-24 text-size-m">
<view class="title flex flex-between "> <view class="title flex flex-between ">
<view class="name flex text-overflow mr-6 text-weight-b"> <view class="name flex text-overflow mr-6 text-weight-b">
@@ -71,27 +73,9 @@
<view class="poup-content"> <view class="poup-content">
<view class="poup-head text-align-center text-weight-b text-size-g ma-24">{{ form.id != undefined ? '编辑友链' : '新增友链' }}</view> <view class="poup-head text-align-center text-weight-b text-size-g ma-24">{{ form.id != undefined ? '编辑友链' : '新增友链' }}</view>
<scroll-view class="poup-body pa-24 pt-0" :scroll-y="true" @touchmove.stop> <scroll-view class="poup-body pa-24 pt-0" :scroll-y="true" @touchmove.stop>
<tm-input <tm-input required :adjust-position="true" :round="3" :borderBottom="false" title="网站名称" bg-color="grey-lighten-5" v-model="form.name" placeholder="请输入网站名称"></tm-input>
required
:adjust-position="true"
:round="3"
:borderBottom="false"
title="网站名称"
bg-color="grey-lighten-5"
v-model="form.name"
placeholder="请输入网站名称"
></tm-input>
<tm-input <tm-input required :borderBottom="false" :adjust-position="true" :round="3" title="网站地址" bg-color="grey-lighten-5" v-model="form.url" placeholder="请输入网站地址"></tm-input>
required
:borderBottom="false"
:adjust-position="true"
:round="3"
title="网站地址"
bg-color="grey-lighten-5"
v-model="form.url"
placeholder="请输入网站地址"
></tm-input>
<view class="pl-32 mb-24 input-tips text-grey text-size-s">填写提示需要加上 http://</view> <view class="pl-32 mb-24 input-tips text-grey text-size-s">填写提示需要加上 http://</view>
<tm-input :borderBottom="false" :round="3" bg-color="grey-lighten-5" title="网站分组" placeholder="请输入选择网站分组" :value="form.team"> <tm-input :borderBottom="false" :round="3" bg-color="grey-lighten-5" title="网站分组" placeholder="请输入选择网站分组" :value="form.team">
@@ -101,38 +85,10 @@
</tm-pickers> </tm-pickers>
</template> </template>
</tm-input> </tm-input>
<tm-input <tm-input input-type="number" :borderBottom="false" :adjust-position="true" :round="3" title="排序编号" bg-color="grey-lighten-5" v-model.number="form.priority" placeholder="请输入排序"></tm-input>
input-type="number" <tm-input :borderBottom="false" :vertical="true" :adjust-position="true" inputType="textarea" :round="3" title="网站描述" :height="120" bg-color="grey-lighten-5" v-model="form.description" placeholder="请输入描述"></tm-input>
:borderBottom="false"
:adjust-position="true"
:round="3"
title="排序编号"
bg-color="grey-lighten-5"
v-model.number="form.priority"
placeholder="请输入排序"
></tm-input>
<tm-input
:borderBottom="false"
:vertical="true"
:adjust-position="true"
inputType="textarea"
:round="3"
title="网站描述"
:height="120"
bg-color="grey-lighten-5"
v-model="form.description"
placeholder="请输入描述"
></tm-input>
<tm-input <tm-input :borderBottom="false" :adjust-position="true" :round="3" title="LOGO" bg-color="grey-lighten-5" v-model="form.logo" placeholder="请输入LOGO地址"></tm-input>
:borderBottom="false"
:adjust-position="true"
:round="3"
title="LOGO"
bg-color="grey-lighten-5"
v-model="form.logo"
placeholder="请输入LOGO地址"
></tm-input>
<view class="ma-30 mt-12 pb-12 bg-grey"> <view class="ma-30 mt-12 pb-12 bg-grey">
<image v-if="form.logo" class="thumbnail round-3" :src="form.logo" mode="aspectFill" @click="$utils.previewImage([form.logo])"></image> <image v-if="form.logo" class="thumbnail round-3" :src="form.logo" mode="aspectFill" @click="$utils.previewImage([form.logo])"></image>
<view v-else class="thumbnail round-3 text-grey grey-lighten-5 flex flex-col flex-center "> <view v-else class="thumbnail round-3 text-grey grey-lighten-5 flex flex-col flex-center ">
@@ -153,215 +109,172 @@
</template> </template>
<script> <script>
import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue'; import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue';
import tmButton from '@/tm-vuetify/components/tm-button/tm-button.vue'; import tmButton from '@/tm-vuetify/components/tm-button/tm-button.vue';
import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue'; import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue';
import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue'; import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue';
import tmPoup from '@/tm-vuetify/components/tm-poup/tm-poup.vue'; import tmPoup from '@/tm-vuetify/components/tm-poup/tm-poup.vue';
import tmInput from '@/tm-vuetify/components/tm-input/tm-input.vue'; import tmInput from '@/tm-vuetify/components/tm-input/tm-input.vue';
import tmPickers from '@/tm-vuetify/components/tm-pickers/tm-pickers.vue'; import tmPickers from '@/tm-vuetify/components/tm-pickers/tm-pickers.vue';
import tmTags from '@/tm-vuetify/components/tm-tags/tm-tags.vue'; import tmTags from '@/tm-vuetify/components/tm-tags/tm-tags.vue';
import tmTabs from '@/tm-vuetify/components/tm-tabs/tm-tabs.vue'; import tmTabs from '@/tm-vuetify/components/tm-tabs/tm-tabs.vue';
import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue'; import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue';
export default { export default {
components: { components: {
tmSkeleton, tmSkeleton,
tmButton, tmButton,
tmEmpty, tmEmpty,
tmFlotbutton, tmFlotbutton,
tmPoup, tmPoup,
tmInput, tmInput,
tmPickers, tmPickers,
tmTags, tmTags,
tmTabs, tmTabs,
tmTranslate tmTranslate
},
data() {
return {
loading: 'loading',
queryParams: {
size: 10,
page: 0
},
dataList: [],
filterList: [],
poupShow: false,
form: {
id: undefined,
description: '',
logo: '',
name: '',
team: '',
url: '',
priority: 0
},
tab: {
activeIndex: 0,
list: []
},
selectTeam: [],
teamList: []
};
},
onLoad() {
this.fnSetPageTitle('友链管理');
this.fnGetTeamData();
},
created() {
this.fnGetData();
},
onPullDownRefresh() {
this.fnGetData();
},
methods: {
fnOnTabChange(index) {
this.fnToTopPage();
let _filterData = [];
if (index == 0) {
_filterData = this.dataList;
} else {
_filterData = this.dataList.filter(x => x.team == this.teamList[index - 1]);
}
this.filterList = JSON.parse(JSON.stringify(_filterData));
}, },
fnGetTeamData() { data() {
this.$httpApi.admin return {
.getLinkTeamList() loading: 'loading',
.then(res => { queryParams: {
if (res.status == 200) { size: 10,
this.tab.list = ['全部', ...res.data]; page: 0
this.teamList = res.data; },
} else { dataList: [],
uni.$tm.toast('友链分组数据加载失败!'); filterList: [],
} poupShow: false,
}) form: {
.catch(err => { id: undefined,
uni.$tm.toast('友链分组数据加载失败!'); description: '',
}); logo: '',
}, name: '',
fnGetData() { team: '',
this.loading = 'loading'; url: '',
uni.showLoading({ priority: 0
mask: true, },
title: '加载中...' tab: {
}); activeIndex: 0,
this.tab.activeIndex = 0; list: []
this.$httpApi.admin },
.getLinkList(this.queryParams) selectTeam: [],
.then(res => { teamList: []
if (res.status == 200) {
const _dataList = res.data.map(item => {
item.logo = this.$utils.checkUrl(item.logo);
return item;
});
this.dataList = _dataList;
this.filterList = _dataList;
this.loading = 'success';
} else {
this.loading = 'error';
uni.$tm.toast('加载失败,请重试!');
}
})
.catch(err => {
console.error(err);
this.loading = 'error';
uni.$tm.toast('加载失败,请重试!');
})
.finally(() => {
uni.hideLoading();
uni.stopPullDownRefresh();
});
},
fnOnPoupChange(e) {
if (!e) {
this.fnResetForm();
}
},
fnShowFormModal(link) {
if (link) {
this.form = Object.assign({}, {}, link);
if (link.team) {
this.selectTeam = [link.team];
}
} else {
this.fnResetForm();
}
this.poupShow = true;
},
fnOnSelectTeam(e) {
this.form.team = e[0].data;
this.selectTeam = [e[0].data];
},
fnResetForm() {
this.form = {
id: undefined,
description: '',
logo: '',
name: '',
team: '',
url: '',
priority: 0
}; };
}, },
fnSubmit() {
if (this.form.name.trim() == '') { onLoad() {
return uni.$tm.toast('友链名称未填写!'); this.fnSetPageTitle('友链管理');
} this.fnGetTeamData();
if (this.form.id == undefined) {
this.$httpApi.admin
.addLink(this.form)
.then(res => {
if (res.status == 200) {
uni.$tm.toast(`保存成功!`);
setTimeout(() => {
uni.startPullDownRefresh();
}, 1200);
} else {
uni.$tm.toast('操作失败,请重试!');
}
})
.catch(err => {
uni.$tm.toast('操作失败,请重试!');
});
} else {
this.$httpApi.admin
.updateLink(this.form.id, this.form)
.then(res => {
if (res.status == 200) {
uni.$tm.toast(`保存成功!`);
let updateIndex = this.dataList.findIndex(x => x.id == this.form.id);
this.$set(this.dataList, updateIndex, this.form);
} else {
uni.$tm.toast('操作失败,请重试!');
}
})
.catch(err => {
uni.$tm.toast('操作失败,请重试!');
});
}
}, },
// 删除 created() {
fnDelete(link) { this.fnGetData();
const _link = link || this.form; },
uni.$eShowModal({ onPullDownRefresh() {
title: '提示', this.fnGetData();
content: `您是否要将 ${_link.name} 删除?`, },
showCancel: true, methods: {
cancelText: '否', fnOnTabChange(index) {
cancelColor: '#999999', this.fnResetSetAniWaitIndex();
confirmText: '是', this.fnToTopPage();
confirmColor: '#03a9f4' let _filterData = [];
}) if (index == 0) {
.then(res => { _filterData = this.dataList;
} else {
_filterData = this.dataList.filter(x => x.team == this.teamList[index - 1]);
}
this.filterList = JSON.parse(JSON.stringify(_filterData));
},
fnGetTeamData() {
this.$httpApi.admin
.getLinkTeamList()
.then(res => {
if (res.status == 200) {
this.tab.list = ['全部', ...res.data];
this.teamList = res.data;
} else {
uni.$tm.toast('友链分组数据加载失败!');
}
})
.catch(err => {
uni.$tm.toast('友链分组数据加载失败!');
});
},
fnGetData() {
this.loading = 'loading';
uni.showLoading({
mask: true,
title: '加载中...'
});
this.tab.activeIndex = 0;
this.$httpApi.admin
.getLinkList(this.queryParams)
.then(res => {
if (res.status == 200) {
const _dataList = res.data.map(item => {
item.logo = this.$utils.checkUrl(item.logo);
return item;
});
this.dataList = _dataList;
this.filterList = _dataList;
this.loading = 'success';
} else {
this.loading = 'error';
uni.$tm.toast('加载失败,请重试!');
}
})
.catch(err => {
console.error(err);
this.loading = 'error';
uni.$tm.toast('加载失败,请重试!');
})
.finally(() => {
uni.hideLoading();
uni.stopPullDownRefresh();
});
},
fnOnPoupChange(e) {
if (!e) {
this.fnResetForm();
}
},
fnShowFormModal(link) {
if (link) {
this.form = Object.assign({}, {}, link);
if (link.team) {
this.selectTeam = [link.team];
}
} else {
this.fnResetForm();
}
this.poupShow = true;
},
fnOnSelectTeam(e) {
this.form.team = e[0].data;
this.selectTeam = [e[0].data];
},
fnResetForm() {
this.form = {
id: undefined,
description: '',
logo: '',
name: '',
team: '',
url: '',
priority: 0
};
},
fnSubmit() {
if (this.form.name.trim() == '') {
return uni.$tm.toast('友链名称未填写!');
}
if (this.form.id == undefined) {
this.$httpApi.admin this.$httpApi.admin
.deleteLink(_link.id) .addLink(this.form)
.then(res => { .then(res => {
if (res.status == 200) { if (res.status == 200) {
uni.$tm.toast(`${_link.name} 已删除`); uni.$tm.toast(`保存成功`);
const delIndex = this.dataList.findIndex(x => x.id == _link.id); setTimeout(() => {
this.dataList.splice(delIndex, 1); uni.startPullDownRefresh();
}, 1200);
} else { } else {
uni.$tm.toast('操作失败,请重试!'); uni.$tm.toast('操作失败,请重试!');
} }
@@ -369,78 +282,134 @@ export default {
.catch(err => { .catch(err => {
uni.$tm.toast('操作失败,请重试!'); uni.$tm.toast('操作失败,请重试!');
}); });
}) } else {
.catch(err => {}); this.$httpApi.admin
.updateLink(this.form.id, this.form)
.then(res => {
if (res.status == 200) {
uni.$tm.toast(`保存成功!`);
let updateIndex = this.dataList.findIndex(x => x.id == this.form.id);
this.$set(this.dataList, updateIndex, this.form);
} else {
uni.$tm.toast('操作失败,请重试!');
}
})
.catch(err => {
uni.$tm.toast('操作失败,请重试!');
});
}
},
// 删除
fnDelete(link) {
const _link = link || this.form;
uni.$eShowModal({
title: '提示',
content: `您是否要将 ${_link.name} 删除?`,
showCancel: true,
cancelText: '否',
cancelColor: '#999999',
confirmText: '是',
confirmColor: '#03a9f4'
})
.then(res => {
this.$httpApi.admin
.deleteLink(_link.id)
.then(res => {
if (res.status == 200) {
uni.$tm.toast(`${_link.name} 已删除!`);
const delIndex = this.dataList.findIndex(x => x.id == _link.id);
this.dataList.splice(delIndex, 1);
} else {
uni.$tm.toast('操作失败,请重试!');
}
})
.catch(err => {
uni.$tm.toast('操作失败,请重试!');
});
})
.catch(err => {});
}
} }
} };
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.app-page { .app-page {
width: 100vw; width: 100vw;
min-height: 100vh; min-height: 100vh;
}
.loading-wrap {
padding: 24rpx;
.loading-error {
height: 65vh;
} }
}
.link-card {
box-sizing: border-box;
box-shadow: 0rpx 4rpx 24rpx rgba(0, 0, 0, 0.03);
.head {
.left {
width: 166rpx;
height: 166rpx;
.logo {
width: 100%;
height: 100%;
}
}
.right {
width: 0;
flex-grow: 1;
.name { .loading-wrap {
width: 0; padding: 24rpx;
flex-grow: 1;
display: flex; .loading-error {
align-items: center; height: 65vh;
}
.label {
width: 84rpx;
}
.value {
width: 0;
flex-grow: 1;
}
} }
} }
.foot {
.link-card {
box-sizing: border-box; box-sizing: border-box;
// border-top: 2rpx solid rgba(0, 0, 0, 0.03); box-shadow: 0rpx 4rpx 24rpx rgba(0, 0, 0, 0.03);
.head {
.left {
width: 166rpx;
height: 166rpx;
.logo {
width: 100%;
height: 100%;
}
}
.right {
width: 0;
flex-grow: 1;
.name {
width: 0;
flex-grow: 1;
display: flex;
align-items: center;
}
.label {
width: 84rpx;
}
.value {
width: 0;
flex-grow: 1;
}
}
}
.foot {
box-sizing: border-box;
// border-top: 2rpx solid rgba(0, 0, 0, 0.03);
}
} }
}
.poup-content { .poup-content {
overflow: hidden; overflow: hidden;
} }
.poup-body {
height: 71vh;
box-sizing: border-box;
touch-action: none;
}
.thumbnail {
width: 100%;
height: 260rpx;
}
.update-btn { .poup-body {
background-color: rgba(240, 250, 255, 1); height: 71vh;
} box-sizing: border-box;
.del-btn { touch-action: none;
background-color: rgba(254, 241, 240, 1) !important; }
}
</style> .thumbnail {
width: 100%;
height: 260rpx;
}
.update-btn {
background-color: rgba(240, 250, 255, 1);
}
.del-btn {
background-color: rgba(254, 241, 240, 1) !important;
}
</style>
+234 -228
Dosyayı Görüntüle
@@ -12,7 +12,7 @@
<block v-else> <block v-else>
<block v-for="(item, index) in dataList" :key="index"> <block v-for="(item, index) in dataList" :key="index">
<tm-translate animation-name="fadeUp" :wait="(index + 1) * 50"> <tm-translate animation-name="fadeUp" :wait="calcAniWait(index)">
<view class="card mb-24 bg-white pa-24 round-3"> <view class="card mb-24 bg-white pa-24 round-3">
<view class="border-b-1 pb-20 text-size-l text-weight-b"> <view class="border-b-1 pb-20 text-size-l text-weight-b">
<tm-tags :dense="true" :shadow="0" color="bg-gradient-light-blue-accent" size="s" model="fill">ID{{ item.id }}</tm-tags> <tm-tags :dense="true" :shadow="0" color="bg-gradient-light-blue-accent" size="s" model="fill">ID{{ item.id }}</tm-tags>
@@ -59,245 +59,251 @@
</template> </template>
<script> <script>
import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue'; import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue';
import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue'; import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue';
import tmTags from '@/tm-vuetify/components/tm-tags/tm-tags.vue'; import tmTags from '@/tm-vuetify/components/tm-tags/tm-tags.vue';
import tmButton from '@/tm-vuetify/components/tm-button/tm-button.vue'; import tmButton from '@/tm-vuetify/components/tm-button/tm-button.vue';
import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue'; import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue';
import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue'; import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue';
export default { export default {
components: { components: {
tmSkeleton, tmSkeleton,
tmEmpty, tmEmpty,
tmButton, tmButton,
tmTags, tmTags,
tmFlotbutton, tmFlotbutton,
tmTranslate tmTranslate
}, },
data() { data() {
return { return {
loading: 'loading', loading: 'loading',
queryParams: { queryParams: {
size: 8, size: 8,
page: 0, page: 0,
sort: undefined sort: undefined
}, },
result: {}, result: {},
dataList: [], dataList: [],
total: 0, total: 0,
isLoadMore: false, isLoadMore: false,
loadMoreText: '加载中...' loadMoreText: '加载中...'
};
},
filters: {
formatLogType(val) {
const logTypes = {
BLOG_INITIALIZED: {
value: 0,
text: '博客初始化'
},
POST_PUBLISHED: {
value: 5,
text: '文章发布'
},
POST_EDITED: {
value: 15,
text: '文章修改'
},
POST_DELETED: {
value: 20,
text: '文章删除'
},
LOGGED_IN: {
value: 25,
text: '用户登录'
},
LOGGED_OUT: {
value: 30,
text: '注销登录'
},
LOGIN_FAILED: {
value: 35,
text: '登录失败'
},
PASSWORD_UPDATED: {
value: 40,
text: '修改密码'
},
PROFILE_UPDATED: {
value: 45,
text: '资料修改'
},
SHEET_PUBLISHED: {
value: 50,
text: '页面发布'
},
SHEET_EDITED: {
value: 55,
text: '页面修改'
},
SHEET_DELETED: {
value: 60,
text: '页面删除'
},
MFA_UPDATED: {
value: 65,
text: '两步验证'
},
LOGGED_PRE_CHECK: {
value: 70,
text: '登录验证'
}
}; };
return logTypes[val].text; },
} filters: {
}, formatLogType(val) {
const logTypes = {
onLoad() { BLOG_INITIALIZED: {
this.fnSetPageTitle('日志管理'); value: 0,
}, text: '博客初始化'
created() { },
this.fnGetData(); POST_PUBLISHED: {
}, value: 5,
onPullDownRefresh() { text: '文章发布'
this.queryParams.page = 0; },
this.dataList = []; POST_EDITED: {
this.fnGetData(); value: 15,
}, text: '文章修改'
onReachBottom(e) { },
if (this.result.hasNext) { POST_DELETED: {
this.queryParams.page += 1; value: 20,
this.isLoadMore = true; text: '文章删除'
this.fnGetData(); },
} else { LOGGED_IN: {
uni.showToast({ value: 25,
icon: 'none', text: '用户登录'
title: '没有更多数据了' },
}); LOGGED_OUT: {
} value: 30,
}, text: '注销登录'
methods: { },
fnGetData() { LOGIN_FAILED: {
uni.showLoading({ value: 35,
mask: true, text: '登录失败'
title: '加载中...' },
}); PASSWORD_UPDATED: {
// 设置状态为加载中 value: 40,
if (!this.isLoadMore) { text: '修改密码'
this.loading = 'loading'; },
} PROFILE_UPDATED: {
this.loadMoreText = '加载中...'; value: 45,
this.$httpApi.admin text: '资料修改'
.getLogsListByPage(this.queryParams) },
.then(res => { SHEET_PUBLISHED: {
if (res.status == 200) { value: 50,
this.loadMoreText = res.data.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~'; text: '页面发布'
this.result = res.data; },
this.total = res.data.total; SHEET_EDITED: {
const _tempDataList = res.data.content.map(item => { value: 55,
item['time'] = uni.$tm.dayjs(item.createTime).format('YYYY-MM-DD HH:mm:ss'); text: '页面修改'
return item; },
}); SHEET_DELETED: {
if (this.isLoadMore) { value: 60,
this.dataList = this.dataList.concat(_tempDataList); text: '页面删除'
} else { },
this.dataList = _tempDataList; MFA_UPDATED: {
} value: 65,
this.loading = 'success'; text: '两步验证'
} else { },
uni.$tm.toast('加载失败,请重试!'); LOGGED_PRE_CHECK: {
thi.loading = 'error'; value: 70,
text: '登录验证'
} }
}) };
.catch(err => { return logTypes[val].text;
console.error(err); }
uni.$tm.toast('加载失败,请重试!');
this.loading = 'error';
this.loadMoreText = '加载失败,请下拉刷新!';
})
.finally(() => {
setTimeout(() => {
uni.hideLoading();
uni.stopPullDownRefresh();
}, 300);
});
}, },
// 删除 onLoad() {
fnOnClear() { this.fnSetPageTitle('日志管理');
uni.$eShowModal({ },
title: '提示', created() {
content: `您确定要清空所有的日志记录吗?`, this.fnGetData();
showCancel: true, },
cancelText: '否', onPullDownRefresh() {
cancelColor: '#999999', this.queryParams.page = 0;
confirmText: '是', this.dataList = [];
confirmColor: '#03a9f4' this.fnGetData();
}) },
.then(res => { onReachBottom(e) {
uni.showLoading({ if (this.result.hasNext) {
mask: true, this.queryParams.page += 1;
title: '正在清空...' this.isLoadMore = true;
}); this.fnGetData();
this.$httpApi.admin } else {
.deleteAllLogs() uni.showToast({
.then(res => { icon: 'none',
if (res.status == 200) { title: '没有更多数据了'
uni.$tm.toast('操作成功!'); });
setTimeout(() => { }
this.queryParams.page = 0; },
this.dataList = []; methods: {
this.fnGetData(); fnGetData() {
}, 1000); uni.showLoading({
mask: true,
title: '加载中...'
});
// 设置状态为加载中
if (!this.isLoadMore) {
this.loading = 'loading';
}
this.loadMoreText = '加载中...';
this.$httpApi.admin
.getLogsListByPage(this.queryParams)
.then(res => {
if (res.status == 200) {
this.loadMoreText = res.data.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~';
this.result = res.data;
this.total = res.data.total;
const _tempDataList = res.data.content.map(item => {
item['time'] = uni.$tm.dayjs(item.createTime).format('YYYY-MM-DD HH:mm:ss');
return item;
});
if (this.isLoadMore) {
this.dataList = this.dataList.concat(_tempDataList);
} else { } else {
uni.$tm.toast('操作失败,请重试!'); this.dataList = _tempDataList;
} }
}) this.loading = 'success';
.catch(err => { } else {
console.error(err); uni.$tm.toast('加载失败,请重试!');
uni.$tm.toast('操作失败,请重试!'); thi.loading = 'error';
}
})
.catch(err => {
console.error(err);
uni.$tm.toast('加载失败,请重试!');
this.loading = 'error';
this.loadMoreText = '加载失败,请下拉刷新!';
})
.finally(() => {
setTimeout(() => {
uni.hideLoading();
uni.stopPullDownRefresh();
}, 300);
});
},
// 删除
fnOnClear() {
uni.$eShowModal({
title: '提示',
content: `您确定要清空所有的日志记录吗?`,
showCancel: true,
cancelText: '否',
cancelColor: '#999999',
confirmText: '是',
confirmColor: '#03a9f4'
})
.then(res => {
uni.showLoading({
mask: true,
title: '正在清空...'
}); });
}) this.$httpApi.admin
.catch(err => {}); .deleteAllLogs()
.then(res => {
if (res.status == 200) {
uni.$tm.toast('操作成功!');
setTimeout(() => {
this.queryParams.page = 0;
this.dataList = [];
this.fnGetData();
}, 1000);
} else {
uni.$tm.toast('操作失败,请重试!');
}
})
.catch(err => {
console.error(err);
uni.$tm.toast('操作失败,请重试!');
});
})
.catch(err => {});
}
} }
} };
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.app-page { .app-page {
width: 100vw; width: 100vw;
min-height: 100vh; min-height: 100vh;
} }
.loading-wrap {
padding: 24rpx; .loading-wrap {
} padding: 24rpx;
.page-content { }
}
.content-empty { .page-content {}
width: 100vw;
height: 65vh; .content-empty {
} width: 100vw;
.card { height: 65vh;
box-shadow: 0rpx 2rpx 24rpx rgba(0, 0, 0, 0.05); }
}
.desc-item { .card {
.desc-label { box-shadow: 0rpx 2rpx 24rpx rgba(0, 0, 0, 0.05);
width: 150rpx; }
position: relative;
&::after { .desc-item {
content: ''; .desc-label {
position: absolute; width: 150rpx;
right: 0px; position: relative;
top: 0rpx;
&::after {
content: '';
position: absolute;
right: 0px;
top: 0rpx;
}
}
.desc-value {
word-wrap: break-word;
word-break: break-all;
padding-left: 6rpx;
} }
} }
.desc-value { </style>
word-wrap: break-word;
word-break: break-all;
padding-left: 6rpx;
}
}
</style>
+355 -432
Dosyayı Görüntüle
@@ -1,17 +1,7 @@
<template> <template>
<view class="app-page flex flex-col"> <view class="app-page flex flex-col">
<view class="e-fixed shadow-2 bg-white"> <view class="e-fixed shadow-2 bg-white">
<tm-search <tm-search :clear="true" v-model="queryParams.keyword" :round="24" :shadow="0" confirmText="搜索" color="light-blue" insertColor="light-blue" align="center" @confirm="fnOnSearch()"></tm-search>
:clear="true"
v-model="queryParams.keyword"
:round="24"
:shadow="0"
confirmText="搜索"
color="light-blue"
insertColor="light-blue"
align="center"
@confirm="fnOnSearch()"
></tm-search>
<tm-tabs v-if="team.list.length != 0" color="light-blue" :shadow="0" v-model="team.activeIndex" :list="team.list" align="center" @change="fnOnTabChange"></tm-tabs> <tm-tabs v-if="team.list.length != 0" color="light-blue" :shadow="0" v-model="team.activeIndex" :list="team.list" align="center" @change="fnOnTabChange"></tm-tabs>
</view> </view>
@@ -35,7 +25,7 @@
<view v-if="dataList.length == 0" class="content-empty flex flex-center"><tm-empty icon="icon-shiliangzhinengduixiang-" label="暂无任何图片"></tm-empty></view> <view v-if="dataList.length == 0" class="content-empty flex flex-center"><tm-empty icon="icon-shiliangzhinengduixiang-" label="暂无任何图片"></tm-empty></view>
<block v-else> <block v-else>
<block v-for="(item, index) in dataList" :key="index"> <block v-for="(item, index) in dataList" :key="index">
<tm-translate animation-name="fadeUp" :wait="(index + 1) * 50"> <tm-translate animation-name="fadeUp" :wait="calcAniWait(index)">
<view class="card mb-24 flex flex-col bg-white pa-24 round-3"> <view class="card mb-24 flex flex-col bg-white pa-24 round-3">
<view class="thumbnail round-2" @click="fnPreview(item, index)"> <view class="thumbnail round-2" @click="fnPreview(item, index)">
<image class="thumbnail-img round-2" :src="item.showThumbnail" mode="aspectFill"></image> <image class="thumbnail-img round-2" :src="item.showThumbnail" mode="aspectFill"></image>
@@ -66,99 +56,23 @@
<view class="poup-content"> <view class="poup-content">
<view class="poup-head text-align-center text-weight-b text-size-g ma-24">{{ form.id != undefined ? '编辑图片' : '新增图片' }}</view> <view class="poup-head text-align-center text-weight-b text-size-g ma-24">{{ form.id != undefined ? '编辑图片' : '新增图片' }}</view>
<scroll-view :enable-flex="true" class="poup-body pa-24 pt-0 pb-0" :scroll-y="true" :scroll-top="poupBodyScrollTop" @touchmove.stop @scroll="fnOnPoupBodyScroll"> <scroll-view :enable-flex="true" class="poup-body pa-24 pt-0 pb-0" :scroll-y="true" :scroll-top="poupBodyScrollTop" @touchmove.stop @scroll="fnOnPoupBodyScroll">
<tm-input <tm-input :adjust-position="true" :round="3" clear :borderBottom="false" title="图片名称" bg-color="grey-lighten-5" v-model="form.name" placeholder="请输入图片名称"></tm-input>
:adjust-position="true"
:round="3"
clear
:borderBottom="false"
title="图片名称"
bg-color="grey-lighten-5"
v-model="form.name"
placeholder="请输入图片名称"
></tm-input>
<tm-input <tm-input name="team" :adjust-position="true" :round="3" bg-color="grey-lighten-5" :borderBottom="false" title="图片分组" placeholder="请选择输入或分组" v-model="form.team">
name="team"
:adjust-position="true"
:round="3"
bg-color="grey-lighten-5"
:borderBottom="false"
title="图片分组"
placeholder="请选择输入或分组"
v-model="form.team"
>
<tm-pickers slot="rightBtn" rang-key="name" :default-value.sync="team.selected" :list="team.selectList" @confirm="fnOnSelectTeamConfirm"> <tm-pickers slot="rightBtn" rang-key="name" :default-value.sync="team.selected" :list="team.selectList" @confirm="fnOnSelectTeamConfirm">
<tm-button size="m" :dense="true" :shadow="0" theme="bg-gradient-light-blue-accent">选择</tm-button> <tm-button size="m" :dense="true" :shadow="0" theme="bg-gradient-light-blue-accent">选择</tm-button>
</tm-pickers> </tm-pickers>
</tm-input> </tm-input>
<view class="pl-32 mb-24 input-tips text-grey text-size-s">填写提示图片分组可选择也可以输入新的分组名称</view> <view class="pl-32 mb-24 input-tips text-grey text-size-s">填写提示图片分组可选择也可以输入新的分组名称</view>
<tm-pickersDate <tm-pickersDate :full-number="true" :show-detail="{ year: true, month: true, day: true, hour: true, min: true, sec: true }" :default-value="takeTime" @confirm="fnOnTakeTimeConfirm">
:full-number="true" <tm-input title="拍摄时间" :adjust-position="true" :round="3" bg-color="grey-lighten-5" :borderBottom="false" placeholder="请选择拍摄时间" disabled :value="takeTime"></tm-input>
:show-detail="{ year: true, month: true, day: true, hour: true, min: true, sec: true }"
:default-value="takeTime"
@confirm="fnOnTakeTimeConfirm"
>
<tm-input
title="拍摄时间"
:adjust-position="true"
:round="3"
bg-color="grey-lighten-5"
:borderBottom="false"
placeholder="请选择拍摄时间"
disabled
:value="takeTime"
></tm-input>
</tm-pickersDate> </tm-pickersDate>
<tm-input <tm-input :borderBottom="false" :adjust-position="true" :round="3" clear title="拍摄地点" bg-color="grey-lighten-5" v-model="form.location" placeholder="请输入拍摄地点"></tm-input>
:borderBottom="false" <tm-input :borderBottom="false" :vertical="false" clear :adjust-position="true" inputType="textarea" :round="3" title="图片描述" :height="160" bg-color="grey-lighten-5" v-model="form.description" placeholder="请输入图片描述"></tm-input>
:adjust-position="true" <tm-input name="url" clear :borderBottom="false" :adjust-position="true" :round="3" title="图片地址" bg-color="grey-lighten-5" v-model="form.url" placeholder="请输入或选择图片" @clear="fnOnUrlInputChange" @blur="fnOnUrlInputChange" @input="fnOnUrlInputChange">
:round="3"
clear
title="拍摄地点"
bg-color="grey-lighten-5"
v-model="form.location"
placeholder="请输入拍摄地点"
></tm-input>
<tm-input
:borderBottom="false"
:vertical="false"
clear
:adjust-position="true"
inputType="textarea"
:round="3"
title="图片描述"
:height="160"
bg-color="grey-lighten-5"
v-model="form.description"
placeholder="请输入图片描述"
></tm-input>
<tm-input
name="url"
clear
:borderBottom="false"
:adjust-position="true"
:round="3"
title="图片地址"
bg-color="grey-lighten-5"
v-model="form.url"
placeholder="请输入或选择图片"
@clear="fnOnUrlInputChange"
@blur="fnOnUrlInputChange"
@input="fnOnUrlInputChange"
>
<tm-button slot="rightBtn" size="m" :dense="true" :shadow="0" theme="bg-gradient-light-blue-accent" @click="fnShowAttachmentsSelect('url')">选择</tm-button> <tm-button slot="rightBtn" size="m" :dense="true" :shadow="0" theme="bg-gradient-light-blue-accent" @click="fnShowAttachmentsSelect('url')">选择</tm-button>
</tm-input> </tm-input>
<tm-input <tm-input name="thumbnail" :borderBottom="false" :adjust-position="true" :round="3" clear title="缩略图片" bg-color="grey-lighten-5" v-model="form.thumbnail" placeholder="请输入或选择缩略图">
name="thumbnail"
:borderBottom="false"
:adjust-position="true"
:round="3"
clear
title="缩略图片"
bg-color="grey-lighten-5"
v-model="form.thumbnail"
placeholder="请输入或选择缩略图"
>
<tm-button slot="rightBtn" size="m" :dense="true" :shadow="0" theme="bg-gradient-light-blue-accent" @click="fnShowAttachmentsSelect('thumbnail')"> <tm-button slot="rightBtn" size="m" :dense="true" :shadow="0" theme="bg-gradient-light-blue-accent" @click="fnShowAttachmentsSelect('thumbnail')">
选择 选择
</tm-button> </tm-button>
@@ -181,316 +95,273 @@
</template> </template>
<script> <script>
import throttle from '@/utils/throttle.js'; import throttle from '@/utils/throttle.js';
import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue'; import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue';
import tmButton from '@/tm-vuetify/components/tm-button/tm-button.vue'; import tmButton from '@/tm-vuetify/components/tm-button/tm-button.vue';
import tmSearch from '@/tm-vuetify/components/tm-search/tm-search.vue'; import tmSearch from '@/tm-vuetify/components/tm-search/tm-search.vue';
import tmTabs from '@/tm-vuetify/components/tm-tabs/tm-tabs.vue'; import tmTabs from '@/tm-vuetify/components/tm-tabs/tm-tabs.vue';
import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue'; import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue';
import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue'; import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue';
import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue'; import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue';
import tmPoup from '@/tm-vuetify/components/tm-poup/tm-poup.vue'; import tmPoup from '@/tm-vuetify/components/tm-poup/tm-poup.vue';
import tmInput from '@/tm-vuetify/components/tm-input/tm-input.vue'; import tmInput from '@/tm-vuetify/components/tm-input/tm-input.vue';
import tmPickersDate from '@/tm-vuetify/components/tm-pickersDate/tm-pickersDate.vue'; import tmPickersDate from '@/tm-vuetify/components/tm-pickersDate/tm-pickersDate.vue';
import tmPickers from '@/tm-vuetify/components/tm-pickers/tm-pickers.vue'; import tmPickers from '@/tm-vuetify/components/tm-pickers/tm-pickers.vue';
import AttachmentSelect from '@/components/attachment-select/attachment-select.vue'; import AttachmentSelect from '@/components/attachment-select/attachment-select.vue';
export default { export default {
components: { components: {
tmSkeleton, tmSkeleton,
tmButton, tmButton,
tmSearch, tmSearch,
tmTabs, tmTabs,
tmEmpty, tmEmpty,
tmFlotbutton, tmFlotbutton,
tmTranslate, tmTranslate,
tmPoup, tmPoup,
tmInput, tmInput,
tmPickersDate, tmPickersDate,
tmPickers, tmPickers,
AttachmentSelect AttachmentSelect
}, },
data() { data() {
return { return {
loading: 'loading', loading: 'loading',
team: { team: {
activeIndex: 0, activeIndex: 0,
list: [], list: [],
selected: [], selected: [],
selectList: [] selectList: []
}, },
queryParams: { queryParams: {
size: 10, size: 10,
page: 0, page: 0,
sort: 'createTime,desc', sort: 'createTime,desc',
sort: 'id,asc' sort: 'id,asc'
}, },
result: null, result: null,
dataList: [], dataList: [],
total: 0, total: 0,
isLoadMore: false, isLoadMore: false,
loadMoreText: '加载中...', loadMoreText: '加载中...',
poupShow: false, poupShow: false,
attachmentsSelectShow: false, attachmentsSelectShow: false,
selectAttachmentsType: 'url', selectAttachmentsType: 'url',
takeTime: undefined,
form: {
id: undefined,
location: undefined,
name: undefined,
takeTime: undefined, takeTime: undefined,
team: undefined, form: {
thumbnail: undefined, id: undefined,
url: undefined, location: undefined,
description: undefined name: undefined,
}, takeTime: undefined,
poupBodyScrollTop: 0 team: undefined,
}; thumbnail: undefined,
}, url: undefined,
description: undefined
},
poupBodyScrollTop: 0
};
},
onLoad() { onLoad() {
this.fnSetPageTitle('图库管理'); this.fnSetPageTitle('图库管理');
this.fnGetTeamList(); this.fnGetTeamList();
},
created() {
this.fnGetData();
},
onPullDownRefresh() {
this.queryParams.page = 0;
this.dataList = [];
this.fnGetData();
},
onReachBottom(e) {
if (this.result.hasNext) {
this.queryParams.page += 1;
this.isLoadMore = true;
this.fnGetData();
} else {
uni.showToast({
icon: 'none',
title: '没有更多数据了'
});
}
},
methods: {
// 获取分类列表
fnGetTeamList() {
this.$httpApi.admin
.getPhotosTeams()
.then(res => {
if (res.status == 200) {
let _list = res.data;
this.team.selectList = _list.map((item, index) => {
return {
id: index,
name: item,
value: item
};
});
if (_list.length > 1) {
_list.unshift('全部');
this.team.list = _list;
}
}
})
.catch(err => {});
}, },
fnOnSearch() { created() {
this.queryParams.page = 0;
this.isLoadMore = false;
this.fnToTopPage();
this.fnGetData(); this.fnGetData();
}, },
fnOnTabChange(index) { onPullDownRefresh() {
this.queryParams.team = index == 0 ? undefined : this.team.list[index];
this.queryParams.page = 0; this.queryParams.page = 0;
this.dataList = []; this.dataList = [];
this.fnToTopPage();
this.fnGetData(); this.fnGetData();
}, },
fnOnTakeTimeConfirm(e) { onReachBottom(e) {
this.takeTime = `${e.year}-${e.month}-${e.day} ${e.hour}:${e.min}:${e.sec}`; if (this.result.hasNext) {
this.form.takeTime = new Date(this.takeTime).getTime(); this.queryParams.page += 1;
}, this.isLoadMore = true;
fnOnSelectTeamConfirm(e) { this.fnGetData();
const _select = e[0].data; } else {
this.form.team = _select.value; uni.showToast({
}, icon: 'none',
fnGetData() { title: '没有更多数据了'
uni.showLoading({ });
mask: true,
title: '加载中...'
});
// 设置状态为加载中
if (!this.isLoadMore) {
this.loading = 'loading';
} }
this.loadMoreText = '加载中...'; },
this.$httpApi.admin methods: {
.getPhotos(this.queryParams) // 获取分类列表
.then(res => { fnGetTeamList() {
if (res.status == 200) { this.$httpApi.admin
this.loadMoreText = res.data.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~'; .getPhotosTeams()
this.result = res.data; .then(res => {
this.total = res.data.total; if (res.status == 200) {
let _list = res.data.content.map(item => { let _list = res.data;
// 处理显示的图片 this.team.selectList = _list.map((item, index) => {
item['showThumbnail'] = this.$utils.checkThumbnailUrl(item.thumbnail); return {
return item; id: index,
}); name: item,
value: item
if (this.isLoadMore) { };
this.dataList = this.dataList.concat(_list); });
} else { if (_list.length > 1) {
this.dataList = _list; _list.unshift('全部');
this.team.list = _list;
}
} }
this.loading = 'success'; })
} else { .catch(err => {});
},
fnOnSearch() {
this.fnResetSetAniWaitIndex();
this.queryParams.page = 0;
this.isLoadMore = false;
this.fnToTopPage();
this.fnGetData();
},
fnOnTabChange(index) {
this.fnResetSetAniWaitIndex();
this.queryParams.team = index == 0 ? undefined : this.team.list[index];
this.queryParams.page = 0;
this.dataList = [];
this.fnToTopPage();
this.fnGetData();
},
fnOnTakeTimeConfirm(e) {
this.takeTime = `${e.year}-${e.month}-${e.day} ${e.hour}:${e.min}:${e.sec}`;
this.form.takeTime = new Date(this.takeTime).getTime();
},
fnOnSelectTeamConfirm(e) {
const _select = e[0].data;
this.form.team = _select.value;
},
fnGetData() {
uni.showLoading({
mask: true,
title: '加载中...'
});
// 设置状态为加载中
if (!this.isLoadMore) {
this.loading = 'loading';
}
this.loadMoreText = '加载中...';
this.$httpApi.admin
.getPhotos(this.queryParams)
.then(res => {
if (res.status == 200) {
this.loadMoreText = res.data.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~';
this.result = res.data;
this.total = res.data.total;
let _list = res.data.content.map(item => {
// 处理显示的图片
item['showThumbnail'] = this.$utils.checkThumbnailUrl(item.thumbnail);
return item;
});
if (this.isLoadMore) {
this.dataList = this.dataList.concat(_list);
} else {
this.dataList = _list;
}
this.loading = 'success';
} else {
uni.$tm.toast('加载失败,请重试!');
this.loading = 'error';
}
})
.catch(err => {
console.error(err);
uni.$tm.toast('加载失败,请重试!'); uni.$tm.toast('加载失败,请重试!');
this.loading = 'error'; this.loading = 'error';
this.loadMoreText = '加载失败,请下拉刷新!';
})
.finally(() => {
setTimeout(() => {
uni.hideLoading();
uni.stopPullDownRefresh();
}, 300);
});
},
fnOnAttachmentsSelectClose() {
this.attachmentsSelectShow = false;
},
fnOnPoupBodyScroll(e) {
throttle(() => {
this.poupBodyScrollTop = e.detail.scrollTop;
}, 1000);
},
fnOnPoupChange(e) {
if (!e) {
this.fnResetForm();
}
},
fnOnUrlInputChange() {
if (this.form.url) {
this.$set(this.form, 'showThumbnail', this.$utils.checkThumbnailUrl(this.form.url));
}
},
fnShowAttachmentsSelect(type) {
this.selectAttachmentsType = type;
this.attachmentsSelectShow = true;
},
// 监听附件选择
fnOnAttachmentsSelect(file) {
if (this.selectAttachmentsType == 'url') {
this.form.url = file.path;
this.form.showThumbnail = this.$utils.checkThumbnailUrl(file.path);
if (!this.form.thumbnail) {
this.form.thumbnail = file.path;
} }
}) } else {
.catch(err => {
console.error(err);
uni.$tm.toast('加载失败,请重试!');
this.loading = 'error';
this.loadMoreText = '加载失败,请下拉刷新!';
})
.finally(() => {
setTimeout(() => {
uni.hideLoading();
uni.stopPullDownRefresh();
}, 300);
});
},
fnOnAttachmentsSelectClose() {
this.attachmentsSelectShow = false;
},
fnOnPoupBodyScroll(e) {
throttle(() => {
this.poupBodyScrollTop = e.detail.scrollTop;
}, 1000);
},
fnOnPoupChange(e) {
if (!e) {
this.fnResetForm();
}
},
fnOnUrlInputChange() {
if (this.form.url) {
this.$set(this.form, 'showThumbnail', this.$utils.checkThumbnailUrl(this.form.url));
}
},
fnShowAttachmentsSelect(type) {
this.selectAttachmentsType = type;
this.attachmentsSelectShow = true;
},
// 监听附件选择
fnOnAttachmentsSelect(file) {
if (this.selectAttachmentsType == 'url') {
this.form.url = file.path;
this.form.showThumbnail = this.$utils.checkThumbnailUrl(file.path);
if (!this.form.thumbnail) {
this.form.thumbnail = file.path; this.form.thumbnail = file.path;
} }
} else { this.attachmentsSelectShow = false;
this.form.thumbnail = file.path; },
} fnResetForm() {
this.attachmentsSelectShow = false; this.form = { id: undefined, location: undefined, name: undefined, takeTime: undefined, team: undefined, thumbnail: undefined, url: undefined, description: undefined };
}, this.takeTime = uni.$tm.dayjs(new Date().getTime()).format('YYYY-MM-DD HH:mm:ss');
fnResetForm() { },
this.form = { id: undefined, location: undefined, name: undefined, takeTime: undefined, team: undefined, thumbnail: undefined, url: undefined, description: undefined }; fnEdit(item) {
this.takeTime = uni.$tm.dayjs(new Date().getTime()).format('YYYY-MM-DD HH:mm:ss'); this.poupBodyScrollTop = 0;
}, if (!item.takeTime) {
fnEdit(item) { item.takeTime = new Date().getTime();
this.poupBodyScrollTop = 0; }
if (!item.takeTime) { this.takeTime = uni.$tm.dayjs(item.takeTime).format('YYYY-MM-DD HH:mm:ss');
item.takeTime = new Date().getTime(); this.form = item;
} if (this.form.team) {
this.takeTime = uni.$tm.dayjs(item.takeTime).format('YYYY-MM-DD HH:mm:ss'); this.team.selected = [this.team.selectList.findIndex(x => x.name == this.form.team)];
this.form = item; } else {
if (this.form.team) { this.team.selected = [];
this.team.selected = [this.team.selectList.findIndex(x => x.name == this.form.team)]; }
} else { this.poupShow = true;
this.team.selected = []; },
} // 新增
this.poupShow = true; fnAdd() {
}, this.fnResetForm();
// 新增 this.poupBodyScrollTop = 0;
fnAdd() { this.poupShow = true;
this.fnResetForm(); },
this.poupBodyScrollTop = 0; // 保存
this.poupShow = true; fnSave() {
}, if (!this.form.name) {
// 保存 return uni.$tm.toast('请填写图片名称!');
fnSave() { }
if (!this.form.name) { if (!this.$utils.checkIsUrl(this.form.url)) {
return uni.$tm.toast('请填写图片名称'); return uni.$tm.toast('请选择或输入正确的图片地址');
} }
if (!this.$utils.checkIsUrl(this.form.url)) { if (!this.$utils.checkIsUrl(this.form.thumbnail)) {
return uni.$tm.toast('请选择或输入正确的图地址!'); return uni.$tm.toast('请选择或输入正确的缩略图地址!');
} }
if (!this.$utils.checkIsUrl(this.form.thumbnail)) { if (this.form.id == undefined) {
return uni.$tm.toast('请选择或输入正确的缩略图地址!');
}
if (this.form.id == undefined) {
this.$httpApi.admin
.createPhotos(this.form)
.then(res => {
if (res.status == 200) {
uni.$tm.toast(`保存成功!`);
this.poupShow = false;
setTimeout(() => {
this.fnResetForm();
this.fnGetTeamList();
uni.startPullDownRefresh();
}, 1000);
} else {
uni.$tm.toast('操作失败,请重试!');
}
})
.catch(err => {
uni.$tm.toast('操作失败,请重试!');
});
} else {
this.$httpApi.admin
.updatePhotosById(this.form.id, this.form)
.then(res => {
if (res.status == 200) {
uni.$tm.toast(`保存成功!`);
let updateIndex = this.dataList.findIndex(x => x.id == this.form.id);
this.$set(this.dataList, updateIndex, this.form);
setTimeout(() => {
this.fnGetTeamList();
}, 500);
} else {
uni.$tm.toast('操作失败,请重试!');
}
})
.catch(err => {
uni.$tm.toast('操作失败,请重试!');
});
}
},
// 删除
fnDelete(item, index) {
uni.$eShowModal({
title: '提示',
content: `您是否删除名为 ${item.name} 的图片?`,
showCancel: true,
cancelText: '否',
cancelColor: '#999999',
confirmText: '是',
confirmColor: '#03a9f4'
})
.then(res => {
this.$httpApi.admin this.$httpApi.admin
.deletePhotosById(item.id) .createPhotos(this.form)
.then(res => { .then(res => {
if (res.status == 200) { if (res.status == 200) {
uni.$tm.toast(`${item.name} 分类已删除`); uni.$tm.toast(`保存成功`);
this.dataList.splice(index, 1); this.poupShow = false;
setTimeout(() => {
this.fnResetForm();
this.fnGetTeamList();
uni.startPullDownRefresh();
}, 1000);
} else { } else {
uni.$tm.toast('操作失败,请重试!'); uni.$tm.toast('操作失败,请重试!');
} }
@@ -498,56 +369,108 @@ export default {
.catch(err => { .catch(err => {
uni.$tm.toast('操作失败,请重试!'); uni.$tm.toast('操作失败,请重试!');
}); });
}) } else {
.catch(err => {}); this.$httpApi.admin
}, .updatePhotosById(this.form.id, this.form)
// 预览 .then(res => {
fnPreview(item, index) { if (res.status == 200) {
uni.previewImage({ uni.$tm.toast(`保存成功!`);
current: index, let updateIndex = this.dataList.findIndex(x => x.id == this.form.id);
urls: this.dataList.map(x => x.url), this.$set(this.dataList, updateIndex, this.form);
indicator: 'number', setTimeout(() => {
loop: true this.fnGetTeamList();
}); }, 500);
} else {
uni.$tm.toast('操作失败,请重试!');
}
})
.catch(err => {
uni.$tm.toast('操作失败,请重试!');
});
}
},
// 删除
fnDelete(item, index) {
uni.$eShowModal({
title: '提示',
content: `您是否删除名为 ${item.name} 的图片?`,
showCancel: true,
cancelText: '否',
cancelColor: '#999999',
confirmText: '是',
confirmColor: '#03a9f4'
})
.then(res => {
this.$httpApi.admin
.deletePhotosById(item.id)
.then(res => {
if (res.status == 200) {
uni.$tm.toast(`${item.name} 分类已删除!`);
this.dataList.splice(index, 1);
} else {
uni.$tm.toast('操作失败,请重试!');
}
})
.catch(err => {
uni.$tm.toast('操作失败,请重试!');
});
})
.catch(err => {});
},
// 预览
fnPreview(item, index) {
uni.previewImage({
current: index,
urls: this.dataList.map(x => x.url),
indicator: 'number',
loop: true
});
}
} }
} };
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.app-page { .app-page {
width: 100vw; width: 100vw;
min-height: 100vh; min-height: 100vh;
}
.loading-wrap {
padding: 24rpx;
.loading-error {
height: 65vh;
} }
}
.btn-wrap {
box-sizing: border-box;
padding-top: 12rpx;
padding-bottom: 12rpx;
box-shadow: 0rpx -4rpx 24rpx rgba(0, 0, 0, 0.05);
}
.card {
box-shadow: 0rpx 4rpx 24rpx rgba(0, 0, 0, 0.05);
}
.thumbnail {
width: 100%;
&-img {
width: 100%;
height: 300rpx;
}
}
.poup-content { .loading-wrap {
overflow: hidden; padding: 24rpx;
}
.poup-body { .loading-error {
height: 69vh; height: 65vh;
box-sizing: border-box; }
touch-action: none; }
}
</style> .btn-wrap {
box-sizing: border-box;
padding-top: 12rpx;
padding-bottom: 12rpx;
box-shadow: 0rpx -4rpx 24rpx rgba(0, 0, 0, 0.05);
}
.card {
box-shadow: 0rpx 4rpx 24rpx rgba(0, 0, 0, 0.05);
}
.thumbnail {
width: 100%;
&-img {
width: 100%;
height: 300rpx;
}
}
.poup-content {
overflow: hidden;
}
.poup-body {
height: 69vh;
box-sizing: border-box;
touch-action: none;
}
</style>
+263 -279
Dosyayı Görüntüle
@@ -14,7 +14,7 @@
<view v-if="dataList.length == 0" class="content-empty flex flex-center"><tm-empty icon="icon-shiliangzhinengduixiang-" label="无数据"></tm-empty></view> <view v-if="dataList.length == 0" class="content-empty flex flex-center"><tm-empty icon="icon-shiliangzhinengduixiang-" label="无数据"></tm-empty></view>
<block v-else> <block v-else>
<block v-for="(tag, index) in dataList" :key="index"> <block v-for="(tag, index) in dataList" :key="index">
<tm-translate animation-name="fadeUp" :wait="(index + 1) * 50"> <tm-translate animation-name="fadeUp" :wait="calcAniWait(index)">
<view class="tags-card flex round-3 bg-white pa-24 mb-24" @click="fnShowFormModal(tag)"> <view class="tags-card flex round-3 bg-white pa-24 mb-24" @click="fnShowFormModal(tag)">
<text class="del-icon flex flex-center" @click.stop="fnDelete(tag, index)">×</text> <text class="del-icon flex flex-center" @click.stop="fnDelete(tag, index)">×</text>
<view class="left"> <view class="left">
@@ -46,36 +46,11 @@
<view class="poup-content"> <view class="poup-content">
<view class="poup-head text-align-center text-weight-b text-size-g ma-24">{{ form.id != undefined ? '编辑标签' : '新增标签' }}</view> <view class="poup-head text-align-center text-weight-b text-size-g ma-24">{{ form.id != undefined ? '编辑标签' : '新增标签' }}</view>
<scroll-view class="poup-body pa-24 pt-0" :scroll-y="true" @touchmove.stop> <scroll-view class="poup-body pa-24 pt-0" :scroll-y="true" @touchmove.stop>
<tm-input <tm-input required :adjust-position="true" :round="3" :borderBottom="false" title="名称" bg-color="grey-lighten-5" v-model="form.name" placeholder="请输入标签名称"></tm-input>
required
:adjust-position="true"
:round="3"
:borderBottom="false"
title="名称"
bg-color="grey-lighten-5"
v-model="form.name"
placeholder="请输入标签名称"
></tm-input>
<view class="pl-32 mb-24 input-tips text-grey text-size-s">填写提示页面上所显示的名称</view> <view class="pl-32 mb-24 input-tips text-grey text-size-s">填写提示页面上所显示的名称</view>
<tm-input <tm-input :borderBottom="false" :adjust-position="true" :round="3" title="别名" bg-color="grey-lighten-5" v-model="form.slug" placeholder="请输入标签别名"></tm-input>
:borderBottom="false"
:adjust-position="true"
:round="3"
title="别名"
bg-color="grey-lighten-5"
v-model="form.slug"
placeholder="请输入标签别名"
></tm-input>
<view class="pl-32 mb-24 input-tips text-grey text-size-s">填写提示一般为单个标签页面的标识最好为英文</view> <view class="pl-32 mb-24 input-tips text-grey text-size-s">填写提示一般为单个标签页面的标识最好为英文</view>
<tm-input <tm-input bg-color="grey-lighten-5" :border-bottom="false" :adjust-position="true" :round="3" title="颜色" placeholder="点击右侧选择标签颜色" v-model="form.color">
bg-color="grey-lighten-5"
:border-bottom="false"
:adjust-position="true"
:round="3"
title="颜色"
placeholder="点击右侧选择标签颜色"
v-model="form.color"
>
<template v-slot:rightBtn> <template v-slot:rightBtn>
<tm-button class="ml-12" theme="bg-gradient-blue-accent" :round="3" :font-size="24" :height="66" block :width="120" @click="fnSelectColor"> <tm-button class="ml-12" theme="bg-gradient-blue-accent" :round="3" :font-size="24" :height="66" block :width="120" @click="fnSelectColor">
选择颜色 选择颜色
@@ -108,206 +83,162 @@
</template> </template>
<script> <script>
import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue'; import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue';
import tmButton from '@/tm-vuetify/components/tm-button/tm-button.vue'; import tmButton from '@/tm-vuetify/components/tm-button/tm-button.vue';
import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue'; import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue';
import tmTabs from '@/tm-vuetify/components/tm-tabs/tm-tabs.vue'; import tmTabs from '@/tm-vuetify/components/tm-tabs/tm-tabs.vue';
import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue'; import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue';
import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue'; import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue';
import tmTags from '@/tm-vuetify/components/tm-tags/tm-tags.vue'; import tmTags from '@/tm-vuetify/components/tm-tags/tm-tags.vue';
import tmPoup from '@/tm-vuetify/components/tm-poup/tm-poup.vue'; import tmPoup from '@/tm-vuetify/components/tm-poup/tm-poup.vue';
import tmInput from '@/tm-vuetify/components/tm-input/tm-input.vue'; import tmInput from '@/tm-vuetify/components/tm-input/tm-input.vue';
import tColorPicker from '@/components/t-color-picker/t-color-picker.vue'; import tColorPicker from '@/components/t-color-picker/t-color-picker.vue';
import AttachmentSelect from '@/components/attachment-select/attachment-select.vue'; import AttachmentSelect from '@/components/attachment-select/attachment-select.vue';
export default { export default {
components: { components: {
tmSkeleton, tmSkeleton,
tmButton, tmButton,
tmEmpty, tmEmpty,
tmTabs, tmTabs,
tmTranslate, tmTranslate,
tmFlotbutton, tmFlotbutton,
tmTags, tmTags,
tmPoup, tmPoup,
tmInput, tmInput,
tColorPicker, tColorPicker,
AttachmentSelect AttachmentSelect
},
data() {
return {
loading: 'loading',
queryParams: {
size: 10,
page: 0,
more: true
},
dataList: [],
poupShow: false,
selectColor: { r: 255, g: 255, b: 255, a: 1 },
attachmentsSelectShow: false,
form: {
color: undefined,
createTime: undefined,
fullPath: undefined,
id: undefined,
name: '',
slug: undefined,
thumbnail: undefined,
showThumbnail: undefined
}
};
},
onLoad() {
this.fnSetPageTitle('标签管理');
},
created() {
this.fnGetData();
},
onPullDownRefresh() {
this.isLoadMore = false;
this.queryParams.page = 0;
this.fnGetData();
},
methods: {
fnGetData() {
uni.showLoading({
mask: true,
title: '加载中...'
});
// 设置状态为加载中
if (!this.isLoadMore) {
this.loading = 'loading';
}
this.loadMoreText = '加载中...';
this.$httpApi.admin
.getTagsList(this.queryParams)
.then(res => {
this.loading = 'success';
this.dataList = res.data.map(item => {
if (item.thumbnail) {
item['showThumbnail'] = this.$utils.checkThumbnailUrl(item.thumbnail);
} else {
item['showThumbnail'] = '';
}
return item;
});
})
.catch(err => {
console.error(err);
this.loading = 'error';
this.loadMoreText = '加载失败,请下拉刷新!';
})
.finally(() => {
setTimeout(() => {
uni.hideLoading();
uni.stopPullDownRefresh();
}, 800);
});
}, },
data() {
fnSelectColor() { return {
this.$refs.colorPicker.open(); loading: 'loading',
}, queryParams: {
size: 10,
fnOnConfirmSelectColor(e) { page: 0,
this.selectColor = e.rgba; more: true
this.$set(this.form, 'color', e.hex); },
}, dataList: [],
fnOnAttachmentsSelectClose() { poupShow: false,
this.attachmentsSelectShow = false; selectColor: { r: 255, g: 255, b: 255, a: 1 },
console.log('this.attachmentsSelectShow', this.attachmentsSelectShow); attachmentsSelectShow: false,
}, form: {
fnOnPoupChange(e) { color: undefined,
if (!e) { createTime: undefined,
this.fnResetForm(); fullPath: undefined,
} id: undefined,
}, name: '',
// 监听附件选择 slug: undefined,
fnOnAttachmentsSelect(file) { thumbnail: undefined,
this.form.thumbnail = file.path; showThumbnail: undefined
this.form.showThumbnail = this.$utils.checkThumbnailUrl(file.path);
this.attachmentsSelectShow = false;
},
fnShowFormModal(tag) {
if (tag) {
this.form = Object.assign({}, {}, tag);
if (tag.thumbnail) {
this.form.showThumbnail = this.$utils.checkThumbnailUrl(tag.thumbnail);
} }
} else {
this.fnResetForm();
}
this.poupShow = true;
},
fnResetForm() {
this.form = {
color: undefined,
createTime: undefined,
fullPath: undefined,
id: undefined,
name: '',
slug: undefined,
thumbnail: undefined,
showThumbnail: undefined
}; };
}, },
fnSubmit() {
if (this.form.name.trim() == '') { onLoad() {
return uni.$tm.toast('标签名称未填写!'); this.fnSetPageTitle('标签管理');
}
if (this.form.id == undefined) {
this.$httpApi.admin
.createTags(this.form)
.then(res => {
if (res.status == 200) {
uni.$tm.toast(`保存成功!`);
uni.startPullDownRefresh();
} else {
uni.$tm.toast('操作失败,请重试!');
}
})
.catch(err => {
uni.$tm.toast('操作失败,请重试!');
});
} else {
this.$httpApi.admin
.updateTagsById(this.form.id, this.form)
.then(res => {
if (res.status == 200) {
uni.$tm.toast(`保存成功!`);
let updateIndex = this.dataList.findIndex(x => x.id == this.form.id);
this.$set(this.dataList, updateIndex, this.form);
} else {
uni.$tm.toast('操作失败,请重试!');
}
})
.catch(err => {
uni.$tm.toast('操作失败,请重试!');
});
}
}, },
// 删除 created() {
fnDelete(tag) { this.fnGetData();
const _tag = tag || this.form; },
uni.$eShowModal({ onPullDownRefresh() {
title: '提示', this.isLoadMore = false;
content: `您是否要将 ${_tag.name} 的标签删除?`, this.queryParams.page = 0;
showCancel: true, this.fnGetData();
cancelText: '否', },
cancelColor: '#999999',
confirmText: '是', methods: {
confirmColor: '#03a9f4' fnGetData() {
}) uni.showLoading({
.then(res => { mask: true,
title: '加载中...'
});
// 设置状态为加载中
if (!this.isLoadMore) {
this.loading = 'loading';
}
this.loadMoreText = '加载中...';
this.$httpApi.admin
.getTagsList(this.queryParams)
.then(res => {
this.loading = 'success';
this.dataList = res.data.map(item => {
if (item.thumbnail) {
item['showThumbnail'] = this.$utils.checkThumbnailUrl(item.thumbnail);
} else {
item['showThumbnail'] = '';
}
return item;
});
})
.catch(err => {
console.error(err);
this.loading = 'error';
this.loadMoreText = '加载失败,请下拉刷新!';
})
.finally(() => {
setTimeout(() => {
uni.hideLoading();
uni.stopPullDownRefresh();
}, 800);
});
},
fnSelectColor() {
this.$refs.colorPicker.open();
},
fnOnConfirmSelectColor(e) {
this.selectColor = e.rgba;
this.$set(this.form, 'color', e.hex);
},
fnOnAttachmentsSelectClose() {
this.attachmentsSelectShow = false;
console.log('this.attachmentsSelectShow', this.attachmentsSelectShow);
},
fnOnPoupChange(e) {
if (!e) {
this.fnResetForm();
}
},
// 监听附件选择
fnOnAttachmentsSelect(file) {
this.form.thumbnail = file.path;
this.form.showThumbnail = this.$utils.checkThumbnailUrl(file.path);
this.attachmentsSelectShow = false;
},
fnShowFormModal(tag) {
if (tag) {
this.form = Object.assign({}, {}, tag);
if (tag.thumbnail) {
this.form.showThumbnail = this.$utils.checkThumbnailUrl(tag.thumbnail);
}
} else {
this.fnResetForm();
}
this.poupShow = true;
},
fnResetForm() {
this.form = {
color: undefined,
createTime: undefined,
fullPath: undefined,
id: undefined,
name: '',
slug: undefined,
thumbnail: undefined,
showThumbnail: undefined
};
},
fnSubmit() {
if (this.form.name.trim() == '') {
return uni.$tm.toast('标签名称未填写!');
}
if (this.form.id == undefined) {
this.$httpApi.admin this.$httpApi.admin
.deleteTagsById(_tag.id) .createTags(this.form)
.then(res => { .then(res => {
if (res.status == 200) { if (res.status == 200) {
uni.$tm.toast(`${_tag.name} 标签已删除`); uni.$tm.toast(`保存成功`);
const delIndex = this.dataList.findIndex(x => x.id == _tag.id); uni.startPullDownRefresh();
this.dataList.splice(delIndex, 1);
} else { } else {
uni.$tm.toast('操作失败,请重试!'); uni.$tm.toast('操作失败,请重试!');
} }
@@ -315,73 +246,126 @@ export default {
.catch(err => { .catch(err => {
uni.$tm.toast('操作失败,请重试!'); uni.$tm.toast('操作失败,请重试!');
}); });
}) } else {
.catch(err => {}); this.$httpApi.admin
.updateTagsById(this.form.id, this.form)
.then(res => {
if (res.status == 200) {
uni.$tm.toast(`保存成功!`);
let updateIndex = this.dataList.findIndex(x => x.id == this.form.id);
this.$set(this.dataList, updateIndex, this.form);
} else {
uni.$tm.toast('操作失败,请重试!');
}
})
.catch(err => {
uni.$tm.toast('操作失败,请重试!');
});
}
},
// 删除
fnDelete(tag) {
const _tag = tag || this.form;
uni.$eShowModal({
title: '提示',
content: `您是否要将 ${_tag.name} 的标签删除?`,
showCancel: true,
cancelText: '否',
cancelColor: '#999999',
confirmText: '是',
confirmColor: '#03a9f4'
})
.then(res => {
this.$httpApi.admin
.deleteTagsById(_tag.id)
.then(res => {
if (res.status == 200) {
uni.$tm.toast(`${_tag.name} 标签已删除!`);
const delIndex = this.dataList.findIndex(x => x.id == _tag.id);
this.dataList.splice(delIndex, 1);
} else {
uni.$tm.toast('操作失败,请重试!');
}
})
.catch(err => {
uni.$tm.toast('操作失败,请重试!');
});
})
.catch(err => {});
}
} }
} };
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.app-page { .app-page {
width: 100vw; width: 100vw;
min-height: 100vh; min-height: 100vh;
}
.loading-wrap {
.loading-error {
height: 65vh;
} }
}
.content-empty {
width: 100%;
height: 60vh;
}
.poup-content { .loading-wrap {
overflow: hidden; .loading-error {
} height: 65vh;
.poup-body {
height: 58vh;
box-sizing: border-box;
}
.thumbnail {
width: 100%;
height: 260rpx;
}
.tags-card {
position: relative;
box-sizing: border-box;
box-shadow: 0rpx 2rpx 24rpx rgba(0, 0, 0, 0.03);
.del-icon {
width: 46rpx;
height: 46rpx;
position: absolute;
right: 24rpx;
top: 24rpx;
border-radius: 50%;
box-sizing: border-box;
border: 4rpx solid #fff;
background-color: #ff8177;
box-shadow: 0rpx 0rpx 24rpx rgba(0, 0, 0, 0.05);
font-size: 32rpx;
color: #fff;
}
.left {
width: 160rpx;
height: 140rpx;
.cover {
width: 100%;
height: inherit;
// background-color: #788ea7;
background-color: #607d8b;
} }
} }
.right {
.content-empty {
width: 100%;
height: 60vh;
}
.poup-content {
overflow: hidden;
}
.poup-body {
height: 58vh;
box-sizing: border-box; box-sizing: border-box;
.color { }
.thumbnail {
width: 100%;
height: 260rpx;
}
.tags-card {
position: relative;
box-sizing: border-box;
box-shadow: 0rpx 2rpx 24rpx rgba(0, 0, 0, 0.03);
.del-icon {
width: 46rpx;
height: 46rpx;
position: absolute;
right: 24rpx;
top: 24rpx;
border-radius: 50%;
box-sizing: border-box;
border: 4rpx solid #fff;
background-color: #ff8177;
box-shadow: 0rpx 0rpx 24rpx rgba(0, 0, 0, 0.05);
font-size: 32rpx;
color: #fff; color: #fff;
} }
.left {
width: 160rpx;
height: 140rpx;
.cover {
width: 100%;
height: inherit;
// background-color: #788ea7;
background-color: #607d8b;
}
}
.right {
box-sizing: border-box;
.color {
color: #fff;
}
}
} }
} </style>
</style>