| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461 |
- <template>
- <view class="margin-30">
- <navigator v-if="$isEmpty(bank)" url="/pages/userBank/add" class="card_add" hover-class="none">
- <view class="margin-bottom-10">
- <u-icon name="plus-circle-fill" color="#F5A85B" size="70"></u-icon>
- </view>
- <view class="" style="color: #666666;">
- 添加银行卡
- </view>
- </navigator>
- <navigator url="select-bank" class="bank" v-else hover-class="none">
- <view class="left center">
- <image :src="bank.bankCode?'/static/bank/'+bank.bankCode+'.png':''" mode=""></image>
- <view class="content">
- <text>{{bank.bankName}}</text>
- <text>{{dealAccountNo(bank.accountNo)}}</text>
- </view>
- </view>
- <view class="center">
- <text class="cuIcon-right" style="font-size: 36rpx;color: #888888;"></text>
- </view>
- </navigator>
- <view class="card">
- <text class="title" v-if="type==withdrawType.BALANCE_WITHDRAW">结算金额</text>
- <text class="title" v-else>提现金额</text>
- <view class="input">
- <text class="text-price center text-bold" style="font-size: 60rpx;"></text>
- <view @click="show" class="margin-left-20 center"
- style="width: 60%;justify-content: flex-start;color: #ff9900;">
- <text class="text-xl" v-text="withdrawAmount"></text>
- <view class="cusor" v-if="type==withdrawType.POINT_WITHDRAW"></view>
- </view>
- <view v-if="type==withdrawType.POINT_WITHDRAW" @click="allWithdraw" class="center margin-bottom-10 margin-left-20">
- <view class="cu-btn withdraw-btn sm round center">
- <text>全部提现</text>
- </view>
- </view>
- </view>
- <view class="canWithdraw">
- <text class="text-base text-sm " style="margin-bottom: 20rpx;">* 到账金额以实际为准</text>
- <view class="" style="font-weight: 300;">
- <text v-if="type==withdrawType.BALANCE_WITHDRAW">可结算金额</text>
- <text v-else >可提现金额</text>
- <text class="price margin-left-20" style="font-size: 32rpx;">{{canWithDraw}}</text>
- </view>
-
- <view class="margin-top-10" style="font-weight: 300;" v-if="type=='withdraw'">
- <text>费率</text>
- <text @click="rateShow=true" class="cuIcon-question margin-left-10 text-lg"></text>
- </view>
- </view>
-
- </view>
- <u-popup v-model="rateShow" :mask-close-able="false" mode="center" height="40%" width="76%" borderRadius="20"
- negative-top="100">
- <view class="popup-content" style="height: 98%;">
- <view class="">
- <text class="popup-title">费率说明</text>
- <view class="popup-desc">
- <text>累计营收0-1000元,费率为0.5%;</text>
- <text>1001-10000元,费率为0.38%;</text>
- <text>10000-100000元,费率0.3%;</text>
- <text>100000元起申请更低费率。</text>
- </view>
- </view>
- <view class="center">
- <view class="cu-btn btn-bg-color round" style="height: 80rpx;font-size: 30rpx;width: 80%;"
- @click="rateShow=false">
- 确认
- </view>
- </view>
- </view>
- </u-popup>
- <amountInput :maxNumber="canWithDraw" ref="amountInput" :confirmText="type==withdrawType.BALANCE_WITHDRAW?'确认结算':'确认提现'" btnColor="#ff9900" @change="change"
- @confirm="debounceWithdraw"></amountInput>
- <u-modal :mask-close-able="true" confirm-text="确定提现" @confirm="doWithdraw" v-model="passwordShow" title="提示">
- <view class="slot-content" style="padding: 20rpx;">
- <u-input v-model="withdrawPassword" placeholder="请填写提现密码" type="password" />
- </view>
- </u-modal>
- <toast ref="toast"></toast>
- <loading ref="loading" type="3"/>
- </view>
- </template>
- <script>
- import md5Libs from "uview-ui/libs/function/md5";
- import amountInput from '@/components/amountInput/amountInput.vue';
- export default {
- components: {
- amountInput
- },
- data() {
- return {
- //提现的id
- withdrawId:'',
- //默认积分提现
- withdrawType:this.$global.WITHDRAW_TYPE,
- type:this.$global.WITHDRAW_TYPE.POINT_WITHDRAW,
- rateShow: false,
- bank: {},
- //可提现
- canWithDraw: '',
- //提现金额
- withdrawAmount: 0,
- //提现密码
- withdrawPassword: '',
- passwordShow: false,
- count:0,
- };
- },
- onLoad(options) {
- this.fetchCardList()
- this.init(options)
- this.fetchBillsInfo()
- },
- onShow() {
- if (this.canReset) {
- this.bank = this.$util.getBackParams('bank')
- if (this.$isEmpty(this.bank)) {
- this.fetchCardList()
- }
- }
- this.canReset = true
- },
- computed: {
- dealAccountNo() {
- return data => {
- return this.$util.dealAccountNo(data)
- }
- },
- dealBankCodeType() {
- return data => {
- return this.$getBankCodeType(data)
- }
- }
- },
- methods: {
- async fetchBillsInfo() {
- let params = {
- shopId: this.vuex_shopId
- }
- let res=await this.$api.shop.shopBillsInfo(params)
- let dataInfo = res.data
- if (this.type==this.$global.WITHDRAW_TYPE.BALANCE_WITHDRAW) {
- this.canWithDraw=dataInfo.balance
- this.withdrawAmount=this.canWithDraw
- this.$refs.amountInput.initialMoney(this.withdrawAmount)
- }else if (this.type==this.$global.WITHDRAW_TYPE.POINT_WITHDRAW) {
- this.canWithDraw=dataInfo.point
- }
- },
- init(options){
- this.type=options.type
-
- if (this.type==this.$global.WITHDRAW_TYPE.BALANCE_WITHDRAW) {
- uni.setNavigationBarTitle({
- title:'余额结算'
- })
- return
- }
- if (this.type==this.$global.WITHDRAW_TYPE.POINT_WITHDRAW) {
- uni.setNavigationBarTitle({
- title:'积分提现'
- })
- return
- }
- },
- async fetchShopDetail() {
- let params = {
- id: this.vuex_shopId
- }
- let data = (await this.$api.shop.detail(params)).data
- this.canWithDraw = data.balance
- },
- fetchCardList() {
- let params = {
- merchantNo: this.vuex_merchantNo
- }
- this.$api.yeepay.withdrawCardQuery(params).then(res => {
- let result = JSON.parse(res.data.result)
- this.bank = result.bankCardAccountList[0]
- })
- },
- change(e) {
- if (!e) {
- this.withdrawAmount = 0
- } else {
- this.withdrawAmount = e
- }
- },
- show() {
- if (this.type==this.$global.WITHDRAW_TYPE.POINT_WITHDRAW) {
- this.$refs.amountInput.show()
- }else{
- this.$refs.toast.info('不可修改结算金额')
- }
- },
- //全部提现
- allWithdraw() {
- this.withdrawAmount = this.canWithDraw
- this.$refs.amountInput.initialMoney(this.withdrawAmount)
- },
- //防抖提现
- debounceWithdraw() {
- if (this.isFirst) {
- this.withdrawConfirm()
- this.isFirst = false
- } else {
- this.$u.debounce(this.withdrawConfirm, 500)
- }
- },
- async withdrawConfirm() {
- if (this.$isEmpty(this.bank)) {
- this.$u.toast('请选择银行')
- return
- }
- let params={
- ownerType:'商户',
- ownerId:this.vuex_shopId,
- price:this.withdrawAmount,
- bankAccountType:this.bank.bankCardType,
- bankCode:this.bank.bankCode,
- receiverAccountName:this.bank.accountName,
- receiverAccountNo:this.bank.accountNo,
- userBankId:this.bank.bindCardId,
- receiveType:'REAL_TIME'
- }
- let res={}
- if (this.type==this.$global.WITHDRAW_TYPE.POINT_WITHDRAW) {
- res=await this.$api.withdraw.userPointWithdraw(params)
- }
-
- if (this.type==this.$global.WITHDRAW_TYPE.BALANCE_WITHDRAW) {
- res=await this.$api.withdraw.userBalanceWithdraw(params)
- }
- if (this.$isEmpty(res.data)) {
- this.$refs.toast.error('操作失败')
- }
- let payOrderParams={
- orderId:res.data,
- orderType:'orderType'
- }
- let resp={}
- if (this.type==this.$global.WITHDRAW_TYPE.POINT_WITHDRAW) {
- resp=await this.$api.withdraw.pointPayOrder(payOrderParams)
- }
- if (this.type==this.$global.WITHDRAW_TYPE.BALANCE_WITHDRAW) {
- resp=await this.$api.withdraw.balancePayOrder(payOrderParams)
- }
- if (resp.success && this.$isNotEmpty(resp.data)) {
- this.withdrawId=resp.data
- this.$refs.toast.info('已提交申请,请耐心等待')
- // this.$refs.loading.showLoading('处理中')
- // this.check()
- }
- },
- doWithdraw() {
- if (this.$isEmpty(this.withdrawPassword)) {
- this.$u.toast('请输入提现密码')
- this.passwordShow = true
- return
- }
- console.log(md5Libs.md5(this.withdrawPassword));
- },
- check(){
- let _this=this
- let timer= setInterval(async ()=>{
- _this.count++
- let params={
- id:_this.withdrawId
- }
- let res=await _this.$api.withdraw.detail(params)
- if (res.data && res.data.withdrawStatus == 'DONE') {
- this.fetchBillsInfo()
- this.$refs.toast.info('操作成功')
- _this.$refs.loading.hide()
- clearInterval(timer)
- }
- if (_this.count == 5) {
- this.$refs.toast.info('已提交申请,请耐心等待')
- _this.$refs.loading.hide()
- clearInterval(timer)
- }
- },1000)
- },
- }
- };
- </script>
- <style lang="scss" scoped>
- .bank {
- border-radius: 20rpx;
- background-color: #FFFFFF;
- padding: 44rpx;
- display: flex;
- justify-content: space-between;
- .left {
- display: flex;
- image {
- width: 90rpx;
- height: 90rpx;
- margin-right: 20rpx;
- }
- .content {
- display: flex;
- flex-direction: column;
- text:first-child {
- color: #252525;
- font-weight: 800;
- font-size: 34rpx;
- }
- text:last-child {
- margin-top: 15rpx;
- color: #888888;
- font-size: 26rpx;
- }
- }
- }
- }
- .card_add {
- border-radius: 20rpx;
- padding: 40rpx 0;
- background-color: #FFFFFF;
- display: flex;
- justify-content: center;
- align-items: center;
- flex-direction: column;
- }
- .btn-withdraw {
- position: absolute;
- right: -30rpx;
- top: 26rpx;
- .btn {
- padding: 16rpx 38rpx;
- background-color: #FFE6CD;
- color: $base-color;
- }
- }
- .card {
- overflow: hidden;
- position: relative;
- border-radius: 20rpx;
- margin-top: 30rpx;
- padding: 40rpx;
- background-color: #FFFFFF;
- display: flex;
- flex-direction: column;
- .title {
- font-size: 36rpx;
- font-weight: 800;
- margin-bottom: 30rpx;
- }
- .input {
- display: flex;
- border-bottom: 1rpx solid #DFDFDF;
- .withdraw-btn {
- background-color: #FFFFFF;
- color: $base-color;
- border: 1rpx solid $base-color;
- height: 52rpx;
- width: 170rpx;
- font-size: 28rpx;
- line-height: 54rpx;
- }
- }
- .canWithdraw {
- flex-direction: column;
- display: flex;
- margin-top: 24rpx;
- color: #252525;
- }
- .rate {
- margin-top: 40rpx;
- .item {
- margin-bottom: 20rpx;
- display: flex;
- justify-content: space-between;
- text:first-child {
- color: #252525;
- }
- text:last-child {
- color: #999999;
- }
- }
- }
- }
- .submit-btn {
- background-color: $base-color;
- color: #FFFFFF;
- border-radius: 10rpx;
- }
- .popup-content {
- height: 100%;
- padding: 50rpx 60rpx;
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- .popup-title {
- font-size: 38rpx;
- font-weight: 800;
- }
- .popup-desc {
- margin-top: 50rpx;
- color: #666666;
- display: flex;
- flex-direction: column;
- text {
- line-height: 40rpx;
- margin-bottom: 10rpx;
- }
- }
- }
- .cusor {
- margin-left: 10rpx;
- width: 6rpx;
- border-radius: 20rpx;
- height: 60%;
- background-color: $base-color;
- animation: blink 1200ms infinite ease-in-out;
- }
- @keyframes blink {
- from {
- opacity: 0;
- }
- }
- </style>
|