| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234 |
- <template>
- <view class="ezy-my-page">
- <view class="icon-title-navBar-box">
- <view class="nav-bar-title"></view>
- </view>
- <view class="my-page-box">
- <view class="my-head-box">
- <icon class="head-img-box" :style="{backgroundImage: 'url(' + myInfoData.icon + ')'}"></icon>
- <view class="head-content-box">
- <text>{{myInfoData.nickName}}</text>
- <!-- <view class="ezy-jf-box" v-if="loginFlag">
- <icon class="jf-icon"></icon>
- <text class="jf-text">{{myInfoData.credit}}</text>
- </view> -->
- </view>
- </view>
- <!-- 图 -->
- <view class="my-banner-img"></view>
- <!-- 设置 -->
- <view class="my-list-box">
- <view class="list-item" @click="ddBtn">
- <icon class="list-icon yysz-icon"></icon>
- <text>订单</text>
- </view>
- <view class="list-item" @click="yingyongshezhi">
- <icon class="list-icon yysz-icon"></icon>
- <text>应用设置</text>
- </view>
- <view v-if="appleCode=='true'&¤tPlatform=='ios' || currentPlatform=='android'" class="list-item"
- @click="duihuamaDuihuan">
- <icon class="list-icon duihuanma-icon"></icon>
- <text>兑换码</text>
- </view>
- <view class="list-item" @click="test">
- <icon class="list-icon yysz-icon"></icon>
- <text>test</text>
- </view>
- </view>
- </view>
- <duihuanmaDialog ref="duihuanmaDialogRef" @confirm-btn="duihuanmaBtn" title="兑换"></duihuanmaDialog>
- <loginComp ref="loginRef"></loginComp>
- <!-- 底部 -->
- <custom-tab-bar :show="true" :current-index="currentTabIndex" />
- </view>
- </template>
- <script setup>
- import duihuanmaDialog from "./components/duihuanmaDialog.vue"
- import cacheManager from '../../utils/cacheManager';
- import {
- myInfo,
- zhuxiao,
- duihuanmaCode,
- myCardList,
- commonCardList
- } from '@/api/my.js'
- import CustomTabBar from '@/components/custom-tabbar/index.vue';
- import loginComp from "@/components/loginComp/index.vue"
- import {
- onLoad,
- onShow
- } from '@dcloudio/uni-app';
- import {
- reactive,
- ref
- } from "vue";
- let appleCode =ref(null)
- let currentPlatform = ref(null);
- let authInfo = ref(null);
- let loginRef = ref(null);
- let currentTabIndex = ref(3)
- let myInfoData = reactive({
- userImg: '',
- userName: '',
- credit: '',
- vipFlag: '',
- nickName: '',
- icon: '',
- });
- let pageFrom = ref(null)
- onShow(() => {
- currentTabIndex.value = 3
- if(pageFrom.value ==='myInfo'){
- getMyInfo();
- }
- })
- /***************** 测试 ******************/
- const testRef = ref(null)
- function handleTest() {
- testRef.value.showPopup(7)
- }
- /***************** 测试 ******************/
- // 获取用户数据
- function getMyInfo() {
- myInfo({}).then(res => {
- myInfoData.userName = res.data.userName;
- myInfoData.nickName = res.data.nickName;
- pageFrom.value = ''
- appleCode.value = res.data.appleCode.toString()
- if (res.data.nickName) {
- myInfoData.nickName = res.data.nickName;
- } else {
- myInfoData.nickName = '鹅状元';
- }
- if (res.data.icon) {
- myInfoData.icon = res.data.icon;
- } else {
- getUserImg(res.data.growthType)
- }
- })
- }
- // 获取用户头像
- function getUserImg(data) {
- switch (data) {
- case 0:
- myInfoData.icon = 'static/images/my/head-img0.png'
- break;
- case 1:
- myInfoData.icon = 'static/images/my/head-img1.png'
- break;
- case 2:
- myInfoData.icon = 'static/images/my/head-img2.png'
- break;
- case 3:
- myInfoData.icon = 'static/images/my/head-img3.png'
- break;
- default:
- myInfoData.icon = 'static/images/my/head-unlogin-img.png'
- break;
- }
- }
- function yingyongshezhi() {
- pageFrom.value = 'myInfo'
- uni.navigateTo({
- url: '/pages/chanpinMy/myInfo'
- })
- }
- function ddBtn(){
- uni.navigateTo({
- url: '/pages/chanpinMy/order'
- })
- }
- function duihuamaDuihuan() {
- // 兑换码兑换策略
- if (currentPlatform.value == 'ios') {
- // ios
- if (authInfo.value.youke) {
- // 非登录
- } else {
- // 已登录
- duihuanmaDialogRef.value.handleShow();
- }
- } else {
- // android
- if (authInfo.value.youke) {
- // 非登录 -> 去登录
- } else {
- // 已登录
- duihuanmaDialogRef.value.handleShow();
- }
- }
- }
- function duihuanmaBtn() {
- let req = {
- code: data
- }
- duihuanmaCode(req).then(res => {
- if (res.code == 0) {
- toast('兑换成功')
- const localList = cacheManager.get('auth').levelIdList || []
- const mergeList = [...new Set([...localList, ...res.data.levelIdList])]
- cacheManager.updateObject('auth', {
- levelIdList: mergeList
- })
- uni.redirectTo({
- url: '/pages/my/index'
- })
- } else {
- toast('兑换失败请重试或联系管理员')
- return false
- }
- }).catch(err => {
- })
- }
- onLoad((options) => {
- uni.hideTabBar()
- getAuthData();
- getMyInfo();
- isIOSorAndroid()
- })
- function isIOSorAndroid() {
- const systemInfo = uni.getSystemInfoSync();
- if (systemInfo.platform == 'ios') {
- currentPlatform.value = 'ios'
- } else {
- currentPlatform.value = 'android'
- }
- }
- function getAuthData() {
- authInfo.value = cacheManager.get('auth');
- }
- function test() {
- loginRef.value.showPopup()
- }
- </script>
|