|
@@ -8,7 +8,7 @@
|
|
|
<img src="../assets/icon_bianji.png" class="icon" alt="" />
|
|
<img src="../assets/icon_bianji.png" class="icon" alt="" />
|
|
|
</div>
|
|
</div>
|
|
|
<div class="userInfo" v-else @click="goLogin">
|
|
<div class="userInfo" v-else @click="goLogin">
|
|
|
- <van-image width="60" height="60" radius="4" :src="notLogo"></van-image>
|
|
|
|
|
|
|
+ <van-image width="60" height="60" radius="4" :src="defaultAvatar"></van-image>
|
|
|
<span class="name">未登录</span>
|
|
<span class="name">未登录</span>
|
|
|
<img src="../assets/icon_bianji.png" class="icon" alt="" />
|
|
<img src="../assets/icon_bianji.png" class="icon" alt="" />
|
|
|
</div>
|
|
</div>
|
|
@@ -54,7 +54,7 @@
|
|
|
<span class="text1" @click="$router.push({ name: 'wallet' })">我的钱包</span>
|
|
<span class="text1" @click="$router.push({ name: 'wallet' })">我的钱包</span>
|
|
|
</div>
|
|
</div>
|
|
|
<van-grid class="card-content" :border="false" :column-num="1">
|
|
<van-grid class="card-content" :border="false" :column-num="1">
|
|
|
- <van-grid-item text="465.26" @click="$router.push({ name: 'wallet' })">
|
|
|
|
|
|
|
+ <van-grid-item :text="balanceText" @click="$router.push({ name: 'wallet' })">
|
|
|
<template #icon>
|
|
<template #icon>
|
|
|
<img class="grid-icon" src="../assets/info_icon_qianbao.png" alt="" />
|
|
<img class="grid-icon" src="../assets/info_icon_qianbao.png" alt="" />
|
|
|
</template>
|
|
</template>
|
|
@@ -108,9 +108,12 @@
|
|
|
|
|
|
|
|
<script setup>
|
|
<script setup>
|
|
|
import { computed } from 'vue'
|
|
import { computed } from 'vue'
|
|
|
-import { useUserStore } from '../stores/user'
|
|
|
|
|
|
|
+import { useUserStore } from '@/stores/user'
|
|
|
import { useRouter } from 'vue-router'
|
|
import { useRouter } from 'vue-router'
|
|
|
-import notLogo from '../assets/png_moren.png'
|
|
|
|
|
|
|
+import defaultAvatar from '@/assets/png_moren.png'
|
|
|
|
|
+import { ref, watch } from 'vue'
|
|
|
|
|
+import { http } from '@/plugins/http'
|
|
|
|
|
+
|
|
|
const userStore = useUserStore()
|
|
const userStore = useUserStore()
|
|
|
const user = computed(() => {
|
|
const user = computed(() => {
|
|
|
return userStore.user
|
|
return userStore.user
|
|
@@ -124,6 +127,30 @@ const goLogin = () => {
|
|
|
const goSetting = () => {
|
|
const goSetting = () => {
|
|
|
router.push({ name: 'setting' })
|
|
router.push({ name: 'setting' })
|
|
|
}
|
|
}
|
|
|
|
|
+const balance = ref({})
|
|
|
|
|
+function getBalance() {
|
|
|
|
|
+ http.get('/user/balance').then(res => {
|
|
|
|
|
+ balance.value = res
|
|
|
|
|
+ })
|
|
|
|
|
+}
|
|
|
|
|
+watch(user, val => {
|
|
|
|
|
+ if (val) {
|
|
|
|
|
+ getBalance()
|
|
|
|
|
+ } else {
|
|
|
|
|
+ balance.value = {}
|
|
|
|
|
+ }
|
|
|
|
|
+})
|
|
|
|
|
+getBalance()
|
|
|
|
|
+const balanceText = computed(() => {
|
|
|
|
|
+ if (balance.value) {
|
|
|
|
|
+ if (balance.value.balance > 1000000) {
|
|
|
|
|
+ return (balance.value.balance / 1000000).toFixed(1).replace(/\.0$/, '') + 'M'
|
|
|
|
|
+ } else if (balance.value.balance > 1000) {
|
|
|
|
|
+ return (balance.value.balance / 1000).toFixed(1).replace(/\.0$/, '') + 'K'
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return 'N/A'
|
|
|
|
|
+})
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="less" scoped>
|
|
<style lang="less" scoped>
|