订单列表,进入订单详情,操作之后,返回订单列表,不想全部更新,只想更新这一条数据?
详情页:
updateListRow() {
const { id } = this.data
if (id > 0) {
const pages = getCurrentPages();
const prevPage = pages[pages.length - 2];
prevPage.updateListRow(id);
}
},
列表页
async updateListRow(id) {
let { list } = this.data
const listIndex = list.findIndex((row) => row.id === id)
if (listIndex !== -1) {
let requestParam = { page: 1, rows: 1, id: list[listIndex].id }
const result = await orderModel.list(requestParam)
if (result) {
if (result.list.length === 0) {
list = list.splice(listIndex, 1)
} else {
list[listIndex] = result.list[0]
}
this.setData({ list })
}
}
},