index.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. export const actions = {
  2. // 全局服务初始化
  3. nuxtServerInit (store, {isDev, req}) {
  4. // 检查设备类型
  5. const userAgent = process.server ? req.headers['user-agent'] : navigator.userAgent
  6. const isMobile = /(iPhone|iPad|Opera Mini|Android.*Mobile|NetFront|PSP|BlackBerry|Windows Phone)/ig.test(userAgent)
  7. const cookie = process.server ? req.headers['cookie'] : null
  8. store.commit('option/SET_MOBILE_LAYOUT', isMobile)
  9. store.commit('option/SET_USER_AGENT', userAgent)
  10. store.commit('option/SET_COOKIES', cookie)
  11. // 设置跳转的URL
  12. if (!isDev) {
  13. store.commit('option/UPDATE_URL', 'http://10.1.51.107:4444')
  14. }
  15. return Promise.all([
  16. // 全局数据
  17. store.dispatch('loadUserInfo'),
  18. store.dispatch('loadNewsType')
  19. ])
  20. },
  21. // 获取用户信息
  22. loadUserInfo ({ commit }) {
  23. commit('option/REQUEST_USER_INFO')
  24. return this.$http.get('/user/authentication')
  25. .then(response => {
  26. console.log(response.data.data)
  27. commit('option/REQUEST_USER_INFO_SUCCESS', response.data.data)
  28. }, err => {
  29. console.log('22', err)
  30. commit('option/REQUEST_USER_INFO_FAILURE', err)
  31. })
  32. },
  33. // 用户退出
  34. logout ({ commit }) {
  35. return this.$http.get('/logout')
  36. .then(response => {
  37. commit('option/REQUEST_LOGOUT_SUCCESS', response.data)
  38. })
  39. },
  40. // 获取表单配置
  41. loadFormData ({ commit }, params = {}) {
  42. commit('formConfig/REQUEST_FORMDATA')
  43. return this.$cityService.get('/api/serve/config.action', {params})
  44. .then(response => {
  45. commit('formConfig/GET_FORMDATA_SUCCESS', response.data)
  46. }, err => {
  47. commit('formConfig/GET_FORMDATA_FAILURE', err)
  48. })
  49. },
  50. // 获取服务列表
  51. loadServiceList ({ commit }, params = {}) {
  52. commit('serviceList/REQUEST_SERVICEDATA')
  53. return this.$cityService.get('/api/serve/mainPage/getServices.action', {params})
  54. .then(response => {
  55. commit('serviceList/GET_SERVICEDATA_SUCCESS', response.data)
  56. }, err => {
  57. commit('serviceList/GET_SERVICEDATA_FAILURE', err)
  58. })
  59. },
  60. // 获取轮播图片
  61. loadCarouselInfo ({ commit }, params = {}) {
  62. commit('carouselInfo/REQUEST_INFODATA')
  63. return this.$cityService.get('/api/serve/mainPage/getRecyclePics.action', {params})
  64. .then(response => {
  65. commit('carouselInfo/GET_INFODATA_SUCCESS', response.data)
  66. }, err => {
  67. commit('carouselInfo/GET_INFODATA_FAILURE', err)
  68. })
  69. },
  70. // 查询表单列表数据
  71. searchServiceList ({commit}, params = {}) {
  72. commit('searchList/REQUEST_SEARCHLIST')
  73. return this.$cityService.get('/api/serve/query.action', {params})
  74. .then(response => {
  75. commit('searchList/GET_SEARCHLIST_SUCCESS', response.data)
  76. }, err => {
  77. commit('searchList/GET_SEARCHLIST_FAILURE', err)
  78. })
  79. },
  80. // 获取服务流程信息
  81. loadServiceProcess ({commit}, params = {}) {
  82. commit('serviceProcess/REQUEST_PROCESSINFO')
  83. return this.$cityService.get('/api/serve/getProcesses.action', {params})
  84. .then(response => {
  85. commit('serviceProcess/GET_PROCESSINFO_SUCCESS', response.data)
  86. }, err => {
  87. commit('serviceProcess/GET_PROCESSINFO_FAILURE', err)
  88. })
  89. },
  90. // 获取附件信息
  91. loadAttach ({commit}, params = {}) {
  92. commit('loadAttach/REQUEST_ATTACH')
  93. return this.$cityService.get('/api/serve/getAttach.action', {params})
  94. .then(response => {
  95. commit('loadAttach/GET_ATTACH_SUCCESS', response.data)
  96. }, err => {
  97. commit('loadAttach/GET_ATTACH_FAILURE', err)
  98. })
  99. },
  100. // 通用的更新接口信息
  101. upDatAPort ({commit}, params = {}) {
  102. commit('updatePort/REQUEST_UPDATE')
  103. return this.$cityService.get('/api/serve/update.action', {params})
  104. .then(response => {
  105. commit('updatePort/GET_UPDATE_SUCCESS', response.data)
  106. }, err => {
  107. commit('updatePort/GET_UPDATE_FAILURE', err)
  108. })
  109. },
  110. // 获取新闻类型
  111. loadNewsType ({commit}) {
  112. commit('news/REQUEST_NEWTYPE')
  113. return this.$cityService.get('/api/serve/mainPage/getNewsType.action')
  114. .then(response => {
  115. commit('news/GET_NEWTYPE_SUCCESS', response.data)
  116. }, err => {
  117. commit('news/GET_NEWTYPE_FAILURE', err)
  118. })
  119. },
  120. // 获取新闻列表
  121. loadNewsList ({commit}, params = {}) {
  122. commit('news/REQUEST_LIST')
  123. return this.$cityService.get('/api/serve/mainPage/getNewslist.action', {params})
  124. .then(response => {
  125. commit('news/GET_LIST_SUCCESS', response.data)
  126. }, err => {
  127. commit('news/GET_LIST_FAILURE', err)
  128. })
  129. },
  130. // 获取新闻详情信息
  131. loadNewsDetail ({commit}, params = {}) {
  132. commit('news/REQUEST_DETAIL')
  133. return this.$cityService.get('/api/serve/mainPage/getNewsContent.action', {params})
  134. .then(response => {
  135. commit('news/GET_DETAIL_SUCCESS', response.data)
  136. }, err => {
  137. commit('news/GET_DETAIL_FAILURE', err)
  138. })
  139. },
  140. // 获取园区活动类型
  141. loadGardenType ({commit}) {
  142. commit('gardens/REQUEST_GARDENTYPE')
  143. return this.$cityService.get('/api/serve/mainPage/getActivityType.action')
  144. .then(response => {
  145. commit('gardens/GET_GARDENTYPE_SUCCESS', response.data)
  146. }, err => {
  147. commit('gardens/GET_GARDENTYPE_FAILURE', err)
  148. })
  149. },
  150. // 获取园区活动列表
  151. loadGardenList ({commit}, params = {}) {
  152. commit('gardens/REQUEST_LIST')
  153. return this.$cityService.get('/api/serve/mainPage/getActivitylist.action', {params})
  154. .then(response => {
  155. commit('gardens/GET_LIST_SUCCESS', response.data)
  156. }, err => {
  157. commit('gardens/GET_LIST_FAILURE', err)
  158. })
  159. },
  160. // 获取园区活动详情信息
  161. loadGardenDetail ({commit}, params = {}) {
  162. commit('gardens/REQUEST_DETAIL')
  163. return this.$cityService.get('/api/serve/mainPage/getActivityContent.action', {params})
  164. .then(response => {
  165. commit('gardens/GET_DETAIL_SUCCESS', response.data)
  166. }, err => {
  167. commit('gardens/GET_DETAIL_FAILURE', err)
  168. })
  169. }
  170. }