my.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <template>
  2. <view class="ezy-my-page">
  3. <view class="icon-title-navBar-box">
  4. <view class="nav-bar-title"></view>
  5. </view>
  6. <view class="my-page-box">
  7. <view class="my-head-box">
  8. <icon class="head-img-box" :style="{backgroundImage: 'url(' + myInfoData.icon + ')'}"></icon>
  9. <view class="head-content-box">
  10. <text>{{myInfoData.nickName}}</text>
  11. <!-- <view class="ezy-jf-box" v-if="loginFlag">
  12. <icon class="jf-icon"></icon>
  13. <text class="jf-text">{{myInfoData.credit}}</text>
  14. </view> -->
  15. </view>
  16. </view>
  17. <!-- 图 -->
  18. <view class="my-banner-img"></view>
  19. <!-- 设置 -->
  20. <view class="my-list-box">
  21. <view class="list-item" @click="yingyongshezhi">
  22. <icon class="list-icon yysz-icon"></icon>
  23. <text>应用设置</text>
  24. </view>
  25. </view>
  26. </view>
  27. <!-- 底部 -->
  28. <custom-tab-bar :show="true" :current-index="currentTabIndex" />
  29. </view>
  30. </template>
  31. <script setup>
  32. import {
  33. myInfo,
  34. zhuxiao,
  35. duihuanmaCode,
  36. myCardList,
  37. commonCardList
  38. } from '@/api/my.js'
  39. import CustomTabBar from '@/components/custom-tabbar/index.vue';
  40. import {
  41. onLoad,
  42. onShow
  43. } from '@dcloudio/uni-app';
  44. import {
  45. reactive,
  46. ref
  47. } from "vue";
  48. let currentTabIndex = ref(3)
  49. let myInfoData = reactive({
  50. userImg: '',
  51. userName: '',
  52. credit: '',
  53. vipFlag: '',
  54. nickName: '',
  55. icon: '',
  56. });
  57. let pageFrom = ref(null)
  58. onShow(() => {
  59. currentTabIndex.value = 3
  60. if(pageFrom.value ==='myInfo'){
  61. getMyInfo();
  62. }
  63. })
  64. /***************** 测试 ******************/
  65. const testRef = ref(null)
  66. function handleTest() {
  67. testRef.value.showPopup(7)
  68. }
  69. /***************** 测试 ******************/
  70. // 获取用户数据
  71. function getMyInfo() {
  72. myInfo({}).then(res => {
  73. myInfoData.userName = res.data.userName;
  74. myInfoData.nickName = res.data.nickName;
  75. pageFrom.value = ''
  76. if (res.data.nickName) {
  77. myInfoData.nickName = res.data.nickName;
  78. } else {
  79. myInfoData.nickName = '鹅状元';
  80. }
  81. if (res.data.icon) {
  82. myInfoData.icon = res.data.icon;
  83. } else {
  84. getUserImg(res.data.growthType)
  85. }
  86. })
  87. }
  88. // 获取用户头像
  89. function getUserImg(data) {
  90. switch (data) {
  91. case 0:
  92. myInfoData.icon = 'static/images/my/head-img0.png'
  93. break;
  94. case 1:
  95. myInfoData.icon = 'static/images/my/head-img1.png'
  96. break;
  97. case 2:
  98. myInfoData.icon = 'static/images/my/head-img2.png'
  99. break;
  100. case 3:
  101. myInfoData.icon = 'static/images/my/head-img3.png'
  102. break;
  103. default:
  104. myInfoData.icon = 'static/images/my/head-unlogin-img.png'
  105. break;
  106. }
  107. }
  108. function yingyongshezhi() {
  109. pageFrom.value = 'myInfo'
  110. uni.navigateTo({
  111. url: '/pages/chanpinMy/myInfo'
  112. })
  113. }
  114. onLoad((options) => {
  115. uni.hideTabBar()
  116. getMyInfo();
  117. })
  118. </script>