| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- import axios from '~/plugins/axios'
- export const actions = {
- // 获取用户信息
- getUserInfo ({ commit }, params = {}) {
- commit('lotteryInfo/REQUEST_USER_INFO')
- return axios.get('/lottery/userInfo', {params})
- .then(response => {
- commit('lotteryInfo/GET_USER_INFO_SUCCESS', response.data)
- }, err => {
- commit('lotteryInfo/GET_USER_INFO_FAILURE', err)
- })
- },
- // 获取下一等级
- getNextLevel ({ commit }, params = {}) {
- commit('lotteryInfo/REQUEST_NEXT_LEVEL')
- return axios.get('/lottery/user/activityItems', {params})
- .then(response => {
- commit('lotteryInfo/GET_NEXT_LEVEL_SUCCESS', response.data)
- }, err => {
- commit('lotteryInfo/GET_NEXT_LEVEL_FAILURE', err)
- })
- },
- // 获取活动参与者中奖记录
- getWinningRecord ({ commit }, params = {}) {
- commit('lotteryInfo/REQUEST_WIN_RECORD')
- return axios.get('/lottery/user/winninghistories', {params})
- .then(response => {
- commit('lotteryInfo/GET_WIN_RECORD_SUCCESS', response.data)
- }, err => {
- commit('lotteryInfo/GET_WIN_RECORD_FAILURE', err)
- })
- },
- // 获取个人中奖记录
- getOwnWinningRecord ({ commit }, params = {}) {
- commit('lotteryInfo/REQUEST_OWN_WIN_RECORD')
- return axios.get('/lottery/user/winninghistories/one', {params})
- .then(response => {
- commit('lotteryInfo/GET_OWN_WIN_RECORD_SUCCESS', response.data)
- }, err => {
- commit('lotteryInfo/GET_OWN_WIN_RECORD_FAILURE', err)
- })
- },
- // 获取当前等级对应奖品
- currentGradePrizes ({ commit }, params = {}) {
- let resItems = []
- commit('lotteryInfo/REQUEST_CURRENT_GRADE_PRIZES')
- return axios.get('/lottery/user/prizes', {params})
- .then(res => {
- // if (res.data.data) {
- // resItems = res.data
- // for (let i = 0; i < resItems.data.length; i++) {
- // resItems.data[i].$index = i
- // resItems.code = 200
- // resItems.success = true
- // }
- // console.log(resItems, 'resItems')
- // commit('lotteryInfo/GET_CURRENT_GRADE_PRIZES_SUCCESS', resItems)
- // }
- resItems = res.data
- for (let i = 0; i < resItems.data.length; i++) {
- resItems.data[i].$index = i
- resItems.code = 200
- resItems.success = true
- }
- commit('lotteryInfo/GET_CURRENT_GRADE_PRIZES_SUCCESS', resItems)
- }, err => {
- commit('lotteryInfo/GET_CURRENT_GRADE_PRIZES_FAILURE', err)
- })
- },
- // 抽奖
- getOwnLotteryInfo ({ commit }, params = {}) {
- commit('lotteryInfo/REQUEST_OWN_LOTTERY_INFO')
- return axios.get('/lottery/user/draw', {params})
- .then(response => {
- commit('lotteryInfo/GET_OWN_LOTTERY_INFO_SUCCESS', response.data)
- }, err => {
- commit('lotteryInfo/GET_OWN_LOTTERY_INFO_FAILURE', err)
- })
- }
- }
|