提交 8d3caf7e authored 作者: 劳广强's avatar 劳广强

feat: 文章列表页 接入接口

上级 a530a2b0
...@@ -25,19 +25,20 @@ ...@@ -25,19 +25,20 @@
</view> </view>
<view class="buttom_btn"> <view class="buttom_btn">
<view class="btn_box"> <!-- <view class="btn_box">-->
<view :class="[!follow ? 'btn_box_item' : 'item_active']" bindtap="follow"> <!-- <view :class="[!follow ? 'btn_box_item' : 'item_active']" bindtap="follow">-->
<image v-if="!follow" class="btn_icon" mode="aspectFill" src="/static/icon/ic_wz_guanzhu1@2x.png" /> <!-- <image v-if="!follow" class="btn_icon" mode="aspectFill" src="/static/icon/ic_wz_guanzhu1@2x.png" />-->
<image v-else class="btn_icon" mode="aspectFill" src="/static/icon/ic_wz_guanzhu3@2x.png" /> <!-- <image v-else class="btn_icon" mode="aspectFill" src="/static/icon/ic_wz_guanzhu3@2x.png" />-->
</view> <!-- </view>-->
<view :class="[!fabulous ? 'btn_box_item' : 'item_active2']" bindtap="fabulous"> <!-- <view :class="[!fabulous ? 'btn_box_item' : 'item_active2']" bindtap="fabulous">-->
<image v-if="!fabulous" class="btn_icon" mode="aspectFill" src="/static/icon/ic_wz_dianzan1@2x.png" /> <!-- <image v-if="!fabulous" class="btn_icon" mode="aspectFill" src="/static/icon/ic_wz_dianzan1@2x.png" />-->
<image v-else class="btn_icon" mode="aspectFill" src="/static/icon/ic_wz_dianzan3@2x.png" /> <!-- <image v-else class="btn_icon" mode="aspectFill" src="/static/icon/ic_wz_dianzan3@2x.png" />-->
</view> <!-- </view>-->
<button class="btn_box_item" bindtap="showTip"> <!-- <button class="btn_box_item" bindtap="showTip">-->
<image class="btn_icon" mode="aspectFill" src="/static/icon/ic_fenxiang@2x.png" /> <!-- <image class="btn_icon" mode="aspectFill" src="/static/icon/ic_fenxiang@2x.png" />-->
</button> <!-- </button>-->
</view> <!-- </view>-->
<!-- <van-action-sheet v-show="showTip" cancel-text="取消" bind:close="close" bind:cancel="cancelShare">--> <!-- <van-action-sheet v-show="showTip" cancel-text="取消" bind:close="close" bind:cancel="cancelShare">-->
<!-- <view class="share_box">--> <!-- <view class="share_box">-->
<!-- <button open-type="share" class="share_pyq_btn">分享给好友</button>--> <!-- <button open-type="share" class="share_pyq_btn">分享给好友</button>-->
...@@ -46,11 +47,11 @@ ...@@ -46,11 +47,11 @@
<!-- </van-action-sheet>--> <!-- </van-action-sheet>-->
</view> </view>
<view class="share_bg" bindtap="closetipPyq" v-if="tipPyq"> <!-- <view class="share_bg" bindtap="closetipPyq" v-if="tipPyq">-->
<view class="share_bg_box"> <!-- <view class="share_bg_box">-->
<image mode="aspectFill" class="img_pyq_tip" src="/static/img_pyq_tip@2x.png" /> <!-- <image mode="aspectFill" class="img_pyq_tip" src="/static/img_pyq_tip@2x.png" />-->
</view> <!-- </view>-->
</view> <!-- </view>-->
</view> </view>
</template> </template>
......
...@@ -2,20 +2,19 @@ ...@@ -2,20 +2,19 @@
<view> <view>
<view class="article_box"> <view class="article_box">
<view class="article_list"> <view class="article_list">
<view class="article_item" v-for="(item, index) in articleSort" @click="changeArticle(item, index)" :key="item.name"> <view class="article_item" v-for="(item, index) in articleTypeList" @click="changeArticle(item, index)" :key="item.name">
<view :class="[articleIdx === index ? 'article_active' : 'article_item_name']">{{ item.name }}</view> <view :class="[articleIdx === index ? 'article_active' : 'article_item_name']">{{ item.name }}</view>
<view :class="[articleIdx === index ? 'task_line' : 'task_line_none']"></view> <view :class="[articleIdx === index ? 'task_line' : 'task_line_none']"></view>
</view> </view>
</view> </view>
</view> </view>
<view class="line"></view> <view class="line"></view>
<view v-if="!articleList.length" class="data_none"> <view v-if="!articleLoading && !articleList.length" class="data_none">
<image mode="aspectFill" class="data_img" src="/static/pic_wushuju@2x.png" /> <image mode="aspectFill" class="data_img" src="/static/pic_wushuju@2x.png" />
<view class="data_title">暂无数据</view> <view class="data_title">暂无数据</view>
</view> </view>
<view class="article_boxs"> <view class="article_boxs">
<view v-for="(item, index) in articleList" :key="item.index" style="width: 100%"> <view v-for="(item, index) in articleList" :key="item.index" style="width: 100%" @click="onArticleClick(item, index)">
<navigator hover-class="none" url="/package-one/article-detail/article-detail?id=item.id" />
<view class="article_container" style="width: 100%"> <view class="article_container" style="width: 100%">
<view class="article_left"> <view class="article_left">
<view class="article_title">{{ item.title }}</view> <view class="article_title">{{ item.title }}</view>
...@@ -49,19 +48,50 @@ import { articleSort, articleList } from '@/pages/article-list/mock'; ...@@ -49,19 +48,50 @@ import { articleSort, articleList } from '@/pages/article-list/mock';
export default { export default {
data() { data() {
return { return {
articleSort, articleTypeList: [],
articleList, articleTypeId: 0,
articleList: [],
articleIdx: 0, articleIdx: 0,
articleLoading: true,
id: null, id: null,
ifShare: true, ifShare: true,
is_fabulous: null, // 点赞 is_fabulous: null, // 点赞
is_follow: null, // 关注 is_follow: null, // 关注
}; };
}, },
onLoad(query) {
this.fetchArticleTypeData();
},
methods: { methods: {
async fetchArticleTypeData() {
const { list } = await uni.$u.http.get('/api/app/articletype/list');
this.articleTypeList = list;
this.articleTypeId = list[0]?.id ?? 0;
this.fetchArticleData();
},
async fetchArticleData() {
this.articleLoading = true;
const { list } = await uni.$u.http.get('/api/article/list', {
params: {
article_type_id: this.articleTypeId,
},
});
this.articleList = list;
this.articleLoading = false;
},
async changeArticle(item, index) { async changeArticle(item, index) {
if (this.articleIdx === index) return; if (this.articleIdx === index) return;
this.articleIdx = index; this.articleIdx = index;
this.articleTypeId = item.id;
this.fetchArticleData();
},
onArticleClick(item, index) {
uni.$u.route({ url: 'pages/article-detail/index', params: { id: item.id } });
}, },
}, },
}; };
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论