| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567 |
- <template>
- <div class="wallet-page">
- <div class="wallet-list flex-between">
- <div class="gradient flex-center-between li" v-for="(item, index) in 2" :key="index">
- <div class="wallet-list-li-left">
- <div class="">{{ index == 0 ? $t('common.mibi') : $t('common.baomibi') }} {{ $t('personalCenter.yue') }}</div>
- <div class="">{{ index == 0 ? appStore?.userInfo?.pointsBalance || 0 || 0 : appStore?.userInfo?.baoMiBalance
- || 0 }}</div>
- </div>
- <div class="wallet-list-li-right flex-align-center">
- <div @click="show = true" class="flex-align-center btn" v-if="index == 1">
- <img src="/src/assets/imgs/my/tixian@2x.png" alt="">
- <div class="">{{ $t('personalCenter.shenqingtixian') }}</div>
- </div>
- <div @click="changeTransformation(index)" class="flex-align-center btn">
- <img src="/src/assets/imgs/my/zhuanhuan@2x.png" alt="">
- <div class="">{{ index == 0 ? $t('personalCenter.zhuanhuanbaomibi') : $t('personalCenter.zhuanghuanmibi') }}
- </div>
- </div>
- </div>
- </div>
- </div>
- <el-tabs v-model="form.changeType" class="demo-tabs" @tab-click="handleClick">
- <el-tab-pane :label="$t(tab.label)" v-for="tab in tabs" :key="tab.name" :name="tab.name">
- <div class="tabs flex-align-center" v-if="form.changeType != 3">
- <div @click="changeType(index)" :class="{ active: index + 1 == form.balanceType }" class="tab"
- v-for="(item, index) in 2">{{
- index == 0 ? $t('common.mibi') : $t('common.baomibi') }}{{ $t('personalCenter.details') }}
- </div>
- </div>
- <template v-if="form.changeType == 3">
- <div class="wallet-page-list">
- <div class="lis" v-for="(item, index) in list" :key="index">
- <div class="flex-center-between">
- <el-tag
- :type="item.applyStatus == 0 ? 'primary' : item.applyStatus == 1 ? 'success' : item.applyStatus == 2 ? 'danger' : ''">{{
- item.applyStatus == 0 ? '待审核' : item.applyStatus == 1 ? '已通过' : '未通过' }}</el-tag>
- <div class="price">¥{{ item.applyAmount }}</div>
- </div>
- <div class="flex-center-between">
- <div class="">订单号:{{ item.applyNo }}</div>
- <div class="">手续费:{{ item.feeAmount }}</div>
- </div>
- <div class="flex-center-between">
- <div class="">提现方式:{{ item.settleType == 'alipay' ? '支付宝' : item.settleType == 'wechat' ? '微信' : '银行卡'
- }}</div>
- <div class="">提现账号:{{ item.receiveAccount }}</div>
- </div>
- <div class="flex-center-between">
- <div class="">申请时间:{{ item.createTime }}</div>
-
- <el-text v-if=" item.applyStatus == 2" class="mx-1" type="danger">拒绝理由:{{ item.auditRemark }}</el-text>
- </div>
-
- </div>
- </div>
- </template>
- <template v-else>
- <div class="wallet-page-list" v-if="list?.length">
- <div v-for="(item, index) in list" :key="index" class="li">
- <div class="title">
- <div class="">{{ item.bizTypeName }}</div>
- <div class="">{{ item.createTime }}</div>
- </div>
- <div class="price" :class="{ green: form.changeType == 1 }">{{ form.changeType == 1 ? '+' : '' }}{{
- item.balanceChange }}</div>
- </div>
- </div>
- </template>
- </el-tab-pane>
- </el-tabs>
- <template v-if="list?.length">
- <Pagination :total="form.total" :page-size="form.pageSize" :current-page="form.pageNum"
- @page-change="handlePageChange" />
- </template>
- <el-empty v-else :description="$t('common.empty')" />
- <el-dialog v-model="dialogVisible"
- :title="`${transformationIndex == 0 ? $t('personalCenter.zhuanhuanbaomibi') : $t('personalCenter.zhuanghuanmibi')}`"
- width="523">
- <el-form :model="walletForm" label-width="auto" label-position="top" :rules="rules" ref="ruleFormRefs">
- <el-row>
- <el-col :span="24">
- <div class="input">
- <el-form-item :label="$t('common.use') + $t('common.baomibi')" v-if="transformationIndex" prop="orderAmt">
- <el-input-number v-model="walletForm.orderAmt" :min="1" :max="appStore?.userInfo?.baoMiBalance"
- controls-position="right" size="large" @change="handleChange" style="width: 100%;"
- :placeholder="$t('common.placeholderInput')" align="left" :input-style="{ fontSize: '28px' }"
- class="inputStyle" />
- </el-form-item>
- <el-form-item :label="$t('common.use') + $t('common.mibi')" v-else prop="orderAmt">
- <el-input-number v-model="walletForm.orderAmt" :min="Number(configTxt.configValue)"
- :max="appStore?.userInfo?.pointsBalance" :step="Number(configTxt.configValue)"
- controls-position="right" size="large" @change="handleChange" style="width: 100%;"
- :placeholder="$t('common.placeholderInput')" align="left" :input-style="{ fontSize: '28px' }"
- class="inputStyle" />
- </el-form-item>
- </div>
- </el-col>
- </el-row>
- <div class="line">
- <img src="/src/assets/imgs/my/arrow-left-right-fill@2x.png" alt="">
- </div>
- <el-row>
- <el-col :span="24">
- <div class="input">
- <el-form-item v-if="transformationIndex"
- :label="$t('common.available') + $t('common.mibi') + `(手续费率:${walletForm.feeRate})`">
- <el-input v-model="walletForm.targetAmount" :placeholder="$t('common.placeholderInput')" readonly
- disabled :input-style="{ fontSize: '28px' }" class="inputStyle" />
- </el-form-item>
- <el-form-item v-else :label="$t('common.available') + $t('common.baomibi')">
- <el-input v-model="walletForm.targetAmount" :placeholder="$t('common.placeholderInput')" readonly
- disabled :input-style="{ fontSize: '28px' }" class="inputStyle" />
- </el-form-item>
- </div>
- </el-col>
- </el-row>
- <div class="" style="font-size: 14px;margin-top: 16px;"> <text style="color: #E43434;">*</text> {{
- configTxt.configName }}{{ configTxt.configValue }}</div>
- </el-form>
- <template #footer>
- <div class="dialog-footer flex-center">
- <el-button @click="dialogVisible = false">{{ $t('common.cancel') }}</el-button>
- <el-button class="gradient" type="primary" @click="confirmTransformation(ruleFormRefs)">
- {{ $t('common.confirm') }}
- </el-button>
- </div>
- </template>
- </el-dialog>
- <el-dialog v-model="show" :title="$t('personalCenter.shenqingtixian')" width="500">
- <el-form ref="ruleFormRef" :model="ruleForm" :rules="rules" label-width="auto">
- <el-row>
- <el-col :span="24">
- <el-form-item label="提现金额" prop="applyAmount">
- <el-input type="number" :min="1" :max="appStore?.userInfo?.baoMiBalance" v-model="ruleForm.applyAmount"
- :placeholder="$t('common.placeholderInput')" />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="24">
- <el-form-item label="提现方式" prop="settleType">
- <el-select v-model="ruleForm.settleType" placeholder="Select" style="width: 100%">
- <el-option label="支付宝" value="alipay" />
- <el-option label="银行卡" value="bank_card" />
- </el-select>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="24">
- <el-form-item label="姓名" prop="withdrawPerson">
- <el-input v-model="ruleForm.withdrawPerson" :placeholder="$t('common.placeholderInput')" />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="24">
- <el-form-item label="账号" prop="receiveAccount">
- <el-input v-model="ruleForm.receiveAccount" :placeholder="$t('common.placeholderInput')" />
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- <template #footer>
- <div class="dialog-footer flex-center">
- <el-button @click="show = false">{{ $t('common.cancel') }}</el-button>
- <el-button class="gradient" type="primary" @click="submitForm(ruleFormRef)">{{
- $t('common.confirm') }}</el-button>
- </div>
- </template>
- </el-dialog>
- </div>
- </template>
- <script lang="ts" setup>
- import { ref, onMounted } from 'vue'
- import type { TabsPaneContext } from 'element-plus'
- import Pagination from '@/components/Pagination.vue'
- import { getUserInfo } from '@/api/auth'
- import { payConfigDearch, calRate } from '@/api/order'
- import { recordList, applyWithdraw, withdrawList } from '@/api/my'
- import { createOrder } from '@/api/order.js'
- import { useAppStore } from '@/pinia/appStore'
- import DGTMessage from '@/utils/message'
- import { useI18n } from 'vue-i18n'
- const { t } = useI18n()
- const appStore = useAppStore();
- const tabs = ref([
- { label: 'personalCenter.incomeDetails', name: 1 },
- { label: 'personalCenter.usageRecord', name: 2 },
- { label: 'personalCenter.withdrawHistory', name: 3 },
- ])
- const list = ref([])
- const form = ref({
- pageNum: 1,
- pageSize: 10,
- total: 0,
- balanceType: 1,//1-米币 2-暴米币
- changeType: 1,//1-增加 2-减少
- orderByColumn: 'create_time',
- isAsc: 'desc'
- })
- const walletForm = ref({
- payMethod: '',
- orderType: '',
- productId: '',
- orderNum: null,
- orderAmt: 1,
- feeRate: 0,
- targetAmount: 0
- })
- const ruleFormRef = ref()
- const configTxt = ref({})
- const userInfo = ref({})//用户信息
- const dialogVisible = ref(false);
- const transformationIndex = ref(0);
- const show = ref(false);
- const ruleForm = ref({
- applyAmount: null,
- settleType: "alipay",
- withdrawPerson: "",
- receiveAccount: ""
- })
- const ruleFormRefs = ref()
- const validatePass = (rule: any, value: any, callback: any) => {
- if (!value) {
- callback(new Error(t('common.placeholderInput')))
- } else if (Number(value) % Number(configTxt.value.configValue) !== 0 && transformationIndex.value == 0) {
- callback(new Error(`米币数量必须为${configTxt.value.configValue}的整倍数`))
- } else {
- callback()
- }
- }
- const validatePass1 = (rule: any, value: any, callback: any) => {
- if (!value) {
- callback(new Error(t('common.placeholderInput')))
- return
- } else if (Number(value) > appStore.userInfo.baoMiBalance) {
- callback(new Error(`余额不足`))
- } else {
- callback()
- }
- }
- const rules = ref({
- applyAmount: [
- { required: true, validator: validatePass1, trigger: 'blur' }
- ],
- settleType: [
- { required: true, message: t('common.qingxuanze'), trigger: 'blur' }
- ],
- withdrawPerson: [
- { required: true, message: t('common.placeholderInput'), trigger: 'blur' }
- ],
- receiveAccount: [
- { required: true, message: t('common.placeholderInput'), trigger: 'blur' }
- ],
- orderAmt: [
- { required: true, trigger: 'blur', validator: validatePass },
- ],
- })
- const submitForm = async (formEl) => {
- console.log(formEl)
- if (!formEl) return
- await formEl.validate(async (valid, fields) => {
- if (valid) {
- let res = await applyWithdraw(ruleForm.value);
- if (res.code === 200) {
- show.value = false;
- appStore.USERINFO();
- getList()
- DGTMessage.success(t('common.success'));
- }
- }
- })
- }
- // 确认转换
- const confirmTransformation = async (formEl) => {
- if (!formEl) return
- await formEl.validate(async (valid, fields) => {
- if (valid) {
- let res = await createOrder({
- payMethod: walletForm.value.payMethod,
- orderType: walletForm.value.orderType,
- productId: '',
- orderNum: walletForm.value.targetAmount,
- orderAmt: walletForm.value.orderAmt
- })
- if (res.code === 200) {
- if (res.data.paySuccess) {
- dialogVisible.value = false;
- appStore.USERINFO();
- DGTMessage.success(`${transformationIndex.value ? t('personalCenter.zhuanhuanbaomibi') : t('personalCenter.zhuanghuanmibi')}${t('common.success')}`)
- }
- }
- }
- })
- }
- // 米币暴米币转换
- const changeTransformation = async (index: any) => {
- transformationIndex.value = index;
- walletForm.value.payMethod = index ? 'BMI' : 'MI';
- walletForm.value.orderType = index ? 'exchange_mi' : 'exchange_bmi';
- let { data } = await payConfigDearch({ id: '03' });
- let result = data.filter((item: any) => item.configCode == 'bmb_to_mb_rate')
- if (result.length) {
- configTxt.value = result[0]
- }
- walletForm.value.orderAmt = index == 0 ? Number(configTxt.value.configValue) : 1
- handleChange()
- dialogVisible.value = true;
- }
- const handleChange = async () => {
- if (walletForm.value.orderAmt) {
- if (transformationIndex.value == 0 && Number(walletForm.value.orderAmt) % Number(configTxt.value.configValue) !== 0) return
- let res = await calRate({
- orderType: walletForm.value.orderType,
- orderNum: walletForm.value.orderAmt
- });
- if (res.code === 200) {
- walletForm.value.feeRate = res.data.feeRate
- walletForm.value.targetAmount = res.data.targetAmount
- }
- }
- }
- // 米币暴米币切换
- const changeType = (index) => {
- form.value.pageNum = 1;
- form.value.balanceType = index + 1;
- getList()
- }
- const handleClick = (tab: TabsPaneContext) => {
- form.value.pageNum = 1;
- form.value.changeType = tab.props.name;
- getList()
- }
- const getList = async () => {
- let api = form.value.changeType == 3 ? withdrawList(form.value) : recordList(form.value)
- let res = await api;
- list.value = res.rows;
- form.value.total = res.total;
- }
- const handlePageChange = (newPage: number) => {
- // list.value = []
- form.value.pageNum = page;
- getList()
- }
- // 获取用户信息
- const getInfo = async () => {
- let res = await getUserInfo();
- userInfo.value = res.user;
- }
- onMounted(() => {
- getInfo()
- getList()
- })
- </script>
- <style scoped lang="scss">
- .wallet-page {
- padding-bottom: 16px;
- .tabs {
- margin-bottom: 16px;
- .tab {
- cursor: pointer;
- color: #2D71FF;
- padding: 0 12px;
- line-height: 30px;
- font-size: 14px;
- background: #EAF0FF;
- border-radius: 4px;
- margin-right: 16px;
- }
- .active {
- color: #FFFFFF;
- background: linear-gradient(90deg, #0055FE 0%, #C832FA 100%);
- }
- }
- .wallet-list {
- gap: 16px;
- padding: 16px;
- .li {
- flex: 1;
- padding: 16px;
- border-radius: 16px;
- .wallet-list-li-left {
- div {
- color: #FFFFFF;
- font-size: 14px;
- line-height: 1;
- &:last-child {
- margin-top: 8px;
- font-size: 32px;
- font-weight: bold;
- }
- }
- }
- .wallet-list-li-right {
- .btn {
- cursor: pointer;
- margin-left: 8px;
- color: #2D71FF;
- font-size: 14px;
- padding: 0 20px;
- height: 40px;
- background: #FFFFFF;
- border-radius: 10px;
- img {
- width: 16px;
- height: 16px;
- margin-right: 4px;
- }
- &:hover {
- opacity: 0.7;
- }
- }
- }
- }
- }
- }
- .wallet-page-list {
- .li {
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 16px;
- border-radius: 16px;
- background: #F5F7FA;
- margin-bottom: 16px;
- &:last-child {
- margin-bottom: 0;
- }
- .title {
- div {
- font-size: 16px;
- line-height: 1;
- &:last-child {
- margin-top: 8px;
- color: #666666;
- font-size: 14px;
- }
- }
- }
- }
- .price {
- font-size: 16px;
- font-weight: bold;
- color: #F52929;
- }
- .green {
- color: #1FB362;
- }
- .lis {
- padding: 16px;
- border-radius: 16px;
- background: #F5F7FA;
- margin-bottom: 16px;
- &:last-child {
- margin-bottom: 0;
- }
- }
- }
- .input {
- padding: 16px;
- background: #F5F7FA;
- border-radius: 16px;
- }
- .line {
- height: 16px;
- position: relative;
- img {
- top: 50%;
- width: 40px;
- height: 40px;
- left: 50%;
- z-index: 9;
- transform: translate(-50%, -50%);
- position: absolute;
- }
- }
- .inputStyle {
- :deep(.el-input__wrapper) {
- background-color: transparent;
- box-shadow: none !important;
- padding: 0;
- }
- :deep(.el-input__inner) {
- font-size: 28px;
- }
- :deep(.el-input-number__increase),
- :deep(.el-input-number__decrease) {
- display: none;
- }
- }
- </style>
|