訂單列表,進入訂單詳情朵纷,操作之后炭臭,返回訂單列表,不想全部更新袍辞,只想更新這一條數據鞋仍?
詳情頁:
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 })
? ? ? ? ? ? }
? ? ? ? }
? ? },