123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386 |
- <template>
- <view class="withdrawal-main">
- <view class="withdrawal-item">
- <label class="withdrawal-label">提现到账</label>
- <view class="withdrawal-item-right" @click="openSheet">
- <view class="withdrawal-text">{{ w_key }}</view>
- <up-icon name="arrow-right"></up-icon>
- </view>
- </view>
- <view class="withdrawal-item">
- <label class="withdrawal-label">本人支付宝账号提现</label>
- <view class="withdrawal-item-right" @click="openSheetNumber">
- <view class="withdrawal-text">{{ s_key }}</view>
- <up-icon name="arrow-right"></up-icon>
- </view>
- </view>
- <view v-if="w_key === '支付宝账户'">
- <view class="withdrawal-item">
- <label class="withdrawal-label">支付宝姓名</label>
- </view>
- <view class="price-box">
- <input
- class="price-input2"
- placeholder="请输入支付宝姓名"
- border="none"
- v-model="priceData.name"
- />
- </view>
- <view class="withdrawal-item">
- <label class="withdrawal-label">支付宝户名</label>
- </view>
- <view class="price-box">
- <input
- class="price-input2"
- placeholder="请输入支付宝户名"
- border="none"
- v-model="priceData.code"
- />
- </view>
- <view v-show="s_key === '他人支付宝账号提现'">
- <view class="withdrawal-item">
- <label class="withdrawal-label">身份证号</label>
- </view>
- <view class="price-box">
- <input
- class="price-input2"
- placeholder="请输入身份证号"
- border="none"
- v-model="priceData.idCard"
- />
- </view>
- </view>
- </view>
- <view class="withdrawal-item">
- <label class="withdrawal-label">提现金额</label>
- </view>
- <view class="price-box">
- <up-icon name="rmb" size="28" color="rgba(0, 0, 0, 1)"></up-icon>
- <input
- class="price-input"
- placeholder="请输入提现金额"
- border="none"
- v-model="priceData.price"
- @change="change"
- />
- </view>
- <view class="withdrawal-item">
- <label class="withdrawal-label"
- >可提现余额 <up-icon name="rmb"></up-icon>{{ maxPrice }}</label
- >
- <view class="withdrawal-item-right" @click="onMaxChange">
- <view class="withdrawal-text">全部提现</view>
- </view>
- </view>
- <view style="margin-top: 45px">
- <up-button type="primary" text="确定提现" @click="onSubmit"></up-button>
- <up-button type="error" text="提现历史" @click="onHistory" style="margin-top: 20rpx;"></up-button>
- </view>
- <up-action-sheet
- :show="show"
- @close="close"
- @select="select"
- :actions="actions"
- >
- </up-action-sheet>
- <up-action-sheet
- :show="showNumber"
- @close="close"
- @select="selectNumber"
- :actions="actionsProxy"
- ></up-action-sheet>
- </view>
- </template>
- <script setup>
- import { ref, relative } from 'vue'
- import {
- getVolunteerAccountInfo,
- getAccountInfo,
- submitAmountApply,
- vonTtAlipayAccountHistory,
- getWithdrawStatus
- } from '@/api/mine'
- import { onShow } from '@dcloudio/uni-app'
- import row from 'uview-plus/components/u-row/row'
- const actions = [
- {
- name: '支付宝账户',
- },
- ]
- const actionsProxy = [
- {
- name: '本人支付宝账号提现',
- value: 1,
- },
- {
- name: '他人支付宝账号提现',
- value: 2,
- },
- ]
- const userType = uni.getStorageSync('userType') //读取本地存储
- const w_key = ref('支付宝账户')
- const s_key = ref('本人支付宝账号提现')
- const show = ref(false)
- const showNumber = ref(false)
- const maxPrice = ref(0)
- const priceData = ref({
- // price: '0.01',
- // name: '搁置',
- // code: '18696601943'
- price: '',
- name: '',
- code: '',
- idCard: '',
- })
- const change = (e) => {
- console.log('change', e)
- const regex = /^\d*\.?\d*$/
- if (!regex.test(e.detail.value)) {
- priceData.value.price = priceData.value.price.replace(/[^\d.]/g, '')
- }
- }
- const openSheet = (index) => {
- show.value = true
- }
- const openSheetNumber = (index) => {
- showNumber.value = true
- }
- const close = () => {
- show.value = false
- showNumber.value = false
- }
- const select = (row) => {
- w_key.value = row.name
- console.log('select', row)
- }
- // const selectNumber = (row) => {
- // s_key.value = row.name
- // console.log('selectNumber', row)
- // }
- const errors = (e) => {
- uni.showToast({
- title: e,
- icon: 'none',
- })
- }
- const handleCheck = () => {
- const is =
- priceData.value.price &&
- priceData.value.price > 0 &&
- priceData.value.name &&
- priceData.value.code
- if (is) {
- return true
- }
- !priceData.value.price && errors('请输入提现金额')
- priceData.value.price <= 0 && errors('请输入正确的金额')
- !priceData.value.name && errors('请输入账户名')
- !priceData.value.code && errors('请输入账号')
- return false
- }
- const onSubmit = () => {
- console.log('TCL: priceData', priceData.value)
- // init();
- const type = handleCheck()
- type &&
- submitAmountApply({
- takeAmount: priceData.value.price,
- alipayName: priceData.value.name,
- alipayAccountNo: priceData.value.code,
- payType: '2',
- alipayAccountType: s_key.value === '本人支付宝账号提现' ? 1 : 2,
- idCard: priceData.value.idCard,
- }).then((res) => {
- if (res.code === 200) {
- uni.showToast({
- title: '提交成功',
- icon: 'success',
- })
- setTimeout(() => {
- uni.redirectTo({ url: `/pages_mine/pages/wallet/index` })
- }, 800)
- }
- })
- }
- // 进入提现历史详情
- const onHistory = () => {
- uni.navigateTo({
- url:'/pages_mine/pages/withdrawal/detailsList'
- })
- }
- const onMaxChange = () => {
- priceData.value.price = maxPrice.value
- }
- const init = async () => {
- try {
- uni.showLoading({
- title: '数据加载中...',
- })
- // 获取初始账户历史数据,alipayAccountType=1(本人)
- const historyRes = await vonTtAlipayAccountHistory({ alipayAccountType: 1 })
- if (historyRes.data) {
- priceData.value.name = historyRes.data.alipayName || ''
- priceData.value.code = historyRes.data.alipayAccountNo || ''
- priceData.value.idCard = historyRes.data.idCard || ''
- }
- if (userType === 2) {
- const res = await getVolunteerAccountInfo()
- maxPrice.value = res.data.balance
- }
- if (userType === 1) {
- const res = await getAccountInfo()
- maxPrice.value = res.data.balance
- }
- } catch (error) {
- console.log('error', error)
- uni.showToast({
- title: error.msg,
- icon: 'error',
- })
- } finally {
- uni.hideLoading()
- }
- }
- const selectNumber = async (row) => {
- s_key.value = row.name
- console.log('selectNumber', row)
-
- try {
- uni.showLoading({
- title: '加载数据...',
- mask: true
- })
-
- // 根据类型获取账户历史
- const type = row.name === '他人支付宝账号提现' ? 2 : 1
- const res = await vonTtAlipayAccountHistory({ alipayAccountType: type })
-
- if (row.name === '他人支付宝账号提现') {
- if (res.data) {
- priceData.value.name = res.data.alipayName || ''
- priceData.value.code = res.data.alipayAccountNo || ''
- priceData.value.idCard = res.data.idCard || ''
- } else {
- // 如果没有历史数据,获取当前状态
- const statusRes = await getWithdrawStatus()
- if (statusRes.code === 200 && statusRes.data) {
- priceData.value.name = statusRes.data.alipayName || ''
- priceData.value.code = statusRes.data.alipayAccountNo || ''
- priceData.value.idCard = statusRes.data.idCard || ''
- } else {
- // 如果data为null,清空相关字段
- priceData.value.name = ''
- priceData.value.code = ''
- priceData.value.idCard = ''
- }
- }
- } else {
- // 切换回本人时清空数据
- priceData.value.name = ''
- priceData.value.code = ''
- priceData.value.idCard = ''
- // 重新查一次本人账号历史
- if (res.data) {
- priceData.value.name = res.data.alipayName || ''
- priceData.value.code = res.data.alipayAccountNo || ''
- priceData.value.idCard = res.data.idCard || ''
- }
- }
- } catch (error) {
- console.error('获取账户信息失败:', error)
- uni.showToast({
- title: '获取账户信息失败',
- icon: 'none'
- })
- } finally {
- uni.hideLoading()
- }
- }
- onShow(() => {
- init()
- })
- </script>
- <style lang="scss" scoped>
- .withdrawal-main {
- position: fixed;
- top: 0px;
- left: 0px;
- right: 0px;
- bottom: 0px;
- background-color: #fff;
- padding: 0 12px;
- .withdrawal-item {
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 12px 0;
- .withdrawal-label {
- font-size: 14px;
- font-weight: 500;
- line-height: 20.27px;
- color: rgba(153, 153, 153, 1);
- display: flex;
- align-items: center;
- }
- .withdrawal-item-right {
- display: flex;
- align-items: center;
- .withdrawal-text {
- font-size: 16px;
- font-weight: 700;
- line-height: 23.17px;
- color: rgba(0, 0, 0, 1);
- margin-right: 6px;
- }
- }
- }
- .price-box {
- display: flex;
- .price-input {
- flex: 1;
- height: 58px;
- padding: 0 12px;
- font-size: 28px;
- }
- .price-input2 {
- flex: 1;
- height: 38px;
- padding: 0 12px;
- font-size: 16px;
- }
- }
- }
- </style>
|