community.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <template name="community">
  2. <view class="home">
  3. <view class="card-bottom">
  4. <!-- 顶部分页栏 -->
  5. <view class="top-tab">
  6. <view :class="['tab-item flex-center', activeTab == k ? 'active' : '']" @tap="handleTab(k)" v-for="(v, k) in fetch.cate" :key="k">{{ v.name }}</view>
  7. </view>
  8. <view class="scroll-wrapper">
  9. <view class="margin-bottom" v-for="(v, k) in fetch.info" :key="k">
  10. <y-DiaryItem :item="v" :cate_id="cate_id"/>
  11. </view>
  12. <y-LoadMore :status="loadMoreStatus" />
  13. </view>
  14. <!-- 右下角按钮 -->
  15. <y-Fab :bottom="140" :right="40" @click="showModal" v-if="button_show"/>
  16. </view>
  17. <view v-if="show">
  18. <communityPush :title="title" :is_upload="true" @hideModal="hideModal" @getRefresh="getRefresh" :cate_id="cate_id" :type="type" :type_id="type_id"></communityPush>
  19. </view>
  20. </view>
  21. </template>
  22. <script>
  23. import communityPush from "@/pages/dream/view/communityPush";
  24. export default {
  25. name: "community",
  26. props: {
  27. info_id : {
  28. type : String,
  29. value : null
  30. },
  31. content_id : {
  32. type : String,
  33. value : null
  34. },
  35. page_id : {
  36. type : String,
  37. value : null
  38. },
  39. parent_page_id : {
  40. type : String,
  41. value : null
  42. },
  43. type : {
  44. type : Number,
  45. value : null
  46. },
  47. type_id : {
  48. type : String,
  49. value : null
  50. },
  51. index : 0
  52. },
  53. data() {
  54. return {
  55. title : '发表新话题',
  56. show : false,
  57. button_show : true,
  58. fetch : {
  59. cate : [],
  60. info : [],
  61. },
  62. cate_id : 0,
  63. activeTab: 0,
  64. loadMoreStatus: 1,
  65. };
  66. },
  67. created() {
  68. this.getData();
  69. },
  70. onReachBottom() {
  71. },
  72. methods:{
  73. getRefresh : function(cate_id, type, type_id) {
  74. this.getInfo(cate_id, 1);
  75. },
  76. getData : function() {
  77. var self = this;
  78. this.Dever.get(this, 'app/community/?l=api.category', {info_id:this.info_id, page_id:this.page_id, content_id:this.content_id,noloading:1}, function(t) {
  79. if (t && t.cate.length > 0 && t.cate[self.activeTab]) {
  80. self.getInfo(t.cate[self.activeTab].id, 1);
  81. }
  82. });
  83. },
  84. getInfo : function(cate_id, page) {
  85. var self = this;
  86. self.cate_id = cate_id;
  87. this.Dever.get(this, 'app/community/?l=api.info', {cate_id:cate_id, type:this.type, type_id:this.type_id}, function(t) {
  88. if (t && t.info.length > 0) {
  89. self.loadMoreStatus = 2;
  90. } else {
  91. self.loadMoreStatus = 3;
  92. }
  93. self.hideModal();
  94. });
  95. },
  96. handleTab : function(index) {
  97. if (this.activeTab == index) {
  98. return;
  99. }
  100. this.activeTab = index;
  101. this.getInfo(this.fetch.cate[this.activeTab].id, 1);
  102. },
  103. showModal : function () {
  104. this.show = true;
  105. this.button_show = false;
  106. },
  107. hideModal : function () {
  108. this.show = false;
  109. this.button_show = true;
  110. }
  111. },
  112. components:{
  113. communityPush
  114. }
  115. }
  116. </script>
  117. <style lang="less" scoped>
  118. page {
  119. --mainColor: #435257;
  120. --activeColor: #36b39b;
  121. }
  122. view {
  123. box-sizing: border-box;
  124. }
  125. .flex-center {
  126. display: flex;
  127. align-items: center;
  128. justify-content: center;
  129. }
  130. .mainColor {
  131. color: var(--mainColor);
  132. }
  133. .aColor {
  134. color: var(--activeColor);
  135. }
  136. .color-nine{
  137. color: #999999;
  138. }
  139. .main-btn {
  140. border-radius: 40upx;
  141. display: flex;
  142. align-items: center;
  143. justify-content: center;
  144. color: var(--mainColor);
  145. border: 1upx solid var(--mainColor);
  146. padding: 10rpx 40rpx;
  147. }
  148. .active-btn {
  149. color: #FFFFFF !important;
  150. background-color: var(--activeColor) !important;
  151. border: 1upx solid var(--activeColor) !important;
  152. }
  153. /* 点赞和评论 */
  154. .margin-bottom {
  155. padding-bottom: 14px;
  156. background-color: #ddd;
  157. }
  158. .home {
  159. padding-top: 120rpx;
  160. .top-barrage {
  161. width: 100%;
  162. height: 320rpx;
  163. overflow: hidden;
  164. }
  165. .card-bottom {
  166. width: 100%;
  167. .top-tab {
  168. display: flex;
  169. height: 120rpx;
  170. position: fixed;
  171. top: 0;
  172. width: 100%;
  173. z-index: 100;
  174. background-color: #ffffff;
  175. .tab-item {
  176. flex: 1;
  177. color: #999;
  178. border-bottom: 4rpx solid #ececec;
  179. }
  180. .active {
  181. color: var(--mainColor);
  182. border-bottom: 4rpx solid var(--mainColor);
  183. }
  184. }
  185. }
  186. }
  187. </style>