| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 |
- // 列表页
- <template>
- <ws-page :menuIndex="1">
- <section class="group-list">
- <section class="top">
- <section class="info">
- <h3>协作群组</h3>
- <p>适用于云端工作团队共享、管理日报和工时统计等</p>
- </section>
- <nuxt-link to="/group/create">
- <el-button type="primary">创建</el-button>
- </nuxt-link>
- </section>
- <section v-if="list" class="list">
- <nuxt-link
- class="group-item"
- :to="`/group/${item.id}`"
- v-for="(item, index) of list"
- :key="index"
- >
- <section class="imgs" v-if="item.developers.length === 1">
- <template v-for="(developer, idx) of item.developers">
- <img class="img" :src="developer && developer.icon_url" alt="icon_url" :key="idx" />
- </template>
- </section>
- <section class="imgs" v-else-if="item.developers.length === 2">
- <template v-for="(developer, idx) of item.developers">
- <img class="img two" :src="developer && developer.icon_url" alt="icon_url" :key="idx" />
- </template>
- </section>
- <section class="imgs" v-else>
- <template v-for="(developer, idx) of item.developers">
- <img
- v-if="idx < 3"
- class="img three"
- :src="developer && developer.icon_url"
- alt="icon_url"
- :key="idx"
- />
- </template>
- </section>
- <p class="name">{{item.name}}</p>
- <p class="count">{{item.member_num}}人</p>
- </nuxt-link>
- </section>
- <el-pagination
- v-if="pageTotal / pageSize > 1"
- background
- layout="prev, pager, next"
- :total="pageTotal"
- :page-size="pageSize"
- @current-change="changePage"
- ></el-pagination>
- </section>
- </ws-page>
- </template>
- <script>
- import mixinGroup from "@/mixins/group";
- export default {
- head() {
- return {
- title: `云端协作群组-程序员客栈`
- };
- },
- mixins: [mixinGroup],
- data() {
- return {
- list: null,
- pageSize: 15,
- pageTotal: 0,
- currentPage: 1
- };
- },
- mounted() {
- if (this.hasLogined) {
- this.getList();
- } else {
- // 前往登录页
- this.goLogin();
- }
- this.getUserStatus();
- },
- methods: {
- async getList() {
- let res = await this.$axios.$post(`/api/group/list`, {
- page: this.currentPage,
- page_size: this.pageSize
- });
- if (res) {
- this.list = res.data.list;
- this.pageTotal = res.data.total;
- }
- },
- changePage(page) {
- this.currentPage = page;
- this.getList();
- },
- /**
- * 获取用户状态判断前往那个版本
- */
- async getUserStatus() {
- let res = await this.$axios.$post(`/api/user/update_info`);
- }
- }
- };
- </script>
- <style scoped>
- .group-list {
- display: flex;
- flex-direction: column;
- width: 816px;
- padding: 20px;
- background: white;
- }
- .top {
- display: flex;
- justify-content: space-between;
- height: 40px;
- }
- .info {
- display: flex;
- align-items: center;
- }
- .info p {
- margin-left: 12px;
- color: #999;
- font-size: 14px;
- }
- .el-button {
- width: 100px;
- background: var(--mainColor);
- }
- .list {
- display: flex;
- flex-wrap: wrap;
- }
- .group-item {
- display: flex;
- flex-direction: column;
- justify-content: center;
- align-items: center;
- width: 250px;
- height: 220px;
- border-radius: 4px;
- border: 1px solid rgba(220, 223, 230, 1);
- margin-top: 20px;
- font-size: 14px;
- color: #333;
- cursor: pointer;
- margin: 20px 4px 0;
- }
- .group-item:nth-child(n + 2) {
- /* margin-right: 0; */
- }
- .group-item:hover {
- border: 1px solid var(--mainColor);
- }
- .imgs {
- position: relative;
- display: flex;
- justify-content: center;
- align-items: center;
- width: 48px;
- height: 78px;
- }
- .img {
- width: 48px;
- height: 48px;
- border: 2px solid white;
- border-radius: 50%;
- }
- .two {
- position: absolute;
- }
- .two:nth-child(1) {
- top: 0;
- left: 0;
- }
- .two:nth-child(2) {
- top: 30px;
- left: 0;
- }
- .three {
- position: absolute;
- }
- .three:nth-child(1) {
- top: 0;
- left: 0;
- }
- .three:nth-child(2) {
- top: 30px;
- left: -20px;
- }
- .three:nth-child(3) {
- top: 30px;
- left: 20px;
- }
- .name {
- margin: 14px 0 10px;
- }
- .count {
- color: #999;
- }
- .el-pagination {
- margin-top: 20px;
- text-align: center;
- }
- </style>
|