123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- export const actions = {
- // 全局服务初始化
- nuxtServerInit (store, {isDev, req}) {
- // 检查设备类型
- const userAgent = process.server ? req.headers['user-agent'] : navigator.userAgent
- const isMobile = /(iPhone|iPad|Opera Mini|Android.*Mobile|NetFront|PSP|BlackBerry|Windows Phone)/ig.test(userAgent)
- const cookie = process.server ? req.headers['cookie'] : null
- store.commit('option/SET_MOBILE_LAYOUT', isMobile)
- store.commit('option/SET_USER_AGENT', userAgent)
- store.commit('option/SET_COOKIES', cookie)
- // 设置跳转的URL
- if (!isDev) {
- store.commit('option/UPDATE_URL', 'http://10.1.51.107:4444')
- }
- return Promise.all([
- // 全局数据
- store.dispatch('loadUserInfo'),
- store.dispatch('loadNewsType')
- ])
- },
- // 获取用户信息
- loadUserInfo ({ commit }) {
- commit('option/REQUEST_USER_INFO')
- return this.$http.get('/user/authentication')
- .then(response => {
- console.log(response.data.data)
- commit('option/REQUEST_USER_INFO_SUCCESS', response.data.data)
- }, err => {
- console.log('22', err)
- commit('option/REQUEST_USER_INFO_FAILURE', err)
- })
- },
- // 用户退出
- logout ({ commit }) {
- return this.$http.get('/logout')
- .then(response => {
- commit('option/REQUEST_LOGOUT_SUCCESS', response.data)
- })
- },
- // 获取表单配置
- loadFormData ({ commit }, params = {}) {
- commit('formConfig/REQUEST_FORMDATA')
- return this.$cityService.get('/api/serve/config.action', {params})
- .then(response => {
- commit('formConfig/GET_FORMDATA_SUCCESS', response.data)
- }, err => {
- commit('formConfig/GET_FORMDATA_FAILURE', err)
- })
- },
- // 获取服务列表
- loadServiceList ({ commit }, params = {}) {
- commit('serviceList/REQUEST_SERVICEDATA')
- return this.$cityService.get('/api/serve/mainPage/getServices.action', {params})
- .then(response => {
- commit('serviceList/GET_SERVICEDATA_SUCCESS', response.data)
- }, err => {
- commit('serviceList/GET_SERVICEDATA_FAILURE', err)
- })
- },
- // 获取轮播图片
- loadCarouselInfo ({ commit }, params = {}) {
- commit('carouselInfo/REQUEST_INFODATA')
- return this.$cityService.get('/api/serve/mainPage/getRecyclePics.action', {params})
- .then(response => {
- commit('carouselInfo/GET_INFODATA_SUCCESS', response.data)
- }, err => {
- commit('carouselInfo/GET_INFODATA_FAILURE', err)
- })
- },
- // 查询表单列表数据
- searchServiceList ({commit}, params = {}) {
- commit('searchList/REQUEST_SEARCHLIST')
- return this.$cityService.get('/api/serve/query.action', {params})
- .then(response => {
- commit('searchList/GET_SEARCHLIST_SUCCESS', response.data)
- }, err => {
- commit('searchList/GET_SEARCHLIST_FAILURE', err)
- })
- },
- // 获取服务流程信息
- loadServiceProcess ({commit}, params = {}) {
- commit('serviceProcess/REQUEST_PROCESSINFO')
- return this.$cityService.get('/api/serve/getProcesses.action', {params})
- .then(response => {
- commit('serviceProcess/GET_PROCESSINFO_SUCCESS', response.data)
- }, err => {
- commit('serviceProcess/GET_PROCESSINFO_FAILURE', err)
- })
- },
- // 获取附件信息
- loadAttach ({commit}, params = {}) {
- commit('loadAttach/REQUEST_ATTACH')
- return this.$cityService.get('/api/serve/getAttach.action', {params})
- .then(response => {
- commit('loadAttach/GET_ATTACH_SUCCESS', response.data)
- }, err => {
- commit('loadAttach/GET_ATTACH_FAILURE', err)
- })
- },
- // 通用的更新接口信息
- upDatAPort ({commit}, params = {}) {
- commit('updatePort/REQUEST_UPDATE')
- return this.$cityService.get('/api/serve/update.action', {params})
- .then(response => {
- commit('updatePort/GET_UPDATE_SUCCESS', response.data)
- }, err => {
- commit('updatePort/GET_UPDATE_FAILURE', err)
- })
- },
- // 获取新闻类型
- loadNewsType ({commit}) {
- commit('news/REQUEST_NEWTYPE')
- return this.$cityService.get('/api/serve/mainPage/getNewsType.action')
- .then(response => {
- commit('news/GET_NEWTYPE_SUCCESS', response.data)
- }, err => {
- commit('news/GET_NEWTYPE_FAILURE', err)
- })
- },
- // 获取新闻列表
- loadNewsList ({commit}, params = {}) {
- commit('news/REQUEST_LIST')
- return this.$cityService.get('/api/serve/mainPage/getNewslist.action', {params})
- .then(response => {
- commit('news/GET_LIST_SUCCESS', response.data)
- }, err => {
- commit('news/GET_LIST_FAILURE', err)
- })
- },
- // 获取新闻详情信息
- loadNewsDetail ({commit}, params = {}) {
- commit('news/REQUEST_DETAIL')
- return this.$cityService.get('/api/serve/mainPage/getNewsContent.action', {params})
- .then(response => {
- commit('news/GET_DETAIL_SUCCESS', response.data)
- }, err => {
- commit('news/GET_DETAIL_FAILURE', err)
- })
- },
- // 获取园区活动类型
- loadGardenType ({commit}) {
- commit('gardens/REQUEST_GARDENTYPE')
- return this.$cityService.get('/api/serve/mainPage/getActivityType.action')
- .then(response => {
- commit('gardens/GET_GARDENTYPE_SUCCESS', response.data)
- }, err => {
- commit('gardens/GET_GARDENTYPE_FAILURE', err)
- })
- },
- // 获取园区活动列表
- loadGardenList ({commit}, params = {}) {
- commit('gardens/REQUEST_LIST')
- return this.$cityService.get('/api/serve/mainPage/getActivitylist.action', {params})
- .then(response => {
- commit('gardens/GET_LIST_SUCCESS', response.data)
- }, err => {
- commit('gardens/GET_LIST_FAILURE', err)
- })
- },
- // 获取园区活动详情信息
- loadGardenDetail ({commit}, params = {}) {
- commit('gardens/REQUEST_DETAIL')
- return this.$cityService.get('/api/serve/mainPage/getActivityContent.action', {params})
- .then(response => {
- commit('gardens/GET_DETAIL_SUCCESS', response.data)
- }, err => {
- commit('gardens/GET_DETAIL_FAILURE', err)
- })
- }
- }
|