newsyg.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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 params={
  86. staffTime:staffTime,
  87. }
  88. staffTrainTime(params).then(res=>{
  89. })
  90. },
  91. init(){
  92. // 发布类型
  93. getDictionaryFn('publication_type').then(res=>{
  94. if(res.code==200){
  95. if(res.data){
  96. this.tabval=res.data[0].dictValue;
  97. if(this.tabval==1){
  98. this.type='ystv'
  99. }else{
  100. this.type='ygsp'
  101. }
  102. this.wzlxList = res.data.map(v => {
  103. return {
  104. dictLabel: v.dictLabel,
  105. dictValue: v.dictValue
  106. }
  107. })
  108. this.getDataFn()
  109. }
  110. }
  111. })
  112. },
  113. getDetail(data){
  114. if(this.tabval=='ystv'){
  115. this.$tab.navigateTo("/manage/pages/community/newsygdetail?id="+data)
  116. }else{
  117. this.$tab.navigateTo("/manage/pages/community/newsaddvideo?id="+data)
  118. }
  119. },
  120. getPut(id){
  121. if(checkPermi((['wuye:partyNews:edit']))){
  122. this.$tab.navigateTo("/manage/pages/community/newsadd?id="+id)
  123. }else{
  124. this.$tab.navigateTo("/manage/pages/community/newsygdetail?id="+id)
  125. }
  126. },
  127. getAddFn(){
  128. this.$tab.navigateTo("/manage/pages/community/newsadd")
  129. },
  130. getAddvideoFn(){
  131. this.$tab.navigateTo("/manage/pages/community/newsaddvideo")
  132. },
  133. getReadlist(){
  134. this.$tab.navigateTo("/manage/pages/community/readlist")
  135. },
  136. getCount(){
  137. this.$tab.navigateTo("/manage/pages/community/readcount")
  138. },
  139. getrefreshData(){
  140. this.pageNum=1;
  141. this.list=[];
  142. this.reachflag=true;
  143. this.getDataFn()
  144. },
  145. getTabFn(val){
  146. this.tabval=val;
  147. if(this.tabval==1){
  148. this.type='ystv'
  149. }else{
  150. this.type='ygsp'
  151. }
  152. this.getrefreshData()
  153. },
  154. bindDateChangea(e){
  155. var val=e.detail.value;
  156. this.cxrq=val;
  157. },
  158. getPause(obj){
  159. var data=JSON.parse(JSON.stringify(obj))
  160. var params={
  161. manualId:data.id,
  162. progress:data.progress,
  163. }
  164. manualPut(params).then(res=>{
  165. if(res.code==200){
  166. }
  167. })
  168. },
  169. getDelFn(data){
  170. var that=this;
  171. manualDel(data).then(res=>{
  172. if(res.code==200){
  173. this.$toast("删除成功");
  174. setTimeout(function(){
  175. that.getrefreshData()
  176. },1500)
  177. }
  178. })
  179. },
  180. getDataFn(){
  181. var params={
  182. pageSize:this.pageSize,
  183. pageNum: this.pageNum,
  184. manualType:this.tabval
  185. }
  186. manualList(params).then(res=>{
  187. if(res.code==200){
  188. if (res.rows.length < this.pageSize) {
  189. this.reachflag = false
  190. this.wtdt = '到底了~';
  191. } else {
  192. var num = parseInt(res.rows.length) + parseInt(this.pageSize) * parseInt(this.pageNum - 1)
  193. if (num < res.total) {
  194. this.reachflag = true
  195. this.wtdt = ''
  196. } else {
  197. this.reachflag = false
  198. this.wtdt = '到底了~';
  199. }
  200. }
  201. var newArr=JSON.parse(JSON.stringify(res.rows))
  202. newArr.forEach(ite=>{
  203. ite.right=0;
  204. ite.currentTime=0;
  205. ite.duration=0;
  206. ite.initialtime=0;//当前播放位置
  207. ite.putflag=false;//是否修改
  208. })
  209. // console.log(newArr,555)
  210. if (this.pageNum == 1) {
  211. this.list = newArr;
  212. } else {
  213. this.list = this.list.concat(newArr)
  214. }
  215. }else{
  216. this.$toast(res.msg)
  217. }
  218. })
  219. },
  220. }
  221. }
  222. </script>
  223. <style>
  224. page{background: #F3F3F0;}
  225. </style>
  226. <style lang="scss" scoped>
  227. .car{padding: 148rpx 0 10rpx;}
  228. .cartop{position: fixed;left: 0;right: 0;top: 0;background-color: #ffffff;z-index: 2;
  229. .tabtop{padding:28rpx 200rpx 40rpx 0;position: relative;
  230. .tabt{font-weight: 500;font-size: 32rpx;color: #666666;position: relative;line-height: 56rpx;padding: 0 40rpx;
  231. &.act{font-weight: bold;font-size: 32rpx;color: #272727;
  232. &::after{content: '';width: 40rpx;height: 10rpx;background: #0156FE;border-radius: 6rpx;position: absolute;left: 50%;margin-left: -20rpx;bottom: -10rpx;}
  233. }
  234. }
  235. .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;
  236. text{height: 20rpx;min-width: 20rpx;padding: 0 8rpx;box-sizing: border-box;line-height: 20rpx;margin-left: 10rpx;font-weight: bold;
  237. font-size:16rpx;
  238. color: #FCF9F1;
  239. background: #D32C26;
  240. border-radius: 5px;}
  241. }
  242. }
  243. }
  244. .carlists{padding: 0 18rpx;}
  245. </style>