falt:暂存

This commit is contained in:
Apcallover
2024-04-29 11:01:41 +08:00
parent e1580de161
commit 4d8d0335fb
10 changed files with 710 additions and 578 deletions

View File

@@ -7,7 +7,17 @@ import {
//轮播图
export const getEmploymentSurveyManage = (params) => request({
url: '/api/jobslink-api/content/employmentSurveyManage/list',
url: '/api/jobslink-api/content/questionnaireSurveyInfo/list',
method: 'get',
params
});
export const queryByIdQuestionnaireSurveyInfo = (params) => request({
url: '/api/jobslink-api/content/questionnaireSurveyInfo/queryById',
method: 'get',
params
});
export const replyQuestionnaireSurveyInfo = (params) => request({
url: '/api/jobslink-api/content/questionnaireSurveyInfo/reply',
method: 'post',
data: params
});

View File

@@ -1,16 +1,19 @@
<template>
<view class="">
<block v-for="(item, index) in dataSource" :key="item.id">
<view class="search-item" @click="toDetail(item)">
{{item.surveyTitle}}
<view style="flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;">{{ item.workname }}
<view>
<view v-if="dataSource.length">
<block v-for="(item, index) in dataSource" :key="item.id">
<view class="search-item" @click="toDetail(item)">
{{item.surveyTitle}}
<view style="flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;">{{ item.workname }}
</view>
<image src="../../static/img/eyeopen.svg" style="width: 32rpx;height: 32rpx;margin-right: 10rpx;"
mode="">
</image>
<view class="baddd"></view>
</view>
<image src="../../static/img/eyeopen.svg" style="width: 32rpx;height: 32rpx;margin-right: 10rpx;"
mode="">
</image>
<view class="baddd"></view>
</view>
</block>
</block>
</view>
<empty v-else content="暂无问卷" mrTop="300"></empty>
</view>
</template>
@@ -28,9 +31,15 @@
created() {
this.getList("refresh");
},
onReachBottom() {
this.getList();
},
onPullDownRefresh() {
this.getList("refresh");
},
methods: {
toDetail() {
toDetail(row) {
this.navTo(`/pageMy/setUserBase/sub/appliRecordsDeatil?id=${row.id}`)
},
async getList(type = 'add') {
if (type === "refresh") {
@@ -41,6 +50,7 @@
page: this.pageNumber
}
let resData = await getEmploymentSurveyManage(params)
uni.stopPullDownRefresh()
if (resData.data.code === 200) {
const {
current,

View File

@@ -113,6 +113,8 @@
addComplaint() {
if (this.isNext) {
this.isNext = false
} else {
return
}
this.$refs.uForm.validate().then(async (res) => {
let params = {

View File

@@ -15,8 +15,6 @@
<u-form-item label="咨询人电话:" prop="consultPhone" labelWidth="80" borderBottom>
<u--input v-model="fromData.consultPhone" border="surround" placeholder="请输入11位电话号码"></u--input>
</u-form-item>
</u--form>
<view class="btn_add">
<u-button type="primary" size="large" text="发送信件" @click="addConsult"></u-button>
@@ -84,7 +82,10 @@
addConsult() {
if (this.isNext) {
this.isNext = false
} else {
return
}
this.$refs.uForm.validate().then(async (res) => {
uni.showLoading({
title: '请求中'

View File

@@ -0,0 +1,101 @@
<template>
<view class="app_cotainer">
<view class="content">
<p>描述{{infoMation.surveyContent}}</p>
</view>
<u--form labelPosition="left" :fromData="fromData" :model="fromData" :rules="rules" ref="uForm1">
<u-form-item label="" prop="replyContent" labelWidth="80" borderBottom>
<u--textarea v-model="fromData.replyContent" placeholder="回复内容"></u--textarea>
</u-form-item>
</u--form>
<view class="btn_add">
<u-button type="primary" size="large" text="发送信件" @click="submit"></u-button>
</view>
</view>
</template>
<script>
const rules = {
'replyContent': {
type: 'string',
required: true,
message: '请填写投诉标题',
trigger: ['blur', 'change']
},
}
import {
queryByIdQuestionnaireSurveyInfo,
replyQuestionnaireSurveyInfo
} from '@/api/help.js'
export default {
data() {
return {
infoMation: {},
fromData: {},
rules: Object.assign({}, rules),
isNext: true,
}
},
onLoad({
id
}) {
this.getDetail(id)
},
created() {
},
methods: {
async submit() {
if (this.isNext) {
this.isNext = false
} else {
return
}
if (!this.fromData.replyContent) {
this.isNext = true
return this.$api.mag('请输入回复内容')
}
console.log('submit', this.fromData)
let params = {
surveyId: this.infoMation.id,
...this.fromData,
}
uni.showLoading({
title: '请求中'
})
let resData = await replyQuestionnaireSurveyInfo(params)
uni.hideLoading()
this.isNext = true
if (resData.data?.code === 200) {
uni.$u.toast(resData.data.msg)
this.$api.sleep(1000).then(() => {
uni.navigateBack(1)
})
}
},
getDetail(id) {
return new Promise(async (resolve, reject) => {
let resData = await queryByIdQuestionnaireSurveyInfo({
id
})
if (resData.data.code === 200) {
this.infoMation = resData.data.data
resolve(resData.data.data)
} else {
reject()
}
})
}
}
}
</script>
<style scoped>
.app_cotainer {
padding: 24rpx;
}
.content {
margin-bottom: 100rpx;
}
</style>

View File

@@ -707,13 +707,21 @@
}
},
{
"path": "help/mailbox",
"path": "setUserBase/applicationsRecord",
"style": {
"navigationBarTitleText": "咨询信箱列表",
"navigationBarTitleText": "问卷调查列表",
"navigationBarBackgroundColor": "#FFFFFF",
"enablePullDownRefresh": true
}
},
{
"path": "setUserBase/sub/appliRecordsDeatil",
"style": {
"navigationBarTitleText": "问卷调查",
"navigationBarBackgroundColor": "#FFFFFF",
"enablePullDownRefresh": false
}
},
{
"path": "help/questions/questionDetail",
"style": {

View File

@@ -62,7 +62,7 @@
咨询信箱
<image src="../../static/img/right.svg" mode=""></image>
</view>
<view class="btnList" @click="navTo('/pageMy/help/mailbox')">
<view class="btnList" @click="navTo('/pageMy/setUserBase/applicationsRecord')">
<image src="../../static/img/phone.svg" mode=""></image>
问卷调查
<image src="../../static/img/right.svg" mode=""></image>

View File

@@ -1,183 +1,183 @@
<template>
<view class="body">
<view v-for="(value,key) in data" class="newsList" @click="goList(value)" :key="key">
<view class="newsIcon">
<image :src="value.icon" mode=""></image>
<view v-if="news.unread[value.id] > 0" class="point"></view>
</view>
<view class="newsListRight">
<view class="head">
<view class="head_left">
{{value.title}}
</view>
<view class="head_right" v-if="value.data.length > 0">
{{value.data[0][0][value.prop.time]}}
</view>
</view>
<view class="content" v-if="value.data.length > 0">
{{value.prop.desc(value)}}
</view>
</view>
</view>
<cs-button></cs-button>
</view>
</template>
<script>
import {
mapGetters
} from 'vuex'
export default {
data() {
return {
loading: false
}
},
onLoad() {},
onShow() {
if (!this.$store.state.user.token) {
uni.redirectTo({
url: "/pages/login/login"
})
} else {
uni.$emit('newsReadChange')
}
},
onPullDownRefresh() {
this.loading = true
this.$store.dispatch("newsInit").then(() => {
this.loading = false
uni.stopPullDownRefresh();
}).catch(() => {
this.loading = false
uni.stopPullDownRefresh();
})
},
methods: {
goList(item) {
// if (item.data.length === 0) {
// uni.showToast({
// title: '暂无消息',
// icon: 'none'
// });
// return
// }
console.log(item.data)
// 任务推送、岗位推送、政策推送
if(item.title == '零工岗位推送') {
console.log('零工岗位推送')
uni.navigateTo({
url: './taskProjectList'
})
} else if(item.title == '全职岗位推送') {
console.log('全职岗位推送')
uni.navigateTo({
url: './jobProjectList'
})
} else if(item.title == '政策推送') {
console.log('政策推送')
uni.navigateTo({
url: './policyList'
})
} else {
uni.navigateTo({
url: './newsList?type=' + item.id
})
}
}
},
computed: {
...mapGetters(['news']),
data() {
console.log(this.news.data,'-----------------------------');
return this.news.data
}
}
}
</script>
<style>
.content {
font-family: PingFangSC-Regular;
font-size: 28rpx;
color: #666666;
width: 560rpx;
overflow: hidden;
white-space: nowrap;
/*不换行*/
text-overflow: ellipsis;
/*超出部分文字以...显示*/
}
.head_right {
float: right;
font-family: PingFangSC-Regular;
font-size: 24rpx;
color: #CCCCCC;
}
.head_left {
float: left;
font-family: PingFangSC-Regular;
font-size: 36rpx;
color: #333333;
}
.head {
overflow: hidden;
width: 560rpx;
}
.newsListRight {
float: left;
width: 560rpx;
height: 50rpx;
line-height: 50rpx;
padding-left: 30rpx;
}
.newsList .newsIcon {
position: relative;
width: 100rpx;
height: 100rpx;
display: inline-block;
float: left;
}
.newsList image {
width: 100rpx;
height: 100rpx;
}
.newsList .point {
position: absolute;
top: 5rpx;
right: 10rpx;
width: 20rpx;
height: 20rpx;
background: red;
border-radius: 50%;
}
.newsList {
border-bottom: 1rpx solid #dddddd;
padding-bottom: 30rpx;
padding-right: 30rpx;
padding-top: 30rpx;
overflow: hidden;
display: flex;
align-items: center;
}
.body {
background-color: #fefefe;
padding-left: 30rpx;
width: 720rpx;
}
page {
background: #f6f6f6;
}
</style>
<template>
<view class="body">
<view v-for="(value,key) in data" class="newsList" @click="goList(value)" :key="key">
<view class="newsIcon">
<image :src="value.icon" mode=""></image>
<view v-if="news.unread[value.id] > 0" class="point"></view>
</view>
<view class="newsListRight">
<view class="head">
<view class="head_left">
{{value.title}}
</view>
<view class="head_right" v-if="value.data.length > 0">
{{value.data[0][0][value.prop.time]}}
</view>
</view>
<view class="content" v-if="value.data.length > 0">
{{value.prop.desc(value)}}
</view>
</view>
</view>
<cs-button></cs-button>
</view>
</template>
<script>
import {
mapGetters
} from 'vuex'
export default {
data() {
return {
loading: false
}
},
onLoad() {},
onShow() {
if (!this.$store.state.user.token) {
uni.redirectTo({
url: "/pages/login/login"
})
} else {
uni.$emit('newsReadChange')
}
},
onPullDownRefresh() {
this.loading = true
this.$store.dispatch("newsInit").then(() => {
this.loading = false
uni.stopPullDownRefresh();
}).catch(() => {
this.loading = false
uni.stopPullDownRefresh();
})
},
methods: {
goList(item) {
// if (item.data.length === 0) {
// uni.showToast({
// title: '暂无消息',
// icon: 'none'
// });
// return
// }
console.log(item.data)
// 任务推送、岗位推送、政策推送
if (item.title == '零工岗位推送') {
console.log('零工岗位推送')
uni.navigateTo({
url: './taskProjectList'
})
} else if (item.title == '全职岗位推送') {
console.log('全职岗位推送')
uni.navigateTo({
url: './jobProjectList'
})
} else if (item.title == '政策推送') {
console.log('政策推送')
uni.navigateTo({
url: './policyList'
})
} else {
uni.navigateTo({
url: './newsList?type=' + item.id
})
}
}
},
computed: {
...mapGetters(['news']),
data() {
console.log(this.news.data, '-----------------------------');
return this.news.data
}
}
}
</script>
<style>
.content {
font-family: PingFangSC-Regular;
font-size: 28rpx;
color: #666666;
width: 560rpx;
overflow: hidden;
white-space: nowrap;
/*不换行*/
text-overflow: ellipsis;
/*超出部分文字以...显示*/
}
.head_right {
float: right;
font-family: PingFangSC-Regular;
font-size: 24rpx;
color: #CCCCCC;
}
.head_left {
float: left;
font-family: PingFangSC-Regular;
font-size: 36rpx;
color: #333333;
}
.head {
overflow: hidden;
width: 560rpx;
}
.newsListRight {
float: left;
width: 560rpx;
height: 50rpx;
line-height: 50rpx;
padding-left: 30rpx;
}
.newsList .newsIcon {
position: relative;
width: 100rpx;
height: 100rpx;
display: inline-block;
float: left;
}
.newsList image {
width: 100rpx;
height: 100rpx;
}
.newsList .point {
position: absolute;
top: 5rpx;
right: 10rpx;
width: 20rpx;
height: 20rpx;
background: red;
border-radius: 50%;
}
.newsList {
border-bottom: 1rpx solid #dddddd;
padding-bottom: 30rpx;
padding-right: 30rpx;
padding-top: 30rpx;
overflow: hidden;
display: flex;
align-items: center;
}
.body {
background-color: #fefefe;
padding-left: 30rpx;
width: 720rpx;
}
page {
background: #f6f6f6;
}
</style>

View File

@@ -1,374 +1,374 @@
import {
inviteCount,
inviteList,
inviteRead,
inviteRemove,
noticeCount,
noticeList,
noticeRead,
noticeRemove
} from '@/api/news.js'
import website from '@/config/website.js'
const size = 20
const handler = {
'0': {
count: noticeCount,
getList: noticeList,
read: noticeRead,
remove: noticeRemove
},
'1': {
count: inviteCount,
getList: inviteList,
read: inviteRead,
remove: inviteRemove
}
}
function getCount(data) {
let sum = 0
for (let key in data) {
sum += data[key]
}
return sum
}
let refreshTimer = null;
function startRefreshToken(dispatch) {
refreshTimer = setInterval(() => {
dispatch("newsInit");
}, website.newsRefreshTime);
}
function stopRefreshToken() {
clearInterval(refreshTimer)
}
const news = {
state: {
count: 0,
data: {
"0": {
id: "0",
title: "消息通知",
icon: "../../static/img/notice.svg",
page: {
current: 0,
size,
total: size
},
data: [],
prop: {
title: 'title',
desc: (value) => {
if (value.data[0])
return value.data[0][0]['desc']
},
time: 'createTime',
isRead: 'isRead',
listDesc: 'desc',
},
navigateTo(item) {
uni.$once('getNewsDetail', (cb) => {
cb(item)
})
uni.navigateTo({
url: "/pages/news/newsDetail?type=0"
})
}
},
"1": {
id: "1",
title: "岗位推送",
icon: "../../static/img/renwu.png",
page: {
current: 0,
size,
total: size
},
data: [],
prop: {
title: 'missionTitle',
desc: (value) => {
if (value.data[0])
return `您收到${value.data[0][0]['companyName']}岗位`
},
time: 'createTime',
isRead: 'status',
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)}`
})
}
},
"2": {
id: "1",
title: "岗位推送",
icon: "../../static/img/gangwei.svg",
page: {
current: 0,
size,
total: size
},
data: [],
prop: {
title: 'missionTitle',
desc: (value) => {
if (value.data[0])
return `您收到${value.data[0][0]['companyName']}的岗位`
},
time: 'createTime',
isRead: 'status',
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)}`
})
}
},
// "3": {
// id: "1",
// title: "技能推送",
// icon: "../../static/img/jineng.svg",
// page: {
// current: 0,
// size,
// total: size
// },
// data: [],
// prop: {
// title: 'missionTitle',
// desc: (value) => {
// if (value.data[0])
// return `您收到${value.data[0][0]['companyName']}的任务`
// },
// time: 'createTime',
// isRead: 'status',
// 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)}`
// })
// }
// },
"4": {
id: "1",
title: "政策推送",
icon: "../../static/img/zhengce.svg",
page: {
current: 0,
size,
total: size
},
data: [],
prop: {
title: 'missionTitle',
desc: (value) => {
if (value.data[0])
return `您收到${value.data[0][0]['companyName']}的岗位`
},
time: 'createTime',
isRead: 'status',
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)}`
})
}
}
},
unread: {
"0": 0,
"1": 0
},
allUnread: 0,
dic: {}
},
actions: {
newsInit({
dispatch
}) {
const ps = []
ps.push(dispatch('getUnreadNum'))
for (let key in handler) {
ps.push(dispatch('newsReload', key))
}
return Promise.all(ps)
},
newsReload({
dispatch,
commit
}, id) {
commit('CLEAR_NEWS_DATA', id)
return dispatch('newsGetNextPage', id)
},
getUnreadNum({
commit
}) {
for (let key in handler) {
handler[key].count().then((result) => {
commit('SET_UNREADNUM', {
id: key,
count: result
})
})
}
},
newsGetNextPage({
state,
commit
}, id) {
const item = state.data[id]
const page = item.page
const current = page.current + 1
return new Promise((resolve, reject) => {
if (parseInt(page.total / page.size) + 1 < current) {
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)
})
},
removeNew({
commit
}, {
id,
key,
group,
index
}) {
return new Promise((resolve, reject) => {
commit('REMOVE_NEWS', {
id,
key,
group,
index
})
handler[key].remove(id).then(resolve, reject)
})
},
readNew({
commit
}, {
key,
id
}) {
return new Promise((resolve, reject) => {
commit('READ_NEWS', {
key,
id
})
handler[key].read(id).then(resolve, reject)
})
},
endRefreshNewsTimer(){
stopRefreshToken()
},
startRefreshNewsTimer({
state,
commit,
dispatch
}) {
console.log('触发2')
dispatch('newsInit').then(() => {
startRefreshToken(dispatch);
})
}
},
mutations: {
SET_UNREADNUM: (state, {
id,
count
}) => {
state.unread[id] = count
state.allUnread = getCount(state.unread)
},
CLEAR_NEWS_DATA: (state, id) => {
state.data[id].page = {
current: 0,
size
}
state.data[id].data = []
},
ADD_NEWS_DATA: (state, {
id,
data,
current,
total
}) => {
data.forEach(item => {
state.dic[item.id] = item
})
state.data[id].page.total = total
state.data[id].page.current = current
if (data.length > 0) {
state.data[id].data.push(data)
}
},
REMOVE_NEWS: (state, {
id,
key,
group,
index
}) => {
const readProp = state.data[key].prop['isRead']
if (state.dic[id][readProp] === 0) {
state.unread[key]--
state.allUnread--
}
state.dic[id] = undefined
const data = state.data[key].data
data[group].splice(index, 1)
if (data[group].length === 0) {
data.splice(group, 1)
}
},
READ_NEWS: (state, {
key,
id
}) => {
const readProp = state.data[key].prop['isRead']
if (state.dic[id][readProp] === 0) {
state.dic[id][readProp] = 1
state.unread[key]--
state.allUnread--
}
}
},
getters: {
}
};
export default news;
import {
inviteCount,
inviteList,
inviteRead,
inviteRemove,
noticeCount,
noticeList,
noticeRead,
noticeRemove
} from '@/api/news.js'
import website from '@/config/website.js'
const size = 20
const handler = {
'0': {
count: noticeCount,
getList: noticeList,
read: noticeRead,
remove: noticeRemove
},
'1': {
count: inviteCount,
getList: inviteList,
read: inviteRead,
remove: inviteRemove
}
}
function getCount(data) {
let sum = 0
for (let key in data) {
sum += data[key]
}
return sum
}
let refreshTimer = null;
function startRefreshToken(dispatch) {
refreshTimer = setInterval(() => {
dispatch("newsInit");
}, website.newsRefreshTime);
}
function stopRefreshToken() {
clearInterval(refreshTimer)
}
const news = {
state: {
count: 0,
data: {
"0": {
id: "0",
title: "消息通知",
icon: "../../static/img/notice.svg",
page: {
current: 0,
size,
total: size
},
data: [],
prop: {
title: 'title',
desc: (value) => {
if (value.data[0])
return value.data[0][0]['desc']
},
time: 'createTime',
isRead: 'isRead',
listDesc: 'desc',
},
navigateTo(item) {
uni.$once('getNewsDetail', (cb) => {
cb(item)
})
uni.navigateTo({
url: "/pages/news/newsDetail?type=0"
})
}
},
"1": {
id: "1",
title: "岗位推送",
icon: "../../static/img/renwu.png",
page: {
current: 0,
size,
total: size
},
data: [],
prop: {
title: 'missionTitle',
desc: (value) => {
if (value.data[0])
return `您收到${value.data[0][0]['companyName']}岗位`
},
time: 'createTime',
isRead: 'status',
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)}`
})
}
},
"2": {
id: "1",
title: "岗位推送",
icon: "../../static/img/gangwei.svg",
page: {
current: 0,
size,
total: size
},
data: [],
prop: {
title: 'missionTitle',
desc: (value) => {
if (value.data[0])
return `您收到${value.data[0][0]['companyName']}的岗位`
},
time: 'createTime',
isRead: 'status',
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)}`
})
}
},
// "3": {
// id: "1",
// title: "技能推送",
// icon: "../../static/img/jineng.svg",
// page: {
// current: 0,
// size,
// total: size
// },
// data: [],
// prop: {
// title: 'missionTitle',
// desc: (value) => {
// if (value.data[0])
// return `您收到${value.data[0][0]['companyName']}的任务`
// },
// time: 'createTime',
// isRead: 'status',
// 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)}`
// })
// }
// },
"4": {
id: "1",
title: "政策推送",
icon: "../../static/img/zhengce.svg",
page: {
current: 0,
size,
total: size
},
data: [],
prop: {
title: 'missionTitle',
desc: (value) => {
if (value.data[0])
return `您收到${value.data[0][0]['companyName']}的岗位`
},
time: 'createTime',
isRead: 'status',
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)}`
})
}
}
},
unread: {
"0": 0,
"1": 0
},
allUnread: 0,
dic: {}
},
actions: {
newsInit({
dispatch
}) {
const ps = []
ps.push(dispatch('getUnreadNum'))
for (let key in handler) {
ps.push(dispatch('newsReload', key))
}
return Promise.all(ps)
},
newsReload({
dispatch,
commit
}, id) {
commit('CLEAR_NEWS_DATA', id)
return dispatch('newsGetNextPage', id)
},
getUnreadNum({
commit
}) {
for (let key in handler) {
handler[key].count().then((result) => {
commit('SET_UNREADNUM', {
id: key,
count: result
})
})
}
},
newsGetNextPage({
state,
commit
}, id) {
const item = state.data[id]
const page = item.page
const current = page.current + 1
return new Promise((resolve, reject) => {
if (parseInt(page.total / page.size) + 1 < current) {
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)
})
},
removeNew({
commit
}, {
id,
key,
group,
index
}) {
return new Promise((resolve, reject) => {
commit('REMOVE_NEWS', {
id,
key,
group,
index
})
handler[key].remove(id).then(resolve, reject)
})
},
readNew({
commit
}, {
key,
id
}) {
return new Promise((resolve, reject) => {
commit('READ_NEWS', {
key,
id
})
handler[key].read(id).then(resolve, reject)
})
},
endRefreshNewsTimer() {
stopRefreshToken()
},
startRefreshNewsTimer({
state,
commit,
dispatch
}) {
console.log('触发2')
dispatch('newsInit').then(() => {
startRefreshToken(dispatch);
})
}
},
mutations: {
SET_UNREADNUM: (state, {
id,
count
}) => {
state.unread[id] = count
state.allUnread = getCount(state.unread)
},
CLEAR_NEWS_DATA: (state, id) => {
state.data[id].page = {
current: 0,
size
}
state.data[id].data = []
},
ADD_NEWS_DATA: (state, {
id,
data,
current,
total
}) => {
data.forEach(item => {
state.dic[item.id] = item
})
state.data[id].page.total = total
state.data[id].page.current = current
if (data.length > 0) {
state.data[id].data.push(data)
}
},
REMOVE_NEWS: (state, {
id,
key,
group,
index
}) => {
const readProp = state.data[key].prop['isRead']
if (state.dic[id][readProp] === 0) {
state.unread[key]--
state.allUnread--
}
state.dic[id] = undefined
const data = state.data[key].data
data[group].splice(index, 1)
if (data[group].length === 0) {
data.splice(group, 1)
}
},
READ_NEWS: (state, {
key,
id
}) => {
const readProp = state.data[key].prop['isRead']
if (state.dic[id][readProp] === 0) {
state.dic[id][readProp] = 1
state.unread[key]--
state.allUnread--
}
}
},
getters: {
}
};
export default news;

View File

@@ -3,10 +3,10 @@ module.exports = {
port: 1887,
proxy: {
'/api': {
target: 'http://192.168.1.101:8200',
target: 'http://10.165.0.173:8000',
ws: true,
pathRewrite: {
'^/api/jobslink-api': '/'
'^/api': '/'
}
},
'/qq/map': {