wangguoyu 2 meses atrás
pai
commit
596916a79b

+ 11 - 0
api/my.js

@@ -20,4 +20,15 @@ export function zhuxiao(data = {}) {
     data,
     timeout: 20000
   })
+}
+export function duihuanmaCode(data = {}) {
+  return request({
+    'url': '/app/user/my/code',
+    headers: {
+      isToken: true
+    },
+    method: 'post',
+    data,
+    timeout: 20000
+  })
 }

+ 1 - 0
common/styles/global/pages.scss

@@ -827,6 +827,7 @@
 		.login-out-icon{background-image: url("@/static/images/my/list-icon4.png");}
 		.about-icon{background-image: url("@/static/images/my/list-icon5.png");}
 		.zhuxiao-icon{background-image: url("@/static/images/my/list-icon6.png");}
+		.duihuanma-icon{background-image: url("@/static/images/my/list-icon8.png");}
 		.yszc-icon{background-image: url("@/static/images/my/list-icon7.png");}
 	}
 	@media (max-height: 736px) {

+ 55 - 0
components/dialog/duihuanmaDialog.vue

@@ -0,0 +1,55 @@
+<!-- 小弹窗 一行文字 -->
+<template>
+	<uni-popup ref="tipSmallPopup" :animation="false" :is-mask-click="false"
+	 mask-background-color="rgba(255, 255, 255, 0.6);">
+	 <view class="ezy-tip-dialog tip-small-dialog">
+		<view class="tip-content-box">
+			<view class="tip-title">{{title}}</view>
+				<input class="uni-input" focus v-model="duihuamaValue" placeholder="请输入兑换码" />
+			<view class="tip-btn-box">
+				<view class="not-confirm-btn" @click="handleClose"></view>
+				<view class="confirm-btn" @click="confirmBtn"></view>
+			</view>
+		</view>
+	 </view>
+	</uni-popup>
+</template>
+
+<script setup>
+	import { ref } from 'vue';
+	const props = defineProps({
+	  title: {
+	    type: String,
+	    default: '提示'
+	  },
+	  content: {
+	    type: String,
+		require: true,
+	    default: ''
+	  },
+	});
+	const tipSmallPopup = ref(null); // 索引
+	const duihuamaValue = ref(''); // 索引
+	const $emit = defineEmits(['confirm-btn'])
+	// 打开弹窗
+	function handleShow() {
+		tipSmallPopup.value.open();
+	}
+	// 取消
+	function handleClose() {
+		duihuamaValue.value = ''
+		tipSmallPopup.value.close();
+	}
+	// 确认
+	function confirmBtn(){
+		$emit('confirm-btn',duihuamaValue.value);
+		tipSmallPopup.value.close();
+		duihuamaValue.value = ''
+	}
+	defineExpose({
+			handleShow
+		})
+</script>
+
+<style>
+</style>

+ 153 - 106
pages/my/index.vue

@@ -6,15 +6,16 @@
 				<text>{{myInfoData.userName}}</text>
 				<view class="ezy-jf-box" v-if="loginFlag">
 					<icon class="jf-icon"></icon>
-					<text class="jf-text" >{{myInfoData.credit}}</text>
+					<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">
+			: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>
+				<view class="hyqy-btn" @click="hyqyBtn(index)" v-if="getHyqyBtn(index)"></view>
 			</swiper-item>
 		</swiper>
 		<view class="my-list-box">
@@ -26,7 +27,7 @@
 				<icon class="list-icon error-icon"></icon>
 				<text>我的错题</text>
 			</view>
-			<view  v-if="loginFlag" class="list-row" @click="orderClick">
+			<view v-if="loginFlag" class="list-row" @click="orderClick">
 				<icon class="list-icon order-icon"></icon>
 				<text>我的订单</text>
 			</view>
@@ -34,11 +35,15 @@
 				<icon class="list-icon about-icon"></icon>
 				<text>关于我们</text>
 			</view>
-			<view  v-if="loginFlag" class="list-row no-jt" @click="yonghuzhuxiao">
+			<view v-if="loginFlag" 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">
+			<view v-if="loginFlag" class="list-row no-jt" @click="yinsizhengce">
 				<icon class="list-icon yszc-icon"></icon>
 				<text>隐私政策</text>
 			</view>
@@ -47,10 +52,12 @@
 				<text>退出登录</text>
 			</view>
 		</view>
-		<CustomTabBar :cardId="cardId" :currentTabNumber="2" :nianji="nianji" :zhangId="zhangId" :tipFlag="tipFlag"></CustomTabBar>
+		<CustomTabBar :cardId="cardId" :currentTabNumber="2" :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="false"></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>
@@ -58,26 +65,45 @@
 
 <script setup>
 	import agreeContentDialog from '@/pages/login/agreeContentDialog.vue';
-	import {toast,getUserIdentity} from "@/utils/common";
+	import {
+		toast,
+		getUserIdentity
+	} from "@/utils/common";
 	import cacheManager from '@/utils/cacheManager.js';
-	import {logout} from '@/api/login.js'
-	import {myInfo,zhuxiao} from '@/api/my.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 {
+		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 {
+		MESSAGE_VISITER_TO_LOGIN
+	} from "@/utils/constant.js"
 	import {
 		onShow
 	} from '@dcloudio/uni-app';
 	onShow(() => {
-		if(!cacheManager.get('auth')){
+		if (!cacheManager.get('auth')) {
 			youkeFun();
-		}else{
+		} else {
 			// 非游客
 			noYoukeFun();
 		}
@@ -90,11 +116,12 @@
 	const tipFlag = ref(null); //游客使用
 	const tipContent = '你确定要执行这个操作吗?';
 	const zhuxiaoContent = '你确定要执行这个操作吗?';
+	const duihuanmaContent = '你确定要执行这个操作吗?';
 	let hyqyData = reactive({
-			indicatorDots: true,
-			autoplay: true,
-			interval: 10000,
-			duration: 500
+		indicatorDots: true,
+		autoplay: true,
+		interval: 10000,
+		duration: 500
 	});
 	let loginFlag = ref(false);
 	let telDialogFlag = ref(false);
@@ -104,10 +131,11 @@
 		credit: '',
 		vipFlag: '',
 	});
-	let routerOpt  = ref(false);
+	let routerOpt = ref(false);
 	const exitDialogRef = ref(null);
 	const youkeDialogRef = ref(null);
 	const zhuxiaoDialogRef = ref(null);
+	const duihuanmaDialogRef = ref(null);
 
 	const exitLogin = () => {
 		exitDialogRef.value.handleShow();
@@ -115,9 +143,9 @@
 
 	// 退出按钮
 	const exitBtn = () => {
-		if(loginFlag.value){
+		if (loginFlag.value) {
 			logout().then(res => {
-					toast('退出登录成功')
+				toast('退出登录成功')
 				cacheManager.clearAll();
 				uni.reLaunch({
 					url: '/pages/login/index'
@@ -125,74 +153,94 @@
 			}).catch(err => {
 				toast('退出登录失败,请稍后重试')
 			})
-		}else{
+		} else {
 			uni.reLaunch({
 				url: '/pages/login/index'
 			});
 		}
 
 	}
-	
+
 	const zhuxiaoBtn = () => {
 		let req = {
-		
+
 		}
-		zhuxiao().then(res=>{
+		zhuxiao().then(res => {
 			cacheManager.clearAll();
-				toast('用户注销成功')
+			toast('用户注销成功')
 			uni.redirectTo({
 				url: '/pages/login/index'
 			});
-		}).catch(err=>{
-				toast('失败,请稍后重试')
+		}).catch(err => {
+			toast('失败,请稍后重试')
 		})
 	}
-	
-	function yonghuzhuxiao(){
-			zhuxiaoDialogRef.value.handleShow();
+
+	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 => {
+			toast('失败,请稍后重试')
+		})
 	}
-	
-	function yinsizhengce(){
-			agreeType.value = 'ystk'
-			agreeContentDialogRef.value.handleShow();
+
+	function yinsizhengce() {
+		agreeType.value = 'ystk'
+		agreeContentDialogRef.value.handleShow();
 	}
-	
+
 	// 游客弹窗---确定
 
-	function ykConfirm(){
+	function ykConfirm() {
 		uni.redirectTo({
 			url: '/pages/login/index'
 		});
 	}
 
 	// 手机号码
-	function telClick(){
-		if(loginFlag.value){
+	function telClick() {
+		if (loginFlag.value) {
 			telDialogFlag.value = true;
-		}else{
+		} else {
 			youkeDialogRef.value.handleShow();
 		}
 
 	}
 
 	// 手机号码绑定
-	function bindBtn(){
+	function bindBtn() {
 		telDialogFlag.value = false;
 		myGetAuth()
 	}
 
 	// 关闭手机号码弹窗
-	function telClose(){
+	function telClose() {
 		telDialogFlag.value = false;
 	}
 
 	// 关于我们
-	function aboutClick(){
-		if(loginFlag.value){
+	function aboutClick() {
+		if (loginFlag.value) {
 			uni.redirectTo({
 				url: '/pages/my/aboutPage'
 			});
-		}else{
+		} else {
 			uni.redirectTo({
 				url: `/pages/my/aboutPage?nianji=${routerOpt.nianji}&cardId=${routerOpt.cardId}&zhangId=${routerOpt.zhangId}&tipFlag=${routerOpt.tipFlag}`
 			});
@@ -200,18 +248,18 @@
 	}
 
 	// 订单
-	function orderClick(){
-		if(loginFlag.value){
+	function orderClick() {
+		if (loginFlag.value) {
 			uni.redirectTo({
 				url: '/pages/pay/order'
 			});
-		}else{
+		} else {
 			youkeDialogRef.value.handleShow();
 		}
 	}
 
 	// 获取用户数据
-	function getMyInfo(){
+	function getMyInfo() {
 		myInfo({}).then(res => {
 			getUserImg(res.data.growthType)
 			myInfoData.userName = res.data.userName;
@@ -220,54 +268,54 @@
 	}
 
 	// 获取用户头像
-	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 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;
+	function hyqyBtn(index) {
+		let cardId = index + 1;
 		/* index为学科 1数学 2英语 */
-		if(loginFlag.value){
+		if (loginFlag.value) {
 			// 非游客
 			uni.redirectTo({
 				url: `/pages/pay/svip?cardId=${cardId}&formPage=my`
 			})
-		}else{
+		} else {
 			// 游客
 			youkeDialogRef.value.handleShow();
 		}
 	}
 
 	// 判断是否是游客
-	function myGetAuth(){
+	function myGetAuth() {
 		let LocalStorage = cacheManager.get('auth');
 		if (LocalStorage) {
 			// 非游客
 			noYoukeFun()
-		}else{
+		} else {
 			youkeFun();
 		}
 	}
 
 	// 游客
-	function youkeFun(){
+	function youkeFun() {
 		zhangId.value = routerOpt.zhangId
 		nianji.value = routerOpt.nianji
 		cardId.value = routerOpt.cardId
@@ -279,23 +327,23 @@
 	}
 
 	// 非游客
-	function noYoukeFun(){
+	function noYoukeFun() {
 		loginFlag.value = true;
 		getMyInfo();
 	}
 
 	// 获取会员权益card class
-	function getHyqyClass(index){
-		let VipIndex =index +1;
-		if(cacheManager.get('auth')){
+	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;
+				return 'hyqy-box' + VipIndex;
+			} else {
+				return 'hyqy-disabled-box' + VipIndex;
 			}
-		}else{
+		} else {
 			// 游客
 			return 'yk-disabled-box';
 		}
@@ -303,41 +351,40 @@
 	}
 
 	//获取会员权益按钮是否显示
-	function getHyqyBtn(index){
-		let VipIndex =index +1;
-		if(cacheManager.get('auth')){
+	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;
+			} else {
+				return true;
+			}
+		} else {
 			// 游客
 			return false;
 		}
 	}
 
 	onLoad((options) => {
-		if(!cacheManager.get('auth')){
+		if (!cacheManager.get('auth')) {
 			// 游客
 			routerOpt = options;
-		}else{
-		}
+		} else {}
 	})
 
-  function checkWrong() {
-	if(loginFlag.value){
-		const AuthCode = getUserIdentity();
-		if (AuthCode == 'Visitor') {
+	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();
-			return;
 		}
-		uni.redirectTo({
-		  url: '/pages/wrong/index'
-		})
-	}else{
-		youkeDialogRef.value.handleShow();
 	}
-  }
-</script>
+</script>

BIN
static/images/my/list-icon8.png


+ 5 - 5
unpackage/dist/cache/.vite/deps/_metadata.json

@@ -1,19 +1,19 @@
 {
-  "hash": "2a404f3e",
-  "configHash": "088a760f",
+  "hash": "122c3a9d",
+  "configHash": "d5858f9f",
   "lockfileHash": "e3b0c442",
-  "browserHash": "02dde0a8",
+  "browserHash": "d8bf20c4",
   "optimized": {
     "uview-plus": {
       "src": "../../../../../node_modules/uview-plus/index.js",
       "file": "uview-plus.js",
-      "fileHash": "5d9e2b17",
+      "fileHash": "5da21bbe",
       "needsInterop": false
     },
     "ts-md5/dist/md5": {
       "src": "../../../../../node_modules/ts-md5/dist/md5.js",
       "file": "ts-md5_dist_md5.js",
-      "fileHash": "cec44cf6",
+      "fileHash": "674d644d",
       "needsInterop": true
     }
   },