index.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. // 列表页
  2. <template>
  3. <ws-page :menuIndex="1">
  4. <section class="group-list">
  5. <section class="top">
  6. <section class="info">
  7. <h3>协作群组</h3>
  8. <p>适用于云端工作团队共享、管理日报和工时统计等</p>
  9. </section>
  10. <nuxt-link to="/group/create">
  11. <el-button type="primary">创建</el-button>
  12. </nuxt-link>
  13. </section>
  14. <section v-if="list" class="list">
  15. <nuxt-link
  16. class="group-item"
  17. :to="`/group/${item.id}`"
  18. v-for="(item, index) of list"
  19. :key="index"
  20. >
  21. <section class="imgs" v-if="item.developers.length === 1">
  22. <template v-for="(developer, idx) of item.developers">
  23. <img class="img" :src="developer && developer.icon_url" alt="icon_url" :key="idx" />
  24. </template>
  25. </section>
  26. <section class="imgs" v-else-if="item.developers.length === 2">
  27. <template v-for="(developer, idx) of item.developers">
  28. <img class="img two" :src="developer && developer.icon_url" alt="icon_url" :key="idx" />
  29. </template>
  30. </section>
  31. <section class="imgs" v-else>
  32. <template v-for="(developer, idx) of item.developers">
  33. <img
  34. v-if="idx < 3"
  35. class="img three"
  36. :src="developer && developer.icon_url"
  37. alt="icon_url"
  38. :key="idx"
  39. />
  40. </template>
  41. </section>
  42. <p class="name">{{item.name}}</p>
  43. <p class="count">{{item.member_num}}人</p>
  44. </nuxt-link>
  45. </section>
  46. <el-pagination
  47. v-if="pageTotal / pageSize > 1"
  48. background
  49. layout="prev, pager, next"
  50. :total="pageTotal"
  51. :page-size="pageSize"
  52. @current-change="changePage"
  53. ></el-pagination>
  54. </section>
  55. </ws-page>
  56. </template>
  57. <script>
  58. import mixinGroup from "@/mixins/group";
  59. export default {
  60. head() {
  61. return {
  62. title: `云端协作群组-程序员客栈`
  63. };
  64. },
  65. mixins: [mixinGroup],
  66. data() {
  67. return {
  68. list: null,
  69. pageSize: 15,
  70. pageTotal: 0,
  71. currentPage: 1
  72. };
  73. },
  74. mounted() {
  75. if (this.hasLogined) {
  76. this.getList();
  77. } else {
  78. // 前往登录页
  79. this.goLogin();
  80. }
  81. this.getUserStatus();
  82. },
  83. methods: {
  84. async getList() {
  85. let res = await this.$axios.$post(`/api/group/list`, {
  86. page: this.currentPage,
  87. page_size: this.pageSize
  88. });
  89. if (res) {
  90. this.list = res.data.list;
  91. this.pageTotal = res.data.total;
  92. }
  93. },
  94. changePage(page) {
  95. this.currentPage = page;
  96. this.getList();
  97. },
  98. /**
  99. * 获取用户状态判断前往那个版本
  100. */
  101. async getUserStatus() {
  102. let res = await this.$axios.$post(`/api/user/update_info`);
  103. }
  104. }
  105. };
  106. </script>
  107. <style scoped>
  108. .group-list {
  109. display: flex;
  110. flex-direction: column;
  111. width: 816px;
  112. padding: 20px;
  113. background: white;
  114. }
  115. .top {
  116. display: flex;
  117. justify-content: space-between;
  118. height: 40px;
  119. }
  120. .info {
  121. display: flex;
  122. align-items: center;
  123. }
  124. .info p {
  125. margin-left: 12px;
  126. color: #999;
  127. font-size: 14px;
  128. }
  129. .el-button {
  130. width: 100px;
  131. background: var(--mainColor);
  132. }
  133. .list {
  134. display: flex;
  135. flex-wrap: wrap;
  136. }
  137. .group-item {
  138. display: flex;
  139. flex-direction: column;
  140. justify-content: center;
  141. align-items: center;
  142. width: 250px;
  143. height: 220px;
  144. border-radius: 4px;
  145. border: 1px solid rgba(220, 223, 230, 1);
  146. margin-top: 20px;
  147. font-size: 14px;
  148. color: #333;
  149. cursor: pointer;
  150. margin: 20px 4px 0;
  151. }
  152. .group-item:nth-child(n + 2) {
  153. /* margin-right: 0; */
  154. }
  155. .group-item:hover {
  156. border: 1px solid var(--mainColor);
  157. }
  158. .imgs {
  159. position: relative;
  160. display: flex;
  161. justify-content: center;
  162. align-items: center;
  163. width: 48px;
  164. height: 78px;
  165. }
  166. .img {
  167. width: 48px;
  168. height: 48px;
  169. border: 2px solid white;
  170. border-radius: 50%;
  171. }
  172. .two {
  173. position: absolute;
  174. }
  175. .two:nth-child(1) {
  176. top: 0;
  177. left: 0;
  178. }
  179. .two:nth-child(2) {
  180. top: 30px;
  181. left: 0;
  182. }
  183. .three {
  184. position: absolute;
  185. }
  186. .three:nth-child(1) {
  187. top: 0;
  188. left: 0;
  189. }
  190. .three:nth-child(2) {
  191. top: 30px;
  192. left: -20px;
  193. }
  194. .three:nth-child(3) {
  195. top: 30px;
  196. left: 20px;
  197. }
  198. .name {
  199. margin: 14px 0 10px;
  200. }
  201. .count {
  202. color: #999;
  203. }
  204. .el-pagination {
  205. margin-top: 20px;
  206. text-align: center;
  207. }
  208. </style>