newsyg.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. <template>
  2. <view class="car">
  3. <view class="cartop">
  4. <view class="tabtop flexc">
  5. <view class="tabt" :class="tabval==ite.dictValue?'act':''" v-for="(ite,idx) in wzlxList" :key="idx" @click="getTabFn(ite.dictValue)">{{ite.dictLabel}}</view>
  6. <view class="numbox" @click="getCount">
  7. 阅读统计
  8. </view>
  9. </view>
  10. </view>
  11. <!-- 列表 -->
  12. <view class="carlists">
  13. <car-list :datainfo="list" :wtdt="wtdt" :type='type' @getDetail="getDetail" @getReadlist="getReadlist" @getPause="getPause" @getDelFn="getDelFn" @getPut="getPut"></car-list>
  14. </view>
  15. <block v-if="checkPermi(['wuYe:manual:add'])">
  16. <view style="height: 100rpx;"></view>
  17. <view class="rfbtn" @click="getAddFn" v-if="type=='ystv'">发布图文</view>
  18. <view class="rfbtn" @click="getAddvideoFn" v-else>发布视频</view>
  19. </block>
  20. <loading></loading>
  21. </view>
  22. </template>
  23. <script>
  24. import config from '@/config'
  25. const baseUrl = config.baseUrl
  26. import carList from "@/manage/components/car/list.vue"
  27. import { checkPermi, checkRole } from "@/utils/permission"; // 权限判断函数
  28. import {getDictionaryFn} from "@/api/system/user.js"
  29. import {manualList,manualDel,manualPut,staffTrainTime} from "@/api/work/manage.js"
  30. export default{
  31. components:{carList},
  32. data(){
  33. return{
  34. cxrq:"",
  35. text:'',
  36. list:[],
  37. pageSize: 10,
  38. pageNum: 1,
  39. reachflag: true,
  40. wtdt:'',
  41. tabval:'ystv',
  42. type:'',
  43. wzlxList:[],
  44. stayDuration: 0,
  45. pageLoadTime:0,
  46. }
  47. },
  48. onUnload() {
  49. uni.$off('newsygList')
  50. // 计算停留时长
  51. this.calculateStayDuration();
  52. },
  53. onLoad: function() {
  54. uni.$on('newsygList',(res)=>{
  55. this.getrefreshData()
  56. })
  57. this.init()
  58. // 记录页面加载时间
  59. this.pageLoadTime = Date.now();
  60. },
  61. onHide() {
  62. // 页面隐藏时计算停留时长
  63. this.calculateStayDuration();
  64. },
  65. onShow() {
  66. // 页面重新显示时重新记录加载时间
  67. this.pageLoadTime = Date.now();
  68. },
  69. mounted:function(){
  70. },
  71. // 上拉触底加载更多触发事件
  72. onReachBottom() {
  73. if (this.reachflag) {
  74. this.pageNum++
  75. this.getDataFn()
  76. }
  77. },
  78. methods:{
  79. checkPermi, checkRole,
  80. // 计算停留时长
  81. calculateStayDuration() {
  82. const currentTime = Date.now();
  83. var time=Math.floor((currentTime - this.pageLoadTime) / 1000); // 转换为秒
  84. // var staffTime=Math.ceil(time/60);//向上取整,转换成分钟
  85. var staffTime=Math.round(time/60);//四舍五入转换成分钟
  86. var params={
  87. staffTime:staffTime,
  88. }
  89. staffTrainTime(params).then(res=>{
  90. })
  91. },
  92. init(){
  93. // 发布类型
  94. getDictionaryFn('publication_type').then(res=>{
  95. if(res.code==200){
  96. if(res.data){
  97. this.tabval=res.data[0].dictValue;
  98. if(this.tabval==1){
  99. this.type='ystv'
  100. }else{
  101. this.type='ygsp'
  102. }
  103. this.wzlxList = res.data.map(v => {
  104. return {
  105. dictLabel: v.dictLabel,
  106. dictValue: v.dictValue
  107. }
  108. })
  109. this.getDataFn()
  110. }
  111. }
  112. })
  113. },
  114. getDetail(data){
  115. if(this.tabval=='ystv'){
  116. this.$tab.navigateTo("/manage/pages/community/newsygdetail?id="+data)
  117. }else{
  118. this.$tab.navigateTo("/manage/pages/community/newsaddvideo?id="+data)
  119. }
  120. },
  121. getPut(id){
  122. if(checkPermi((['wuye:partyNews:edit']))){
  123. this.$tab.navigateTo("/manage/pages/community/newsadd?id="+id)
  124. }else{
  125. this.$tab.navigateTo("/manage/pages/community/newsygdetail?id="+id)
  126. }
  127. },
  128. getAddFn(){
  129. this.$tab.navigateTo("/manage/pages/community/newsadd")
  130. },
  131. getAddvideoFn(){
  132. this.$tab.navigateTo("/manage/pages/community/newsaddvideo")
  133. },
  134. getReadlist(e){
  135. this.$tab.navigateTo("/manage/pages/community/readlist?id="+e)
  136. },
  137. getCount(){
  138. this.$tab.navigateTo("/manage/pages/community/readcount")
  139. },
  140. getrefreshData(){
  141. this.pageNum=1;
  142. this.list=[];
  143. this.reachflag=true;
  144. this.getDataFn()
  145. },
  146. getTabFn(val){
  147. this.tabval=val;
  148. if(this.tabval==1){
  149. this.type='ystv'
  150. }else{
  151. this.type='ygsp'
  152. }
  153. this.getrefreshData()
  154. },
  155. bindDateChangea(e){
  156. var val=e.detail.value;
  157. this.cxrq=val;
  158. },
  159. getPause(obj){
  160. var data=JSON.parse(JSON.stringify(obj))
  161. var params={
  162. manualId:data.id,
  163. progress:data.progress,
  164. }
  165. manualPut(params).then(res=>{
  166. if(res.code==200){
  167. }
  168. })
  169. },
  170. getDelFn(data){
  171. var that=this;
  172. manualDel(data).then(res=>{
  173. if(res.code==200){
  174. this.$toast("删除成功");
  175. setTimeout(function(){
  176. that.getrefreshData()
  177. },1500)
  178. }
  179. })
  180. },
  181. getDataFn(){
  182. var params={
  183. pageSize:this.pageSize,
  184. pageNum: this.pageNum,
  185. manualType:this.tabval
  186. }
  187. manualList(params).then(res=>{
  188. if(res.code==200){
  189. if (res.rows.length < this.pageSize) {
  190. this.reachflag = false
  191. this.wtdt = '到底了~';
  192. } else {
  193. var num = parseInt(res.rows.length) + parseInt(this.pageSize) * parseInt(this.pageNum - 1)
  194. if (num < res.total) {
  195. this.reachflag = true
  196. this.wtdt = ''
  197. } else {
  198. this.reachflag = false
  199. this.wtdt = '到底了~';
  200. }
  201. }
  202. var newArr=JSON.parse(JSON.stringify(res.rows))
  203. newArr.forEach(ite=>{
  204. ite.right=0;
  205. ite.currentTime=0;
  206. ite.duration=0;
  207. ite.initialtime=0;//当前播放位置
  208. ite.putflag=false;//是否修改
  209. })
  210. // console.log(newArr,555)
  211. if (this.pageNum == 1) {
  212. this.list = newArr;
  213. } else {
  214. this.list = this.list.concat(newArr)
  215. }
  216. }else{
  217. this.$toast(res.msg)
  218. }
  219. })
  220. },
  221. }
  222. }
  223. </script>
  224. <style>
  225. page{background: #F3F3F0;}
  226. </style>
  227. <style lang="scss" scoped>
  228. .car{padding: 148rpx 0 10rpx;}
  229. .cartop{position: fixed;left: 0;right: 0;top: 0;background-color: #ffffff;z-index: 2;
  230. .tabtop{padding:28rpx 200rpx 40rpx 0;position: relative;
  231. .tabt{font-weight: 500;font-size: 32rpx;color: #666666;position: relative;line-height: 56rpx;padding: 0 40rpx;
  232. &.act{font-weight: bold;font-size: 32rpx;color: #272727;
  233. &::after{content: '';width: 40rpx;height: 10rpx;background: #0156FE;border-radius: 6rpx;position: absolute;left: 50%;margin-left: -20rpx;bottom: -10rpx;}
  234. }
  235. }
  236. .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;
  237. text{height: 20rpx;min-width: 20rpx;padding: 0 8rpx;box-sizing: border-box;line-height: 20rpx;margin-left: 10rpx;font-weight: bold;
  238. font-size:16rpx;
  239. color: #FCF9F1;
  240. background: #D32C26;
  241. border-radius: 5px;}
  242. }
  243. }
  244. }
  245. .carlists{padding: 0 18rpx;}
  246. </style>