功能:同步小程序流程

This commit is contained in:
xiaowang
2026-05-23 18:45:41 +08:00
parent 844516988b
commit 30ae763e18
117 changed files with 8823 additions and 76 deletions
@@ -1,12 +1,36 @@
/**
* Purpose: commentApi supports index.js by holding or executing the comment api page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const commentApi = require('../../api/comment')
Page({
/**
* Purpose: data supports index.js by holding or executing the data page or API role.
* Usage: import, call, read, or update this page-data from the owning page/module while preserving the surrounding loading and permission flow.
*/
data: {
/**
* Purpose: loading supports index.js by holding or executing the loading page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
loading: false,
/**
* Purpose: keyword supports index.js by holding or executing the keyword page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
keyword: '',
/**
* Purpose: comments supports index.js by holding or executing the comments page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
comments: []
},
/**
* Purpose: onShow supports index.js by holding or executing the on show page or API role.
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
*/
onShow() {
this.loadComments()
},
@@ -16,8 +40,16 @@ Page({
wx.stopPullDownRefresh()
},
/**
* Purpose: handleKeywordInput supports index.js by holding or executing the handle keyword input page or API role.
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
*/
handleKeywordInput(event) {
this.setData({
/**
* Purpose: keyword supports index.js by holding or executing the keyword page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
keyword: event.detail.value
})
},
@@ -26,14 +58,30 @@ Page({
this.setData({ loading: true })
try {
const comments = await commentApi.listComments({
/**
* Purpose: keyword supports index.js by holding or executing the keyword page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
keyword: this.data.keyword || undefined
})
this.setData({
/**
* Purpose: comments supports index.js by holding or executing the comments page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
comments: Array.isArray(comments) ? comments : []
})
} catch (error) {
wx.showToast({
/**
* Purpose: title supports index.js by holding or executing the title page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
title: error.message || '评论加载失败',
/**
* Purpose: icon supports index.js by holding or executing the icon page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
icon: 'none'
})
} finally {
@@ -41,19 +89,43 @@ Page({
}
},
/**
* Purpose: handleSearch supports index.js by holding or executing the handle search page or API role.
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
*/
handleSearch() {
this.loadComments()
},
/**
* Purpose: handleDelete supports index.js by holding or executing the handle delete page or API role.
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
*/
handleDelete(event) {
const id = event.currentTarget.dataset.id
if (!id) {
return
}
wx.showModal({
/**
* Purpose: title supports index.js by holding or executing the title page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
title: '删除评论',
/**
* Purpose: content supports index.js by holding or executing the content page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
content: '确认删除这条评论?',
/**
* Purpose: confirmText supports index.js by holding or executing the confirm text page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
confirmText: '删除',
/**
* Purpose: success supports index.js by holding or executing the success page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
success: async res => {
if (!res.confirm) {
return