fix: issues
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<template>
|
||||
<van-image width="100%" height="100" src="https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg" />
|
||||
<div style="width:100%; height: 50px;background-color: #3700B3;"></div>
|
||||
|
||||
<charge-notice-bar v-if="user.admin_contact" :contact="user.admin_contact" />
|
||||
<!-- 可以使用 CellGroup 作为容器 -->
|
||||
<van-cell-group>
|
||||
<van-cell size="large" title="账户余额" :value="user.balance ?? '--'" />
|
||||
@@ -11,28 +12,25 @@
|
||||
</van-field>
|
||||
</van-cell-group>
|
||||
|
||||
<van-cell-group title="充值码" v-if="user.is_admin">
|
||||
<van-cell v-for="c in codes" size="large" :title="getCodeAmountTitle(c)" :value="c.code" @click="copyCode(c)" />
|
||||
</van-cell-group>
|
||||
<charge-code v-if="user.is_admin === true" />
|
||||
|
||||
<balance-history />
|
||||
|
||||
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import BalanceHistory from "@/components/BalanceHistory.vue";
|
||||
import ChargeCode from "@/components/ChargeCode.vue";
|
||||
import ChargeNoticeBar from "@/components/ChargeNoticeBar.vue";
|
||||
import request from "@/utils/request";
|
||||
|
||||
const codes = ref({});
|
||||
const user = ref({});
|
||||
const chargeCode = ref("")
|
||||
|
||||
const loadUserInfo = () => {
|
||||
request.get("/users/info").then((res) => {
|
||||
user.value = res.data;
|
||||
|
||||
if (user.value.is_admin) {
|
||||
loadChargeCodes();
|
||||
}
|
||||
}).catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
@@ -42,17 +40,6 @@ onMounted(() => {
|
||||
loadUserInfo();
|
||||
});
|
||||
|
||||
const loadChargeCodes = () => {
|
||||
if (!user.value.is_admin) {
|
||||
return;
|
||||
}
|
||||
|
||||
request.get("/users/codes").then((res) => {
|
||||
codes.value = res.data;
|
||||
}).catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
};
|
||||
|
||||
const confirmCharge = () => {
|
||||
if (!chargeCode.value) {
|
||||
@@ -80,16 +67,6 @@ const confirmCharge = () => {
|
||||
});
|
||||
};
|
||||
|
||||
const getCodeAmountTitle = (code) => {
|
||||
return code.amount / 100 + " 元/ " + code.amount + " 点";
|
||||
};
|
||||
|
||||
const copyCode = (c) => {
|
||||
// h5 copy c.code to clipboard
|
||||
navigator.clipboard.writeText(c.code);
|
||||
|
||||
showSuccessToast(getCodeAmountTitle(c) + " 已复制");
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user