...
|
...
|
@@ -24,14 +24,24 @@ export default function() { |
|
|
askBuyNum: 0,
|
|
|
couponNum: 0,
|
|
|
assetData: {
|
|
|
isFetching: false,
|
|
|
list: [],
|
|
|
currentPage: 1,
|
|
|
pageSize: 20,
|
|
|
endReached: false,
|
|
|
compensateIncome: '¥0.00',
|
|
|
goodsIncome: '¥0.00',
|
|
|
totalIncome: '¥0.00',
|
|
|
waitApplyCashAmount: '0.00',
|
|
|
waitApplyInfo: {
|
|
|
isEnd: false,
|
|
|
currentPage: 1,
|
|
|
pageSize: 20,
|
|
|
totalPage: 0,
|
|
|
list: []
|
|
|
},
|
|
|
incomeInfo: {
|
|
|
isEnd: false,
|
|
|
currentPage: 1,
|
|
|
pageSize: 20,
|
|
|
totalPage: 0,
|
|
|
list: []
|
|
|
}
|
|
|
},
|
|
|
walletData: {
|
|
|
isFetching: false,
|
...
|
...
|
@@ -293,6 +303,18 @@ export default function() { |
|
|
state.resource1 = Object.assign({}, state.resource1, resource1);
|
|
|
state.resource2 = Object.assign({}, state.resource1, resource2);
|
|
|
},
|
|
|
|
|
|
setAssetStatisticalInfo(state, summary = {}) {
|
|
|
const {compensateIncome, goodsIncome, totalIncome, waitApplyCashAmount} = summary;
|
|
|
|
|
|
state.assetData.compensateIncome = formatNumber(compensateIncome || 0);
|
|
|
state.assetData.goodsIncome = formatNumber(goodsIncome || 0);
|
|
|
state.assetData.totalIncome = formatNumber(totalIncome || 0);
|
|
|
state.assetData.waitApplyCashAmount = waitApplyCashAmount;
|
|
|
},
|
|
|
setAssets(state, assetsInfo = {}) {
|
|
|
state.assetData = {...state.assetData, ...assetsInfo};
|
|
|
}
|
|
|
},
|
|
|
actions: {
|
|
|
async fetchRollBoardList({ commit }) {
|
...
|
...
|
@@ -379,38 +401,82 @@ export default function() { |
|
|
commit('addCouponSummary', { count: result.data });
|
|
|
}
|
|
|
},
|
|
|
async fetchAssets({ commit, state }, isRefresh) {
|
|
|
let {
|
|
|
isFetching,
|
|
|
endReached,
|
|
|
currentPage,
|
|
|
list,
|
|
|
pageSize,
|
|
|
} = state.assetData;
|
|
|
async fetchAssets({state, dispatch}, isRefresh) {
|
|
|
const {incomeInfo, waitApplyInfo} = state.assetData;
|
|
|
|
|
|
if (isFetching || (!isRefresh && endReached)) {
|
|
|
if (!isRefresh && waitApplyInfo.isEnd && incomeInfo.isEnd) {
|
|
|
return;
|
|
|
}
|
|
|
let oldList = isRefresh ? [] : list;
|
|
|
|
|
|
// commit('assetFetching', {isFetching: true});
|
|
|
let page = isRefresh ? 1 : currentPage + 1;
|
|
|
if (waitApplyInfo.isEnd) {
|
|
|
const res = await dispatch('fetchInComeAssets');
|
|
|
|
|
|
return res;
|
|
|
} else {
|
|
|
const res = await dispatch('fetchWaitApplyAssets', isRefresh);
|
|
|
|
|
|
return res;
|
|
|
}
|
|
|
},
|
|
|
|
|
|
async fetchInComeAssets({commit, state}, isRefresh) {
|
|
|
let {currentPage, list, pageSize} = state.assetData.incomeInfo;
|
|
|
|
|
|
const page = isRefresh ? 1 : currentPage + 1;
|
|
|
|
|
|
if (isRefresh) {
|
|
|
list = [];
|
|
|
}
|
|
|
|
|
|
const result = await this.$api.get('/api/ufo/mine/assets', {
|
|
|
type: 1,
|
|
|
type: 2,
|
|
|
page,
|
|
|
limit: pageSize,
|
|
|
});
|
|
|
|
|
|
// commit('assetFetching', {isFetching: false});
|
|
|
if (result.code === 200) {
|
|
|
let assetData = parseAssetList(result.data);
|
|
|
let newList = [...oldList, ...assetData.list];
|
|
|
|
|
|
assetData.list = newList;
|
|
|
commit('addAssets', assetData);
|
|
|
assetData.list = [...list, ...assetData.list];
|
|
|
|
|
|
commit('setAssetStatisticalInfo', result.data.summary);
|
|
|
commit('setAssets', {incomeInfo: assetData});
|
|
|
|
|
|
return assetData;
|
|
|
}
|
|
|
},
|
|
|
|
|
|
async fetchWaitApplyAssets({commit, state, dispatch}, isRefresh) {
|
|
|
let {currentPage, list, pageSize} = state.assetData.waitApplyInfo;
|
|
|
|
|
|
return result;
|
|
|
const page = isRefresh ? 1 : currentPage + 1;
|
|
|
|
|
|
if (isRefresh) {
|
|
|
list = [];
|
|
|
}
|
|
|
|
|
|
const result = await this.$api.get('/api/ufo/mine/assets', {
|
|
|
type: 1,
|
|
|
page,
|
|
|
limit: pageSize,
|
|
|
});
|
|
|
|
|
|
if (result.code === 200) {
|
|
|
let assetData = parseAssetList(result.data);
|
|
|
|
|
|
assetData.list = [...list, ...assetData.list];
|
|
|
|
|
|
commit('setAssetStatisticalInfo', result.data.summary);
|
|
|
commit('setAssets', {waitApplyInfo: assetData});
|
|
|
|
|
|
if (assetData.isEnd) {
|
|
|
const res = await dispatch('fetchInComeAssets', isRefresh);
|
|
|
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
return assetData;
|
|
|
}
|
|
|
},
|
|
|
|
|
|
async applyCash(_, id) {
|
...
|
...
|
|