You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
173 lines
5.9 KiB
173 lines
5.9 KiB
<template>
|
|
<view class="wallet-index">
|
|
<wallet-info
|
|
:balance="balance"
|
|
@click:douyin="dyBtnClick"
|
|
@click:baofu="bfBtnClick"
|
|
@click:admin="toWebView"
|
|
@click:recharge="rechargeBtn"
|
|
@click:record="toRechargeRecord"
|
|
></wallet-info>
|
|
<view class="wi-tips">
|
|
<view class="wt-tit">温馨提示:</view>
|
|
<view class="wt-content">
|
|
<text class="wc-txt">
|
|
1、如需要宝付分账账户可以自己单独提现,请访问 {{ oxAddress }}
|
|
<text class="wt-copy" @click="copyBtn">复制</text>
|
|
\r\n 账户为宝付的商户号,密码为申请时预留的手机号码
|
|
\r\n 2、平台提现为平台版抖音小程序、平台版微信小程序的分账结算金额提现。
|
|
</text>
|
|
</view>
|
|
</view>
|
|
|
|
<wallet-modal-success ref="walletModalSuccess" :title="'充值成功'">
|
|
<template v-slot:tip>充值成功!</template>
|
|
<template v-slot:btn>充值记录</template>
|
|
</wallet-modal-success>
|
|
|
|
<recharge-modal :balance="balance" ref="rechargeModal"></recharge-modal>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import walletInfo from './modules/wallet_info.vue'
|
|
import walletModalSuccess from '../../components/wallet_modal_success.vue';
|
|
import rechargeModal from "./modules/recharge_modal.vue";
|
|
import { WALLET_API } from '../../js/api';
|
|
import servers from '../../js/server';
|
|
import { routeTo, showLoad, hideLoad, debounce, showModal } from '@/utils/util';
|
|
export default {
|
|
components: {
|
|
'wallet-info': walletInfo,
|
|
walletModalSuccess,
|
|
rechargeModal
|
|
},
|
|
data(){
|
|
return {
|
|
oxAddress: 'https://sps.ouxuanzhineng.cn',
|
|
brand_id: '',
|
|
balance: 0,
|
|
}
|
|
},
|
|
onLoad(options){
|
|
this.brand_id = options.brand_id ?? '';
|
|
this.getWalletBalance(options.brand_id);
|
|
console.log(uni.getAccountInfoSync().miniProgram)
|
|
},
|
|
onReady(){
|
|
// this.$refs?.walletModalSuccess?.alert();
|
|
},
|
|
methods: {
|
|
toRechargeRecord(){
|
|
let { brand_id } = this;
|
|
routeTo(`/subpackage/wallet/pages/index/recharge_record?brand_id=${brand_id ?? ''}`, 'nT');
|
|
},
|
|
rechargeBtn: debounce(function(){
|
|
let { brand_id } = this;
|
|
this.$refs?.rechargeModal?.show?.({
|
|
success: async num =>{
|
|
let { wxpay_info } = await this.getPayInfo({ brand_id, pay_amount: num });
|
|
uni.requestPayment({
|
|
...wxpay_info,
|
|
success: res => {
|
|
this.$refs?.walletModalSuccess?.alert?.();
|
|
},
|
|
fail: err => {
|
|
console.log('wallet index rechargeBtn fail --->', err);
|
|
if(err?.errMsg?.indexOf?.('cancel') === -1)showModal({ content: err?.errMsg ?? '支付失败!' })
|
|
}
|
|
})
|
|
}
|
|
})
|
|
}, 300, true),
|
|
toWebView(){
|
|
routeTo(`/pages/web_view/web_view?src=${encodeURIComponent(this.getAdminAddress())}`,'nT');
|
|
},
|
|
getAdminAddress(){
|
|
let _appid = uni.getAccountInfoSync()?.miniProgram?.appId || '';
|
|
if(_appid === "wx7106e84614cf0060")return 'https://testadmin.ouxuanzhineng.cn'; // 测试后台地址
|
|
return 'https://admin.ouxuanzhineng.cn'; // 正式后台地址
|
|
},
|
|
copyBtn(){
|
|
uni.setClipboardData({
|
|
data: this.oxAddress,
|
|
})
|
|
},
|
|
getWalletBalance(brand_id){
|
|
showLoad();
|
|
servers.get({
|
|
url: WALLET_API.walletBalance,
|
|
data: {
|
|
brand_id: brand_id
|
|
},
|
|
failMsg: '获取钱包余额失败'
|
|
})
|
|
.then(res=>{
|
|
hideLoad();
|
|
this.balance = +res.balance ?? 0;
|
|
})
|
|
.catch(err=>{
|
|
hideLoad();
|
|
console.log(err);
|
|
})
|
|
},
|
|
dyBtnClick(){
|
|
routeTo(`/subpackage/wallet/pages/douyin_withdraw/index?brand_id=${this.brand_id ?? ''}`, 'nT');
|
|
},
|
|
bfBtnClick(){
|
|
routeTo(`/subpackage/wallet/pages/baofu_withdraw/index?brand_id=${this.brand_id ?? ''}`, 'nT');
|
|
|
|
},
|
|
// 获取支付信息
|
|
getPayInfo({ brand_id, pay_amount }){
|
|
showLoad();
|
|
return servers.post({
|
|
url: WALLET_API.wxpayinfo,
|
|
data: { brand_id, pay_amount },
|
|
isDefaultGet: false,
|
|
})
|
|
.then(res => {
|
|
hideLoad();
|
|
let _data = res?.data || {};
|
|
if(_data.code === 0){
|
|
return _data?.data ?? {};
|
|
}else{
|
|
return Promise.reject(_data);
|
|
}
|
|
})
|
|
.catch(err => {
|
|
hideLoad();
|
|
showModal({
|
|
title: '提示',
|
|
content: err.message || '加载支付信息失败!'
|
|
})
|
|
console.warn('wallet index getPayInfo err --->', err);
|
|
// return Promise.reject(err);
|
|
})
|
|
},
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
.wallet-index{
|
|
padding: 32upx;
|
|
.wi-tips{
|
|
margin-top: 24upx;
|
|
padding: 40upx;
|
|
border-radius: 30upx;
|
|
background: #fff;
|
|
.wt-tit{
|
|
@include flcw($color: #9A9A9D);
|
|
}
|
|
.wt-content{
|
|
margin-top: 20upx;
|
|
@include flcw($color: #1A1A1A, $height: 49upx);
|
|
.wt-copy{
|
|
padding: 0 12upx;
|
|
@include flcw($color: $mColor);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</style>
|