|
|
@@ -345,9 +345,10 @@ import ArticleBookshelf from '../../components/ArticleBookshelf.vue'
|
|
|
import FamilyChallengeCard from '../../components/FamilyChallengeCard.vue'
|
|
|
import IntentPicker from '../../components/intent-picker.vue'
|
|
|
import JourneyCard from '../../components/journey-card.vue'
|
|
|
-import { acceptParentInvite, productList, getActivityList, getFeaturedArticles, getFamilyEnergySandbox, getVisibleFamilyMembers, getChildren, getChallengeList, switchToFamilyMember, getMyMembership, updateChallengeProgress, respondChallenge, getTodayTasks, completeTask as completeTaskApi, getTodayParentTasks, completeParentTask as completeParentTaskApi, getTaskHistory, getNotices, getUserIntent, chooseUserIntent } from '../../utils/api.js'
|
|
|
+import { acceptParentInvite, productList, getActivityList, getFeaturedArticles, getFamilyEnergySandbox, getVisibleFamilyMembers, getChildren, getChallengeList, switchToFamilyMember, getMyMembership, updateChallengeProgress, respondChallenge, getTodayTasks, completeTask as completeTaskApi, getTodayParentTasks, completeParentTask as completeParentTaskApi, getTaskHistory, getNotices, getNotificationList, getUserIntent, chooseUserIntent } from '../../utils/api.js'
|
|
|
import nav from '../../utils/nav.js'
|
|
|
import config from '@/config.js'
|
|
|
+import { parseDate } from '../../utils/format.js'
|
|
|
|
|
|
export default {
|
|
|
components: {
|
|
|
@@ -545,6 +546,7 @@ export default {
|
|
|
self.loadTodayTasks()
|
|
|
self.loadFamilyFeed()
|
|
|
self.loadNotices()
|
|
|
+ self.loadNotifications()
|
|
|
}).catch(function(e) {
|
|
|
console.log('获取孩子列表失败', e)
|
|
|
self.childrenChecked = true
|
|
|
@@ -684,6 +686,34 @@ export default {
|
|
|
}
|
|
|
}).catch(function() {})
|
|
|
},
|
|
|
+ // W3: 用户通知入动态(未读优先显示在 familyFeed 顶部)
|
|
|
+ loadNotifications: function() {
|
|
|
+ var self = this
|
|
|
+ getNotificationList().then(function(res) {
|
|
|
+ if (res.code === 200 && res.data) {
|
|
|
+ var notifications = res.data.map(function(n) {
|
|
|
+ var timeStr = ''
|
|
|
+ if (n.createdAt) {
|
|
|
+ var d = parseDate(n.createdAt)
|
|
|
+ if (d) {
|
|
|
+ timeStr = (d.getMonth() + 1) + '月' + d.getDate() + '日'
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ text: '📬 ' + n.title,
|
|
|
+ time: timeStr,
|
|
|
+ type: 'notification',
|
|
|
+ unread: (n.isRead === 0),
|
|
|
+ notice: n
|
|
|
+ }
|
|
|
+ })
|
|
|
+ var unread = notifications.filter(function(n) { return n.unread })
|
|
|
+ var read = notifications.filter(function(n) { return !n.unread })
|
|
|
+ // 未读在前,已读在后,合并到 familyFeed 顶部
|
|
|
+ self.familyFeed = unread.concat(read, self.familyFeed).slice(0, 10)
|
|
|
+ }
|
|
|
+ }).catch(function() {})
|
|
|
+ },
|
|
|
quickCompleteTask: function(task) {
|
|
|
var self = this
|
|
|
completeTaskApi(task.id, self.currentChildId, '').then(function(res) {
|