提交 90cdef7e 编写于 作者: H hdx

long-list: 更新API地址

上级 9f81e82c
...@@ -2,23 +2,23 @@ ...@@ -2,23 +2,23 @@
<list-view class="list" @scrolltolower="loadData"> <list-view class="list" @scrolltolower="loadData">
<list-item class="list-item" v-for="(item, index) in dataList" :key="index"> <list-item class="list-item" v-for="(item, index) in dataList" :key="index">
<view class="list-item-icon"> <view class="list-item-icon">
<image class="list-item-icon-image" :src="item.img"></image> <image class="list-item-icon-image" :src="item.author_avatar_link"></image>
</view> </view>
<view class="list-item-fill"> <view class="list-item-fill">
<view class="flex-row"> <view class="flex-row">
<text class="title">{{item.name}}</text> <text class="title">{{item.plugin_name}}</text>
</view> </view>
<view class="description"> <view class="description">
<text class="description-text">{{item.intro}}</text> <text class="description-text">{{item.plugin_intro}}</text>
</view>
<view class="tag-list">
<text class="tag-item" v-for="(item2, index2) in item.tags" :key="index2">{{item2}}</text>
</view> </view>
<!-- <view class="tag-list">
<text class="tag-item" v-for="(item2, index2) in item.tags" :key="index2">{{item2.name}}</text>
</view> -->
<!-- <uts-rate></uts-rate> --> <!-- <uts-rate></uts-rate> -->
<view class="flex-row update-date"> <view class="flex-row update-date">
<text class="update-date-text">更新日期</text> <text class="update-date-text">更新日期</text>
<!-- <text class="update-date-value">{{item.updateDate}}</text> --> <text class="update-date-value">{{item.update_date}}</text>
<!-- <text class="author">Dcloud</text> --> <text class="author">{{item.author_name}}</text>
</view> </view>
</view> </view>
</list-item> </list-item>
...@@ -26,18 +26,22 @@ ...@@ -26,18 +26,22 @@
</template> </template>
<script> <script>
// TODO 临时地址 const SERVER_URL = "https://ext.dcloud.net.cn/plugin/uniappx-plugin-list"
const SERVER_URL = "https://test-ext.dcloud.net.cn/plugin/plugin-list"
const PAGE_SIZE = 10; // 最大值 10 const PAGE_SIZE = 10; // 最大值 10
// TODO 暂不支持tag,更新日期等属性
type ListItem = { type ListItem = {
id : number, plugin_id : number,
img : string, author_avatar_link : string,
name : string, plugin_name : string,
intro : string, plugin_intro : string,
// tags : Array<String>, tags : Array<string>,
// updateDate : string, update_date : string,
author_name : string,
}
type ResponseDataType = {
code : number,
data : ListItem[]
} }
export default { export default {
...@@ -60,29 +64,23 @@ ...@@ -60,29 +64,23 @@
this.loading = true; this.loading = true;
// TODO request data 没有拼接到 url 中,暂时手动拼接
uni.request({ uni.request({
url: SERVER_URL, url: `${SERVER_URL}?page=${this.$currentPage}&page_size=${PAGE_SIZE}`,
data: { data: {
page: this.$currentPage, page: this.$currentPage,
pageSize: PAGE_SIZE page_size: PAGE_SIZE
}, },
dataType: '',
success: (res) => { success: (res) => {
const responseData = res.data as UTSJSONObject const responseData = JSON.parse<ResponseDataType>(res.data as string)!
if (responseData['data'] == null) { const list = responseData.data
return;
} list.forEach((item) => {
this.dataList.push(item)
const responseDataList = responseData['data'] as UTSJSONObject[] })
for (const item in responseDataList) {
this.dataList.push({ this.isEnded = list.length <= 0;
id: item["id"] as number,
img: 'https:' + item["img"] as string,
name: item["name"] as string,
intro: item["intro"] as string,
} as ListItem)
}
this.isEnded = responseDataList.length <= 0;
this.$currentPage++ this.$currentPage++
}, },
...@@ -141,7 +139,7 @@ ...@@ -141,7 +139,7 @@
} }
.description { .description {
margin-top: 5px; margin-top: 3px;
} }
.description-text { .description-text {
...@@ -182,7 +180,7 @@ ...@@ -182,7 +180,7 @@
.author { .author {
font-size: 12px; font-size: 12px;
color: #008000; color: #005000;
margin-left: auto; margin-left: auto;
} }
</style> </style>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册