myhd.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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 "@/mine/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. hrimg:require('@/static/logo.png'),
  24. list:[],
  25. pageSize: 10,
  26. pageNum: 1,
  27. reachflag: true,
  28. wtdt:'',
  29. tabval:'mypl',
  30. tablist:[{tit:"评论",val:'mypl'},{tit:"点赞",val:'mydz'},{tit:"收藏",val:'mysc'},]
  31. }
  32. },
  33. onLoad: function() {
  34. // this.getDataFn()
  35. },
  36. onPageScroll(e) {
  37. var scrollTop = Number(e.scrollTop);
  38. // var listTop=Number(this.listTop)-Number(this.nvaHeight)
  39. if(scrollTop>2){
  40. this.scroflag=true
  41. }else{
  42. this.scroflag=false
  43. }
  44. },
  45. // 上拉触底加载更多触发事件
  46. onReachBottom() {
  47. if (this.reachflag) {
  48. this.pageNum++
  49. this.getDataFn()
  50. }
  51. },
  52. methods:{
  53. checkPermi, checkRole,
  54. // getNextFn(){
  55. // this.$tab.navigateTo("/work/pages/business/add")
  56. // },
  57. getDelFn(id){
  58. var that=this;
  59. // reservDel(data).then(res=>{
  60. // if(res.code==200){
  61. // this.$toast("删除成功");
  62. // setTimeout(function(){
  63. // that.getrefreshData()
  64. // },1500)
  65. // }
  66. // })
  67. },
  68. getTabFn(val){
  69. this.tabval=val;
  70. this.getrefreshData()
  71. },
  72. getrefreshData(){
  73. this.pageNum=1;
  74. this.list=[];
  75. this.reachflag=true;
  76. this.getDataFn()
  77. },
  78. getSh(data){
  79. var that=this;
  80. var params=JSON.parse(JSON.stringify(data))
  81. commentContentPut(params).then(res=>{
  82. if(res.code==200){
  83. this.$toast('审核成功')
  84. setTimeout(function() {
  85. that.getrefreshData()
  86. }, 1500);
  87. }
  88. })
  89. },
  90. getDataFn(){
  91. var params={
  92. pageSize:this.pageSize,
  93. pageNum: this.pageNum,
  94. }
  95. var tabval=this.tabval
  96. if(tabval=='mypl'){
  97. mycommentIndex(params).then(res=>{
  98. if(res.code==200){
  99. if (res.rows.length < this.pageSize) {
  100. this.reachflag = false
  101. this.wtdt = '到底了~';
  102. } else {
  103. var num = parseInt(res.rows.length) + parseInt(this.pageSize) * parseInt(this.pageNum - 1)
  104. if (num < res.total) {
  105. this.reachflag = true
  106. this.wtdt = ''
  107. } else {
  108. this.reachflag = false
  109. this.wtdt = '到底了~';
  110. }
  111. }
  112. var newArr=JSON.parse(JSON.stringify(res.rows))
  113. newArr.forEach(ite=>{
  114. ite.right=0;
  115. })
  116. if (this.pageNum == 1) {
  117. this.list = newArr;
  118. } else {
  119. this.list = this.list.concat(newArr)
  120. }
  121. }else{
  122. this.$toast(res.msg)
  123. }
  124. })
  125. }else if(tabval=='mydz'){
  126. mycommentLikes(params).then(res=>{
  127. if(res.code==200){
  128. if (res.rows.length < this.pageSize) {
  129. this.reachflag = false
  130. this.wtdt = '到底了~';
  131. } else {
  132. var num = parseInt(res.rows.length) + parseInt(this.pageSize) * parseInt(this.pageNum - 1)
  133. if (num < res.total) {
  134. this.reachflag = true
  135. this.wtdt = ''
  136. } else {
  137. this.reachflag = false
  138. this.wtdt = '到底了~';
  139. }
  140. }
  141. var newArr=JSON.parse(JSON.stringify(res.rows))
  142. newArr.forEach(ite=>{
  143. ite.right=0;
  144. })
  145. if (this.pageNum == 1) {
  146. this.list = newArr;
  147. } else {
  148. this.list = this.list.concat(newArr)
  149. }
  150. }else{
  151. this.$toast(res.msg)
  152. }
  153. })
  154. }else{
  155. mycommentStars(params).then(res=>{
  156. if(res.code==200){
  157. if (res.rows.length < this.pageSize) {
  158. this.reachflag = false
  159. this.wtdt = '到底了~';
  160. } else {
  161. var num = parseInt(res.rows.length) + parseInt(this.pageSize) * parseInt(this.pageNum - 1)
  162. if (num < res.total) {
  163. this.reachflag = true
  164. this.wtdt = ''
  165. } else {
  166. this.reachflag = false
  167. this.wtdt = '到底了~';
  168. }
  169. }
  170. var newArr=JSON.parse(JSON.stringify(res.rows))
  171. newArr.forEach(ite=>{
  172. ite.right=0;
  173. })
  174. if (this.pageNum == 1) {
  175. this.list = newArr;
  176. } else {
  177. this.list = this.list.concat(newArr)
  178. }
  179. }else{
  180. this.$toast(res.msg)
  181. }
  182. })
  183. }
  184. console.log(this.list)
  185. },
  186. }
  187. }
  188. </script>
  189. <style>
  190. page{background: #F3F3F0;}
  191. </style>
  192. <style lang="scss" scoped>
  193. .news{padding:124rpx 18rpx 12rpx;}
  194. .cartop{position: fixed;left: 0;right: 0;top: 0;background-color: #ffffff;z-index: 2;
  195. .toptit{display: flex;justify-content: center;font-weight: 500;font-size: 26rpx;color: #8592AA;height: 70rpx;align-items: center;
  196. background: #E4EDFF;
  197. text{font-size: 32rpx;color: #0156FE;padding: 0 10rpx;}
  198. image{width: 28rpx;height: 26rpx;flex: 0 0 auto;margin-right: 12rpx;}
  199. }
  200. .tabtop{padding-bottom: 40rpx;padding-top: 14rpx;
  201. .tabt{font-weight: 500;font-size: 32rpx;color: #666666;position: relative;line-height: 56rpx;padding: 0 40rpx;
  202. &.act{font-weight: bold;font-size: 32rpx;color: #272727;
  203. &::after{content: '';width: 40rpx;height: 10rpx;background: #0156FE;border-radius: 6rpx;position: absolute;left: 50%;margin-left: -20rpx;bottom: -10rpx;}
  204. }
  205. }
  206. }
  207. }
  208. </style>