457 lines
13 KiB
Plaintext
457 lines
13 KiB
Plaintext
<style lang="less" scoped>
|
||
@import url(../../styles/theme.less);
|
||
page {
|
||
background-color: #ffffff;
|
||
}
|
||
|
||
.ui-tabBar-item{
|
||
padding-right: 64rpx;
|
||
}
|
||
|
||
.ui-topicTitle {
|
||
display: flex;
|
||
margin: 16rpx 30rpx;
|
||
justify-content: space-between;
|
||
align-items: center;
|
||
|
||
.ui-hot {
|
||
width: 136rpx;
|
||
height: 48rpx;
|
||
font-size: 34rpx;
|
||
font-weight: 600;
|
||
color: #333333;
|
||
line-height: 48rpx;
|
||
}
|
||
|
||
.ui-more {
|
||
width: fit-content;
|
||
height: 36rpx;
|
||
font-size: 26rpx;
|
||
font-weight: 400;
|
||
color: #f33b6c;
|
||
line-height: 34rpx;
|
||
|
||
.ui-rig {
|
||
width: 10rpx;
|
||
height: 20rpx;
|
||
margin-left: 5rpx;
|
||
}
|
||
}
|
||
}
|
||
|
||
.ui-hotTopic-box{
|
||
margin-bottom: 48rpx;
|
||
|
||
.ui-scroll {
|
||
width: 100%;
|
||
height: 144rpx;
|
||
display: flex;
|
||
white-space: nowrap;
|
||
|
||
.ui-main {
|
||
width: 216rpx;
|
||
height: 144rpx;
|
||
line-height: 144rpx;
|
||
border-radius: 16rpx;
|
||
display: inline-flex;
|
||
margin-right: 12rpx;
|
||
position: relative;
|
||
flex-direction: column;
|
||
justify-content: center;
|
||
|
||
view:nth-of-type(1) {
|
||
width: 100%;
|
||
height: 36rpx;
|
||
text-align: center;
|
||
line-height: 36rpx;
|
||
font-size: 26rpx;
|
||
font-weight: 500;
|
||
color: #FFFFFF;
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
white-space: nowrap;
|
||
padding: 0 30rpx;
|
||
position: relative;
|
||
z-index: 2;
|
||
}
|
||
|
||
view:nth-of-type(2) {
|
||
width: 100%;
|
||
text-align: center;
|
||
height: 32rpx;
|
||
line-height: 32rpx;
|
||
font-size: 22rpx;
|
||
font-weight: 400;
|
||
color: #FFFFFF;
|
||
position: relative;
|
||
z-index: 2;
|
||
}
|
||
}
|
||
|
||
.ui-main:nth-of-type(1) {
|
||
margin-left: 30rpx;
|
||
}
|
||
|
||
.ui-mask {
|
||
width: 216rpx;
|
||
height: 144rpx;
|
||
border-radius: 16rpx;
|
||
position: absolute;
|
||
top: 0;
|
||
left: 0;
|
||
background: linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.6) 100%);
|
||
}
|
||
}
|
||
}
|
||
|
||
.ui-dynamicTabs {
|
||
margin-right: 24rpx;
|
||
width: 116rpx;
|
||
height: 52rpx;
|
||
border-radius: 26rpx;
|
||
}
|
||
|
||
.ui-activeDynamic {
|
||
color: #f33b6c;
|
||
background: #FFF4F7;
|
||
}
|
||
|
||
.ui-inactiveDynamic {
|
||
color: #c2c2c2;
|
||
background: #F8F8F8;
|
||
}
|
||
|
||
.ui-suspend{
|
||
position: fixed;
|
||
height: 124rpx;
|
||
width: 124rpx;
|
||
right: 30rpx;
|
||
bottom: 320rpx;
|
||
text-align: center;
|
||
z-index: 1000;
|
||
}
|
||
|
||
.m_returnTop {
|
||
position: fixed;
|
||
right: 46rpx;
|
||
bottom: 160rpx;
|
||
z-index: 99;
|
||
-webkit-transition: opacity 1s;
|
||
transition: opacity 1s;
|
||
.u_returnTop_img {
|
||
width: 92rpx;
|
||
height: 92rpx;
|
||
border-radius: 50%;
|
||
box-shadow: 0 0 12rpx 6rpx rgba(0, 0, 0, .06);
|
||
}
|
||
}
|
||
@keyframes opacity{
|
||
0%{opacity: 0}
|
||
100%{
|
||
opacity: 1;
|
||
}
|
||
}
|
||
.hide{
|
||
opacity:0;
|
||
}
|
||
.show{
|
||
opacity:1;
|
||
}
|
||
</style>
|
||
<template>
|
||
<view class="ui-dynamic ui-relative">
|
||
<view class="cu-custom">
|
||
<view class="cu-bar fixed" :style="{height: CustomBar + 'px', paddingTop: StatusBar + 'px',zIndex: 999}">
|
||
<view class="f-fcl ui-ml-30">
|
||
<view class="ui-tabBar-item {{tabBarIndex == index ? 'font_34 color-theme bold' : 'font_30 color333'}}" v-for="(item,index) in tabBarList" :key="index" @tap="tabChange(index)">{{item}}</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
<view :style="{height: navHeight + 'px'}"></view>
|
||
<view :style="{height: windowHeight + 'px',backround: '#ffffff'}">
|
||
<swiper :style="{height: tabBarIndex == 0 ? '100%' : '92%'}" current="{{tabBarIndex}}" duration="300" bindchange="switchTab">
|
||
<swiper-item wx:key="id" style="-webkit-overflow-scrolling:touch">
|
||
<scroll-view :scroll-top="scrollTopHandle" scroll-with-animation="true" scroll-anchoring="{{true}}" refresher-enabled="{{true}}" refresher-triggered="{{triggered}}" bindrefresherpulling="onPulling" bindrefresherrefresh="onRefresh" style="height:100%;-webkit-overflow-scrolling: touch" lower-threshold="300" bindscrolltolower="handleScroll" bindscroll="scrollToUpper" scroll-y>
|
||
<view class="ui-topicTitle">
|
||
<view class="ui-hot">热门话题</view>
|
||
<view class="ui-more" @tap.stop="jumpPath('/pages/dynamic/searchPopular')">更多话题
|
||
<image class="ui-rig" src="https://images.ufutx.com/202101/27/aac7d6a4cdd90938d7bcfb378705058c.png" mode="widthFix"></image>
|
||
</view>
|
||
</view>
|
||
<view class="ui-hotTopic-box">
|
||
<scroll-view scroll-x="true" class="ui-scroll">
|
||
<block v-for="(item,index) in hotTopics" :key="index">
|
||
<view class="cu-avatar ui-main" style="background-image:url({{ item.back_image }});" @tap.stop="jumpPath(`/pages/dynamic/hotTopic?id=${item.id}`)">
|
||
<view>#{{ item.name }}</view>
|
||
<view>{{ item.moment_count }} 动态</view>
|
||
<view class="ui-mask"></view>
|
||
</view>
|
||
</block>
|
||
</scroll-view>
|
||
</view>
|
||
<view class="f-fcl ui-ml-30">
|
||
<view class="font_28 ui-dynamicTabs f-fcc {{dynamicTabsIndex == index ? 'ui-activeDynamic' : 'ui-inactiveDynamic'}}" v-for="(item,index) in dynamicTabs" :key="index" @tap.stop="dynamicTabChange(index)">
|
||
{{ item }}
|
||
</view>
|
||
</view>
|
||
<dynamicList :dynamicList="dynamicList" @changeSelect="changeSelect" @signInVerify="signInVerify" @changListLiker="changListLiker" :from="'dynamic'"></dynamicList>
|
||
</scroll-view>
|
||
</swiper-item>
|
||
</swiper>
|
||
</view>
|
||
</view>
|
||
<image lazy-load="true" class="ui-suspend" src="https://image.fulllinkai.com/202207/01/df8e2ac2ab24eeec52e9914bbab7cdb7.png" mode="widthFix" @tap="jumpPath('/pages/dynamic/issue?from=dynamic')"></image>
|
||
<view class="m_returnTop {{ showBackTopBtn ? 'show' : 'hide'}}">
|
||
<image class="u_returnTop_img" @tap.stop="BackTop" src="https://images.ufutx.com/202106/23/f0d10551dc5d3399cc7f15805cf04f4f.png" mode="scaleToFill" lazy-load="false"></image>
|
||
</view>
|
||
<!--动态操作功能,selectData选择的动态数据、selectIndex选中的动态下标、admin是否管理员、from来自哪个父组件-->
|
||
<dynamicOperation :selectData="selectData" :chooseShow.sync="chooseShow" :selectIndex="selectIndex" :admin="admin" :from="'dynamic'" @hideModal="hideModal" @changeOperation="changeOperation" @signInVerify="signInVerify"></dynamicOperation>
|
||
<loginDialog :loginShow="loginShow" @hiddenLogin="hiddenLogin"></loginDialog>
|
||
</template>
|
||
|
||
<script>
|
||
import wepy from '@wepy/core'
|
||
import https from '../../mixins/https'
|
||
import base from '../../mixins/base'
|
||
import {service} from '../../config'
|
||
import {commentTimeHandle} from '../../mixins/plugins'
|
||
|
||
wepy.page({
|
||
config: {},
|
||
mixins: [https, base],
|
||
|
||
data: {
|
||
loginShow: false,
|
||
chooseShow: false,
|
||
no_more: false,
|
||
loading: false,
|
||
page: 1,
|
||
list: [], // 列表数据
|
||
hotTopics: [], // 热门话题
|
||
|
||
tabBarList: ['动态'],
|
||
tabBarIndex: 0,
|
||
|
||
admin: false,
|
||
dynamicTabs: ['推荐', '最新'],
|
||
dynamicTabsIndex: 0,
|
||
dynamicList: [],
|
||
selectData: {},
|
||
selectIndex: null,
|
||
scrollTopHandle: 0,
|
||
videoIndex: -1,
|
||
showBackTopBtn: false,
|
||
triggered: false,
|
||
|
||
navHeight: 0,
|
||
StatusBar: 0,
|
||
CustomBar: 0,
|
||
Custom: 0,
|
||
windowHeight: 0
|
||
},
|
||
methods: {
|
||
// 获取动态列表数据
|
||
getList() {
|
||
let vm = this
|
||
let data = {
|
||
page: vm.page
|
||
}
|
||
vm.$showLoading('加载中')
|
||
vm.$get({url: `${service.host}/moment/list?is_hot=${vm.dynamicTabsIndex == 0 ? 1 : 0}`, data}).then(({code, data}) => {
|
||
if (code === 0) {
|
||
if (data.data && data.data.length > 0) {
|
||
data.data.forEach((item, index) => {
|
||
item.create_time = commentTimeHandle(item.create_time)
|
||
item.likeGif = 'https://images.ufutx.com/202106/07/b227f3ecf9cbd080fb814450b667b5ce.gif'
|
||
let sty = typeof (item.photos)
|
||
if (sty == 'string') {
|
||
item.photos = JSON.parse(item.photos)
|
||
}
|
||
if ((item.is_audited == 0 || item.is_audited == -1) && item.is_self == 0) {
|
||
data.data.splice(index--, 1)
|
||
}
|
||
})
|
||
}
|
||
if (vm.dynamicList.length === 0 || vm.page === 1) {
|
||
vm.dynamicList = data.data
|
||
} else {
|
||
data.data.map(function (item) {
|
||
vm.dynamicList.push(item)
|
||
})
|
||
}
|
||
if (vm.dynamicList.length < 15 || data.data.length < 15) {
|
||
vm.no_more = true
|
||
}
|
||
setTimeout(() => {
|
||
vm.loading = true
|
||
vm.triggered = false
|
||
}, 500)
|
||
}
|
||
wx.hideLoading()
|
||
}).catch(err => {
|
||
wx.hideLoading()
|
||
console.log(err)
|
||
})
|
||
},
|
||
// 获取热门话题
|
||
getHotTopics() {
|
||
let vm = this
|
||
vm.$get({url: `${service.host}/moment/topic/list`}).then(({code, data}) => {
|
||
if (code === 0) {
|
||
vm.hotTopics = data.data
|
||
}
|
||
wx.hideLoading()
|
||
}).catch(err => {
|
||
wx.hideLoading()
|
||
console.log(err)
|
||
})
|
||
},
|
||
// 列表和详情点赞回调
|
||
changListLiker (index) {
|
||
let vm = this
|
||
let nowTime = new Date()
|
||
vm.dynamicList[index].is_like = !vm.dynamicList[index].is_like
|
||
vm.dynamicList[index].liker_count = vm.dynamicList[index].liker_count + (vm.dynamicList[index].is_like ? 1 : -1)
|
||
vm.dynamicList[index].likeGif = `${vm.dynamicList[index].likeGif}?${nowTime}`
|
||
},
|
||
// 选择某条动态操作弹框
|
||
changeSelect(e, index) {
|
||
let vm = this
|
||
vm.selectData = e
|
||
vm.selectIndex = index
|
||
vm.chooseShow = true
|
||
},
|
||
// 取消动态操作弹框
|
||
hideModal() {
|
||
let vm = this
|
||
vm.chooseShow = false
|
||
vm.selectData = {}
|
||
vm.selectIndex = null
|
||
},
|
||
// 操作后对原动态列表数据改动
|
||
changeOperation(state) {
|
||
let vm = this
|
||
if (state == 'isTop') {
|
||
// 设置动态为置顶
|
||
vm.dynamicList[vm.selectIndex].is_top = 1
|
||
vm.dynamicList.unshift(vm.dynamicList[vm.selectIndex])
|
||
vm.dynamicList.splice(vm.selectIndex + 1, 1)
|
||
} else {
|
||
// 删除动态 || 隐藏动态 || 设置动态为推荐动态 || 不感兴趣 || 取消置顶
|
||
vm.dynamicList.splice(vm.selectIndex, 1)
|
||
}
|
||
},
|
||
// 顶部动态、活动、服务切换tab
|
||
tabChange(index) {
|
||
let vm = this
|
||
vm.tabBarIndex = index
|
||
},
|
||
// swiper手势滑动切换tab
|
||
switchTab(e) {
|
||
let vm = this
|
||
if (e.$wx.detail.source === 'touch') {
|
||
vm.currentTab = e.$wx.detail.current
|
||
}
|
||
},
|
||
// 动态推荐、最新切换
|
||
dynamicTabChange(index) {
|
||
let vm = this
|
||
vm.dynamicTabsIndex = index
|
||
vm.page = 1
|
||
vm.getList(1)
|
||
},
|
||
// 下拉加载中
|
||
onPulling() {
|
||
let vm = this
|
||
vm.triggered = true
|
||
},
|
||
// 初始化数据
|
||
onRefresh() {
|
||
let vm = this
|
||
vm.page = 1
|
||
vm.getList()
|
||
vm.getHotTopics()
|
||
},
|
||
// 动态列表上拉加载更多数据
|
||
handleScroll() {
|
||
let vm = this
|
||
vm.page += 1
|
||
vm.getList()
|
||
},
|
||
// 动态滚动距离超出380,展示回到顶部按钮
|
||
scrollToUpper(e) {
|
||
let vm = this
|
||
vm.scrollTopHandle = 0
|
||
let top = e.$wx.detail.scrollTop
|
||
vm.showBackTopBtn = top > 380
|
||
},
|
||
// 动态回到顶部
|
||
BackTop() {
|
||
let vm = this
|
||
vm.scrollTopHandle = -1
|
||
vm.showBackTopBtn = false
|
||
},
|
||
jumpPath(url) {
|
||
let vm = this
|
||
// 校验是否完成注册资料
|
||
if (!vm.$signInVerify()) {
|
||
vm.loginShow = true
|
||
return
|
||
}
|
||
wx.navigateTo({url: url})
|
||
},
|
||
signInVerify() {
|
||
let vm = this
|
||
vm.loginShow = true
|
||
},
|
||
hiddenLogin() {
|
||
let vm = this
|
||
vm.loginShow = false
|
||
}
|
||
},
|
||
// 上拉获取更多数据
|
||
onReachBottom() {
|
||
let vm = this
|
||
if (!vm.no_more) {
|
||
vm.getList()
|
||
}
|
||
},
|
||
// 下拉刷新
|
||
onPullDownRefresh() {
|
||
let vm = this
|
||
vm.page = 1
|
||
vm.no_more = false
|
||
vm.getList()
|
||
},
|
||
onShow() {
|
||
let vm = this
|
||
let app = vm.$app.$options
|
||
vm.navHeight = app.globalData.navBarHeight
|
||
vm.StatusBar = app.globalData.StatusBar
|
||
vm.CustomBar = app.globalData.CustomBar
|
||
vm.Custom = app.globalData.Custom
|
||
vm.windowHeight = app.globalData.windowHeight
|
||
},
|
||
onLoad() {
|
||
let vm = this
|
||
vm.getList()
|
||
vm.getHotTopics()
|
||
vm.admin = wx.getStorageSync('userInfo').is_moment_admin
|
||
}
|
||
})
|
||
</script>
|
||
<config>
|
||
{
|
||
navigationBarTitleText: '',
|
||
navigationStyle: 'custom',
|
||
enablePullDownRefresh: false,
|
||
backgroundColorTop: '#ffffff',
|
||
backgroundColorBottom: '#ffffff',
|
||
usingComponents: {
|
||
dynamicOperation: '~@/components/dynamicOperation',
|
||
loginDialog: '~@/components/loginDialog',
|
||
dynamicList: '~@/components/dynamicList'
|
||
}
|
||
}
|
||
</config>
|