myhd.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. <template>
  2. <view class="news">
  3. <!-- tab栏 -->
  4. <view class="cartop">
  5. <view class="tabtop flexc">
  6. <view class="tabt" :class="tabval==ite.val?'act':''" v-for="(ite,idx) in tablist" :key="idx" @click="getTabFn(ite.val)">{{ite.tit}}</view>
  7. </view>
  8. </view>
  9. <box-list :datainfo="list" :wtdt="wtdt" :tabval="tabval" type="wdhd" @getDetail='getDetail'></box-list>
  10. <loading></loading>
  11. </view>
  12. </template>
  13. <script>
  14. import config from '@/config'
  15. const baseUrl = config.baseUrl
  16. import boxList from "@/my/components/box/list.vue"
  17. import { checkPermi, checkRole } from "@/utils/permission"; // 权限判断函数
  18. import {mycommentStars,mycommentLikes,mycommentIndex} from "@/api/work/news.js"
  19. export default{
  20. components:{boxList},
  21. data(){
  22. return{
  23. list:[],
  24. pageSize: 10,
  25. pageNum: 1,
  26. reachflag: true,
  27. wtdt:'',
  28. tabval:'mypl',
  29. userId:this.$store.state.user.userId,
  30. tablist:[{tit:"评论",val:'mypl'},{tit:"点赞",val:'mydz'},{tit:"收藏",val:'mysc'},]
  31. }
  32. },
  33. onUnload() {
  34. uni.$off('partyNewsList')
  35. },
  36. onLoad: function() {
  37. uni.$on('partyNewsList',(res)=>{
  38. this.getrefreshData()
  39. })
  40. this.getDataFn()
  41. },
  42. onPageScroll(e) {
  43. var scrollTop = Number(e.scrollTop);
  44. // var listTop=Number(this.listTop)-Number(this.nvaHeight)
  45. if(scrollTop>2){
  46. this.scroflag=true
  47. }else{
  48. this.scroflag=false
  49. }
  50. },
  51. // 上拉触底加载更多触发事件
  52. onReachBottom() {
  53. if (this.reachflag) {
  54. this.pageNum++
  55. this.getDataFn()
  56. }
  57. },
  58. methods:{
  59. checkPermi, checkRole,
  60. // getNextFn(){
  61. // this.$tab.navigateTo("/work/pages/business/add")
  62. // },
  63. getDetail(data){
  64. var info=JSON.parse(JSON.stringify(data))
  65. var type=this.tabval;
  66. var targetType=info.targetType;//1:社区 2:党建
  67. if(type=='mypl'){
  68. var id=info.communityId;
  69. this.$tab.navigateTo("/news/pages/news/detail?id="+id)
  70. }else{
  71. var id=info.targetId;
  72. if(targetType==1){
  73. this.$tab.navigateTo("/news/pages/news/detail?id="+id)
  74. }else if(targetType==2){
  75. this.$tab.navigateTo("/news/pages/news/djdetail?id="+id)
  76. }
  77. }
  78. },
  79. getDelFn(id){
  80. var that=this;
  81. // reservDel(data).then(res=>{
  82. // if(res.code==200){
  83. // this.$toast("删除成功");
  84. // setTimeout(function(){
  85. // that.getrefreshData()
  86. // },1500)
  87. // }
  88. // })
  89. },
  90. getTabFn(val){
  91. this.tabval=val;
  92. this.getrefreshData()
  93. },
  94. getrefreshData(){
  95. this.pageNum=1;
  96. this.list=[];
  97. this.reachflag=true;
  98. this.getDataFn()
  99. },
  100. getSh(data){
  101. var that=this;
  102. var params=JSON.parse(JSON.stringify(data))
  103. commentContentPut(params).then(res=>{
  104. if(res.code==200){
  105. this.$toast('审核成功')
  106. setTimeout(function() {
  107. that.getrefreshData()
  108. }, 1500);
  109. }
  110. })
  111. },
  112. getDataFn(){
  113. var params={
  114. pageSize:this.pageSize,
  115. pageNum: this.pageNum,
  116. userId:this.userId
  117. }
  118. var tabval=this.tabval
  119. if(tabval=='mypl'){
  120. mycommentIndex(params).then(res=>{
  121. if(res.code==200){
  122. if (res.rows.length < this.pageSize) {
  123. this.reachflag = false
  124. this.wtdt = '到底了~';
  125. } else {
  126. var num = parseInt(res.rows.length) + parseInt(this.pageSize) * parseInt(this.pageNum - 1)
  127. if (num < res.total) {
  128. this.reachflag = true
  129. this.wtdt = ''
  130. } else {
  131. this.reachflag = false
  132. this.wtdt = '到底了~';
  133. }
  134. }
  135. var newArr=JSON.parse(JSON.stringify(res.rows))
  136. newArr.forEach(ite=>{
  137. ite.right=0;
  138. })
  139. if (this.pageNum == 1) {
  140. this.list = newArr;
  141. } else {
  142. this.list = this.list.concat(newArr)
  143. }
  144. }else{
  145. this.$toast(res.msg)
  146. }
  147. })
  148. }else if(tabval=='mydz'){
  149. mycommentLikes(params).then(res=>{
  150. if(res.code==200){
  151. if (res.rows.length < this.pageSize) {
  152. this.reachflag = false
  153. this.wtdt = '到底了~';
  154. } else {
  155. var num = parseInt(res.rows.length) + parseInt(this.pageSize) * parseInt(this.pageNum - 1)
  156. if (num < res.total) {
  157. this.reachflag = true
  158. this.wtdt = ''
  159. } else {
  160. this.reachflag = false
  161. this.wtdt = '到底了~';
  162. }
  163. }
  164. var newArr=JSON.parse(JSON.stringify(res.rows))
  165. newArr.forEach(ite=>{
  166. ite.right=0;
  167. })
  168. if (this.pageNum == 1) {
  169. this.list = newArr;
  170. } else {
  171. this.list = this.list.concat(newArr)
  172. }
  173. }else{
  174. this.$toast(res.msg)
  175. }
  176. })
  177. }else{
  178. mycommentStars(params).then(res=>{
  179. if(res.code==200){
  180. if (res.rows.length < this.pageSize) {
  181. this.reachflag = false
  182. this.wtdt = '到底了~';
  183. } else {
  184. var num = parseInt(res.rows.length) + parseInt(this.pageSize) * parseInt(this.pageNum - 1)
  185. if (num < res.total) {
  186. this.reachflag = true
  187. this.wtdt = ''
  188. } else {
  189. this.reachflag = false
  190. this.wtdt = '到底了~';
  191. }
  192. }
  193. var newArr=JSON.parse(JSON.stringify(res.rows))
  194. newArr.forEach(ite=>{
  195. ite.right=0;
  196. })
  197. if (this.pageNum == 1) {
  198. this.list = newArr;
  199. } else {
  200. this.list = this.list.concat(newArr)
  201. }
  202. }else{
  203. this.$toast(res.msg)
  204. }
  205. })
  206. }
  207. console.log(this.list)
  208. },
  209. }
  210. }
  211. </script>
  212. <style>
  213. page{background: #F3F3F0;}
  214. </style>
  215. <style lang="scss" scoped>
  216. .news{padding:124rpx 18rpx 12rpx;}
  217. .cartop{position: fixed;left: 0;right: 0;top: 0;background-color: #ffffff;z-index: 2;
  218. .toptit{display: flex;justify-content: center;font-weight: 500;font-size: 26rpx;color: #8592AA;height: 70rpx;align-items: center;
  219. background: #E4EDFF;
  220. text{font-size: 32rpx;color: #0156FE;padding: 0 10rpx;}
  221. image{width: 28rpx;height: 26rpx;flex: 0 0 auto;margin-right: 12rpx;}
  222. }
  223. .tabtop{padding-bottom: 40rpx;padding-top: 14rpx;
  224. .tabt{font-weight: 500;font-size: 32rpx;color: #666666;position: relative;line-height: 56rpx;padding: 0 40rpx;
  225. &.act{font-weight: bold;font-size: 32rpx;color: #272727;
  226. &::after{content: '';width: 40rpx;height: 10rpx;background: #0156FE;border-radius: 6rpx;position: absolute;left: 50%;margin-left: -20rpx;bottom: -10rpx;}
  227. }
  228. }
  229. }
  230. }
  231. </style>