my.vue 2.9 KB

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