community.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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. <publish :title="title" :is_upload="true" @hideModal="hideModal" @getRefresh="getRefresh" :cate_id="cate_id" :type="type" :type_id="type_id"></publish>
  19. </view>
  20. </view>
  21. </template>
  22. <script>
  23. import publish 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. code : {
  36. type : String,
  37. default : ''
  38. },
  39. param : {},
  40. index : 0
  41. },
  42. data() {
  43. return {
  44. title : '发表新话题',
  45. show : false,
  46. button_show : true,
  47. fetch : {
  48. cate : [],
  49. info : [],
  50. },
  51. cate_id : 0,
  52. activeTab: 0,
  53. loadingType: 3,
  54. };
  55. },
  56. mounted() {
  57. this.type = this.param['type'];
  58. this.type_id = this.param['type_id'] ? this.param['type_id'] : this.content_id;
  59. this.getData();
  60. },
  61. methods:{
  62. getRefresh : function(cate_id, type, type_id, content) {
  63. this.getInfo(cate_id, 1);
  64. },
  65. getData : function() {
  66. var self = this;
  67. this.Dever.get(this, 'app/community/?l=api.category', {code:this.code, content_id:this.content_id,noloading:1}, function(t) {
  68. if (t && t.cate.length > 0 && t.cate[self.activeTab]) {
  69. self.getInfo(t.cate[self.activeTab].id, 1);
  70. }
  71. });
  72. },
  73. getInfo : function(cate_id, page) {
  74. var self = this;
  75. if (!cate_id) {
  76. cate_id = self.cate_id;
  77. }
  78. if(page != 1 && self.loadingType != 3){return ;}
  79. self.loadingType = 1;
  80. self.cate_id = cate_id;
  81. this.Dever.page([page, 'info'], this, 'app/community/?l=api.info', {cate_id:cate_id, type:this.type, type_id:this.type_id,noloading:1}, function(t) {
  82. if (self.Dever.pageData.status == 1) {
  83. self.loadingType = 3;
  84. } else {
  85. self.loadingType = 2;
  86. }
  87. if (page == 1 && !self.Dever.pageData.total) {
  88. self.fetch.info = [];
  89. }
  90. self.hideModal();
  91. });
  92. },
  93. handleTab : function(index) {
  94. if (this.activeTab == index) {
  95. return;
  96. }
  97. this.activeTab = index;
  98. this.getInfo(this.fetch.cate[this.activeTab].id, 1);
  99. },
  100. showModal : function () {
  101. this.show = true;
  102. this.button_show = false;
  103. },
  104. hideModal : function () {
  105. this.show = false;
  106. this.button_show = true;
  107. },
  108. },
  109. components:{
  110. publish
  111. }
  112. }
  113. </script>
  114. <style lang="less" scoped>
  115. page {
  116. --mainColor: #435257;
  117. --activeColor: #36b39b;
  118. }
  119. view {
  120. box-sizing: border-box;
  121. }
  122. .scroll-wrapper {
  123. width:100%;
  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: 0rpx;
  156. background-color: #ddd;
  157. border: 1px solid #bababa;
  158. box-shadow: 2px 2px 10px #bababa;
  159. }
  160. .home {
  161. padding-top: 120rpx;
  162. .top-barrage {
  163. width: 100%;
  164. height: 320rpx;
  165. overflow: hidden;
  166. }
  167. .card-bottom {
  168. width: 100%;
  169. .top-tab {
  170. display: flex;
  171. height: 120rpx;
  172. position: fixed;
  173. top: 0;
  174. left: 0;
  175. width: 100%;
  176. z-index: 100;
  177. background-color: #ffffff;
  178. .tab-item {
  179. flex: 1;
  180. color: #999;
  181. border-bottom: 4rpx solid #ececec;
  182. }
  183. .active {
  184. color: var(--mainColor);
  185. border-bottom: 4rpx solid var(--mainColor);
  186. }
  187. }
  188. }
  189. }
  190. </style>