123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251 |
- <template>
- <view class="car">
- <view class="cartop">
- <view class="tabtop flexc">
- <view class="tabt" :class="tabval==ite.dictValue?'act':''" v-for="(ite,idx) in wzlxList" :key="idx" @click="getTabFn(ite.dictValue)">{{ite.dictLabel}}</view>
- <view class="numbox" @click="getCount">
- 阅读统计
- </view>
- </view>
- </view>
- <!-- 列表 -->
- <view class="carlists">
- <car-list :datainfo="list" :wtdt="wtdt" :type='type' @getDetail="getDetail" @getReadlist="getReadlist" @getPause="getPause" @getDelFn="getDelFn" @getPut="getPut"></car-list>
- </view>
- <block v-if="checkPermi(['wuYe:manual:add'])">
- <view style="height: 100rpx;"></view>
- <view class="rfbtn" @click="getAddFn" v-if="type=='ystv'">发布图文</view>
- <view class="rfbtn" @click="getAddvideoFn" v-else>发布视频</view>
- </block>
-
- <loading></loading>
- </view>
- </template>
- <script>
- import config from '@/config'
- const baseUrl = config.baseUrl
- import carList from "@/manage/components/car/list.vue"
- import { checkPermi, checkRole } from "@/utils/permission"; // 权限判断函数
- import {getDictionaryFn} from "@/api/system/user.js"
- import {manualList,manualDel,manualPut,staffTrainTime} from "@/api/work/manage.js"
- export default{
- components:{carList},
- data(){
- return{
- cxrq:"",
- text:'',
- list:[],
- pageSize: 10,
- pageNum: 1,
- reachflag: true,
- wtdt:'',
- tabval:'ystv',
- type:'',
- wzlxList:[],
- stayDuration: 0,
- pageLoadTime:0,
- }
- },
- onUnload() {
- uni.$off('newsygList')
- // 计算停留时长
- this.calculateStayDuration();
- },
- onLoad: function() {
- uni.$on('newsygList',(res)=>{
- this.getrefreshData()
- })
- this.init()
- // 记录页面加载时间
- this.pageLoadTime = Date.now();
- },
- onHide() {
- // 页面隐藏时计算停留时长
- this.calculateStayDuration();
- },
- onShow() {
- // 页面重新显示时重新记录加载时间
- this.pageLoadTime = Date.now();
- },
- mounted:function(){
-
- },
- // 上拉触底加载更多触发事件
- onReachBottom() {
- if (this.reachflag) {
- this.pageNum++
- this.getDataFn()
- }
- },
- methods:{
- checkPermi, checkRole,
- // 计算停留时长
- calculateStayDuration() {
- const currentTime = Date.now();
- var time=Math.floor((currentTime - this.pageLoadTime) / 1000); // 转换为秒
- var staffTime=Math.ceil(time/60);//向上取整,转换成分钟
- var params={
- staffTime:staffTime,
- }
- staffTrainTime(params).then(res=>{
- })
- },
- init(){
- // 发布类型
- getDictionaryFn('publication_type').then(res=>{
- if(res.code==200){
- if(res.data){
- this.tabval=res.data[0].dictValue;
- if(this.tabval==1){
- this.type='ystv'
- }else{
- this.type='ygsp'
- }
- this.wzlxList = res.data.map(v => {
- return {
- dictLabel: v.dictLabel,
- dictValue: v.dictValue
- }
- })
- this.getDataFn()
- }
- }
- })
- },
- getDetail(data){
- if(this.tabval=='ystv'){
- this.$tab.navigateTo("/manage/pages/community/newsygdetail?id="+data)
- }else{
- this.$tab.navigateTo("/manage/pages/community/newsaddvideo?id="+data)
- }
- },
- getPut(id){
- if(checkPermi((['wuye:partyNews:edit']))){
- this.$tab.navigateTo("/manage/pages/community/newsadd?id="+id)
- }else{
- this.$tab.navigateTo("/manage/pages/community/newsygdetail?id="+id)
- }
- },
- getAddFn(){
- this.$tab.navigateTo("/manage/pages/community/newsadd")
- },
- getAddvideoFn(){
- this.$tab.navigateTo("/manage/pages/community/newsaddvideo")
- },
- getReadlist(){
- this.$tab.navigateTo("/manage/pages/community/readlist")
- },
- getCount(){
- this.$tab.navigateTo("/manage/pages/community/readcount")
- },
- getrefreshData(){
- this.pageNum=1;
- this.list=[];
- this.reachflag=true;
- this.getDataFn()
- },
- getTabFn(val){
- this.tabval=val;
- if(this.tabval==1){
- this.type='ystv'
- }else{
- this.type='ygsp'
- }
- this.getrefreshData()
- },
- bindDateChangea(e){
- var val=e.detail.value;
- this.cxrq=val;
- },
- getPause(obj){
- var data=JSON.parse(JSON.stringify(obj))
- var params={
- manualId:data.id,
- progress:data.progress,
- }
- manualPut(params).then(res=>{
- if(res.code==200){
-
- }
- })
- },
- getDelFn(data){
- var that=this;
- manualDel(data).then(res=>{
- if(res.code==200){
- this.$toast("删除成功");
- setTimeout(function(){
- that.getrefreshData()
- },1500)
- }
- })
- },
- getDataFn(){
- var params={
- pageSize:this.pageSize,
- pageNum: this.pageNum,
- manualType:this.tabval
- }
- manualList(params).then(res=>{
- if(res.code==200){
- if (res.rows.length < this.pageSize) {
- this.reachflag = false
- this.wtdt = '到底了~';
- } else {
- var num = parseInt(res.rows.length) + parseInt(this.pageSize) * parseInt(this.pageNum - 1)
- if (num < res.total) {
- this.reachflag = true
- this.wtdt = ''
- } else {
- this.reachflag = false
- this.wtdt = '到底了~';
- }
- }
- var newArr=JSON.parse(JSON.stringify(res.rows))
- newArr.forEach(ite=>{
- ite.right=0;
- ite.currentTime=0;
- ite.duration=0;
- ite.initialtime=0;//当前播放位置
- ite.putflag=false;//是否修改
- })
- // console.log(newArr,555)
- if (this.pageNum == 1) {
- this.list = newArr;
- } else {
- this.list = this.list.concat(newArr)
- }
- }else{
- this.$toast(res.msg)
- }
- })
-
- },
- }
- }
- </script>
- <style>
- page{background: #F3F3F0;}
- </style>
- <style lang="scss" scoped>
- .car{padding: 148rpx 0 10rpx;}
- .cartop{position: fixed;left: 0;right: 0;top: 0;background-color: #ffffff;z-index: 2;
- .tabtop{padding:28rpx 200rpx 40rpx 0;position: relative;
- .tabt{font-weight: 500;font-size: 32rpx;color: #666666;position: relative;line-height: 56rpx;padding: 0 40rpx;
- &.act{font-weight: bold;font-size: 32rpx;color: #272727;
- &::after{content: '';width: 40rpx;height: 10rpx;background: #0156FE;border-radius: 6rpx;position: absolute;left: 50%;margin-left: -20rpx;bottom: -10rpx;}
- }
- }
- .numbox{width: 152rpx;height: 58rpx;background-color: #FFD5C1;border-radius: 29rpx 0 0 29rpx;font-weight: 500;font-size: 26rpx;color: #FE5A0E;display: flex;align-items: center;justify-content: center;position: absolute;right: 0;
- text{height: 20rpx;min-width: 20rpx;padding: 0 8rpx;box-sizing: border-box;line-height: 20rpx;margin-left: 10rpx;font-weight: bold;
- font-size:16rpx;
- color: #FCF9F1;
- background: #D32C26;
- border-radius: 5px;}
- }
- }
- }
- .carlists{padding: 0 18rpx;}
- </style>
|