| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560 |
- import axios from '~plugins/axios'
- // 获取品牌详情产品分类信息
- function loadBrandCategories({ commit }, params = {}) {
- let id = params.id
- commit('brandCategories/REQUEST_CATEGORIES', params)
- return axios.get(`/api/product/brand/${id}/kinds`)
- .then(response => {
- commit('brandCategories/GET_CATEGORIES_SUCCESS', response.data)
- }, err => {
- commit('brandCategories/GET_CATEGORIES_FAILURE', err)
- })
- }
- // 获取品牌详情型号列表数据
- function loadBrandComponent({ commit }, params = {}) {
- commit('brandComponent/REQUEST_COMPONENT', params)
- return axios.get('/api/product/component/list', { params })
- .then(response => {
- commit('brandComponent/GET_COMPONENT_SUCCESS', response.data)
- }, err => {
- commit('brandComponent/GET_COMPONENT_FAILURE', err)
- })
- }
- export const actions = {
- // 全局服务初始化
- nuxtServerInit(store, { params, route, 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)
- // console.log(req.headers.referer)
- if (route.query) {
- let messageType = route.query.messageType || ''
- store.commit('option/GET_MESSAGETYPE', messageType)
- }
- if (cookie) {
- if (cookie && cookie.length) {
- for (let i = 0; i < cookie.length; i++) {
- if (cookie[i].indexOf('JSESSIONID') > -1) {
- const sessionId = cookie[i]
- const first = sessionId.indexOf(';')
- const second = sessionId.lastIndexOf(';')
- const newSessionId = sessionId.replace(sessionId.substring(first, second), '')
- store.commit('option/SET_SESSION_ID', newSessionId)
- break
- }
- }
- }
- axios.defaults.headers['cookie'] = store.state.option.cookies + '; ' + store.state.option.sessionId
- axios.defaults.headers['User-Agent'] = store.state.option.userAgent
- } else {
- axios.defaults.headers['cookie'] = ''
- axios.defaults.headers['User-Agent'] = ''
- }
- // 设置跳转的URL
- if (!isDev) {
- store.commit('option/UPDATE_URL', 'http://www.usoftmall.com')
- }
- return Promise.all([
- // 全局数据
- store.dispatch('loadUserInfo'),
- store.dispatch('loadProductCounts', { _status: 'actived' }),
- store.dispatch('loadHotSearchDevice'),
- store.dispatch('loadHotSearchBrand'),
- store.dispatch('loadNewFloors')
- ])
- },
- // 获取用户信息
- loadUserInfo({ commit }) {
- commit('option/REQUEST_USER_INFO')
- return axios.get('/user/authentication')
- .then(response => {
- if (response.data.userName) {
- let ens = response.data.enterprises
- if (ens && ens.length) {
- response.data.enterprise = ens.find(item => item.current) || { enName: '个人账户' }
- } else {
- response.data.enterprise = { enName: '个人账户' }
- }
- }
- commit('option/REQUEST_USER_INFO_SUCCESS', response.data)
- }, err => {
- commit('option/REQUEST_USER_INFO_FAILURE', err)
- })
- },
- loadUserWithAdmin ({commit}, params = {}) {
- commit('option/REQUEST_ADMIN_INFO')
- return axios.get('/basic/user/getUserByUU', {params: params})
- .then(response => {
- commit('option/REQUEST_ADMIN_INFO_SUCCESS', response.data)
- }, err => {
- commit('option/REQUEST_ADMIN_INFO_FAILURE', err)
- })
- },
- // 用户退出
- logout({ commit }) {
- return axios.get('/logout')
- .then(response => {
- commit('option/REQUEST_LOGOUT_SUCCESS', response.data)
- })
- },
- // 获取楼层配置
- loadFloors({ commit }) {
- commit('floor/REQUEST_LIST')
- return axios.get('/api/floors/home')
- .then(response => {
- commit('floor/GET_LIST_SUCCESS', response.data)
- }, err => {
- commit('floor/GET_LIST_FAILURE', err)
- })
- },
- // 批量获取产品信息
- loadBatchCommodities({ commit }, params = {}) {
- commit('floor/REQUEST_EXPANDLIST')
- return axios.post('/api/commodity/detail', params.batchCodeList)
- .then(response => {
- commit('floor/GET_EXPANDLIST_SUCCESS', response.data)
- }, err => {
- commit('floor/GET_EXPANDLIST_FAILURE', err)
- })
- },
- // 获取轮播配置
- loadBanners({ commit }, params = {}) {
- commit('carousel/REQUEST_BANNER')
- return axios.get(`/cmsApi?method=queryContentPage&module=${params.type}&orderBy=order_number%20ASC`)
- .then(response => {
- commit('carousel/GET_BANNER_SUCCESS', response.data)
- }, err => {
- commit('carousel/GET_BANNER_FAILURE', err)
- })
- },
- // 获取新楼层配置
- loadNewFloors({ commit }) {
- commit('floor/REQUEST_NEWLIST')
- return axios.get('/api/floors/home-v3')
- .then(response => {
- commit('floor/GET_NEWLIST_SUCCESS', response.data)
- }, err => {
- commit('floor/GET_NEWLIST_FAILURE', err)
- })
- },
- // 获取楼层配置f1
- loadNewFloorsF1({ commit }) {
- commit('floor/REQUEST_LISTF1')
- return axios.get(`/cmsApi?method=queryContentPage&module=home_floor_f1&orderBy=order_number%20ASC`)
- .then(response => {
- commit('floor/GET_LIST_SUCCESSF1', response.data)
- }, err => {
- commit('floor/GET_LIST_FAILUREF1', err)
- })
- },
- // 获取楼层配置f2
- loadNewFloorsF2({ commit }) {
- commit('floor/REQUEST_LISTF2')
- return axios.get(`/cmsApi?method=queryContentPage&module=home_floor_f2&orderBy=order_number%20ASC`)
- .then(response => {
- commit('floor/GET_LIST_SUCCESSF2', response.data)
- }, err => {
- commit('floor/GET_LIST_FAILUREF2', err)
- })
- },
- // 获取楼层配置f3
- loadNewFloorsF3({ commit }) {
- commit('floor/REQUEST_LISTF3')
- return axios.get(`/cmsApi?method=queryContentPage&module=home_floor_f3&orderBy=order_number%20ASC`)
- .then(response => {
- commit('floor/GET_LIST_SUCCESSF3', response.data)
- }, err => {
- commit('floor/GET_LIST_FAILUREF3', err)
- })
- },
- // 获取楼层配置f4
- loadNewFloorsF4({ commit }) {
- commit('floor/REQUEST_LISTF4')
- return axios.get(`/cmsApi?method=queryContentPage&module=home_floor_f4&orderBy=order_number%20ASC`)
- .then(response => {
- commit('floor/GET_LIST_SUCCESSF4', response.data)
- }, err => {
- commit('floor/GET_LIST_FAILUREF4', err)
- })
- },
- // 获取楼层配置f5
- loadNewFloorsF5({ commit }) {
- commit('floor/REQUEST_LISTF5')
- return axios.get(`/cmsApi?method=queryContentPage&module=home_floor_f5&orderBy=order_number%20ASC`)
- .then(response => {
- commit('floor/GET_LIST_SUCCESSF5', response.data)
- }, err => {
- commit('floor/GET_LIST_FAILUREF5', err)
- })
- },
- // 获取子器件类目
- loadProductKinds({ commit }, params = {}) {
- let id = params.id
- commit('product/kind/REQUEST_KIND', params)
- return axios.get(`/api/product/kind/${id}/children`)
- .then(response => {
- commit('product/kind/GET_KIND_SUCCESS', { id, result: response.data })
- }, err => {
- commit('product/kind/GET_KIND_FAILURE', { id, err })
- })
- },
- // 获取全部子器件类目
- loadAllProductKinds({ commit }, params = {}) {
- let id = params.id
- commit('product/kind/REQUEST_KIND', params)
- return axios.get(`/api/product/kind/${id}/children_all`)
- .then(response => {
- commit('product/kind/GET_KIND_SUCCESS', { id, result: response.data })
- }, err => {
- commit('product/kind/GET_KIND_FAILURE', { id, err })
- })
- },
- // 获取首页新闻
- loadNewsSnapshot({ commit }, params = {}) {
- commit('news/REQUEST_SNAPSHOT')
- return axios.get('/api/news/created', { params })
- .then(response => {
- commit('news/GET_SNAPSHOT_SUCCESS', response.data)
- }, err => {
- commit('news/GET_SNAPSHOT_FAILURE', err)
- })
- },
- // 获取器件统计信息
- loadProductCounts({ commit }, params = {}) {
- commit('product/common/REQUEST_COUNTS')
- return axios.get('/api/product/commoncount', { params })
- .then(response => {
- commit('product/common/GET_COUNTS_SUCCESS', response.data)
- }, err => {
- commit('product/common/GET_COUNTS_FAILURE', err)
- })
- },
- // 搜索关键字
- searchKeywords({ commit }, params = {}) {
- commit('search/REQUEST_KEYWORDS')
- return axios.get('/search/similarKeywords', { params })
- .then(response => {
- commit('search/GET_KEYWORDS_SUCCESS', response.data)
- }, err => {
- commit('search/GET_KEYWORDS_FAILURE', err)
- })
- },
- resetSearchKeywords({ commit }) {
- commit('search/RESET_KEYWORDS')
- },
- // 热卖推荐页面
- loadProductHot({ commit }, params = {}) {
- commit('original/REQUEST_HOT')
- return axios.get('/api/commodity/latest', { params })
- .then(response => {
- commit('original/GET_HOT_SUCCESS', response.data)
- }, err => {
- commit('original/GET_HOT_FAILURE', err)
- })
- },
- // 器件详情页面
- // 获得器件详情信息
- loadComponentDetail({ commit }, params = {}) {
- let id = params.id
- commit('componentDetail/REQUEST_DETAIL', params)
- return axios.get(`/api/product/component/${id}`)
- .then(response => {
- commit('componentDetail/GET_DETAIL_SUCCESS', response.data)
- if (response.data) {
- commit('componentMenu/REQUEST_MENU', params)
- return axios.get(`/api/product/kind/structing/${response.data.kindid}`)
- .then(response => {
- commit('componentMenu/GET_MENU_SUCCESS', response.data)
- }, err => {
- commit('componentMenu/GET_MENU_FAILURE', err)
- })
- }
- }, err => {
- commit('componentDetail/GET_DETAIL_FAILURE', err)
- })
- },
- // 获取器件详情页面包屑导航
- loadComponentMenu({ commit }, params = {}) {
- let pid = params.id
- commit('componentMenu/REQUEST_MENU', params)
- return axios.get(`/api/product/kind/structing/${pid}`)
- .then(response => {
- commit('componentMenu/GET_MENU_SUCCESS', response.data)
- }, err => {
- commit('componentMenu/GET_MENU_FAILURE', err)
- })
- },
- // 器件详情页选择商家
- loadComponentStore({ commit }, params = {}) {
- let id = params.uuid
- commit('componentStore/REQUEST_STORE', params)
- return axios.get(`/api/store-service/stores/uuid/${id}`)
- .then(response => {
- commit('componentStore/GET_STORE_SUCCESS', response.data)
- }, err => {
- commit('componentStore/GET_STORE_FAILURE', err)
- })
- },
- // 器件详情页商家列表
- loadComponentInformation({ commit }, params = {}) {
- // let params = {}
- // let filter = {uuid: uuid.uuid, ignoreUMall: false, ignoreStore: false}
- // // let sorting = {minPriceRMB: 'ASC'}
- // params.filter = filter
- // // params.sorting = sorting
- // params.page = pageParams.page
- // params.count = pageParams.count
- commit('componentInformation/REQUEST_INFORMATION')
- return axios.get('/api/commodity/goods/page', { params })
- .then(response => {
- commit('componentInformation/GET_INFORMATION_SUCCESS', response.data)
- }, err => {
- commit('componentInformation/GET_INFORMATION_FAILURE', err)
- })
- },
- // 获取库存寄售店铺storeid
- getUmallStoreId({ commit }) {
- commit('componentUmallStoreId/REQUEST_STOREID')
- return axios.get('/api/store-service/stores/UmallStore')
- .then(response => {
- commit('componentUmallStoreId/GET_STOREID_SUCCESS', response.data)
- }, err => {
- commit('componentUmallStoreId/GET_STOREID_FAILURE', err)
- })
- },
- // 品牌详情页面
- // 获得品牌详情信息
- loadBrandDetail({ commit, dispatch }, params = {}) {
- let id = params.id
- commit('brandDetail/REQUEST_DETAIL', params)
- return axios.get(`/api/product/brand/${id}`)
- .then(response => {
- let brand = response.data || {}
- commit('brandDetail/GET_DETAIL_SUCCESS', response.data)
- return Promise.all([
- loadBrandCategories({ commit }, { id: brand.id }),
- loadBrandComponent({ commit }, { count: 10, filter: { brandid: brand.id }, page: 1 })
- ])
- }, err => {
- commit('brandDetail/GET_DETAIL_FAILURE', err)
- })
- },
- // 获取品牌详情产品分类信息
- loadBrandCategories({ commit }, params = {}) {
- let id = params.id
- commit('brandCategories/REQUEST_CATEGORIES', params)
- return axios.get(`/api/product/brand/${id}/kinds`)
- .then(response => {
- commit('brandCategories/GET_CATEGORIES_SUCCESS', response.data)
- }, err => {
- commit('brandCategories/GET_CATEGORIES_FAILURE', err)
- })
- },
- // 获取品牌详情型号列表数据
- loadBrandComponent({ commit }, params = {}) {
- commit('brandComponent/REQUEST_COMPONENT', params)
- return axios.get('/api/product/component/list', { params })
- .then(response => {
- commit('brandComponent/GET_COMPONENT_SUCCESS', response.data)
- }, err => {
- commit('brandComponent/GET_COMPONENT_FAILURE', err)
- })
- },
- // 获取品牌详情分页信息
- loadBrandPages({ commit }, params = {}) {
- commit('brandPages/REQUEST_PAGES', params)
- return axios.get('/api/product/PAGES/list', { params })
- .then(response => {
- commit('brandPages/GET__SUCCESS', response.data)
- }, err => {
- commit('brandPages/GET_COMPONENT_FAILURE', err)
- })
- },
- // 留言板
- // 提交了留言板信息
- uploadMessageBoardInformation({ commit }, params) {
- commit('messageBoard/REQUEST_INFORMATION')
- return axios.post('/api/operation/messageBoard', params)
- .then(response => {
- commit('messageBoard/GET_INFORMATION_SUCCESS', response.data)
- }, err => {
- commit('messageBoard/GET_INFORMATION_FAILURE', err)
- })
- },
- // 验证用户是否登录
- userIsLogin({ commit }) {
- commit('messageBoardIsLogin/REQUEST_LOGIN')
- return axios.get('/user/authentication')
- .then(response => {
- commit('messageBoardIsLogin/GET_LOGIN_SUCCESS', response.data)
- }, err => {
- commit('messageBoardIsLogin/GET_LOGIN_FAILURE', err)
- })
- },
- // 获取留言记录信息
- getMessageBoardInformation({ commit }, params) {
- let sorting = { createDate: 'DESC' }
- params.sorting = sorting
- commit('messageBoardInformation/REQUEST_INFORMATION', params)
- return axios.get('/operation/messageBoard/pageInfo/user', { params })
- .then(response => {
- commit('messageBoardInformation/GET_INFORMATION_SUCCESS', response.data)
- }, err => {
- commit('messageBoardInformation/GET_INFORMATION_FAILURE', err)
- })
- },
- // 获取帮助中心信息
- loadHelpSnapsho({ commit }, params = {}) {
- commit('help/REQUEST_SNAPSHO')
- return axios.get('/api/help-service/helps', { params })
- .then(response => {
- commit('help/GET_SNAPSHO_SUCCESS', response.data)
- }, err => {
- commit('help/GET_SNAPSHO_FAILURE', err)
- })
- },
- // 获取帮助中心二级菜单
- loadHelpList({ commit }, params = {}) {
- commit('help/REQUEST_HELPLIST')
- return axios.get('/api/help-service/issues', { params })
- .then(response => {
- commit('help/GET_HELPLIST_SUCCESS', response.data)
- }, err => {
- commit('help/GET_HELPLIST_FAILURE', err)
- })
- },
- // 获取帮助中心名称
- loadHelpTitle({ commit }, params = {}) {
- let id = params.id
- commit('help/REQUEST_TITLE')
- return axios.get(`/api/help-service/${id}`, { params })
- .then(response => {
- commit('help/GET_TITLE_SUCCESS', response.data)
- }, err => {
- commit('help/GET_TITLE_FAILURE', err)
- })
- },
- // 获取详情
- loadHelpDetail({ commit }, params = {}) {
- let id = params.id
- commit('help/REQUEST_DETAIL')
- return axios.get(`/api/help-service/issues/${id}`, { params })
- .then(response => {
- commit('help/GET_DETAIL_SUCCESS', response.data)
- let id = response.data.navId
- commit('help/REQUEST_TITLE')
- return axios.get(`/api/help-service/${id}`)
- .then(response => {
- commit('help/GET_TITLE_SUCCESS', response.data)
- }, err => {
- commit('help/GET_TITLE_FAILURE', err)
- })
- }, err => {
- commit('help/GET_DETAIL_FAILURE', err)
- })
- },
- // 获取最多搜索量的 器件
- loadHotSearchDevice({ commit }) {
- commit('hotSearchDevice/REQUEST_HOT')
- return axios.get('/api/product/component/mostSearchComponent')
- .then(response => {
- commit('hotSearchDevice/GET_HOT_SUCCESS', response.data)
- }, err => {
- commit('hotSearchDevice/GET_HOT_FAILURE', err)
- })
- },
- // 获取最多搜索量的 品牌
- loadHotSearchBrand({ commit }) {
- commit('hotSearchBrand/REQUEST_HOT')
- return axios.get('/api/product/brand/mostSearchBrands')
- .then(response => {
- commit('hotSearchBrand/GET_HOT_SUCCESS', response.data)
- }, err => {
- commit('hotSearchBrand/GET_HOT_FAILURE', err)
- })
- },
- // 获取用户开店信息
- loadStoreStatus({ commit }, params = {}) {
- commit('option/REQUEST_STORE_STATUS')
- return axios.get('/store-service/stores', { params: params })
- .then(response => {
- commit('option/REQUEST_STORE_STATUS_SUCCESS', response.data)
- }, err => {
- commit('option/REQUEST_STORE_STATUS_FAILURE', err)
- })
- },
- // 获取首页悬浮计数器交易金额
- loadAllCount ({commit}, params) {
- commit('count/REQUEST_ALLCOUNT')
- return axios.get('/api/product/commoncount', {params})
- .then(res => {
- commit('count/GET_ALLCOUNT_SUCCESS', res.data)
- }, (err) => {
- commit('count/GET_ALLCOUNT_FAILURE', err)
- })
- },
- // 获取首页悬浮计数器询价单
- loadInquirySheet ({commit}, params) {
- commit('count/REQUEST_INQUIRYSHEET')
- return axios.get('/inquiry/public/getPurcInquiryItemCountByMonth', {params})
- .then(res => {
- commit('count/GET_INQUIRYSHEET_SUCCESS', res.data)
- }, (err) => {
- commit('count/GET_INQUIRYSHEET_FAILURE', err)
- })
- },
- loadInquirySheetLast ({commit}, params) {
- commit('count/REQUEST_INQUIRYSHEETLAST')
- return axios.get('/inquiry/public/getPurcInquiryItemCountByMonth', {params})
- .then(res => {
- commit('count/GET_INQUIRYSHEETLAST_SUCCESS', res.data)
- }, (err) => {
- commit('count/GET_INQUIRYSHEETLAST_FAILURE', err)
- })
- },
- // 保存微信信息
- GerWechatInfo({ commit }, params = {}) {
- commit('option/REQUEST_WECHATINFO_STATUS')
- return axios.get('/wx/getWxUserInfo', { params: params })
- .then(response => {
- commit('option/REQUEST_WECHATINFO_STATUS_SUCCESS', response.data)
- if (response.data.openid) {
- localStorage.setItem('USOFTMALLWECHATINFO', JSON.stringify(response.data))
- } else {
- // localStorage.removeItem('USOFTMALLWECHATINFO')
- }
- }, err => {
- localStorage.removeItem('USOFTMALLWECHATINFO')
- commit('option/REQUEST_WECHATINFO_STATUS_FAILURE', err)
- })
- },
- // 获取品牌中心轮播图
- loadBrandCarousel ({ commit }) {
- commit('carousel/REQUEST_BRANDCAROUSEL')
- return axios.get('/cmsApi?method=queryContentPage&module=brandCenter_littleSlideshow')
- .then(response => {
- commit('carousel/GET_BRANDCAROUSEL_SUCCESS', response.data)
- }, err => {
- commit('carousel/GET_BRANDCAROUSEL_FAILURE', err)
- })
- },
- // 获取品牌中心首屏背景图
- loadBrandBanner ({ commit }) {
- commit('product/banner/REQUEST_BRANDBANNER')
- return axios.get('/cmsApi?method=queryContentPage&module=brandCenter_firstScreen')
- .then(response => {
- commit('product/banner/GET_BRANDBANNER_SUCCESS', response.data)
- }, err => {
- commit('product/banner/GET_BRANDBANNER_FAILURE', err)
- })
- }
- }
|