my.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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 class="list-item" @click="shangcheng">
  30. <icon class="list-icon yysz-icon"></icon>
  31. <text>商城</text>
  32. </view>
  33. <view v-if="appleCode=='true'&&currentPlatform=='ios' || currentPlatform=='android'" class="list-item"
  34. @click="duihuamaDuihuan">
  35. <icon class="list-icon duihuanma-icon"></icon>
  36. <text>兑换码</text>
  37. </view>
  38. <!-- <view class="list-item" @click="test">
  39. <icon class="list-icon yysz-icon"></icon>
  40. <text>test</text>
  41. </view>-->
  42. </view>
  43. </view>
  44. <duihuanmaDialog ref="duihuanmaDialogRef" :icon="myInfoData.icon" title="兑换" :userName="myInfoData.userName" :nickName="myInfoData.nickName"></duihuanmaDialog>
  45. <loginComp ref="loginRef"></loginComp>
  46. <!-- 底部 -->
  47. <custom-tab-bar :show="true" :current-index="currentTabIndex" />
  48. </view>
  49. </template>
  50. <script setup>
  51. import duihuanmaDialog from "./components/duihuanma/duihuanmaDialog.vue"
  52. import cacheManager from '@/utils/cacheManager';
  53. import {
  54. myInfo,
  55. zhuxiao,
  56. duihuanmaCode,
  57. myCardList,
  58. commonCardList
  59. } from '@/api/my.js'
  60. import CustomTabBar from '@/components/custom-tabbar/index.vue';
  61. import loginComp from "@/components/loginComp/index.vue"
  62. import {
  63. onLoad,
  64. onShow
  65. } from '@dcloudio/uni-app';
  66. import {
  67. reactive,
  68. ref
  69. } from "vue";
  70. let appleCode =ref(null)
  71. let currentPlatform = ref(null);
  72. let authInfo = ref(null);
  73. let loginRef = ref(null);
  74. let currentTabIndex = ref(3)
  75. let myInfoData = reactive({
  76. userImg: '',
  77. userName: '',
  78. credit: '',
  79. vipFlag: '',
  80. nickName: '',
  81. icon: '',
  82. });
  83. let pageFrom = ref(null)
  84. let duihuanmaDialogRef = ref(null)
  85. onShow(() => {
  86. currentTabIndex.value = 3
  87. if(pageFrom.value ==='myInfo'){
  88. getMyInfo();
  89. }
  90. })
  91. /***************** 测试 ******************/
  92. const testRef = ref(null)
  93. function handleTest() {
  94. testRef.value.showPopup(7)
  95. }
  96. /***************** 测试 ******************/
  97. // 获取用户数据
  98. function getMyInfo() {
  99. myInfo({}).then(res => {
  100. myInfoData.userName = res.data.userName;
  101. myInfoData.nickName = res.data.nickName;
  102. pageFrom.value = ''
  103. appleCode.value = res.data.appleCode.toString()
  104. if (res.data.nickName) {
  105. myInfoData.nickName = res.data.nickName;
  106. } else {
  107. myInfoData.nickName = '鹅状元';
  108. }
  109. if (res.data.icon) {
  110. myInfoData.icon = res.data.icon;
  111. } else {
  112. getUserImg(res.data.growthType)
  113. }
  114. })
  115. }
  116. // 获取用户头像
  117. function getUserImg(data) {
  118. switch (data) {
  119. case 0:
  120. myInfoData.icon = 'static/images/my/head-img0.png'
  121. break;
  122. case 1:
  123. myInfoData.icon = 'static/images/my/head-img1.png'
  124. break;
  125. case 2:
  126. myInfoData.icon = 'static/images/my/head-img2.png'
  127. break;
  128. case 3:
  129. myInfoData.icon = 'static/images/my/head-img3.png'
  130. break;
  131. default:
  132. myInfoData.icon = 'static/images/my/head-unlogin-img.png'
  133. break;
  134. }
  135. }
  136. function yingyongshezhi() {
  137. pageFrom.value = 'myInfo'
  138. uni.navigateTo({
  139. url: '/pages/chanpinMy/myInfo'
  140. })
  141. }
  142. function ddBtn(){
  143. uni.navigateTo({
  144. url: '/pages/chanpinMy/order'
  145. })
  146. }
  147. function duihuamaDuihuan() {
  148. // 兑换码兑换策略
  149. if (authInfo.value.youke) {
  150. // 非登录 -- 登录
  151. } else {
  152. // 已登录
  153. duihuanmaDialogRef.value.handleShow();
  154. }
  155. }
  156. onLoad((options) => {
  157. uni.hideTabBar()
  158. getAuthData();
  159. getMyInfo();
  160. isIOSorAndroid()
  161. })
  162. function isIOSorAndroid() {
  163. const systemInfo = uni.getSystemInfoSync();
  164. if (systemInfo.platform == 'ios') {
  165. currentPlatform.value = 'ios'
  166. } else {
  167. currentPlatform.value = 'android'
  168. }
  169. }
  170. function getAuthData() {
  171. authInfo.value = cacheManager.get('auth');
  172. }
  173. // 商城
  174. function shangcheng() {
  175. uni.navigateTo({
  176. url: '/pages/chanpinShop/index'
  177. })
  178. }
  179. function test() {
  180. loginRef.value.showPopup()
  181. }
  182. </script>