兼兼街公众号代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

212 lines
4.9 KiB

  1. <template>
  2. <view>
  3. <view class="home-pages">
  4. <view style="position: absolute;top: 0; left: 0; height: 188rpx; width: 100%; z-index: 100; background-color: #FFFFFF; box-shadow: 0px 15px 10px -15px #E8E8E8;">
  5. <view style="margin: 28rpx 24rpx; display: flex;">
  6. <image :showLoading="true" :src="userInfo?userInfo.headImage : ''" style="width: 148rpx;height: 148rpx;border-radius: 50%;"></image>
  7. <view style="padding: 28rpx;">
  8. <view style="font-size: 32rpx;font-weight: 600">{{userInfo?userInfo.nickName : '点击登录'}}</view>
  9. <view style="font-size: 30rpx;margin-top: 20rpx;">粉丝数量{{params.total}}</view>
  10. </view>
  11. </view>
  12. </view>
  13. <view class="home-content">
  14. <user-card v-for="(item,i) in informationList" :key="i" :item="item"></user-card>
  15. </view>
  16. </view>
  17. </view>
  18. </template>
  19. <script>
  20. import userCard from '@/components/user-card/index.vue'
  21. export default{
  22. components:{
  23. userCard
  24. },
  25. data(){
  26. return{
  27. userInfo:null,
  28. current:1,
  29. activiteList:[],
  30. informationList:[],
  31. params:{
  32. pageNo:1,
  33. pageSize:10,
  34. total: null,
  35. isLock: true
  36. },
  37. }
  38. },
  39. onShow() {
  40. this.getmyInfo()
  41. },
  42. onLoad() {
  43. this.getinformation()
  44. // if(this.current == 0){
  45. // this.getActivity();
  46. // }else{
  47. // this.getinformation()
  48. // }
  49. },
  50. onPullDownRefresh() {
  51. this.activiteList = [];
  52. this.params.pageNo = 1;
  53. this.params.total = null;
  54. this.params.isLock = true;
  55. this.getinformation()
  56. },
  57. onReachBottom() {
  58. if(this.params.isLock){
  59. this.params.isLock = false;
  60. if(this.params.total !== null && this.params.pageNo * this.params.pageSize >= this.params.total){
  61. this.$Toast('没有更多数据!');
  62. setTimeout(()=>{
  63. this.params.isLock = true;
  64. },3000)
  65. return
  66. }
  67. this.params.pageNo+=1;
  68. this.$Toast('数据加载成功!');
  69. this.getinformation()
  70. }
  71. },
  72. onPullDownRefresh() {
  73. this.params.pageNo = 1;
  74. this.getinformation()
  75. // if(this.current == 0){
  76. // this.getActivity();
  77. // }else{
  78. // this.getinformation()
  79. // }
  80. },
  81. // 隐藏微信h5的标题栏
  82. onReady() {
  83. this.$com.displayNav()
  84. },
  85. methods:{
  86. getmyInfo(){
  87. this.$api('myInfo')
  88. .then(res=>{
  89. if(res.code == 200){
  90. this.role = res.result.role;
  91. this.userInfo = res.result;
  92. this.$store.commit('set_userInfo',res.result)
  93. }else{
  94. this.userInfo = null
  95. }
  96. })
  97. },
  98. // tabClick(e){
  99. // this.current = e.index;
  100. // this.params.pageNo = 1;
  101. // if(this.current == 0){
  102. // this.getActivity(2);
  103. // }else{
  104. // this.getinformation(2)
  105. // }
  106. // },
  107. // getActivity(type){
  108. // uni.showLoading()
  109. // this.$api('activity',this.params)
  110. // .then(res=>{
  111. // uni.hideLoading()
  112. // if(res.code == 200){
  113. // if(this.params.total== null) {
  114. // this.params.total = res.result.total
  115. // }
  116. // if(this.params.pageNo>1){
  117. // uni.hideLoading();
  118. // }
  119. // this.pages = this.pages.concat(res.result.pages);
  120. // this.params.isLock = true;
  121. // }else {
  122. // if(this.params.pageNo>1){
  123. // uni.hideLoading();
  124. // }
  125. // this.params.isLock = true;
  126. // }
  127. // })
  128. // },
  129. getinformation(type){
  130. if(this.pageNo>1){
  131. uni.showLoading({})
  132. }
  133. this.$api('getFans',this.params)
  134. .then(res=>{
  135. if(res.code == 200){
  136. if(this.params.total== null) {
  137. this.params.total = res.result.total
  138. }
  139. if(this.params.pageNo>1){
  140. uni.hideLoading();
  141. }
  142. this.informationList = this.informationList.concat(res.result.records);
  143. this.params.isLock = true;
  144. }else {
  145. if(this.params.pageNo>1){
  146. uni.hideLoading();
  147. }
  148. this.params.isLock = true;
  149. }
  150. })
  151. // uni.showLoading()
  152. // this.$api('getFans',this.params)
  153. // .then(res=>{
  154. // uni.hideLoading()
  155. // if(res.code == 200){
  156. // this.pages = res.result.pages;
  157. // if(type == 2){
  158. // this.informationList = [...this.informationList,...res.result.records];
  159. // }else{
  160. // this.informationList = res.result.records;
  161. // uni.stopPullDownRefresh();
  162. // }
  163. // }
  164. // })
  165. },
  166. seeDetail(item){//查看详情
  167. uni.navigateTo({
  168. url:`/pages/home/course-detial?id=${item.id}`
  169. })
  170. },
  171. newDetail(item){//知识查看详情
  172. uni.navigateTo({
  173. url:`/pages/home/new-detail?id=${item.id}`
  174. })
  175. },
  176. lower(){
  177. if(this.params.pageNo >= this.pages) return;
  178. this.params.pageNo ++;
  179. if(this.current == 0){
  180. this.getActivity(2);
  181. }else{
  182. this.getinformation(2)
  183. }
  184. },
  185. }
  186. }
  187. </script>
  188. <style lang="scss" scoped>
  189. .home-content {
  190. margin-top: 20rpx;
  191. }
  192. .home-pages {
  193. padding: 188rpx 29rpx 0;
  194. background-color: #F7F7F7;
  195. .scroll-Y {
  196. height: calc(100vh - 200rpx);
  197. padding-top: 20rpx;
  198. }
  199. }
  200. </style>