community.vue 4.7 KB

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