import axios from 'axios'; import { message } from 'ant-design-vue'; import { industryInfo, front, frontInfo, getPageDetail, queryRotation, frontSearchCompany, getUserSer } from '@/config/api'; const actions = { /** * 获取行业资讯列表 * @param {any} commit * @param {object} params 提交的数据 */ async getIndustryInfoList({ commit }, params) { try { const res = await industryInfo(params); const { code, msg, data } = res.data; if (code === 200) { return data; } else { message.error(msg || '获取失败'); throw msg; } } catch (error) { throw error || '获取失败'; } }, /** * 获取活动公告列表 * @param {any} commit * @param {object} params 提交的数据 */ async getFrontList({ commit }, params) { try { const res = await front(params); const { code, msg, data } = res.data; if (code === 200) { return data; } else { message.error(msg || '获取失败'); throw msg; } } catch (error) { throw error || '获取失败'; } }, /** * 获取企业简报列表 * @param {any} commit * @param {object} params 提交的数据 */ async getFrontInfoList({ commit }, params) { try { const res = await frontInfo(params); const { code, msg, data } = res.data; if (code === 200) { return data; } else { message.error(msg || '获取失败'); throw msg; } } catch (error) { throw error || '获取失败'; } }, /** * 介绍页面详情查询 * @param {any} commit * @param {object} titleCode 提交的数据 */ async getPageDetail({ commit }, titleCode) { try { const params = { param: { titleCode } }; const res = await getPageDetail(params); const { code, msg, data } = res.data; if (code === 200) { if (data && data.length > 0 && data[0] && data[0].length > 0 && data[0][0].detail) { commit('setContent', data[0][0].detail.content); commit('setTitleCode', data[0][0].detail.titleCode); } } else { message.error(msg || '查询失败'); throw msg; } } catch (error) { throw error || '查询失败'; } }, /** * 介绍页面详情查询 * @param {any} commit * @param {object} showPage 页面显示位置 * 0 首页 * 11 关于我们-公司介绍 * 12 关于我们-组织架构 * 32 创新平台-创新资源平台 * 33 创新平台-创新服务 * 41 孵化平台-众创空间 * 42 孵化平台-公共实验室 * 43 孵化平台-中试基地 * 44 孵化平台-创业导师 * 46 孵化平台-创业服务 * 52 产业平台-产业服务 * 100 XX服务详情 */ async getQueryRotation({ commit }, showPage) { try { const params = { param: { showPage, showPosition: 1 } }; const res = await queryRotation(params); const { code, msg, data } = res.data; if (code === 200) { commit('setBannerLists', data); } else { message.error(msg || '查询失败'); throw msg; } } catch (error) { throw error || '查询失败'; } }, /** * 合作伙伴查询 * @param {any} commit * @param {object} params 提交的数据 */ async getFrontSearchCompany({ commit }, params) { try { const res = await frontSearchCompany(params); const { code, msg, data } = res.data; if (code === 200) { commit('setPartners', data); } else { message.error(msg || '查询失败'); throw msg; } } catch (error) { throw error || '查询失败'; } }, /** * 获取登录人信息 * @param {any} commit */ async getUserSer({ commit }) { try { const token = sessionStorage.getItem('anyringToken'); if (!token) return; const params = { param: {} }; const res = await getUserSer(params); const { code, msg, data } = res.data; if (code === 200) { commit('setUserSer', data); } else { message.error(msg || '查询失败'); throw msg; } } catch (error) { throw error || '查询失败'; } }, }; export default actions;