my.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <template>
  2. <view class="ezy-my-page">
  3. <view class="my-head-box">
  4. <icon class="head-img-box" :style="{backgroundImage: 'url(' + myInfoData.icon + ')'}"></icon>
  5. <view class="head-content-box">
  6. <text>{{myInfoData.nickName}}</text>
  7. </view>
  8. </view>
  9. <!-- 图 -->
  10. <!-- <img :src="" class="hyqy-box-img" /> -->
  11. <!-- 设置 -->
  12. <view class="my-list-box">
  13. <view class="list-item" @click="yingyongshezhi">
  14. <icon class="list-icon yysz-icon"></icon>
  15. <text>应用设置</text>
  16. </view>
  17. </view>
  18. <!-- 底部 -->
  19. <CustomTabBar :currentTabNumber="3"></CustomTabBar>
  20. </view>
  21. </template>
  22. <script setup>
  23. import {
  24. myInfo,
  25. zhuxiao,
  26. duihuanmaCode,
  27. myCardList,
  28. commonCardList
  29. } from '@/api/my.js'
  30. import CustomTabBar from '@/components/custom-tabbar/custom-tabbar.vue';
  31. import {
  32. onLoad
  33. } from '@dcloudio/uni-app';
  34. import {
  35. reactive,
  36. ref
  37. } from "vue";
  38. let myInfoData = reactive({
  39. userImg: '',
  40. userName: '',
  41. credit: '',
  42. vipFlag: '',
  43. nickName: '',
  44. icon: '',
  45. });
  46. // 获取用户数据
  47. function getMyInfo() {
  48. myInfo({}).then(res => {
  49. myInfoData.userName = res.data.userName;
  50. myInfoData.nickName = res.data.nickName;
  51. if (res.data.nickName) {
  52. myInfoData.nickName = res.data.nickName;
  53. } else {
  54. myInfoData.nickName = '鹅状元';
  55. }
  56. if (res.data.icon) {
  57. myInfoData.icon = res.data.icon;
  58. } else {
  59. getUserImg(res.data.growthType)
  60. }
  61. })
  62. }
  63. // 获取用户头像
  64. function getUserImg(data) {
  65. switch (data) {
  66. case 0:
  67. myInfoData.icon = 'static/images/my/head-img0.png'
  68. break;
  69. case 1:
  70. myInfoData.icon = 'static/images/my/head-img1.png'
  71. break;
  72. case 2:
  73. myInfoData.icon = 'static/images/my/head-img2.png'
  74. break;
  75. case 3:
  76. myInfoData.icon = 'static/images/my/head-img3.png'
  77. break;
  78. default:
  79. myInfoData.icon = 'static/images/my/head-unlogin-img.png'
  80. break;
  81. }
  82. }
  83. function yingyongshezhi() {
  84. uni.redirectTo({
  85. url: '/pages/chanpinMy/myInfo'
  86. })
  87. }
  88. onLoad((options) => {
  89. getMyInfo();
  90. })
  91. </script>