420 lines
12 KiB
Vue
Raw Normal View History

2023-09-09 19:01:25 +08:00
<template>
<view class="">
<view class="info">
<view class="bg"></view>
<view class="card">
<view class="title">提现信息</view>
<view class="item">
<text>提现账户</text>
<text v-if="$store.state.app.userInfo.admin_id">{{$store.state.app.userInfo.company.company_name||''}}</text>
<text v-else>{{$store.state.app.userInfo.account||''}}</text>
</view>
<view class="item">
<text>可提现金额</text>
2023-09-09 19:42:44 +08:00
<text>{{payMoney.money}}</text>
2023-09-09 19:01:25 +08:00
</view>
</view>
</view>
2023-09-18 09:59:48 +08:00
<lsjUpload ref="lsjUpload" childId="upload1" :size="10" :option="fileOption" height="200rpx" style="margin-top: 28rpx;" :debug="false" :formats="'pdf'"
:multiple="false" :count="1" :instantly="true" @change="changeFile">
2023-09-18 09:59:48 +08:00
<view class="change-file">请选择PDF类型的发票</view>
</lsjUpload>
<view class="fileList" v-for="(item,index) in files.values()" :key="index">
2023-09-18 09:59:48 +08:00
<view class="name">
<image src="../../static/img/contract/pdf.png" style="width: 40rpx;height: 40rpx;margin-right: 12rpx;"></image>
{{item.name}}
</view>
<view class="btn">
<text @click="resetUpload(item.name)" v-if="item.type=='fail'">重新上传</text>
2023-09-18 09:59:48 +08:00
<text @click="clearShow(item.name)">删除</text>
</view>
</view>
2023-09-09 19:01:25 +08:00
<view class="tip">
<view class="title">提示</view>
<view class="text">
上一周期截至时间是<text>{{payMoney.end_cycle}}</text>;<br />
2023-09-18 09:59:48 +08:00
可提现金额是上一个周期的收益金额,并不是当前公司收益金额,提现后将会由后台审核,审核通过后会直接往您所上传的银行卡汇款,请耐心等待;<br/>
<text style="color: #ff7c32;">提现时请注意,需要先上传PDF类型的电子发票后方可提现</text>
2023-09-09 19:01:25 +08:00
<!-- <text @click="copyPhone('4008888888')">4008888888</text> -->
</view>
</view>
<view class="price" style="margin-top: 0;">
<button class="btn" @click="pay">全部提现</button>
</view>
2023-09-18 09:59:48 +08:00
<u-modal :show="modelShow" title="提醒" content="删除后上传的文件将会消失,你确定要删除吗?" showCancelButton
@confirm="clear(del_name);modelShow=false" @cancel="modelShow=false"></u-modal>
2023-09-09 19:01:25 +08:00
</view>
</template>
<script>
import { userWithdraw, getCurrCycleWithdraw } from "@/api/pay.js"
import { userInfo } from "@/api/oaUser.js"
import { debounce, throttle } from 'lodash'
import { Toast } from '@/libs/uniApi.js'
import { FILE_URL } from '@/api/file.js'
import lsjUpload from '@/uni_modules/lsj-upload/components/lsj-upload/lsj-upload.vue'
2023-09-09 19:01:25 +08:00
export default {
components: {
lsjUpload
},
2023-09-09 19:01:25 +08:00
data() {
return {
priceList: ['10元', '50元', '100元', '500元', '1000元', '5000元', '全部', '自定义'],
2023-09-09 19:01:25 +08:00
changeMoney: -1,
company_money: "0.00",
payMoney: {
2023-09-09 19:42:44 +08:00
money: '0.00',
end_cycle: '',
end_cycle_time: '',
invoice: '' // 发票
2023-09-09 19:01:25 +08:00
},
payTimer: null,
timeCount: 5,
fileOption: {},
2023-09-18 09:59:48 +08:00
files: new Map(),
modelShow: false,
del_name: ''
2023-09-09 19:01:25 +08:00
}
},
// 点击提现记录
onNavigationBarButtonTap(res) {
2023-09-09 19:01:25 +08:00
if (res.index === 0) {
uni.navigateTo({
url: '/subpkg/withdrawList/withdrawList'
})
}
},
onLoad() {
const eventChannel = this.getOpenerEventChannel();
eventChannel.on('company_money', (e) => {
2023-09-09 19:01:25 +08:00
this.company_money = e.company_money;
})
this.loadWithddrawInfo();
this.fileOption = {
url: FILE_URL,
name: 'file',
header: {
token: this.$store.state.app.token
}
}
2023-09-09 19:01:25 +08:00
},
methods: {
/**
* 某文件上传结束回调(成功失败都回调)
* @param {Object} item 当前上传完成的文件
*/
onuploadEnd(item) {
console.log(`${item.name}已上传结束,上传状态=${item.type}`);
// 更新当前窗口状态变化的文件
this.files.set(item.name, item);
// 强制更新视图
this.$forceUpdate();
},
/**
* 上传进度回调
* 如果网页上md文档没有渲染出事件名称onprogre请复制代码的小伙伴自行添加上哈没有哪个事件是只(item)
* @param {Object} item 当前正在上传的文件
*/
onprogre(item) {
// 更新当前状态变化的文件
this.files.set(item.name, item);
// 强制更新视图
this.$forceUpdate();
},
/**
* 文件选择回调
* @param {Object} files 已选择的所有文件Map集合
*/
changeFile(files) {
console.log('当前选择的文件列表:', JSON.stringify([...files.values()]));
// 更新选择的文件
this.files = files;
// 强制更新视图
this.$forceUpdate();
},
/**
* 指定上传某个文件
* @param {Object} name 带后缀名的文件名称
*/
resetUpload(name) {
this.$refs.lsjUpload.upload(name);
},
/**
* 移除某个文件
* @param {Object} name 带后缀名的文件名称
*/
clear(name) {
// name=指定文件名不传name默认移除所有文件
this.$refs.lsjUpload.clear(name);
},
2023-09-18 09:59:48 +08:00
clearShow(name) {
console.log(name);
this.del_name = name;
this.modelShow = true;
},
2023-09-09 19:01:25 +08:00
copyPhone(str = "") {
uni.setClipboardData({
data: str + "",
success: (e) => {
Toast('号码已复制')
},
fail: (e) => {
Toast('复制失败')
}
})
},
changePrice(index) {
if (this.changeMoney == index) this.changeMoney = -1;
else this.changeMoney = index;
if (this.priceList[index] == '自定义') this.payMoney.money = '';
else if (this.priceList[index] == '全部') this.payMoney.money = this.$store.state.app.userInfo.user_money || 0;
else this.payMoney.money = this.priceList[index].split('元')[0];
},
2023-09-09 19:42:44 +08:00
// 获取可提现的数据
async loadWithddrawInfo() {
2023-09-09 19:01:25 +08:00
let res = await getCurrCycleWithdraw();
2023-09-09 20:13:04 +08:00
this.payMoney.money = parseFloat(res.data?.user_currrent_total_withdraw_money).toFixed(2);
2023-09-11 14:25:29 +08:00
this.payMoney.end_cycle_time = res.data.end_cycle;
res.data.end_cycle ? this.payMoney.end_cycle = uni.$u.timeFormat(res.data.end_cycle, 'yyyy-mm-dd') : this
.payMoney.end_cycle || '';
},
// 判断文件是否上传
isFile() {
try {
let file;
this.files.forEach((v, k) => {
file = v.responseText;
})
file = JSON.parse(file);
this.payMoney.invoice = file.data.uri;
2023-09-18 09:59:48 +08:00
if (this.payMoney.invoice.slice(-4) != '.pdf') {
return false;
}
return true;
} catch (e) {
return false
}
2023-09-09 19:01:25 +08:00
},
// 提现
pay() {
2023-09-18 09:59:48 +08:00
if (!this.isFile()) return Toast('请先上传PDF类型的发票!')
2023-09-09 19:01:25 +08:00
if (+this.payMoney.money <= 0) return Toast('提现金额不能小于0!')
if (!this.payTimer) {
this.goApply();
this.payTimer = setInterval(() => {
this.timeCount--;
if (this.timeCount <= 0) {
clearInterval(this.payTimer);
this.payTimer = null;
this.timeCount = 5;
}
}, 1000)
} else Toast(this.timeCount + '秒后再提现!')
},
// 提现
async goApply() {
this.payMoney.invoice = '';
2023-09-12 09:39:40 +08:00
uni.showLoading({
title: '申请中',
mask: true
})
2023-09-09 19:01:25 +08:00
let res = await userWithdraw({
2023-09-09 19:42:44 +08:00
amount: this.payMoney.money,
2023-09-11 14:25:29 +08:00
transfer_end_cycel: this.payMoney.end_cycle_time
2023-09-09 19:01:25 +08:00
});
2023-09-12 09:39:40 +08:00
uni.hideLoading();
2023-09-09 19:01:25 +08:00
uni.showToast({
icon: 'success',
2023-09-09 19:01:25 +08:00
title: res.msg
})
}
},
onPullDownRefresh() {
uni.stopPullDownRefresh()
}
}
</script>
<style lang="scss">
page {
background-color: #fff;
}
2023-09-09 19:01:25 +08:00
.info {
display: flex;
flex-direction: column;
align-items: center;
position: relative;
height: 250rpx;
.bg {
background-color: $theme-oa-color;
height: 170rpx;
width: 100vw;
border-radius: 0rpx 0rpx 28rpx 28rpx;
position: absolute;
top: 0;
left: 0;
}
.card {
width: 694rpx;
min-height: 180rpx;
background: #FFFFFF;
margin-top: 38.55rpx;
box-shadow: 0rpx 0rpx 18rpx 2rpx rgba(50, 116, 249, 0.1);
border-radius: 14rpx 14rpx 14rpx 14rpx;
opacity: 1;
padding: 31.5rpx 28rpx;
display: flex;
flex-direction: column;
justify-content: space-around;
position: absolute;
top: 0;
.title {
font-size: 32rpx;
font-weight: 600;
color: #333333;
padding-bottom: 10rpx;
}
.item {
display: flex;
justify-content: space-between;
font-size: 32rpx;
font-weight: 400;
color: #333333;
text:nth-child(1) {
2023-09-09 19:01:25 +08:00
flex-shrink: 0;
margin-right: 48rpx;
}
}
}
}
.price {
display: flex;
flex-direction: column;
padding: 0 28rpx;
margin-top: 50rpx;
.title {
font-size: 32rpx;
font-weight: 600;
color: #333333;
line-height: 39rpx;
margin-bottom: 42rpx;
}
.tab {
display: flex;
flex-wrap: wrap;
justify-content: space-evenly;
.item {
width: 217rpx;
height: 131rpx;
margin-bottom: 20rpx;
border-radius: 7rpx 7rpx 7rpx 7rpx;
border: 2rpx solid #F5F5F5;
display: flex;
justify-content: center;
align-items: center;
font-size: 32rpx;
font-weight: 500;
line-height: 32rpx;
}
.active {
border: 2rpx solid $theme-oa-color;
color: $theme-oa-color;
}
}
.input {
width: 100%;
height: 112rpx;
background: #F5F5F5;
border-radius: 56rpx 56rpx 56rpx 56rpx;
opacity: 1;
padding: 0 45.56rpx;
box-sizing: border-box;
font-size: 28rpx;
font-weight: 400;
color: #333;
line-height: 35rpx;
}
.btn {
width: 694rpx;
height: 84rpx;
margin-top: 73.6rpx;
background: $theme-oa-color;
box-shadow: 0rpx 14rpx 44rpx 2rpx #E9EFF5;
border-radius: 42rpx 42rpx 42rpx 42rpx;
display: flex;
justify-content: center;
align-items: center;
font-size: 32rpx;
font-weight: 400;
color: #FFFFFF;
}
}
.tip {
display: flex;
flex-direction: column;
padding: 0 28rpx;
margin-top: 84rpx;
.title {
font-size: 32rpx;
font-weight: 500;
color: $theme-oa-color;
line-height: 32rpx;
margin-bottom: 21rpx;
}
.text {
font-size: 28rpx;
font-weight: 400;
color: rgba(0, 0, 0, 0.6);
line-height: 42rpx;
-webkit-background-clip: text;
}
}
.change-file {
margin: 0 auto;
width: 694rpx;
height: 200rpx;
2023-09-18 09:59:48 +08:00
border: 2px dashed #ccc;
border-radius: 14rpx;
color: #999;
font-size: 32rpx;
display: flex;
justify-content: center;
align-items: center;
}
.fileList {
display: flex;
width: 694rpx;
margin: 10rpx auto;
justify-content: space-between;
padding: 28rpx;
border: 2px solid #999;
border-radius: 14rpx;
.name {
display: flex;
}
.btn {
color: red;
}
}
2023-09-09 19:01:25 +08:00
</style>