兼兼街公众号代码
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.

187 lines
4.0 KiB

2 years ago
  1. <template>
  2. <view class="home-pages">
  3. <view class="home-content">
  4. <u-tabs
  5. :list="tabList"
  6. lineWidth="70"
  7. lineHeight="3"
  8. lineColor= "#00CCCC"
  9. :activeStyle="{
  10. color: '#000000',
  11. fontWeight: 'bold',
  12. transform: 'scale(1.35)'
  13. }"
  14. :inactiveStyle="{
  15. color: '#000000',
  16. transform: 'scale(1)'
  17. }"
  18. itemStyle="padding-left: 15px; padding-right: 15px; height: 34px;"
  19. @click="tabClick"
  20. >
  21. </u-tabs>
  22. <scroll-view scroll-y="true" class="scroll-Y" @scrolltolower="lower">
  23. <template v-if="current == 0">
  24. <active-card v-for="(item,i) in studyList" :item="item" :key="i" :i="i" @seeDetail="seeDetail"></active-card>
  25. </template>
  26. <template v-if="current == 1">
  27. <new-card v-for="(item,i) in informationList" :key="i" :item="item" @seeDetail="newDetail"></new-card>
  28. </template>
  29. </scroll-view>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. import activeCard from '@/components/active-card/index.vue'
  35. import newCard from '@/components/new-card/index.vue'
  36. export default{
  37. components:{
  38. activeCard,
  39. newCard
  40. },
  41. data(){
  42. return{
  43. current:0,
  44. studyList:[],
  45. activiteList:[],
  46. informationList:[],
  47. tabList: [
  48. {
  49. name: '家教街'
  50. },
  51. {
  52. name: '校园墙'
  53. }
  54. ],
  55. params:{
  56. pageNo:1,
  57. pageSize:10,
  58. total: null,
  59. isLock: true
  60. },
  61. }
  62. },
  63. onLoad() {
  64. if(this.current == 0){
  65. this.getActivity();
  66. }else{
  67. this.getinformation()
  68. }
  69. },
  70. onPullDownRefresh() {
  71. this.activiteList = [];
  72. this.params.pageNo = 1;
  73. this.params.total = null;
  74. this.params.isLock = true;
  75. this.getActivity();
  76. },
  77. onReachBottom() {
  78. if(this.params.isLock){
  79. this.params.isLock = false;
  80. if(this.params.total !== null && this.params.pageNo * this.params.pageSize >= this.params.total){
  81. this.$Toast('没有更多数据!');
  82. setTimeout(()=>{
  83. this.params.isLock = true;
  84. },3000)
  85. return
  86. }
  87. this.params.pageNo+=1;
  88. this.$Toast('数据加载成功!');
  89. this.getActivity();
  90. }
  91. },
  92. onPullDownRefresh() {
  93. this.params.pageNo = 1;
  94. if(this.current == 0){
  95. this.getActivity();
  96. }else{
  97. this.getinformation()
  98. }
  99. },
  100. // 隐藏微信h5的标题栏
  101. onReady() {
  102. this.$com.displayNav()
  103. },
  104. methods:{
  105. tabClick(e){
  106. this.current = e.index;
  107. this.params.pageNo = 1;
  108. if(this.current == 0){
  109. this.getActivity(2);
  110. }else{
  111. this.getinformation(2)
  112. }
  113. },
  114. getActivity(type){
  115. uni.showLoading()
  116. this.$api('JobList',this.params)
  117. .then(res=>{
  118. uni.hideLoading()
  119. if(res.code == 200){
  120. if(this.params.total== null) {
  121. this.params.total = res.result.total
  122. }
  123. if(this.params.pageNo>1){
  124. uni.hideLoading();
  125. }
  126. this.studyList = this.studyList.concat(res.result.records);
  127. this.params.isLock = true;
  128. }else {
  129. if(this.params.pageNo>1){
  130. uni.hideLoading();
  131. }
  132. this.params.isLock = true;
  133. }
  134. })
  135. },
  136. getinformation(type){
  137. uni.showLoading()
  138. this.$api('information',this.params)
  139. .then(res=>{
  140. uni.hideLoading()
  141. if(res.code == 200){
  142. this.pages = res.result.pages;
  143. if(type == 2){
  144. this.informationList = [...this.informationList,...res.result.records];
  145. }else{
  146. this.informationList = res.result.records;
  147. uni.stopPullDownRefresh();
  148. }
  149. }
  150. })
  151. },
  152. seeDetail(item){//查看详情
  153. uni.navigateTo({
  154. url:`/pages/home/course-detial?id=${item.id}`
  155. })
  156. },
  157. newDetail(item){//知识查看详情
  158. uni.navigateTo({
  159. url:`/pages/home/new-detail?id=${item.id}`
  160. })
  161. },
  162. lower(){
  163. if(this.params.pageNo >= this.pages) return;
  164. this.params.pageNo ++;
  165. if(this.current == 0){
  166. this.getActivity(2);
  167. }else{
  168. this.getinformation(2)
  169. }
  170. },
  171. }
  172. }
  173. </script>
  174. <style lang="scss" scoped>
  175. .home-pages {
  176. padding: 18rpx 29rpx 0;
  177. background-color: #F7F7F7;
  178. .scroll-Y {
  179. height: calc(100vh - 210rpx);
  180. padding-top: 20rpx;
  181. }
  182. }
  183. </style>