123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410 |
- <template>
- <view class="ezy-my-page">
- <view class="my-head-box">
- <icon class="head-img-box" :style="{backgroundImage: 'url(' + myInfoData.userImg + ')'}"></icon>
- <view class="head-content-box">
- <text>{{myInfoData.userName}}</text>
- <view class="ezy-jf-box" v-if="loginFlag">
- <icon class="jf-icon"></icon>
- <text class="jf-text">{{myInfoData.credit}}</text>
- </view>
- </view>
- </view>
- <swiper class="my-hyqy-swiper" circular :indicator-dots="hyqyData.indicatorDots" :autoplay="hyqyData.autoplay"
- :interval="hyqyData.interval" :duration="hyqyData.duration" indicator-color="#5195d3"
- indicator-active-color="#83d9ff">
- <!-- 1.数学 2.英语-->
- <swiper-item v-for="(item, index) in 2" :key="index" class="hyqy-box" :class="getHyqyClass(index)">
- <view class="hyqy-btn" @click="hyqyBtn(index)" v-if="getHyqyBtn(index)"></view>
- </swiper-item>
- </swiper>
- <view class="my-list-box">
- <view class="list-row" @click="telClick">
- <icon class="list-icon tel-icon"></icon>
- <text>手机号码</text>
- </view>
- <view class="list-row" @click="checkWrong">
- <icon class="list-icon error-icon"></icon>
- <text>我的错题</text>
- </view>
- <view v-if="loginFlag" class="list-row" @click="orderClick">
- <icon class="list-icon order-icon"></icon>
- <text>我的订单</text>
- </view>
- <view class="list-row no-jt" @click="aboutClick">
- <icon class="list-icon about-icon"></icon>
- <text>关于我们</text>
- </view>
- <view v-if="appleCode&¤tPlatform=='ios'" class="list-row no-jt" @click="duihuamaDuihuan">
- <icon class="list-icon duihuanma-icon"></icon>
- <text>兑换码</text>
- </view>
- <view v-if="currentPlatform=='android'" class="list-row no-jt" @click="duihuamaDuihuan">
- <icon class="list-icon duihuanma-icon"></icon>
- <text>兑换码</text>
- </view>
- <view v-if="loginFlag" class="list-row no-jt" @click="yonghuzhuxiao">
- <icon class="list-icon zhuxiao-icon"></icon>
- <text>用户注销</text>
- </view>
- <view v-if="loginFlag" class="list-row no-jt" @click="yinsizhengce">
- <icon class="list-icon yszc-icon"></icon>
- <text>隐私政策</text>
- </view>
- <view class="list-row no-jt" @click="exitLogin">
- <icon class="list-icon login-out-icon"></icon>
- <text>退出登录</text>
- </view>
- </view>
- <CustomTabBar :cardId="cardId" :currentTabNumber="3" :nianji="nianji" :zhangId="zhangId" :tipFlag="tipFlag">
- </CustomTabBar>
- <tip-small-dialog ref="exitDialogRef" @confirm-btn="exitBtn" :content="tipContent"></tip-small-dialog>
- <tip-big-dialog ref="youkeDialogRef" @confirm-btn="ykConfirm" :imgShow="true"></tip-big-dialog>
- <tip-small-dialog ref="zhuxiaoDialogRef" @confirm-btn="zhuxiaoBtn" :content="zhuxiaoContent"></tip-small-dialog>
- <duihuanmaDialog ref="duihuanmaDialogRef" @confirm-btn="duihuanmaBtn" title="兑换"></duihuanmaDialog>
- <tel-dialog @telClose="telClose" @bindBtn="bindBtn" v-if="telDialogFlag"></tel-dialog>
- <agree-content-dialog ref="agreeContentDialogRef" :agreeType="agreeType"></agree-content-dialog>
- </view>
- </template>
- <script setup>
- import agreeContentDialog from '@/pages/login/agreeContentDialog.vue';
- import {
- toast,
- getUserIdentity
- } from "@/utils/common";
- import cacheManager from '@/utils/cacheManager.js';
- import {
- logout
- } from '@/api/login.js'
- import {
- myInfo,
- zhuxiao,
- duihuanmaCode
- } from '@/api/my.js'
- import CustomTabBar from '@/components/custom-tabbar/custom-tabbar.vue';
- import {
- getCurrentInstance
- } from 'vue';
- import {
- onLoad
- } from '@dcloudio/uni-app';
- import {
- reactive,
- ref
- } from "vue";
- import tipSmallDialog from '@/components/dialog/tipSmallDialog.vue';
- import duihuanmaDialog from '@/components/dialog/duihuanmaDialog.vue';
- import tipMiddleDialog from '@/components/dialog/tipMiddleDialog.vue';
- import tipBigDialog from '@/components/dialog/tipBigDialog.vue';
- import telDialog from './telDialog.vue'
- import {
- MESSAGE_VISITER_TO_LOGIN
- } from "@/utils/constant.js"
- import {
- onShow
- } from '@dcloudio/uni-app';
- onShow(() => {
- if (!cacheManager.get('auth')) {
- youkeFun();
- } else {
- // 非游客
- noYoukeFun();
- }
- })
- const agreeType = ref(null);
- const agreeContentDialogRef = ref(null);
- const zhangId = ref(null); //游客使用
- const nianji = ref(null); //游客使用
- const cardId = ref(null); //游客使用
- const tipFlag = ref(null); //游客使用
- const tipContent = '你确定要执行这个操作吗?';
- const zhuxiaoContent = '你确定要执行这个操作吗?';
- const duihuanmaContent = '你确定要执行这个操作吗?';
- let hyqyData = reactive({
- indicatorDots: true,
- autoplay: true,
- interval: 10000,
- duration: 500
- });
- let loginFlag = ref(false);
- let telDialogFlag = ref(false);
- let myInfoData = reactive({
- userImg: '',
- userName: '',
- credit: '',
- vipFlag: '',
- });
- let routerOpt = ref(false);
- let appleCode = ref(null);
- let currentPlatform = ref(null);
- const exitDialogRef = ref(null);
- const youkeDialogRef = ref(null);
- const zhuxiaoDialogRef = ref(null);
- const duihuanmaDialogRef = ref(null);
- const exitLogin = () => {
- exitDialogRef.value.handleShow();
- }
- // 退出按钮
- const exitBtn = () => {
- if (loginFlag.value) {
- logout().then(res => {
- toast('退出登录成功')
- cacheManager.clearAll();
- uni.reLaunch({
- url: '/pages/login/index'
- });
- }).catch(err => {
- toast('退出登录失败,请稍后重试')
- })
- } else {
- uni.reLaunch({
- url: '/pages/login/index'
- });
- }
- }
- const zhuxiaoBtn = () => {
- let req = {
- }
- zhuxiao().then(res => {
- cacheManager.clearAll();
- toast('用户注销成功')
- uni.redirectTo({
- url: '/pages/login/index'
- });
- }).catch(err => {
- toast('失败,请稍后重试')
- })
- }
- function yonghuzhuxiao() {
- zhuxiaoDialogRef.value.handleShow();
- }
- function duihuamaDuihuan() {
- duihuanmaDialogRef.value.handleShow();
- }
- function duihuanmaBtn(data) {
- console.log('data', data);
- let req = {
- code: data
- }
- duihuanmaCode(req).then(res => {
- toast('兑换成功')
- cacheManager.updateVipStatus('auth', res.data)
- uni.redirectTo({
- url: '/pages/my/index'
- })
- }).catch(err => {
-
- })
- }
- function yinsizhengce() {
- agreeType.value = 'ystk'
- agreeContentDialogRef.value.handleShow();
- }
- // 游客弹窗---确定
- function ykConfirm() {
- uni.redirectTo({
- url: '/pages/login/index'
- });
- }
- // 手机号码
- function telClick() {
- if (loginFlag.value) {
- telDialogFlag.value = true;
- } else {
- youkeDialogRef.value.handleShow();
- }
- }
- // 手机号码绑定
- function bindBtn() {
- telDialogFlag.value = false;
- myGetAuth()
- }
- // 关闭手机号码弹窗
- function telClose() {
- telDialogFlag.value = false;
- }
- // 关于我们
- function aboutClick() {
- if (loginFlag.value) {
- uni.redirectTo({
- url: '/pages/my/aboutPage'
- });
- } else {
- uni.redirectTo({
- url: `/pages/my/aboutPage?nianji=${routerOpt.nianji}&cardId=${routerOpt.cardId}&zhangId=${routerOpt.zhangId}&tipFlag=${routerOpt.tipFlag}`
- });
- }
- }
- // 订单
- function orderClick() {
- if (loginFlag.value) {
- uni.redirectTo({
- url: '/pages/pay/order'
- });
- } else {
- youkeDialogRef.value.handleShow();
- }
- }
- // 获取用户数据
- function getMyInfo() {
- myInfo({}).then(res => {
- getUserImg(res.data.growthType)
- myInfoData.userName = res.data.userName;
- myInfoData.credit = res.data.credit;
- })
- }
- // 获取用户头像
- function getUserImg(data) {
- switch (data) {
- case 0:
- myInfoData.userImg = 'static/images/my/head-img0.png'
- break;
- case 1:
- myInfoData.userImg = 'static/images/my/head-img1.png'
- break;
- case 2:
- myInfoData.userImg = 'static/images/my/head-img2.png'
- break;
- case 3:
- myInfoData.userImg = 'static/images/my/head-img3.png'
- break;
- default:
- myInfoData.userImg = 'static/images/my/head-unlogin-img.png'
- break;
- }
- }
- // 会员权益按钮
- function hyqyBtn(index) {
- let cardId = index + 1;
- /* index为学科 1数学 2英语 */
- if (loginFlag.value) {
- // 非游客
- uni.redirectTo({
- url: `/pages/pay/svip?cardId=${cardId}&formPage=my`
- })
- } else {
- // 游客
- youkeDialogRef.value.handleShow();
- }
- }
- // 判断是否是游客
- function myGetAuth() {
- let LocalStorage = cacheManager.get('auth');
- if (LocalStorage) {
- // 非游客
- noYoukeFun()
- } else {
- youkeFun();
- }
- }
- // 游客
- function youkeFun() {
- zhangId.value = routerOpt.zhangId
- nianji.value = routerOpt.nianji
- cardId.value = routerOpt.cardId
- tipFlag.value = routerOpt.tipFlag
- // my游客
- loginFlag.value = false;
- myInfoData.userName = '游客';
- myInfoData.userImg = 'static/images/my/head-unlogin-img.png'
- }
- // 非游客
- function noYoukeFun() {
- loginFlag.value = true;
- getMyInfo();
- }
- // 获取会员权益card class
- function getHyqyClass(index) {
- let VipIndex = index + 1;
- if (cacheManager.get('auth')) {
- // 非游客
- let VipArr = cacheManager.get('auth').cardList;
- if (VipArr.includes(VipIndex)) {
- return 'hyqy-box' + VipIndex;
- } else {
- return 'hyqy-disabled-box' + VipIndex;
- }
- } else {
- // 游客
- return 'yk-disabled-box';
- }
- }
- //获取会员权益按钮是否显示
- function getHyqyBtn(index) {
- let VipIndex = index + 1;
- if (cacheManager.get('auth')) {
- let VipArr = cacheManager.get('auth').cardList;
- if (VipArr.includes(VipIndex)) {
- return false;
- } else {
- return true;
- }
- } else {
- // 游客
- return false;
- }
- }
- function isIOSorAndroid(){
- const systemInfo = uni.getSystemInfoSync();
-
- console.log('systemInfo', systemInfo);
-
- if (systemInfo.platform == 'ios') {
- return currentPlatform.value = 'ios'
- } else {
- return currentPlatform.value = 'android'
- }
- }
-
- onLoad((options) => {
- if (!cacheManager.get('auth')) {
- // 游客
- routerOpt = options;
- } else {
- appleCode.value = cacheManager.get("auth").appleCode
- isIOSorAndroid()
- }
- })
-
- function checkWrong() {
- if (loginFlag.value) {
- const AuthCode = getUserIdentity();
- if (AuthCode == 'Visitor') {
- youkeDialogRef.value.handleShow();
- return;
- }
- uni.redirectTo({
- url: '/pages/wrong/index'
- })
- } else {
- youkeDialogRef.value.handleShow();
- }
- }
- </script>
|