community.vue 4.8 KB

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