userCard.vue 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <template>
  2. <a-card class="card">
  3. <a-space size="large">
  4. <a-statistic title="剩余乐跑次数" :value="userCount?.lepao_count" show-group-separator />
  5. <a-button type="primary" size="large" @click="$router.push('/store/goodsList')" style="margin-left: 20px;"><icon-gift /> 去购买</a-button>
  6. </a-space>
  7. </a-card>
  8. </template>
  9. <script setup>
  10. import { ref } from 'vue'
  11. import { useUserStore } from '@/store/modules/user'
  12. import { getCount } from '@/api/goods'
  13. import { Notification } from '@arco-design/web-vue'
  14. const userCount = ref({})
  15. const loading = ref(false)
  16. const user = ref('')
  17. const getuser = async () => {
  18. const userStore = useUserStore()
  19. let userInfo = await userStore.getInfo()
  20. user.value = userInfo
  21. }
  22. const GetCount = async () => {
  23. try {
  24. loading.value = true
  25. const res = await getCount()
  26. if (!res || res.code !== 0)
  27. return Notification.error({
  28. title: '获取用户数据失败!',
  29. content: res.msg || '请稍后再试'
  30. })
  31. userCount.value = res.data
  32. } catch (error) {
  33. Notification.error({
  34. title: '获取用户数据失败!',
  35. content: error.message || '请稍后再试'
  36. })
  37. } finally {
  38. loading.value = false
  39. }
  40. }
  41. GetCount()
  42. getuser()
  43. </script>
  44. <style scoped lang="less"></style>