This repository has been archived by the owner on Nov 15, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
249 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
<template> | ||
<div class="p-wallet-info"> | ||
|
||
<common-header>账单详情</common-header> | ||
|
||
<header class="wallet-header"> | ||
<p>{{ statusText }}</p> | ||
<h2>-{{ detail.value / 100 | postfix(2) }}</h2> | ||
</header> | ||
|
||
<main> | ||
<div class="item"> | ||
<label>交易说明</label> | ||
<span> 提现 </span> | ||
</div> | ||
<div class="item"> | ||
<label>交易账户</label> | ||
<span> {{ detail.type === "alipay" ? "支付宝": '' }} </span> | ||
</div> | ||
<div class="item"> | ||
<label>交易时间</label> | ||
<span> {{ detail.created_at | addTimeOffset }} </span> | ||
</div> | ||
</main> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { mapState } from "vuex"; | ||
export default { | ||
name: "WalletWithdrawInfo", | ||
filters: { | ||
postfix(val, pos) { | ||
if (!val) return "0.00"; | ||
return val.toFixed(pos); | ||
} | ||
}, | ||
data() { | ||
return { | ||
// detail: {} | ||
}; | ||
}, | ||
computed: { | ||
...mapState({ wallet: "wallet" }), | ||
id() { | ||
return Number(this.$route.params.id); | ||
}, | ||
detail() { | ||
return this.$store.getters["wallet/getCashesById"](this.id); | ||
}, | ||
user() { | ||
return this.$store.state.CURRENTUSER; | ||
}, | ||
statusText() { | ||
if (this.detail.status === 0) return "审核中"; | ||
if (this.detail.status === 2) return "审核失败"; | ||
return "交易成功"; | ||
} | ||
}, | ||
mounted() { | ||
if (!this.wallet.list.length) | ||
this.$store.dispatch("wallet/getWalletOrders"); | ||
}, | ||
methods: {} | ||
}; | ||
</script> | ||
|
||
<style lang="less" scoped> | ||
.p-wallet-info { | ||
.wallet-header { | ||
height: 300px; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: space-around; | ||
background-color: #fff; | ||
padding: 40px 20px; | ||
> p { | ||
font-size: 28px; | ||
color: #999; | ||
} | ||
> h2 { | ||
font-size: 100px; | ||
} | ||
} | ||
main { | ||
margin-top: 20px; | ||
background: #fff; | ||
> .item { | ||
height: 100px; | ||
display: flex; | ||
align-items: center; | ||
justify-content: flex-start; | ||
border-top: 1px solid #ededed; | ||
&:first-child { | ||
border-top: none; | ||
} | ||
label { | ||
width: 6em; | ||
font-size: 30px; | ||
color: #999; | ||
padding: 0 1em; | ||
} | ||
} | ||
} | ||
} | ||
</style> |
114 changes: 114 additions & 0 deletions
114
src/page/wallet/components/WalletWithdrawDetailItem.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
<template> | ||
<div class="c-wallet-withdraw-detail-item" @click.stop="showDetail"> | ||
<div class="time" v-html="created_at"/> | ||
<div class="title" >{{ typeText }} 账户提现</div> | ||
<div class="amount"> | ||
<span v-if="detail.status === 0" class="gray">审核中</span> | ||
<span v-if="detail.status === 2" class="gray">审核失败</span> | ||
<span v-if="detail.status === 1">-{{ (detail.value / 100).toFixed(2) }}</span> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { timeOffset } from "@/filters"; | ||
const typeMap = { | ||
alipay: "支付宝", | ||
wx: "微信" | ||
}; | ||
const week = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"]; | ||
function splitYMD(date) { | ||
date = date || new Date(); | ||
date = new Date(date); | ||
const Y = date.getFullYear(); | ||
const M = date.getMonth() + 1; | ||
const D = date.getDate(); | ||
const w = week[date.getDay()]; | ||
const h = (date.getHours() + "").padStart(2, 0); | ||
const m = (date.getMinutes() + "").padStart(2, 0); | ||
const d = (M + "").padStart(2, 0) + "/" + (D + "").padStart(2, 0); | ||
const t = h + ":" + m; | ||
return { Y, M, D, w, d, t }; | ||
} | ||
export default { | ||
name: "WalletWithdrawDetailItem", | ||
props: { | ||
detail: { type: Object, required: true } | ||
}, | ||
data() { | ||
return {}; | ||
}, | ||
computed: { | ||
created_at() { | ||
const now = splitYMD(new Date()); | ||
let time = new Date(this.detail.created_at).getTime() - timeOffset; | ||
time = splitYMD(time); | ||
let D; | ||
if (time.Y < now.Y) { | ||
D = time.d; | ||
} else if (time.M < now.M) { | ||
D = time.d; | ||
} else if (now.D - time.D > 1) { | ||
D = time.w; | ||
} else if (now.D - time.D === 1) { | ||
D = "昨天"; | ||
} else if (now.D - time.D === 0) { | ||
D = "今天"; | ||
} | ||
return `<p>${D}</p><p>${time.t}</p>`; | ||
}, | ||
typeText() { | ||
return typeMap[this.detail.type] || ""; | ||
} | ||
}, | ||
methods: { | ||
showDetail() { | ||
this.$emit("click"); | ||
} | ||
} | ||
}; | ||
</script> | ||
|
||
<style lang="less" scoped> | ||
.c-wallet-withdraw-detail-item { | ||
padding: 30px; | ||
font-size: 30px; | ||
line-height: 36px; | ||
border-bottom: 1px solid #ededed; | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
background-color: #fff; | ||
.time { | ||
color: #b3b3b3; | ||
font-size: 24px; | ||
text-align: center; | ||
line-height: 1; | ||
} | ||
.title { | ||
margin: 0 30px; | ||
width: 100%; | ||
overflow: hidden; | ||
white-space: nowrap; | ||
text-overflow: ellipsis; | ||
} | ||
.amount { | ||
width: 6em; | ||
text-align: right; | ||
> span { | ||
color: #ff9400; | ||
&.gray { | ||
color: #b3b3b3; | ||
} | ||
} | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ import * as api from "@/api/wallet"; | |
|
||
const state = { | ||
list: [], // 充值纪录 | ||
cashes: [], // 提现记录 | ||
items: [], // 充值建议金额 | ||
ratio: 100, // 充值比率 | ||
type: [], // 充值类型 | ||
|
@@ -12,6 +13,9 @@ const getters = { | |
getWalletById: state => id => { | ||
return state.list.filter(wallet => wallet.id === id).pop() || {}; | ||
}, | ||
getCashesById: state => id => { | ||
return state.cashes.filter(wallet => wallet.id === id).pop() || {}; | ||
}, | ||
rechargeItems: state => { | ||
return state.items.map(item => item / 100); | ||
} | ||
|
@@ -75,8 +79,9 @@ const actions = { | |
* @author mutoe <[email protected]> | ||
* @returns {Promise<Object[]>} | ||
*/ | ||
async fetchWithdrawList(state, payload) { | ||
async fetchWithdrawList({ commit }, payload) { | ||
const { data } = await api.getWithdrawList(payload); | ||
commit(TYPES.UPDATE_WALLET, { cashes: data }); | ||
return data; | ||
} | ||
}; | ||
|