guanzhu.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <template>
  2. <view class="content">
  3. <view v-if="dataList.length != 0" class="bg u-flex u-p-l-30 u-p-t-30 u-p-b-10 u-p-r-30" v-for="(item,index) in dataList" :key='index'>
  4. <view class="u-m-r-10">
  5. <u-avatar :src="item.avatar?item.avatar: '../../static/logo.png'" size="100"></u-avatar>
  6. </view>
  7. <view class="u-flex-1 text-white margin-left-xs">
  8. <view class="u-font-16 text-bold">{{item.userName}}</view>
  9. <view class="u-font-14 margin-top-sm u-tips-color" @click="goNav('/pages/me/vip/index')">{{item.updateTime?item.updateTime:''}}</view>
  10. </view>
  11. <view>
  12. <view v-if="item.status == 1" @click="insert(item)" class="round"
  13. style="color: white;background: #557EFD;padding: 10upx 24upx;width: 150upx;text-align: center;font-size: 22upx;">
  14. 互相关注</view>
  15. <view v-if="item.status == 2 && type == 1" @click="insert(item)" class="round"
  16. style="color: white;background: #557EFD;padding: 10upx 24upx;width: 150upx;text-align: center;font-size: 22upx;">
  17. 回关</view>
  18. <view v-if="item.status == 2 && type == 2" @click="insert(item)" class="round"
  19. style="color: white;background: #557EFD;padding: 10upx 24upx;width: 150upx;text-align: center;font-size: 22upx;">
  20. 已关注</view>
  21. </view>
  22. </view>
  23. <empty v-if="dataList.length == 0" ></empty>
  24. </view>
  25. </template>
  26. <script>
  27. import empty from '../../components/empty.vue'
  28. export default {
  29. components: {
  30. empty
  31. },
  32. data() {
  33. return {
  34. dataList: [],
  35. type: 1,
  36. page: 1,
  37. limit: 10
  38. }
  39. },
  40. onLoad(e) {
  41. console.log(e)
  42. this.$queue.showLoading("加载中...");
  43. uni.setNavigationBarTitle({
  44. title: e.name
  45. })
  46. this.type = e.type
  47. if (this.type == 1) {
  48. this.getFansList()
  49. } else {
  50. this.getFollowList()
  51. }
  52. },
  53. methods: {
  54. // 获取粉丝数量
  55. getFansList() {
  56. let data = {
  57. page: this.page,
  58. limit: this.limit
  59. }
  60. this.$Request.get("/app/userFollow/selectFans", data).then(res => {
  61. uni.hideLoading();
  62. if (res.code == 0) {
  63. if(this.page == 1) {
  64. this.dataList = res.data.list
  65. } else {
  66. this.dataList = [...this.dataList, ...res.data.list]
  67. }
  68. } else {
  69. console.log(res.msg)
  70. }
  71. uni.stopPullDownRefresh();
  72. });
  73. },
  74. // 获取关注数量
  75. getFollowList() {
  76. let data = {
  77. page: this.page,
  78. limit: this.limit
  79. }
  80. this.$Request.get("/app/userFollow/selectMyFollow", data).then(res => {
  81. if (res.code == 0) {
  82. if(this.page == 1) {
  83. this.dataList = res.data.list
  84. } else {
  85. this.dataList = [...this.dataList, ...res.data.list]
  86. }
  87. } else {
  88. console.log(res.msg)
  89. }
  90. uni.hideLoading();
  91. uni.stopPullDownRefresh();
  92. });
  93. },
  94. insert(e) {
  95. let that = this
  96. let data = {
  97. followUserId: e.userId
  98. }
  99. that.$Request.get("/app/userFollow/insert", data).then(res => {
  100. console.log(res)
  101. if (res.code == 0) {
  102. uni.showToast({
  103. title: res.msg,
  104. icon: 'none'
  105. })
  106. setTimeout(function() {
  107. if (that.type == 1) {
  108. that.getFansList()
  109. } else {
  110. that.getFollowList()
  111. }
  112. }, 500)
  113. }
  114. });
  115. }
  116. },
  117. onReachBottom: function() {
  118. this.page = this.page + 1;
  119. if (e.type == 1) {
  120. this.getFansList()
  121. } else {
  122. this.getFollowList()
  123. }
  124. },
  125. onPullDownRefresh: function() {
  126. this.page = 1;
  127. // this.dataList = []
  128. if (this.type == 1) {
  129. this.getFansList()
  130. } else {
  131. this.getFollowList()
  132. }
  133. },
  134. }
  135. </script>
  136. <style>
  137. page {
  138. background-color: #F7F7F7;
  139. }
  140. .bg {
  141. background-color: #FFFFFF;
  142. }
  143. </style>