Browse Source

路径调整

wangxy 5 days ago
parent
commit
0c53fde282
1 changed files with 102 additions and 7 deletions
  1. 102 7
      pages/chanpinMy/my.vue

+ 102 - 7
pages/chanpinMy/my.vue

@@ -23,14 +23,29 @@
 					<icon class="list-icon yysz-icon"></icon>
 					<text>应用设置</text>
 				</view>
+				<view v-if="appleCode=='true'&&currentPlatform=='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" />
+		<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,
@@ -39,7 +54,7 @@
 		commonCardList
 	} from '@/api/my.js'
 	import CustomTabBar from '@/components/custom-tabbar/index.vue';
-	
+	import loginComp from "@/components/loginComp/index.vue"
 	import {
 		onLoad,
 		onShow
@@ -48,8 +63,11 @@
 		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: '',
@@ -63,18 +81,20 @@
 	onShow(() => {
 		currentTabIndex.value = 3
 	})
-	/***************** 测试 ******************/ 
+	/***************** 测试 ******************/
 	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;
+			appleCode.value = res.data.appleCode.toString()
 			if (res.data.nickName) {
 				myInfoData.nickName = res.data.nickName;
 			} else {
@@ -109,15 +129,90 @@
 
 		}
 	}
-	
+
 	function yingyongshezhi() {
 		uni.navigateTo({
 			url: '/pages/chanpinMy/myInfo'
 		})
 	}
 
+	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>