123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519 |
- 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)
-
- if (route.query) {
- let messageType = route.query.messageType || ''
- store.commit('option/GET_MESSAGETYPE', messageType)
- }
- if (cookie && cookie.length) {
-
-
-
-
-
-
-
-
- axios.defaults.headers['cookie'] = store.state.option.cookies
- axios.defaults.headers['User-Agent'] = store.state.option.userAgent
- } else {
- axios.defaults.headers['cookie'] = ''
- axios.defaults.headers['User-Agent'] = ''
- }
-
- if (!isDev) {
- store.commit('option/UPDATE_URL', 'https://mall.usoftchina.com')
- }
- return Promise.all([
-
- store.dispatch('loadUserInfo')
- ])
- },
-
- 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)
- })
- },
-
- loadCounterData ({commit}) {
- commit('option/REQUEST_COUNTER')
- return axios.get('/api/product/commoncount')
- .then(res => {
- commit('option/REQUEST_COUNTER_SUCCESS', res.data)
- }, err => {
- commit('option/REQUEST_COUNTER_FAILURE')
- })
- },
-
- loadCurrencyData ({commit}) {
- return axios.get('/basic/enterprise/currency')
- .then(res => {
- commit('option/SET_CURRENCY', res.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)
- })
- },
-
- 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)
- })
- },
-
- loadHotSearch({ commit }) {
- commit('hotSearch/REQUEST_HOT')
- return axios.get('/cmsApi?method=queryContentPage&module=index_hotModels&orderBy=order_number%20ASC')
- .then(response => {
- commit('hotSearch/GET_HOT_SUCCESS', response.data)
- }, err => {
- commit('hotSearch/GET_HOT_FAILURE', err)
- })
- },
-
- loadNewFloors({ commit }, params = {}) {
- commit('floor/REQUEST_NEWLIST')
- return axios.get(`/cmsApi?method=queryContentPage&module=${params.type}&orderBy=order_number%20ASC&status=normal`)
- .then(response => {
- commit('floor/GET_NEWLIST_SUCCESS', response.data)
- }, err => {
- commit('floor/GET_NEWLIST_FAILURE', 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)
- })
- },
-
- searchKeywordsList({ commit }, params = {}) {
- commit('search/REQUEST_KEYWORDSLIST')
- return axios.get('/search/201819', { params })
- .then(response => {
- commit('search/GET_KEYWORDSLIST_SUCCESS', response.data)
- }, err => {
- commit('search/GET_KEYWORDSLIST_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 = {}) {
-
-
-
-
-
-
-
- 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)
- })
- },
-
- 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)
- })
- },
-
- 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/getCountOfLastAndThisMonth', {params})
- .then(res => {
- commit('count/GET_INQUIRYSHEET_SUCCESS', res.data.current || 0)
- commit('count/GET_INQUIRYSHEETLAST_SUCCESS', res.data.last || 0)
- }, (err) => {
- commit('count/GET_INQUIRYSHEET_FAILURE', err)
- commit('count/GET_INQUIRYSHEETLAST_FAILURE', err)
- })
- },
-
- GerWechatInfo({ commit }, params = {}) {
- let id = params.openId
- commit('option/REQUEST_WECHATINFO_STATUS')
- return axios.get('/wx/getWxUserInfo', { params: params })
- .then(response => {
- let Userinfo = localStorage.getItem('USOFTMALLWECHATINFO')
- Userinfo = Userinfo && JSON.parse(Userinfo) || {}
- localStorage.removeItem('USOFTMALLWECHATINFO')
- if (response.data.status >= 0) {
- if (id !== '' && id && id !== undefined) {
- Userinfo.openid = id
- } else {
- Userinfo.headimgurl = response.data.headimgurl
- Userinfo.nickname = response.data.nickname
- Userinfo.openid = response.data.openid
- }
- if (response.data.status === 1) {
- Userinfo.userAccount = response.data.userAccount
- }
- Userinfo.status = response.data.status
- Userinfo.enterprises = response.data.enterprises
- localStorage.setItem('USOFTMALLWECHATINFO', JSON.stringify(Userinfo))
- commit('option/REQUEST_WECHATINFO_STATUS_SUCCESS', Userinfo)
- } else {
-
- }
- }, 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)
- })
- }
- }
|