提交 01083056 编写于 作者: W wanganxp

微调

上级 a377db11
<template>
<view>
<page-head :title="title"></page-head>
<view class="uni-hello-text">
<text class="hello-text">当前示例基于操作系统自身定位能力,暂不支持gcj标准,逆地理信息等功能,如果需要类似能力可以使用腾讯定位等三方定位服务,参考示例:</text>
<view style="padding: 4px;">
<text class="hello-text">
真机运行标准基座仅包含系统定位,即system。\n
部分手机因gms兼容不好可能导致无法定位。\n
gcj国标、逆地理信息等功能需三方sdk定位。如果需要类似能力可以下载腾讯定位插件,打包自定义基座。参考示例:</text>
<u-link :href="'https://gitcode.net/dcloud/uni-api/'" :text="'https://gitcode.net/dcloud/uni-api/'" :inWhiteList="true"></u-link>
</view>
......
......@@ -50,7 +50,7 @@
};
},
onLoad() {
this.pageVisible = true;
this.pageVisible = true; //设这个变量是为了避免联网结束后页面已经关闭,此时还继续执行回调逻辑的问题。不是必须的
this.getBanner();
this.getList();
},
......@@ -85,24 +85,25 @@
},
getList() {
let url = "https://unidemo.dcloud.net.cn/api/news?column=id,post_id,title,author_name,cover,published_at";
if (this.last_id != "") {
const minId = (this.last_id).toInt();
/* if (this.last_id != "") {
const minId = parseInt((this.last_id))
const time = new Date().getTime() + '';
const pageSize = 10;
url = url + "&minId=" + minId + "&time=" + time + "&pageSize=" + pageSize;
}
} */
uni.request({
uni.request<Item[]>({
url: url,
method:"GET",
success: (data) => {
success: (res) => {
if(this.pageVisible){
if (data.statusCode == 200) {
const result = data.data as UTSJSONObject[]
if (res.statusCode == 200) {
console.log(res);
const result = res.data
if(result != null){
let list = this.setTime(result);
this.listData = list.concat(this.listData);
this.last_id = listData[0].id + "";
this.listData = result //因本接口没有更多分页数据,所以重新赋值。正常有分页的列表应该如下面push方式增加数组项
// this.listData.push(...result)
// this.last_id = this.listData[0].id + "";
}
this.refresherTriggered = false;
}
......@@ -134,21 +135,6 @@
url: '/pages/template/list-news/detail/detail?post_id=' + post_id + "&cover=" + cover + "&title=" + title
});
},
setTime(items: UTSJSONObject[]): Item[] {
let newItems = [] as Item[];
for(const item in items){
const e = item;
newItems.push({
author_name: e["author_name"] as string,
cover: e["cover"] as string,
id: e["id"] as number,
post_id: e["post_id"] as string,
published_at: e["published_at"] as string,
title: e["title"] as string
} as Item);
}
return newItems;
},
onRefresherrefresh() {
if(this.pageVisible){
this.refresherTriggered = true
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册