|
|
import {parseAssetList, formatNumber, maskAccount} from '../../utils/mine-handler';
|
|
|
import { parseAssetList, formatNumber } from '../../utils/mine-handler';
|
|
|
import { get, set } from 'lodash';
|
|
|
import { getImgUrl } from '../../common/utils';
|
|
|
import moment from 'moment';
|
|
|
import { sellerOrderStatus, ownType } from '../../../constants/order-constants';
|
|
|
|
|
|
// const uid = '600046428';
|
|
|
const uid = '500031424';
|
...
|
...
|
@@ -23,6 +24,7 @@ export default function() { |
|
|
favoriteNum: 0,
|
|
|
buyNum: 0,
|
|
|
askBuyNum: 0,
|
|
|
couponNum: 0,
|
|
|
assetData: {
|
|
|
isFetching: false,
|
|
|
list: [],
|
...
|
...
|
@@ -31,7 +33,7 @@ export default function() { |
|
|
endReached: false,
|
|
|
compensateIncome: '¥0.00',
|
|
|
goodsIncome: '¥0.00',
|
|
|
totalIncome: '¥0.00'
|
|
|
totalIncome: '¥0.00',
|
|
|
},
|
|
|
walletData: {
|
|
|
isFetching: false,
|
...
|
...
|
@@ -41,52 +43,110 @@ export default function() { |
|
|
endReached: false,
|
|
|
tradeType: 0,
|
|
|
startTime: 0,
|
|
|
endTime: 0
|
|
|
endTime: 0,
|
|
|
},
|
|
|
userWalletInfo: {
|
|
|
totalAmount: 0.00,
|
|
|
totalAmount: 0.0,
|
|
|
withdrawLimit: 0,
|
|
|
withdrawAmount: 0,
|
|
|
shareSettlementAmount: 0,
|
|
|
walletAmount: 0.00
|
|
|
walletAmount: 0.0,
|
|
|
},
|
|
|
filterData: {
|
|
|
tradeTypes: [],
|
|
|
beginTime: 0,
|
|
|
endTime: 0
|
|
|
endTime: 0,
|
|
|
},
|
|
|
resource1: {},
|
|
|
resource2: {}
|
|
|
resource2: {},
|
|
|
},
|
|
|
getters: {
|
|
|
getOrderNums(state) {
|
|
|
let orderSum = {
|
|
|
ready: {name: '待发货', num: state.readyNum, page: {name: 'OrderList', status: 0} },
|
|
|
sent: {name: '已发货', num: state.sentNum, page: {name: 'OrderList', status: 1}},
|
|
|
finish: {name: '交易成功', num: state.finishNum, page: {name: 'OrderList', status: 2}},
|
|
|
fail: {name: '交易失败', num: state.failNum, page: {name: 'OrderList', status: 3}}
|
|
|
ready: {
|
|
|
name: '待发货',
|
|
|
num: state.readyNum,
|
|
|
page: {
|
|
|
name: 'OrderList',
|
|
|
status: sellerOrderStatus.TO_BE_DELIVERED,
|
|
|
},
|
|
|
},
|
|
|
sent: {
|
|
|
name: '已发货',
|
|
|
num: state.sentNum,
|
|
|
page: { name: 'OrderList', status: sellerOrderStatus.SHIPPED },
|
|
|
},
|
|
|
finish: {
|
|
|
name: '交易成功',
|
|
|
num: state.finishNum,
|
|
|
page: { name: 'OrderList', status: sellerOrderStatus.DONE },
|
|
|
},
|
|
|
fail: {
|
|
|
name: '交易失败',
|
|
|
num: state.failNum,
|
|
|
page: { name: 'OrderList', status: sellerOrderStatus.FAILED },
|
|
|
},
|
|
|
};
|
|
|
|
|
|
return orderSum;
|
|
|
},
|
|
|
getMineList(state) {
|
|
|
let tabList = {
|
|
|
board: { title: '公告栏', page: 'noticeList'},
|
|
|
sale: { title: '出售中', num: state.sellerNum, page: ''},
|
|
|
order: {name: 'order'},
|
|
|
resource1: {name: 'resource1', data: state.resource1},
|
|
|
income: {title: '交易收入', num: state.assetData.totalIncome, page: 'income'}, // 原交易收入 tradeIncome
|
|
|
buyOrder: {title: '我购买的订单', num: state.buyNum, page: ''},
|
|
|
buy: {name: 'buy', title: '我的求购', num: state.askBuyNum, page: ''},
|
|
|
collect: {name: 'collect', title: '我的收藏', num: state.favoriteNum, page: 'favorite'},
|
|
|
resource2: {name: 'resource2', data: state.resource2}
|
|
|
board: { title: '公告栏', page: 'noticeList' },
|
|
|
sale: {
|
|
|
title: '出售中',
|
|
|
num: state.sellerNum,
|
|
|
page: 'InSaleOrderList',
|
|
|
},
|
|
|
order: { name: 'order' },
|
|
|
resource1: { name: 'resource1', data: state.resource1 },
|
|
|
income: {
|
|
|
title: '我的收入',
|
|
|
num: '¥' + state.userWalletInfo.walletAmount,
|
|
|
page: 'income',
|
|
|
}, // 原交易收入 tradeIncome
|
|
|
buyOrder: {
|
|
|
title: '我的订单',
|
|
|
num: state.buyNum,
|
|
|
page: 'OrderList',
|
|
|
params: { owner: ownType.BUY },
|
|
|
},
|
|
|
buy: {
|
|
|
name: 'buy',
|
|
|
title: '我的求购',
|
|
|
num: state.askBuyNum,
|
|
|
page: '',
|
|
|
},
|
|
|
collect: {
|
|
|
name: 'collect',
|
|
|
title: '我的收藏',
|
|
|
num: state.favoriteNum,
|
|
|
page: 'favorite',
|
|
|
},
|
|
|
coupon: {
|
|
|
name: 'coupon',
|
|
|
title: '我的优惠券',
|
|
|
num: state.couponNum,
|
|
|
page: ''
|
|
|
},
|
|
|
service: {
|
|
|
name: 'service',
|
|
|
title: '我的客服',
|
|
|
page: 'service'
|
|
|
},
|
|
|
resource2: { name: 'resource2', data: state.resource2 },
|
|
|
|
|
|
};
|
|
|
|
|
|
return tabList;
|
|
|
},
|
|
|
getYearMonth(state) {
|
|
|
let beginTime = moment(new Date(state.filterData.beginTime * 1000)).format('YYYY-MM');
|
|
|
let endTime = moment(new Date(state.filterData.endTime * 1000)).format('YYYY-MM');
|
|
|
let beginTime = moment(
|
|
|
new Date(state.filterData.beginTime * 1000),
|
|
|
).format('YYYY-MM');
|
|
|
let endTime = moment(new Date(state.filterData.endTime * 1000)).format(
|
|
|
'YYYY-MM',
|
|
|
);
|
|
|
|
|
|
var a = moment(endTime.split('-'));
|
|
|
var b = moment(beginTime.split('-'));
|
...
|
...
|
@@ -100,17 +160,17 @@ export default function() { |
|
|
for (let i = 0; i <= yearNum; i++) {
|
|
|
let year = '' + (Number(beginYear) + i);
|
|
|
|
|
|
yearsData.push({text: year, value: year});
|
|
|
yearsData.push({ text: year, value: year });
|
|
|
}
|
|
|
for (let i = 0; i <= monthNum; i++) {
|
|
|
let month = Number(beginMonth) + i;
|
|
|
|
|
|
month = month < 10 ? '0' + month : month;
|
|
|
monthsData.push({text: month, value: month});
|
|
|
monthsData.push({ text: month, value: month });
|
|
|
}
|
|
|
|
|
|
return [yearsData, monthsData];
|
|
|
}
|
|
|
},
|
|
|
},
|
|
|
mutations: {
|
|
|
addList(state, { list }) {
|
...
|
...
|
@@ -128,8 +188,7 @@ export default function() { |
|
|
state.animate = false;
|
|
|
},
|
|
|
addSellerOrder(state, { orderSumList }) {
|
|
|
|
|
|
orderSumList.forEach((item) => {
|
|
|
orderSumList.forEach(item => {
|
|
|
switch (item.listType) {
|
|
|
case 1:
|
|
|
state.sellerNum = item.sum;
|
...
|
...
|
@@ -152,11 +211,11 @@ export default function() { |
|
|
});
|
|
|
},
|
|
|
|
|
|
addFavoriteNum(state, {count}) {
|
|
|
addFavoriteNum(state, { count }) {
|
|
|
state.favoriteNum = count;
|
|
|
},
|
|
|
addOrderSummary(state, {data}) {
|
|
|
data.forEach((item) => {
|
|
|
addOrderSummary(state, { data }) {
|
|
|
data.forEach(item => {
|
|
|
switch (item.actor) {
|
|
|
case 'buy':
|
|
|
state.buyNum = item.sum;
|
...
|
...
|
@@ -169,6 +228,9 @@ export default function() { |
|
|
}
|
|
|
});
|
|
|
},
|
|
|
addCouponSummary(state, {count}) {
|
|
|
state.couponNum = count;
|
|
|
},
|
|
|
addAssets(state, assetData) {
|
|
|
assetData.totalIncome = formatNumber(assetData.totalIncome);
|
|
|
assetData.compensateIncome = formatNumber(assetData.compensateIncome);
|
...
|
...
|
@@ -176,8 +238,10 @@ export default function() { |
|
|
state.assetData = Object.assign({}, state.assetData, assetData);
|
|
|
},
|
|
|
addWallet(state, walletData) {
|
|
|
walletData.list.map((item) => {
|
|
|
item.time = moment(new Date(item.createTime * 1000)).format('YYYY.MM.DD HH:mm');
|
|
|
walletData.list.map(item => {
|
|
|
item.time = moment(new Date(item.createTime * 1000)).format(
|
|
|
'YYYY.MM.DD HH:mm',
|
|
|
);
|
|
|
item.amount = Number(Math.abs(item.amount)).toFixed(2);
|
|
|
return item;
|
|
|
});
|
...
|
...
|
@@ -186,7 +250,7 @@ export default function() { |
|
|
changeWalletType(state, data) {
|
|
|
state.walletData.tradeType = data;
|
|
|
},
|
|
|
changeWalletTime(state, {startTime, endTime}) {
|
|
|
changeWalletTime(state, { startTime, endTime }) {
|
|
|
state.walletData.startTime = startTime;
|
|
|
state.walletData.endTime = endTime;
|
|
|
},
|
...
|
...
|
@@ -196,7 +260,7 @@ export default function() { |
|
|
addfilterData(state, data) {
|
|
|
let tradeTypes = [];
|
|
|
|
|
|
data.tradeTypes.forEach((item) => {
|
|
|
data.tradeTypes.forEach(item => {
|
|
|
let typeItem = {};
|
|
|
|
|
|
typeItem.text = item.desc;
|
...
|
...
|
@@ -206,14 +270,14 @@ export default function() { |
|
|
data.tradeTypes = tradeTypes;
|
|
|
state.filterData = data;
|
|
|
},
|
|
|
assetFetching(state, {isFetching}) {
|
|
|
assetFetching(state, { isFetching }) {
|
|
|
state.assetData.isFetching = isFetching;
|
|
|
},
|
|
|
|
|
|
addResource(state, {resource1 = {}, resource2 = {}}) {
|
|
|
addResource(state, { resource1 = {}, resource2 = {} }) {
|
|
|
state.resource1 = Object.assign({}, state.resource1, resource1);
|
|
|
state.resource2 = Object.assign({}, state.resource1, resource2);
|
|
|
}
|
|
|
},
|
|
|
},
|
|
|
actions: {
|
|
|
async fetchRollBoardList({ commit }) {
|
...
|
...
|
@@ -232,56 +296,85 @@ export default function() { |
|
|
|
|
|
commit('setTimer', timer);
|
|
|
},
|
|
|
async hideMarquee({commit}) {
|
|
|
async hideMarquee({ commit }) {
|
|
|
commit('setTimer', null);
|
|
|
},
|
|
|
async fetchResource({commit}) {
|
|
|
async fetchResource({ commit }) {
|
|
|
const result = await this.$api.get('/api/ufo/mine/resource', {
|
|
|
content_code: MINE_RESOURCE_CODE1,
|
|
|
uid
|
|
|
uid,
|
|
|
});
|
|
|
const result1 = await this.$api.get('/api/ufo/mine/resource', {
|
|
|
content_code: MINE_RESOURCE_CODE2,
|
|
|
uid
|
|
|
uid,
|
|
|
});
|
|
|
|
|
|
if (result.code === 200) {
|
|
|
let src = getImgUrl(get(result, 'data[0].data[0].src') || '', 1000, 240);
|
|
|
let src = getImgUrl(
|
|
|
get(result, 'data[0].data[0].src') || '',
|
|
|
1000,
|
|
|
240,
|
|
|
);
|
|
|
|
|
|
set(result, 'data[0].data[0].src', src);
|
|
|
commit('addResource', {resource1: result.data[0]});
|
|
|
commit('addResource', { resource1: result.data[0] });
|
|
|
}
|
|
|
if (result1.code === 200) {
|
|
|
let src = getImgUrl(get(result1, 'data[0].data[0].src') || '', 1000, 240);
|
|
|
let src = getImgUrl(
|
|
|
get(result1, 'data[0].data[0].src') || '',
|
|
|
1000,
|
|
|
240,
|
|
|
);
|
|
|
|
|
|
set(result1, 'data[0].data[0].src', src);
|
|
|
commit('addResource', {resource2: result1.data[0]});
|
|
|
commit('addResource', { resource2: result1.data[0] });
|
|
|
}
|
|
|
},
|
|
|
async fetchSellerOrder({ commit }) {
|
|
|
const result = await this.$api.get('/api/ufo/mine/seller/orderSummary', {uid});
|
|
|
const result = await this.$api.get(
|
|
|
'/api/ufo/mine/seller/orderSummary',
|
|
|
{ uid },
|
|
|
);
|
|
|
|
|
|
if (result.code === 200) {
|
|
|
commit('addSellerOrder', { orderSumList: result.data });
|
|
|
}
|
|
|
},
|
|
|
async fetchFavoriteNum({ commit }) {
|
|
|
const result = await this.$api.get('/api/ufo/mine/favoriteNum', {uid});
|
|
|
const result = await this.$api.get('/api/ufo/mine/favoriteNum', {
|
|
|
uid,
|
|
|
});
|
|
|
|
|
|
if (result.code === 200) {
|
|
|
commit('addFavoriteNum', { count: result.data.product_favorite_total });
|
|
|
commit('addFavoriteNum', {
|
|
|
count: result.data.product_favorite_total,
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
async fetchOrderSummary({ commit }) {
|
|
|
const result = await this.$api.get('/api/ufo/mine/order/summary', {uid});
|
|
|
const result = await this.$api.get('/api/ufo/mine/order/summary', {
|
|
|
uid,
|
|
|
});
|
|
|
|
|
|
if (result.code === 200) {
|
|
|
commit('addOrderSummary', { data: result.data});
|
|
|
commit('addOrderSummary', { data: result.data });
|
|
|
}
|
|
|
},
|
|
|
async fetchCoupon({commit}) {
|
|
|
const result = await this.$api.get('/api/ufo/mine/coupon', {uid});
|
|
|
|
|
|
if (result.code === 200) {
|
|
|
commit('addCouponSummary', { count: result.data});
|
|
|
}
|
|
|
},
|
|
|
async fetchAssets({ commit, state }, isRefresh) {
|
|
|
let {isFetching, endReached, currentPage, list, pageSize} = state.assetData;
|
|
|
let {
|
|
|
isFetching,
|
|
|
endReached,
|
|
|
currentPage,
|
|
|
list,
|
|
|
pageSize,
|
|
|
} = state.assetData;
|
|
|
|
|
|
if (isFetching || (!isRefresh && endReached)) {
|
|
|
return;
|
...
|
...
|
@@ -290,7 +383,11 @@ export default function() { |
|
|
|
|
|
// commit('assetFetching', {isFetching: true});
|
|
|
let page = isRefresh ? 1 : currentPage + 1;
|
|
|
const result = await this.$api.get('/api/ufo/mine/assets', {page, limit: pageSize, uid});
|
|
|
const result = await this.$api.get('/api/ufo/mine/assets', {
|
|
|
page,
|
|
|
limit: pageSize,
|
|
|
uid,
|
|
|
});
|
|
|
|
|
|
// commit('assetFetching', {isFetching: false});
|
|
|
if (result.code === 200) {
|
...
|
...
|
@@ -304,12 +401,21 @@ export default function() { |
|
|
}
|
|
|
},
|
|
|
|
|
|
async fetchWallet({ commit, state }, {isRefresh, tradeType = 0, startTime = 0, endTime = 0}) {
|
|
|
async fetchWallet(
|
|
|
{ commit, state },
|
|
|
{ isRefresh, tradeType = 0, startTime = 0, endTime = 0 },
|
|
|
) {
|
|
|
if (isRefresh) {
|
|
|
commit('changeWalletType', tradeType);
|
|
|
commit('changeWalletTime', {startTime, endTime});
|
|
|
commit('changeWalletTime', { startTime, endTime });
|
|
|
}
|
|
|
let {isFetching, endReached, currentPage, list, pageSize} = state.walletData;
|
|
|
let {
|
|
|
isFetching,
|
|
|
endReached,
|
|
|
currentPage,
|
|
|
list,
|
|
|
pageSize,
|
|
|
} = state.walletData;
|
|
|
|
|
|
tradeType = state.walletData.tradeType;
|
|
|
startTime = state.walletData.startTime;
|
...
|
...
|
@@ -321,7 +427,14 @@ export default function() { |
|
|
|
|
|
// commit('assetFetching', {isFetching: true});
|
|
|
let page = isRefresh ? 1 : currentPage + 1;
|
|
|
const result = await this.$api.get('/api/ufo/mine/wallet', {page, limit: pageSize, uid, tradeType, startTime, endTime});
|
|
|
const result = await this.$api.get('/api/ufo/mine/wallet', {
|
|
|
page,
|
|
|
limit: pageSize,
|
|
|
uid,
|
|
|
tradeType,
|
|
|
startTime,
|
|
|
endTime,
|
|
|
});
|
|
|
|
|
|
// commit('assetFetching', {isFetching: false});
|
|
|
if (result.code === 200) {
|
...
|
...
|
@@ -331,26 +444,31 @@ export default function() { |
|
|
let newList = [...oldList, ...data.list];
|
|
|
|
|
|
walletData.currentPage = data.page;
|
|
|
walletData.endReached = data.list.length === 0 || data.page === data.totalPage;
|
|
|
walletData.endReached =
|
|
|
data.list.length === 0 || data.page === data.totalPage;
|
|
|
walletData.list = newList;
|
|
|
commit('addWallet', walletData);
|
|
|
}
|
|
|
},
|
|
|
|
|
|
async fetchUserWalletInfo({ commit }) {
|
|
|
const result = await this.$api.get('/api/ufo/mine/userWalletInfo', {uid});
|
|
|
const result = await this.$api.get('/api/ufo/mine/userWalletInfo', {
|
|
|
uid,
|
|
|
});
|
|
|
|
|
|
if (result.code === 200) {
|
|
|
commit('addUserWalletInfo', result.data);
|
|
|
}
|
|
|
},
|
|
|
async fetchWalletFilter({ commit }) {
|
|
|
const result = await this.$api.get('/api/ufo/mine/walletFilter', {uid});
|
|
|
const result = await this.$api.get('/api/ufo/mine/walletFilter', {
|
|
|
uid,
|
|
|
});
|
|
|
|
|
|
if (result.code === 200) {
|
|
|
commit('addfilterData', result.data);
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
},
|
|
|
};
|
|
|
} |
...
|
...
|
|