日照项目的居民端小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

148 lines
2.8 KiB

// pages/vocal/components/list.js
// pages/vocal/components/list.js
import { wxNavigateTo, wxRequestPost } from "@utils/promise-wx-api";
const app = getApp();
Component({
/**
* 组件的属性列表
*/
properties: {
listParams: {
type: Object,
value: {
agencyId: "",
},
},
listUrl: {
type: String,
value: "",
},
listIsMock: {
type: Boolean,
value: false,
},
},
/**
* 组件的初始数据
*/
data: {
total: 1,
num: 1,
moreTips: "暂无数据",
refresherIsTriggered: false,
query: {
agencyId: "",
pageNo: 1,
pageSize: 20,
},
list: [],
isNone: false,
},
observers: {
},
// lifetimes: {
// ,
// },
// pageLifetimes: {
// show() {
// console.log("data22", this.data.list);
// },
// },
ready() {
this.initList()
},
/**
* 组件的方法列表
*/
methods: {
refresh() {
// setTimeout(() => {
// this.setData({
// refresherIsTriggered: false,
// });
// }, 1500);
this.setData({ "query.pageNo": 1, isNone: false });
this.initList();
},
async initList() {
this.setData({
["query.agencyId"]: app.globalData.agencyId,
});
let { list, query, isNone } = this.data;
const { listUrl } = this.properties;
if (isNone) return;
this.setData({
moreTips: "正在加载……",
});
const {
data: {
data: { code, data },
},
msg,
} = await wxRequestPost(listUrl, query, {
isMock: false,
// isQuiet: true
});
if (msg === "success" && code === 0) {
if (query.pageNo === 1) {
list = [...data.list];
} else {
list = [...list, ...data.list];
}
query.pageNo += 1;
if (data.list.length < query.pageSize) {
isNone = true;
}
}
setTimeout(() => {
this.setData({
refresherIsTriggered: false,
});
}, 1500);
this.setData({ list, query, isNone });
if (isNone) {
this.setData({
moreTips: "没有更多了",
});
} else {
this.setData({
moreTips: "上拉加载更多",
});
}
},
getMore() {
console.log("上拉加载更多-----------------");
this.initList();
},
handleBindItem(e) {
const {
currentTarget: {
dataset: { id },
},
} = e;
wxNavigateTo("/subpages/partyHelper/pages/elegant/detail", {
id: id,
});
},
},
});