功能:同步小程序流程
This commit is contained in:
@@ -1,16 +1,49 @@
|
||||
/**
|
||||
* Purpose: userApi supports index.js by holding or executing the user 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 userApi = require('../../api/user')
|
||||
/**
|
||||
* Purpose: navigation supports index.js by holding or executing the navigation 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 navigation = require('../../utils/navigation')
|
||||
const { previewImagesSafely } = require('../../utils/file')
|
||||
|
||||
/**
|
||||
* notifications page logic.
|
||||
* Call guide: page data drives the WXML template, and each method is called by user events or lifecycle callbacks.
|
||||
*/
|
||||
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: messages supports index.js by holding or executing the messages 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.
|
||||
*/
|
||||
messages: [],
|
||||
/**
|
||||
* Purpose: unreadCount supports index.js by holding or executing the unread count 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.
|
||||
*/
|
||||
unreadCount: 0,
|
||||
/**
|
||||
* Purpose: detailVisible supports index.js by holding or executing the detail visible 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.
|
||||
*/
|
||||
detailVisible: false,
|
||||
/**
|
||||
* Purpose: currentMessage supports index.js by holding or executing the current message 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.
|
||||
*/
|
||||
currentMessage: null
|
||||
},
|
||||
|
||||
@@ -31,12 +64,28 @@ Page({
|
||||
const messages = await userApi.listMyMessages()
|
||||
const list = Array.isArray(messages) ? messages : []
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: messages supports index.js by holding or executing the messages 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.
|
||||
*/
|
||||
messages: list,
|
||||
/**
|
||||
* Purpose: unreadCount supports index.js by holding or executing the unread count 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.
|
||||
*/
|
||||
unreadCount: list.filter(item => item.readStatus !== 1).length
|
||||
})
|
||||
} 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 {
|
||||
@@ -54,26 +103,43 @@ Page({
|
||||
if (!item) {
|
||||
return
|
||||
}
|
||||
if (item.actionPath) {
|
||||
const actionTarget = navigation.buildMessageActionPath(item)
|
||||
if (actionTarget) {
|
||||
try {
|
||||
if (item.readStatus !== 1) {
|
||||
await userApi.markMessageRead(item.id)
|
||||
}
|
||||
const opened = await navigation.openActionPath(item.actionPath)
|
||||
const opened = await navigation.openActionPath(actionTarget)
|
||||
await this.loadMessages()
|
||||
if (opened) {
|
||||
return
|
||||
}
|
||||
} 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'
|
||||
})
|
||||
return
|
||||
}
|
||||
}
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: currentMessage supports index.js by holding or executing the current message 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.
|
||||
*/
|
||||
currentMessage: item,
|
||||
/**
|
||||
* Purpose: detailVisible supports index.js by holding or executing the detail visible 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.
|
||||
*/
|
||||
detailVisible: true
|
||||
})
|
||||
/**
|
||||
@@ -86,7 +152,15 @@ Page({
|
||||
await this.loadMessages()
|
||||
} 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'
|
||||
})
|
||||
}
|
||||
@@ -99,7 +173,15 @@ Page({
|
||||
*/
|
||||
handleCloseDetail() {
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: detailVisible supports index.js by holding or executing the detail visible 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.
|
||||
*/
|
||||
detailVisible: false,
|
||||
/**
|
||||
* Purpose: currentMessage supports index.js by holding or executing the current message 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.
|
||||
*/
|
||||
currentMessage: null
|
||||
})
|
||||
},
|
||||
@@ -117,12 +199,13 @@ Page({
|
||||
if (!imageUrl) {
|
||||
return
|
||||
}
|
||||
wx.previewImage({
|
||||
current: imageUrl,
|
||||
urls: [imageUrl]
|
||||
})
|
||||
previewImagesSafely(imageUrl, [imageUrl])
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: noop supports index.js by holding or executing the noop 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.
|
||||
*/
|
||||
noop() {},
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user