Skip to content

Commit

Permalink
更新首页标题
Browse files Browse the repository at this point in the history
  • Loading branch information
mason369 committed Jan 25, 2023
1 parent 4655e4f commit 3b8341b
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 7 deletions.
8 changes: 8 additions & 0 deletions src/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,11 @@ export const getUserInfo = () => {
url : "/app/v1_0/user"
});
}

//获取用户频道列表
export const getUserChannels = () => {
return request({
method: "GET",
url : "/app/v1_0/user/channels"
});
}
1 change: 0 additions & 1 deletion src/utils/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ request.interceptors.request.use(
if (token && isLoginToken) {
config.headers.Authorization = `Bearer ${isLoginToken}`;
}
console.log(token);
return config;
},
(error) => {
Expand Down
44 changes: 38 additions & 6 deletions src/views/home/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,43 @@
>搜索</van-button
>
</van-nav-bar>
<!-- 文章频道列表 -->
<van-tabs v-model="active" animated>
<van-tab
v-for="item in channels"
:title="item.name"
:key="item.id"
>
{{ item.name }}
</van-tab>
</van-tabs>
</div>
</template>

<script>
export default {};
import { getUserChannels } from "@/api";
export default {
name: "Home",
data() {
return {
// 当前选中的频道
active: 0,
// 频道列表
channels: [],
};
},
created() {
this.loadChannels();
},
methods: {
// 加载频道列表
async loadChannels() {
const { data } = await getUserChannels();
this.channels = data.channels;
console.log(this.channels.name);
},
},
};
</script>

<style scoped lang="scss">
Expand All @@ -30,11 +62,11 @@ export default {};
background-color: #5babfb;
font-size: 14px;
color: #ffffff;
border: none;
.van-icon-search{
color: #ffffff;
font-size: 16px;
}
border: none;
.van-icon-search {
color: #ffffff;
font-size: 16px;
}
}
}
}
Expand Down

0 comments on commit 3b8341b

Please sign in to comment.