123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- import axios from '~plugins/axios'
- function countStoreOrderCount (store) {
- return axios.get('/api/provider/order/storeid/' + store.uuid + '/count')
- }
- function findStoreFocusInMobil (store) {
- return axios.get('/trade/storeFocus/ifFocus?storeid=' + store.id)
- }
- export const actions = {
-
- loadSalesStore ({ commit }, params = {isOriginal: false}) {
- commit('storeCms/REQUEST_SALES')
- return axios.get('/api/store-service/stores', {
- params: {
- filter: 'topBySales',
- isOriginal: params.isOriginal
- }
- }).then(response => {
- let stores = response.data || []
- let orderCounts = []
- for (let i = 0; i < stores.length; i++) {
- orderCounts.push(countStoreOrderCount(stores[i]))
- }
-
- return Promise.all(orderCounts)
- .then(result => {
- if (result) {
- for (let i = 0; i < result.length; i++) {
- stores[i].orderCount = result[i].data ? result[i].data.orderCount : 0
- }
- }
- commit('storeCms/GET_SALES_SUCCESS', stores)
- }, err => {
- commit('storeCms/GET_SALES_FAILURE', err)
- })
- }, err => {
- commit('storeCms/GET_SALES_FAILURE', err)
- })
- },
-
- loadFactoriesCount ({commit}, params = {types: 'ORIGINAL_FACTORY'}) {
- commit('stores/REQUEST_ORIGINALCOUNT')
- return axios.get('/api/store-service/stores/type/count', {
- params: {
- types: params.types
- }
- }).then(response => {
- commit('stores/GET_ORIGINALCOUNT_SUCCESS', response.data && response.data.success ? response.data.data : 0)
- }, err => {
- commit('stores/GET_ORIGINALCOUNT_FAILURE', err)
- })
- },
-
- loadAgencyCount ({commit}, params = {types: 'AGENCY-DISTRIBUTION'}) {
- commit('stores/REQUEST_STORE_COUNT')
- return axios.get('/api/store-service/stores/type/count', {
- params: {
- types: params.types
- }
- }).then(response => {
- commit('stores/GET_STORE_COUNT_SUCCESS', response.data && response.data.success ? response.data.data : 0)
- }, err => {
- commit('stores/GET_STORE_COUNT_FAILURE', err)
- })
- },
-
- loadNewStores ({ commit }, params = { types: 'ORIGINAL_FACTORY' }) {
- commit('storeCms/REQUEST_NEW_STORES')
- return axios.get('/api/store-service/stores', {
- params: {
- filter: 'newStore',
- types: params.types,
- size: params.size
- }
- }).then(response => {
- commit('storeCms/GET_NEW_STORES_SUCCESS', response.data)
- }, err => {
- commit('storeCms/GET_NEW_STORES_FAILURE', err)
- })
- },
-
- loadRecommendOriginal ({ commit }, params = {}) {
- commit('storeCms/REQUEST_RECOMMEND_STORE')
- return axios.get('/api/store-service/stores/five', { params })
- .then(response => {
- commit('storeCms/GET_RECOMMEND_STORE_SUCCESS', response.data)
- }, err => {
- commit('storeCms/GET_RECOMMEND_STORE_FAILURE', err)
- })
- },
-
- loadRecommendStores ({ commit }, params = {}) {
- commit('storeCms/REQUEST_RECOMMEND_STORE')
- return axios.get('/api/cms-service/storeIn', { params })
- .then(response => {
- commit('storeCms/GET_RECOMMEND_STORE_SUCCESS', response.data)
- }, err => {
- commit('storeCms/GET_RECOMMEND_STORE_FAILURE', err)
- })
- },
- loadHotComponents ({ commit }) {
- commit('storeCms/REQUEST_HOT_COMPONENTS')
- return axios.get('/cmsApi?method=queryContentPage&module=recommended&orderBy=order_number%20ASC')
- .then(response => {
- commit('storeCms/GET_HOT_COMPONENTS_SUCCESS', response.data)
- }, err => {
- commit('storeCms/GET_HOT_COMPONENTS_FAILURE', err)
- })
- },
- findStoreList ({ commit }, params = {}) {
- params.op = 'pageByType'
- commit('stores/REQUEST_STORE_LIST')
- return axios.get('/api/store-service/stores', { params })
- .then(response => {
- commit('stores/GET_STORE_LIST_SUCCESS', response.data)
- }, err => {
- commit('stores/GET_STORE_LIST_FAILURE', err)
- })
- },
- findSimilarStoreList ({ commit }, params = {}) {
- params.op = 'similar'
- commit('stores/REQUEST_STORE_LIST')
- return axios.get('/api/store-service/stores', { params })
- .then(response => {
- commit('stores/GET_STORE_LIST_SUCCESS', response.data)
- }, err => {
- commit('stores/GET_STORE_LIST_FAILURE', err)
- })
- },
- findStoreListInMobil ({ commit }, params = {}) {
- params.op = 'similar'
- commit('stores/REQUEST_STORE_LIST')
- return axios.get('/api/store-service/stores', { params })
- .then(response => {
- let listData = response.data
- let focusData = []
- for (let i = 0; i < listData.content.length; i++) {
- let str = findStoreFocusInMobil({id: listData.content[i].id})
- focusData.push(str)
- }
-
- return Promise.all(focusData)
- .then(result => {
- if (result) {
- for (let i = 0; i < result.length; i++) {
- listData.content[i].isFocus = result[i] ? result[i].data : 'false'
- }
- }
- commit('stores/GET_STORE_LIST_SUCCESS', listData)
- }, err => {
- console.log(err)
- for (let i = 0; i < listData.content.length; i++) {
- listData.content[i].isFocus = 'false'
- }
- commit('stores/GET_STORE_LIST_SUCCESS', listData)
- })
- }, err => {
- commit('stores/GET_STORE_LIST_FAILURE', err)
- })
- }
- }
|