community.vue 4.4 KB

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