Skip to content
This repository has been archived by the owner on Nov 15, 2018. It is now read-only.

Commit

Permalink
feat(wallet): 钱包明细页面
Browse files Browse the repository at this point in the history
  • Loading branch information
mutoe committed Jul 26, 2018
1 parent e5e983f commit 78d9bef
Show file tree
Hide file tree
Showing 5 changed files with 143 additions and 13 deletions.
24 changes: 18 additions & 6 deletions src/api/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export function postTransform(data) {
}

/**
* 发起提现请求
* 发起充值请求
* @author mutoe <[email protected]>
* @export
* @param {Object} data
Expand All @@ -52,9 +52,21 @@ export function postTransform(data) {
* @returns
*/
export function postWalletRecharge(data) {
return api.post(
"/walletRecharge/orders",
{ ...data, from: 2 },
{ validateStatus: s => s === 201 }
);
const url = "/walletRecharge/orders";
data = Object.assing(data, { from: 2 });
return api.post(url, data, { validateStatus: s => s === 201 });
}

/**
* 发起提现请求
* @author mutoe <[email protected]>
* @export
* @param {Object} data
* @param {number} data.amount
* @param {string} data.type
* @param {string} data.account
* @returns
*/
export function postWalletWithdraw(data) {
return api.post("/plus-pay/cash", data, { validateStatus: s => s === 201 });
}
18 changes: 14 additions & 4 deletions src/page/wallet/WalletWithdraw.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

<common-header>
提现
<!-- <router-link
<router-link
slot="right"
style="width: 4em;"
to="/wallet/withdraw/detail">
提现明细
</router-link> -->
</router-link>
</common-header>

<main class="m-box-model m-aln-center m-justify-center">
Expand Down Expand Up @@ -67,19 +67,29 @@

<script>
import bus from "@/bus";
import { mapState } from "vuex";
export default {
name: "WalletWithdraw",
data() {
return {
form: {
amount: "",
account: ""
account: "",
type: ""
},
disabled: true,
loading: false
};
},
computed: {
...mapState({
wallet: "wallet"
}),
disabled() {
const { amount, account, type } = this.form;
return !amount || !account || !type;
}
},
methods: {
handleOk() {},
selectWithdrawType() {
Expand Down
80 changes: 80 additions & 0 deletions src/page/wallet/WalletWithdrawDetail.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<template lang="html">
<div class="wallet-detail p-wallet-detail">

<common-header class="header"> 提现明细 </common-header>

<load-more
ref="loadmore"
:on-refresh="onRefresh"
:on-load-more="onLoadMore"
class="m-wallet-list">
<wallet-detail-item
v-for="item in list"
v-if="item.id"
:key="item.id"
:detail="item"
@click="showDetail(item.id)" />
</load-more>
</div>
</template>

<script>
import _ from "lodash";
import walletDetailItem from "./WalletDetailItem.vue";
export default {
name: "WalletWithdrawDetail",
components: { walletDetailItem },
data() {
return {
currAction: "out",
list: []
};
},
computed: {
after() {
const len = this.list.length;
return len ? this.list[len - 1].id : 0;
}
},
watch: {
currAction() {
this.list = [];
this.$refs.loadmore.beforeRefresh();
}
},
methods: {
showDetail(id) {
this.$router.push({ path: "/wallet/detail", params: { id } });
},
async onRefresh() {
const data = await this.$store.dispatch("wallet/getWalletOrders", {
action: this.currAction
});
if (data.length > 0) this.list = _.unionBy([...data, ...this.list], "id");
this.$refs.loadmore.topEnd(!(data.length < 15));
},
async onLoadMore() {
const data = await this.$store.dispatch("wallet/getWalletOrders", {
action: this.currAction,
after: this.after
});
if (data.length > 0) {
this.list = [...this.list, ...data];
}
this.$refs.loadmore.bottomEnd(data.length < 15);
}
}
};
</script>

<style lang="less" scoped>
.p-wallet-detail {
.header {
overflow: initial;
}
}
</style>
9 changes: 9 additions & 0 deletions src/routers/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ const WalletRecharge = () =>
import(/* webpackChunkName: 'wallet' */ "@/page/wallet/WalletRecharge.vue");
const WalletWithdraw = () =>
import(/* webpackChunkName: 'wallet' */ "@/page/wallet/WalletWithdraw.vue");
const WalletWithdrawDetail = () =>
import(/* webpackChunkName: 'wallet' */ "@/page/wallet/WalletWithdrawDetail.vue");
const WalletDetail = () =>
import(/* webpackChunkName: 'wallet' */ "@/page/wallet/WalletDetail.vue");
const WalletInfo = () =>
Expand Down Expand Up @@ -35,6 +37,13 @@ export default [
title: "提现"
}
},
{
path: "/wallet/withdraw/detail",
component: WalletWithdrawDetail,
meta: {
title: "提现明细"
}
},
{
path: "/wallet/detail",
component: WalletDetail,
Expand Down
25 changes: 22 additions & 3 deletions src/stores/module/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,25 @@ const mutations = {
};

const actions = {
/**
* 获取钱包流水
* @author mutoe <[email protected]>
* @returns {Promise<Object[]>}
*/
async getWalletOrders({ commit, state }, params) {
let { data } = await api.getWalletOrders(params);
if (params && params.after) data = [...state.list, ...data];
commit(TYPES.UPDATE_WALLET, { list: data });
return data || [];
},

/**
* 获取钱包配置信息
* @author mutoe <[email protected]>
*/
async getWalletInfo({ commit }) {
let {
data: { labels: items, ratio, rule, recharge_type: type }
} = await api.getWalletInfo();
let { data } = await api.getWalletInfo();
const { labels: items, ratio, rule, recharge_type: type } = data;
commit(TYPES.UPDATE_WALLET, { items, type, ratio, rule });
},

Expand All @@ -49,6 +58,16 @@ const actions = {
async requestRecharge(state, payload) {
const { data = "" } = await api.postWalletRecharge(payload);
return data;
},

/**
* 发起提现请求
* @author mutoe <[email protected]>
* @returns
*/
async requestWithdraw(state, payload) {
const { data } = await api.postWalletWithdraw(payload);
return data;
}
};

Expand Down

0 comments on commit 78d9bef

Please sign in to comment.