148 lines
4.3 KiB
Vue
148 lines
4.3 KiB
Vue
<template>
|
|
<view class="purse_recharge_warp">
|
|
<Header :leftTitle="getValue(ACCOUNT_CATEGORY, form.fromCategory) + '兑换'" left-path-type="navigateTo"
|
|
left-path="/pages/mine_package/mine_purse/mine_purse" style="background-color: #FFFFFF;" />
|
|
<view class="purse_recharge_cntent">
|
|
<view class="recharge_balance">
|
|
<view class="recharge_balance_image">
|
|
<view style="margin-top: 6rpx;">
|
|
<up-image src="https://static.tbmall.xin/static/mine/exchange.png" width="20" height="20" bgColor="#f1f6ff00" />
|
|
</view>
|
|
<view class="msg_">可兑换余额</view>
|
|
</view>
|
|
<view class="recharge_balance_">{{ proAmount }}</view>
|
|
</view>
|
|
<view class="form_item">
|
|
<view class="form_item_title">兑换金额</view>
|
|
<up-input placeholder="输入需要兑换的金额" border="surround" clearable v-model="form.amount" :customStyle="{
|
|
'margin-top': '20rpx',
|
|
'background': '#FFFFFF',
|
|
'box-shadow': '0rpx 4rpx 8rpx 0rpx rgba(0,0,0,0.06)',
|
|
'border-radius': '8rpx',
|
|
'height': '80rpx',
|
|
}" type="number"></up-input>
|
|
</view>
|
|
<view class="form_item">
|
|
<view class="form_item_title">目标账户</view>
|
|
<view class="recharge_way_warp">
|
|
<up-radio-group v-model="form.toCategory" placement="column"
|
|
v-if="wayOption && wayOption.length !== 0">
|
|
<view :class="index + 1 < wayOption.length ? 'way_item way_item_but' : 'way_item'"
|
|
v-for="(item, index) in wayOption" :key="item.id">
|
|
<view class="way_item_">
|
|
<!-- <view style="margin-top: 2rpx;"><up-image :src="item.path" width="20" height="20" bgColor="#f1f6ff00"></up-image></view> -->
|
|
<view class="way_item_val">{{ getValue(ACCOUNT_CATEGORY, item.category) }}<text
|
|
v-if="item.rate"> (汇率 1:{{ item.rate }})</text></view>
|
|
</view>
|
|
<up-radio :name="item.category" activeColor="#03AD27">
|
|
</up-radio>
|
|
</view>
|
|
</up-radio-group>
|
|
<view v-else class="not_order_warp">
|
|
<up-image src="https://static.tbmall.xin/static/not_order.png" width="80" height="80"
|
|
bgColor="#f1f6ff00"></up-image>
|
|
<view class="not_order_msg_warp">暂无兑换选项</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<view class="add_but_" @click="rechargeOk">
|
|
立即兑换
|
|
</view>
|
|
</view>
|
|
<up-toast ref="uToastRef"></up-toast>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import Header from '@/components/header.vue';
|
|
import {
|
|
getExchangeRule,
|
|
exchange
|
|
} from '@/api/finance.js';
|
|
import {
|
|
ACCOUNT_CATEGORY,
|
|
getValue
|
|
} from '@/utils/enumUtils.js';
|
|
|
|
export default {
|
|
computed: {
|
|
ACCOUNT_CATEGORY() {
|
|
return ACCOUNT_CATEGORY;
|
|
},
|
|
},
|
|
components: {
|
|
Header
|
|
},
|
|
data() {
|
|
return {
|
|
form: {
|
|
amount: null, //充值金额
|
|
fromCategory: null,
|
|
toCategory: null,
|
|
},
|
|
wayOption: [],
|
|
proAmount: 0, // 可兑换的金额
|
|
}
|
|
},
|
|
onLoad(option) {
|
|
const category = option.category;
|
|
if (category && category !== 'null') {
|
|
this.form.fromCategory = category;
|
|
}
|
|
const amount = option.amount;
|
|
if (amount && amount !== 'null') {
|
|
this.proAmount = amount;
|
|
}
|
|
},
|
|
mounted() {
|
|
this.getWayOption();
|
|
},
|
|
methods: {
|
|
getValue,
|
|
async getWayOption() {
|
|
const params = {
|
|
category: this.form.fromCategory,
|
|
}
|
|
const result = await getExchangeRule(params);
|
|
if (result && result.bizcode === 100) {
|
|
this.wayOption = result.data;
|
|
}
|
|
},
|
|
// 立即提现
|
|
async rechargeOk() {
|
|
const params = this.form;
|
|
if (!params.amount) {
|
|
this.$refs.uToastRef.show({
|
|
type: 'error',
|
|
message: "请输入需要兑换金额",
|
|
});
|
|
return;
|
|
}
|
|
if (!params.toCategory) {
|
|
this.$refs.uToastRef.show({
|
|
type: 'error',
|
|
message: "请选择目标账户",
|
|
});
|
|
return;
|
|
}
|
|
console.log("params", params);
|
|
const result = await exchange(params);
|
|
console.log("result", result);
|
|
if (result && result.bizcode === 100) {
|
|
this.$refs.uToastRef.show({
|
|
type: 'success',
|
|
message: "已成功申请兑换",
|
|
});
|
|
setTimeout(() => {
|
|
uni.navigateTo({
|
|
url: '/pages/mine_package/mine_purse/mine_purse'
|
|
});
|
|
}, 1500)
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped></style> |