c5_labsci/fapp/ciyon_ap/pages/me/cash_charge.vue
2026-01-27 00:52:00 +08:00

124 lines
3.0 KiB
Vue

<template>
<ciy-header title="充值"></ciy-header>
<view v-if="init.code != 1" class="px4 py4">
<view style="height:4em;width:100%;" class="ciy-skeleton"></view>
<view style="height:8em;width:100%;" class="ciy-skeleton"></view>
<view style="height:8em;width:100%;" class="ciy-skeleton"></view>
</view>
<view v-else>
<view class="ciy-card">
<view class="content char4">
<view class="flex flex-wrap" style="gap:1em;">
<view class="fpay" v-for="(item,index) in init.charges" :key="item" @tap="currbuy=index;money=item.chargemoney" :class="{select:currbuy==index}">
<view class="money">
<text>{{item.chargemoney/100}}</text>元
</view>
</view>
</view>
</view>
<view class="ciy-form">
<label>充值金额</label>
<view>
<ciy-inputbet left bb v-model="money" bet="100" unit="元"></ciy-inputbet>
</view>
</view>
<view class="ciy-form-bottom">
<button class="btn lg cc" @tap="paynow">立即充值</button>
</view>
<view class="ciy-tip">充值资金仅可用于本平台指定服务,不可提现、不可转让,平台不提供资金保管或理财服务。</view>
</view>
<view class="ciy-hr"></view>
<ciy-swipelist title="充值记录" @tap="gourl" data-url="cashin_lst" more></ciy-swipelist>
</view>
</template>
<style>
.fpay {
flex: 1 1 33.33%;
text-align: center;
background: var(--bg1);
border-radius: 0.5em;
border: 1px solid var(--bg5);
transition: all 0.5s;
}
.fpay.select {
border: 1px solid var(--man7);
}
.fpay .money {
padding: 2em 0;
font-size: 0.8em;
}
.fpay .money>text {
font-size: 2em;
padding: 0 0.3em;
color: var(--man7);
font-weight: bold;
}
</style>
<script>
export default {
data() {
return {
svg: {},
money: 0,
currbuy: -1
}
},
onLoad() {
this.getinit();
},
methods: {
async getinit() {
var retjson = await this.callfunc({
func: 'me.cash_charge_init',
data: this.pagepost
});
if (retjson.code != 1)
return this.alert(retjson.errmsg);
this.init = retjson;
this.money = this.toint(this.opn.pay);
if(this.money > 0)
this.paynow();
},
async paynow(e) {
if(this.money <= 0)
return this.toast('请选择或填写金额');
if (this._loading)
return;
this._loading = true;
var retjson = await this.callfunc({
func: 'me.cash_charge_pay',
data: {
money: this.money
}
});
this._loading = false;
if (retjson.code != 1)
return this.alert(retjson.errmsg);
retjson.provider = 'wxpay';
try {
var retpay = await uni.requestPayment(retjson);
await this.sleep(1000);
var retjson2 = await this.callfunc({
func: 'me.cash_charge_chk',
data: {
orderid: retjson.orderid
}
});
if (retjson2.code != 1)
return this.toast('支付提示: ' + retjson2.errmsg);
var app = getApp();
var page = app.getpage(1);
if (page && page.getbalance)
page.getbalance(1);
this.toast('充值成功');
} catch (e) {}
}
}
}
</script>