新增:文章详情评论弹幕设置功能

This commit is contained in:
小莫唐尼 2022-12-13 10:51:21 +08:00
parent 9573b303e2
commit 5000da9a64
7 changed files with 98 additions and 33 deletions

View File

@ -12,7 +12,7 @@
</view> </view>
<view class="right"> <view class="right">
<view class="title"> <view class="title">
<text class="is-top" v-if="article.topped">置顶</text> <text class="is-top bg-gradient-blue-accent" v-if="article.topped">置顶</text>
<text class="title-text text-overflow">{{ article.title }}</text> <text class="title-text text-overflow">{{ article.title }}</text>
</view> </view>
<view class="content text-overflow-2">{{ article.summary }}</view> <view class="content text-overflow-2">{{ article.summary }}</view>
@ -33,8 +33,10 @@
</template> </template>
<script> <script>
import tmTags from '@/tm-vuetify/components/tm-tags/tm-tags.vue';
export default { export default {
name: 'article-card', name: 'article-card',
components: { tmTags },
props: { props: {
from: { from: {
type: String, type: String,
@ -253,6 +255,7 @@ export default {
box-sizing: border-box; box-sizing: border-box;
.title { .title {
display: flex; display: flex;
align-items: center;
font-size: 30rpx; font-size: 30rpx;
color: var(--main-text-color); color: var(--main-text-color);
.is-top { .is-top {
@ -264,8 +267,9 @@ export default {
white-space: nowrap; white-space: nowrap;
vertical-align: 4rpx; vertical-align: 4rpx;
color: #fff; color: #fff;
background-image: -webkit-linear-gradient(0deg, #3ca5f6 0, #a86af9 100%); // background-image: -webkit-linear-gradient(0deg, #3ca5f6 0, #a86af9 100%);
border-radius: 4rpx 12rpx; border-radius: 6rpx 12rpx;
box-shadow: none !important;
} }
&-text { &-text {
color: #303133; color: #303133;

View File

@ -53,6 +53,7 @@ export default {
listData: [] listData: []
}; };
}, },
mounted() { mounted() {
//leftBottom 使 //leftBottom 使
if (this.type === 'leftBottom') { if (this.type === 'leftBottom') {
@ -61,7 +62,6 @@ export default {
}, },
methods: { methods: {
add(obj) { add(obj) {
console.log('加载弹幕中...');
this.isShow = true; this.isShow = true;
this.showFlag = true; this.showFlag = true;
let data = { let data = {
@ -71,7 +71,6 @@ export default {
type: this.type type: this.type
}; };
if (this.type === 'leftBottom') { if (this.type === 'leftBottom') {
console.log('leftBottom加载弹幕中...');
let objData = { let objData = {
item: data, item: data,
type: 'leftBottomEnter', type: 'leftBottomEnter',
@ -110,7 +109,7 @@ export default {
} }
} else if (this.type === 'rightToLeft') { } else if (this.type === 'rightToLeft') {
let objData = { let objData = {
item: data.item, item: data,
type: 'rightToLeft', type: 'rightToLeft',
style: { style: {
animationDuration: `${data.time}s`, animationDuration: `${data.time}s`,
@ -130,6 +129,16 @@ export default {
} }
}, },
async remove(options = {}) { async remove(options = {}) {
if (this.type == 'rightToLeft') {
if (this.listData.length != 0) {
const last = this.listData[this.listData.length - 1];
setTimeout(() => {
this.listData = [];
}, last.item.time * 1200 + 1000);
}
return;
}
options = Object.assign( options = Object.assign(
{}, {},
{ {
@ -142,8 +151,8 @@ export default {
const _fnHandleRemove = item => { const _fnHandleRemove = item => {
return new Promise(resolve => { return new Promise(resolve => {
setTimeout(() => { setTimeout(() => {
item['type'] = 'leftBottomExitLeft'; // item['type'] = 'leftBottomExitLeft';
// this.$forceUpdate(); item['type'] = 'is-hide';
resolve(); resolve();
}, options.speed); }, options.speed);
}); });
@ -162,7 +171,7 @@ export default {
await _fnHandleLoop(); await _fnHandleLoop();
setTimeout(() => { setTimeout(() => {
this.listData = []; this.listData = [];
}, 100); }, options.duration + 200);
}, },
repaint(index, type) { repaint(index, type) {
setTimeout(() => { setTimeout(() => {
@ -203,9 +212,12 @@ export default {
transform: translateX(0%); transform: translateX(0%);
opacity: 1; opacity: 1;
} }
50% {
transform: translateX(-50%);
opacity: 1;
}
100% { 100% {
transform: translateX(-200%); transform: translateX(-100%);
opacity: 0; opacity: 0;
} }
} }
@ -238,7 +250,12 @@ export default {
transition: all 1s ease-in-out; transition: all 1s ease-in-out;
&.leftBottom { &.leftBottom {
top: initial; top: initial;
/* #ifdef H5 */
bottom: 130rpx; bottom: 130rpx;
/* #endif */
/* #ifndef H5 */
bottom: 36rpx;
/* #endif */
} }
} }
.danmu-li { .danmu-li {
@ -246,10 +263,11 @@ export default {
width: 100%; width: 100%;
transform: translateX(100%); transform: translateX(100%);
animation-timing-function: linear; animation-timing-function: linear;
transition: transform 0.5s ease-in-out; transition: all 0.5s ease-in-out;
opacity: 1;
&.is-hide { &.is-hide {
transform: translateX(-100%) !important; opacity: 0;
// transform: translateX(-100%) !important;
} }
&.leftBottom { &.leftBottom {
left: 24rpx; left: 24rpx;

View File

@ -34,14 +34,13 @@
:shadow="0" :shadow="0"
label="Ծ‸Ծ博主已设置该文章禁止评论!" label="Ծ‸Ծ博主已设置该文章禁止评论!"
:round="3" :round="3"
close
></tm-alerts> ></tm-alerts>
<view class="empty pt-50" v-if="dataList.length == 0"> <view class="empty pt-50" v-if="dataList.length == 0">
<tm-empty v-if="disallowComment" icon="icon-shiliangzhinengduixiang-" label="暂无评论"> <tm-empty v-if="disallowComment" icon="icon-shiliangzhinengduixiang-" label="暂无评论">
<text class="text-red text-size-s">- 文章已开启禁止评论 -</text> <text class="text-red text-size-s">- 文章已开启禁止评论 -</text>
</tm-empty> </tm-empty>
<tm-empty v-else icon="icon-shiliangzhinengduixiang-" label="暂无评论"> <tm-empty v-else icon="icon-shiliangzhinengduixiang-" label="暂无评论">
<tm-button theme="bg-gradient-light-blue-accent" size="m" @click="fnToComment(null)">抢沙发</tm-button> <tm-button theme="light-blue" :dense="true" :shadow="0" size="m" @click="fnToComment(null)">抢沙发</tm-button>
</tm-empty> </tm-empty>
</view> </view>
<block v-else> <block v-else>

View File

@ -116,7 +116,7 @@
</view> </view>
<!-- 弹幕效果 --> <!-- 弹幕效果 -->
<barrage ref="barrage" :maxTop="240" type="leftBottom"></barrage> <barrage ref="barrage" :maxTop="240" :type="globalAppSettings.barrage.type"></barrage>
<!-- 返回顶部 --> <!-- 返回顶部 -->
<tm-flotbutton :offset="[16, 80]" icon="icon-angle-up" color="bg-gradient-light-blue-accent" @click="fnToTopPage()"></tm-flotbutton> <tm-flotbutton :offset="[16, 80]" icon="icon-angle-up" color="bg-gradient-light-blue-accent" @click="fnToTopPage()"></tm-flotbutton>
<tm-flotbutton :actions="btnOption.actions" actions-pos="left" :show-text="true" color="bg-gradient-orange-accent" @change="fnOnFlotButtonChange"></tm-flotbutton> <tm-flotbutton :actions="btnOption.actions" actions-pos="left" :show-text="true" color="bg-gradient-orange-accent" @change="fnOnFlotButtonChange"></tm-flotbutton>
@ -660,13 +660,15 @@ export default {
await _handleData(data); await _handleData(data);
if (this.globalAppSettings.barrage.use) { if (this.globalAppSettings.barrage.use) {
this.$nextTick(() => { this.$nextTick(() => {
if (_list.length != 0) {
_handleAddBarrage(); _handleAddBarrage();
}
}); });
} }
const _handleRemove = () => { const _handleRemove = () => {
this.$refs['barrage'].remove({ this.$refs['barrage'].remove({
duration: 5000, // duration: 5000, //
speed: 1000 // speed: 600 //
}); });
}; };
let index = 0; let index = 0;

View File

@ -3,7 +3,7 @@
<view class="page-title">我们的故事</view> <view class="page-title">我们的故事</view>
<view class="html-typed" v-html="html">内容渲染</view> <view class="html-typed" v-html="html">内容渲染</view>
<scroll-btn bottom="60rpx" :scrollTop.sync="scrollTop"></scroll-btn> <scroll-btn bottom="160rpx" :scrollTop.sync="scrollTop"></scroll-btn>
</view> </view>
</template> </template>
@ -76,6 +76,7 @@ export default {
rgba(7, 179, 155, 0.1) 86%, rgba(7, 179, 155, 0.1) 86%,
rgba(109, 186, 130, 0.1) rgba(109, 186, 130, 0.1)
); );
color: rgba(26, 26, 26, 1);
} }
.page-title { .page-title {
font-size: 42rpx; font-size: 42rpx;

View File

@ -25,9 +25,10 @@
<tm-input <tm-input
name="status" name="status"
required required
title="首页布局" title="首页文章布局"
placeholder="请选择首页布局" placeholder="请选择首页文章布局"
disabled disabled
align="right"
:value="homeLayout.selectLabel" :value="homeLayout.selectLabel"
right-icon="icon-angle-right" right-icon="icon-angle-right"
></tm-input> ></tm-input>
@ -43,9 +44,10 @@
<tm-input <tm-input
name="status" name="status"
required required
title="卡片样式" title="文章卡片样式"
placeholder="请选择文章卡片样式" placeholder="请选择文章卡片样式"
disabled disabled
align="right"
:value="articleCardStyle.selectLabel" :value="articleCardStyle.selectLabel"
right-icon="icon-angle-right" right-icon="icon-angle-right"
></tm-input> ></tm-input>
@ -78,10 +80,29 @@
<text class="text-size-m ">友链简洁模式</text> <text class="text-size-m ">友链简洁模式</text>
<tm-switch v-model="appSettings.links.useSimple" color="light-blue" :text="['是', '否']"></tm-switch> <tm-switch v-model="appSettings.links.useSimple" color="light-blue" :text="['是', '否']"></tm-switch>
</view> </view>
<view class="mx-32 my-24 border-b-1 pb-24 flex-between"> <view class="mx-32 mt-24 mb-0 border-b-1 pb-24 flex-between">
<text class="text-size-m">启用评论弹幕</text> <text class="text-size-m">启用评论弹幕</text>
<tm-switch v-model="appSettings.barrage.use" color="light-blue" :text="['是', '否']"></tm-switch> <tm-switch v-model="appSettings.barrage.use" color="light-blue" :text="['是', '否']"></tm-switch>
</view> </view>
<tm-pickers
v-if="appSettings.barrage.use"
title="评论弹幕位置"
btn-color="light-blue"
:default-value.sync="barrage.selectDefault"
rang-key="name"
:list="barrage.list"
@confirm="fnOnBarrageConfirm"
>
<tm-input
name="status"
title="评论弹幕位置"
placeholder="请选择评论弹幕位置"
disabled
align="right"
:value="barrage.selectLabel"
right-icon="icon-angle-right"
></tm-input>
</tm-pickers>
<view class="mx-32 my-24 border-b-1 pb-24 flex-between"> <view class="mx-32 my-24 border-b-1 pb-24 flex-between">
<text class="text-size-m">是否圆形头像</text> <text class="text-size-m">是否圆形头像</text>
<tm-switch v-model="appSettings.isAvatarRadius" color="light-blue" :text="['是', '否']"></tm-switch> <tm-switch v-model="appSettings.isAvatarRadius" color="light-blue" :text="['是', '否']"></tm-switch>
@ -177,7 +198,13 @@ export default {
selectLabel: '左图右文', selectLabel: '左图右文',
selectValue: 'lr_image_text' selectValue: 'lr_image_text'
}, },
dotPositionList: [{ name: '右边', value: 'right', checked: true }, { name: '下边', value: 'bottom', checked: false }] dotPositionList: [{ name: '右边', value: 'right', checked: true }, { name: '下边', value: 'bottom', checked: false }],
barrage: {
list: [{ name: '顶部', value: 'rightToLeft' }, { name: '左下', value: 'leftBottom' }],
selectDefault: ['顶部'],
selectLabel: '顶部',
selectValue: 'rightToLeft'
}
}; };
}, },
@ -223,6 +250,11 @@ export default {
this.articleCardStyle.selectDefault = [_articleCardStyle.name]; this.articleCardStyle.selectDefault = [_articleCardStyle.name];
this.articleCardStyle.selectLabel = _articleCardStyle.name; this.articleCardStyle.selectLabel = _articleCardStyle.name;
this.articleCardStyle.selectValue = _articleCardStyle.value; this.articleCardStyle.selectValue = _articleCardStyle.value;
const _barrage = this.fnFindObjInList(this.barrage.list, 'value', this.appSettings.barrage.type);
this.barrage.selectDefault = [_barrage.name];
this.barrage.selectLabel = _barrage.name;
this.barrage.selectValue = _barrage.value;
}, },
// //
fnFindObjInList(list, key, value) { fnFindObjInList(list, key, value) {
@ -253,10 +285,17 @@ export default {
this.articleCardStyle.selectValue = _select.value; this.articleCardStyle.selectValue = _select.value;
this.appSettings.layout.cardType = _select.value; this.appSettings.layout.cardType = _select.value;
}, },
//
fnOnBarrageConfirm(e) {
const _select = e[0].data;
this.barrage.selectDefault = [_select.name];
this.barrage.selectLabel = _select.name;
this.barrage.selectValue = _select.value;
this.appSettings.barrage.type = _select.value;
},
// //
fnOnSave() { fnOnSave() {
this.isSaved = true; this.isSaved = true;
console.log('this.appSettings', this.appSettings);
this.$tm.vx.commit('setting/setSettings', this.appSettings); this.$tm.vx.commit('setting/setSettings', this.appSettings);
uni.$tm.toast('保存成功,部分设置在重启后生效!'); uni.$tm.toast('保存成功,部分设置在重启后生效!');
}, },

View File

@ -38,7 +38,7 @@ export const _DefaultAppSettings = {
// 评论弹幕(文章详情) // 评论弹幕(文章详情)
barrage: { barrage: {
use: true, // 是否启用 use: true, // 是否启用
type: 'leftBottom' // 弹幕类型 type: 'leftBottom' // 弹幕位置rightToLeft leftBottom
}, },
gallery: { gallery: {
// 是否使用瀑布流 // 是否使用瀑布流
@ -61,17 +61,19 @@ export const _DefaultAppSettings = {
contact: { contact: {
// 链接是否使用复制的方式,否则直接在内部打开(小程序需要配置对应链接的业务域名) // 链接是否使用复制的方式,否则直接在内部打开(小程序需要配置对应链接的业务域名)
isLinkCopy: true, isLinkCopy: true,
} },
}
}
// 应用设置存储key值
export const _AppSettingsKey = 'APP_GLOBAL_SETTINGS';
/** /**
* 获取应用设置 * 获取应用设置
*/ */
export const getAppSettings = () => { export const getAppSettings = () => {
let _appSettings = uni.getStorageSync('APP_GLOBAL_SETTINGS') let _appSettings = uni.getStorageSync(_AppSettingsKey)
if (_appSettings) return JSON.parse(_appSettings) if (_appSettings) return JSON.parse(_appSettings)
uni.setStorageSync('APP_GLOBAL_SETTINGS', JSON.stringify(_DefaultAppSettings)) uni.setStorageSync(_AppSettingsKey, JSON.stringify(_DefaultAppSettings))
return _appSettings; return _appSettings;
} }
@ -79,5 +81,5 @@ export const getAppSettings = () => {
* 保存应用设置 * 保存应用设置
*/ */
export const setAppSettings = (appSettings) => { export const setAppSettings = (appSettings) => {
uni.setStorageSync('APP_GLOBAL_SETTINGS', JSON.stringify(appSettings)) uni.setStorageSync(_AppSettingsKey, JSON.stringify(appSettings))
} }