flat: 暂存
This commit is contained in:
@@ -6,8 +6,17 @@ import {
|
||||
noticeCount,
|
||||
noticeList,
|
||||
noticeRead,
|
||||
noticeRemove
|
||||
noticeRemove,
|
||||
noticeStatus1,
|
||||
noticeStatus2,
|
||||
noticeStatus3,
|
||||
settingRead1,
|
||||
settingRead2,
|
||||
settingRead3,
|
||||
} from '@/api/news.js'
|
||||
import {
|
||||
tuiJianMission
|
||||
} from '@/api/mission.js';
|
||||
import website from '@/config/website.js'
|
||||
const size = 20
|
||||
const handler = {
|
||||
@@ -18,17 +27,26 @@ const handler = {
|
||||
remove: noticeRemove
|
||||
},
|
||||
'1': {
|
||||
count: inviteCount,
|
||||
getList: inviteList,
|
||||
read: inviteRead,
|
||||
remove: inviteRemove
|
||||
count: noticeStatus1,
|
||||
getList: tuiJianMission,
|
||||
read: settingRead1
|
||||
},
|
||||
'2': {
|
||||
count: noticeStatus2,
|
||||
read: settingRead2
|
||||
},
|
||||
'3': {
|
||||
count: noticeStatus3,
|
||||
read: settingRead3
|
||||
}
|
||||
}
|
||||
|
||||
function getCount(data) {
|
||||
let sum = 0
|
||||
for (let key in data) {
|
||||
sum += data[key]
|
||||
if (data[key] >= 0) {
|
||||
sum += data[key]
|
||||
}
|
||||
}
|
||||
return sum
|
||||
}
|
||||
@@ -101,14 +119,14 @@ const news = {
|
||||
listDesc: 'companyName',
|
||||
},
|
||||
navigateTo(item, dispatch) {
|
||||
dispatch('readNew', {
|
||||
dispatch('readNew2', {
|
||||
key: '1',
|
||||
id: item.id
|
||||
id: item.noticeId
|
||||
})
|
||||
uni.navigateTo({
|
||||
url: `/pages/projectInfo/projectInfo?type=1&missionNo=${encodeURIComponent(item.missionNo)}&id=${encodeURIComponent(item.id)}`
|
||||
})
|
||||
}
|
||||
// uni.navigateTo({
|
||||
// url: `/pages/projectInfo/projectInfo?type=1&missionNo=${encodeURIComponent(item.missionNo)}&id=${encodeURIComponent(item.id)}`
|
||||
// })
|
||||
},
|
||||
},
|
||||
"2": {
|
||||
id: "1",
|
||||
@@ -132,18 +150,18 @@ const news = {
|
||||
listDesc: 'companyName',
|
||||
},
|
||||
navigateTo(item, dispatch) {
|
||||
dispatch('readNew', {
|
||||
key: '1',
|
||||
id: item.id
|
||||
})
|
||||
uni.navigateTo({
|
||||
url: `/pages/projectInfo/projectInfo?type=1&missionNo=${encodeURIComponent(item.missionNo)}&id=${encodeURIComponent(item.id)}`
|
||||
dispatch('readNew2', {
|
||||
key: '2',
|
||||
id: item.noticeId
|
||||
})
|
||||
// uni.navigateTo({
|
||||
// url: `/pages/projectInfo/projectInfo?type=1&missionNo=${encodeURIComponent(item.missionNo)}&id=${encodeURIComponent(item.id)}`
|
||||
// })
|
||||
}
|
||||
},
|
||||
"4": {
|
||||
"3": {
|
||||
id: "1",
|
||||
uid: "4",
|
||||
uid: "3",
|
||||
title: "推送政策指南",
|
||||
icon: "../../static/img/zhengce.svg",
|
||||
page: {
|
||||
@@ -163,19 +181,21 @@ const news = {
|
||||
listDesc: 'companyName',
|
||||
},
|
||||
navigateTo(item, dispatch) {
|
||||
dispatch('readNew', {
|
||||
key: '1',
|
||||
id: item.id
|
||||
})
|
||||
uni.navigateTo({
|
||||
url: `/pages/projectInfo/projectInfo?type=1&missionNo=${encodeURIComponent(item.missionNo)}&id=${encodeURIComponent(item.id)}`
|
||||
dispatch('readNew2', {
|
||||
key: '3',
|
||||
id: item.noticeId
|
||||
})
|
||||
// uni.navigateTo({
|
||||
// url: `/pages/projectInfo/projectInfo?type=1&missionNo=${encodeURIComponent(item.missionNo)}&id=${encodeURIComponent(item.id)}`
|
||||
// })
|
||||
}
|
||||
}
|
||||
},
|
||||
unread: {
|
||||
"0": 0,
|
||||
"1": 0
|
||||
"1": 0,
|
||||
"2": 0,
|
||||
"3": 0,
|
||||
},
|
||||
allUnread: 0,
|
||||
dic: {}
|
||||
@@ -204,6 +224,7 @@ const news = {
|
||||
}) {
|
||||
for (let key in handler) {
|
||||
handler[key].count().then((result) => {
|
||||
console.log('result', result)
|
||||
commit('SET_UNREADNUM', {
|
||||
id: key,
|
||||
count: result
|
||||
@@ -223,16 +244,33 @@ const news = {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
handler[id].getList(current, page.size).then(res => {
|
||||
const data = res.data.data;
|
||||
commit('ADD_NEWS_DATA', {
|
||||
id,
|
||||
data: data.records,
|
||||
current,
|
||||
total: data.total
|
||||
})
|
||||
resolve(res)
|
||||
}).catch(reject)
|
||||
if (!handler[id].getList) {
|
||||
return
|
||||
}
|
||||
if (id === '1' || id === '2') {
|
||||
handler[id].getList(['1'], id === '1' ? 0 : 1).then(res => {
|
||||
const data = res.data.data;
|
||||
commit('ADD_NEWS_DATA', {
|
||||
id,
|
||||
data: data.records,
|
||||
current,
|
||||
total: data.total
|
||||
})
|
||||
resolve(res)
|
||||
}).catch(reject)
|
||||
} else {
|
||||
handler[id].getList(current, page.size).then(res => {
|
||||
const data = res.data.data;
|
||||
commit('ADD_NEWS_DATA', {
|
||||
id,
|
||||
data: data.records,
|
||||
current,
|
||||
total: data.total
|
||||
})
|
||||
resolve(res)
|
||||
}).catch(reject)
|
||||
}
|
||||
|
||||
})
|
||||
},
|
||||
removeNew({
|
||||
@@ -253,6 +291,22 @@ const news = {
|
||||
handler[key].remove(id).then(resolve, reject)
|
||||
})
|
||||
},
|
||||
readNew2({
|
||||
commit
|
||||
}, {
|
||||
key,
|
||||
id
|
||||
}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
handler[key].read({
|
||||
ids: id
|
||||
}).then(() => {
|
||||
commit('changeUnread', {
|
||||
key
|
||||
})
|
||||
})
|
||||
})
|
||||
},
|
||||
readNew({
|
||||
commit
|
||||
}, {
|
||||
@@ -275,13 +329,29 @@ const news = {
|
||||
commit,
|
||||
dispatch
|
||||
}) {
|
||||
console.log('触发2')
|
||||
dispatch('newsInit').then(() => {
|
||||
startRefreshToken(dispatch);
|
||||
})
|
||||
},
|
||||
readUnread({
|
||||
commit
|
||||
}, {
|
||||
key,
|
||||
}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
})
|
||||
}
|
||||
},
|
||||
mutations: {
|
||||
changeUnread: (state, {
|
||||
key
|
||||
}) => {
|
||||
if (state.unread[key]) {
|
||||
state.unread[key]--
|
||||
state.allUnread--
|
||||
}
|
||||
},
|
||||
SET_UNREADNUM: (state, {
|
||||
id,
|
||||
count
|
||||
@@ -302,6 +372,7 @@ const news = {
|
||||
current,
|
||||
total
|
||||
}) => {
|
||||
console.log(data)
|
||||
data.forEach(item => {
|
||||
state.dic[item.id] = item
|
||||
})
|
||||
@@ -333,7 +404,9 @@ const news = {
|
||||
key,
|
||||
id
|
||||
}) => {
|
||||
// http://localhost:1888/api/jobslink-api/desk/notice/noticeStatus
|
||||
const readProp = state.data[key].prop['isRead']
|
||||
console.log(state.dic, id, readProp)
|
||||
if (state.dic[id][readProp] === 0) {
|
||||
state.dic[id][readProp] = 1
|
||||
state.unread[key]--
|
||||
|
||||
Reference in New Issue
Block a user