|
|
@@ -2,15 +2,19 @@
|
|
|
<div class="cash">
|
|
|
<inner-header title="资金提现"></inner-header>
|
|
|
<section class="content">
|
|
|
- <h2>提现到支付宝({{userInfo.alipay}})</h2>
|
|
|
+ <h2 v-if="isIdCard">提现到银行卡(
|
|
|
+ <span v-if="userInfo.bankAccount">{{userInfo.bankAccount}}</span>
|
|
|
+ <span v-else><a href="/wo/account_manage">去绑定银行卡</a></span>
|
|
|
+ )</h2>
|
|
|
+ <h2 v-else>提现到支付宝({{userInfo.alipay}})</h2>
|
|
|
<div class="input-box">
|
|
|
- <el-input class="cash-input" placeholder="最少提现1元,每日上限3万元" v-model="coins"></el-input>
|
|
|
+ <el-input class="cash-input" placeholder="最少提现10元,每日上限3万元" v-model="coins"></el-input>
|
|
|
<span class="input-icon">¥</span>
|
|
|
<el-button type="text" class="get-all" @click="doGetAll">全部提现</el-button>
|
|
|
</div>
|
|
|
<div class="balance">
|
|
|
可用余额
|
|
|
- <span>¥{{(+coinInfo.balance) || 0}}</span>元
|
|
|
+ <span>¥{{(+userCanWithdrawAmount) || 0}}</span>元
|
|
|
</div>
|
|
|
<el-button @click="doGet" class="get-btn" type="primary">提现</el-button>
|
|
|
<p class="remind-time">预计1~3个工作日到账</p>
|
|
|
@@ -36,17 +40,22 @@
|
|
|
<el-button type="primary" @click="doDialogConfirm">确 定</el-button>
|
|
|
</div>
|
|
|
</el-dialog>
|
|
|
+ <SuccessToast :isShowToast="isShowToastSuccess" @close="isShowToastSuccess=false"/>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import InputVer from "@/components/input/ver";
|
|
|
import InnerHeader from "@/components/inner_header";
|
|
|
+import SuccessToast from "@/components/wo/successToast";
|
|
|
+const Max_Money = 30000
|
|
|
+const Min_Money = 10
|
|
|
|
|
|
export default {
|
|
|
components: {
|
|
|
InputVer,
|
|
|
- InnerHeader
|
|
|
+ InnerHeader,
|
|
|
+ SuccessToast
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
@@ -57,17 +66,29 @@ export default {
|
|
|
// 验证码
|
|
|
ver: "",
|
|
|
// 费率
|
|
|
- rate: ""
|
|
|
+ rate: "",
|
|
|
+ isIdCard: false, //是否是提现到银行卡
|
|
|
+ isShowToastSuccess: false, //是否展示成功后的提示
|
|
|
};
|
|
|
},
|
|
|
computed: {
|
|
|
coinInfo() {
|
|
|
- return this.alipayInfo.coinInfo || {};
|
|
|
+ return this.alipayInfo && this.alipayInfo.coinInfo || {};
|
|
|
+ },
|
|
|
+ userCanWithdrawAmount() {
|
|
|
+ const {balance=0, incomeTaxBalance=0} = this.alipayInfo && this.alipayInfo.coinInfo || {}
|
|
|
+ return this.isIdCard ? incomeTaxBalance : balance
|
|
|
},
|
|
|
userInfo() {
|
|
|
- return this.alipayInfo.userInfo || {};
|
|
|
+ return this.alipayInfo && this.alipayInfo.userInfo || {};
|
|
|
}
|
|
|
},
|
|
|
+ created() {
|
|
|
+ console.log('this.$route.query', this.$route.query)
|
|
|
+ //type 1-支付宝 2-银行卡 默认是1
|
|
|
+ const {type=1} = this.$route.query || {}
|
|
|
+ this.isIdCard = Number(type) === 2
|
|
|
+ },
|
|
|
mounted() {
|
|
|
this.getAlipayInfo();
|
|
|
this.getRate();
|
|
|
@@ -77,7 +98,11 @@ export default {
|
|
|
* 全部提现
|
|
|
*/
|
|
|
doGetAll() {
|
|
|
- this.coins = this.coinInfo.balance;
|
|
|
+ this.coins = this.userCanWithdrawAmount;
|
|
|
+ if (this.userCanWithdrawAmount > Max_Money) {
|
|
|
+ this.$message.info("每日最多可提现3万元")
|
|
|
+ this.coins = Max_Money
|
|
|
+ }
|
|
|
},
|
|
|
/**
|
|
|
* 获取支付宝信息
|
|
|
@@ -87,6 +112,11 @@ export default {
|
|
|
console.log(res);
|
|
|
if (res) {
|
|
|
this.alipayInfo = res.data;
|
|
|
+ const {alipay, bankAccount} = res.data.alipayInfo || {}
|
|
|
+ //银行卡提现,但没绑定时 提示
|
|
|
+ if (!bankAccount && this.isIdCard === 2) {
|
|
|
+ this.$message.info("请前往程序员客栈APP绑定银行卡!")
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
/**
|
|
|
@@ -107,6 +137,18 @@ export default {
|
|
|
this.$message("请输入提现金额");
|
|
|
return;
|
|
|
}
|
|
|
+ //最少
|
|
|
+ if (Min_Money > this.userCanWithdrawAmount) {
|
|
|
+ this.$message(`单次最少提现${Min_Money}元`);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //最多允许提现2位小数
|
|
|
+ let docRight = (this.coins + "").split(".")[1]
|
|
|
+ console.log("docRight", docRight)
|
|
|
+ if (docRight && docRight.length > 2) {
|
|
|
+ this.$message(`最多允许输入2位小数`);
|
|
|
+ return;
|
|
|
+ }
|
|
|
// 错误处理
|
|
|
let coinsNum = +(this.coins + "").replace(/[^\d\.]/g, "");
|
|
|
if (
|
|
|
@@ -117,7 +159,8 @@ export default {
|
|
|
this.$message("请输入正确的提现金额");
|
|
|
return;
|
|
|
}
|
|
|
- if (coinsNum > this.coinInfo.balance) {
|
|
|
+ //余额不足
|
|
|
+ if (coinsNum > this.userCanWithdrawAmount) {
|
|
|
this.$message("可提现余额不足");
|
|
|
return;
|
|
|
}
|
|
|
@@ -140,22 +183,42 @@ export default {
|
|
|
cancelButtonText: "取消",
|
|
|
type: "warning"
|
|
|
}).then(async () => {
|
|
|
- let res = await this.$axios.$post("/api/account/take_coins_to_alipay", {
|
|
|
+ this.withdrawFn()
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ /** 提现到支付宝 **/
|
|
|
+ async withdrawFn() {
|
|
|
+ let res = null
|
|
|
+ if (this.isIdCard) {
|
|
|
+ res = await this.$axios.$post("/api/account/takeSalary", {
|
|
|
+ coins: +this.coins,
|
|
|
+ auth_code: this.ver
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ res = await this.$axios.$post("/api/account/take_coins_to_alipay", {
|
|
|
coins: +this.coins,
|
|
|
payee_real_name: this.userinfo.realname,
|
|
|
alipay_account: this.userInfo.alipay,
|
|
|
auth_code: this.ver
|
|
|
});
|
|
|
- if (res) {
|
|
|
- this.$message({
|
|
|
- type: "success",
|
|
|
- message: "提现成功"
|
|
|
- });
|
|
|
- setTimeout(() => {
|
|
|
- location.reload();
|
|
|
- }, 1000);
|
|
|
- }
|
|
|
- });
|
|
|
+ }
|
|
|
+ if (res && Number(res.status) === 1) {
|
|
|
+ this.$message({
|
|
|
+ type: "success",
|
|
|
+ message: res.info || "提现成功"
|
|
|
+ });
|
|
|
+ this.dialogShow = false
|
|
|
+ setTimeout(() => {
|
|
|
+ if (this.isIdCard) {
|
|
|
+ this.isShowToastSuccess = true
|
|
|
+ this.getAlipayInfo()
|
|
|
+ this.coins = 0
|
|
|
+ } else {
|
|
|
+ window.reload()
|
|
|
+ }
|
|
|
+ }, 1000);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
};
|