wangxy преди 12 часа
родител
ревизия
c5c852969d

+ 35 - 0
pages/chanpinMy/components/duihuanma/duihuanError.vue

@@ -0,0 +1,35 @@
+<template>
+	<uni-popup ref="dlRef" :animation="true" :is-mask-click="false" mask-background-color="rgba(255, 255, 255, 0.6);">
+		<view>兑换无效,请重新输入</view>
+		<view @click="handleConfirm">确认</view>
+	</uni-popup>
+</template>
+
+<script setup>
+import {ref} from "vue"
+
+const dlRef = ref(null);
+
+const emits =defineEmits(['confirm'])
+
+function handleConfirm() {
+	emits('confirm')
+}
+
+function handleShow() {
+	dlRef.value.open('center')
+}
+
+function handleClose() {
+	dlRef.value.close();
+}
+
+defineExpose({
+	handleShow
+})
+
+</script>
+
+<style scoped>
+
+</style>

+ 35 - 0
pages/chanpinMy/components/duihuanma/duihuanSuccess.vue

@@ -0,0 +1,35 @@
+<template>
+	<uni-popup ref="dlRef" :animation="true" :is-mask-click="false" mask-background-color="rgba(255, 255, 255, 0.6);">
+		<view>兑换成功</view>
+		<view @click="handleConfirm">确认</view>
+	</uni-popup>
+</template>
+
+<script setup>
+import {ref} from "vue"
+
+const dlRef = ref(null);
+
+const emits =defineEmits(['confirm'])
+
+function handleConfirm() {
+	emits('confirm')
+}
+
+function handleShow() {
+	dlRef.value.open('center')
+}
+
+function handleClose() {
+	dlRef.value.close();
+}
+
+defineExpose({
+	handleShow
+})
+
+</script>
+
+<style scoped>
+
+</style>

+ 112 - 0
pages/chanpinMy/components/duihuanma/duihuanmaDialog.vue

@@ -0,0 +1,112 @@
+<!-- 小弹窗 一行文字 -->
+<template>
+  <uni-popup ref="tipSmallPopup" :animation="true" :is-mask-click="false"
+             mask-background-color="rgba(255, 255, 255, 0.6);">
+    <view class="icon-title-navBar-box">
+      <view @click="handleBack" class="nav-bar-icon"></view>
+      <text class="nav-bar-title">兑换码</text>
+    </view>
+    <view class="ezy-tip-dialog tip-small-dialog duihuan-dialog" style="height: 100vh">
+      <view class="tip-content-box">
+        <view class="icon-title-navBar-box">
+          <view class="nav-bar-title">{{ title }}</view>
+        </view>
+		<icon class="head-img-box" :style="{backgroundImage: 'url(' + icon + ')'}"></icon>
+        <view>{{ nickName }}</view>
+        <view>{{ userName }}</view>
+        <input class="duihuan-input" type="text" focus v-model="duihuamaValue" placeholder="请输入兑换码"/>
+        <view class="tip-btn-box">
+          <view class="confirm-btn" @click="confirmBtn"></view>
+        </view>
+      </view>
+    </view>
+  </uni-popup>
+  <!-- 失败 -->
+  <duihuanError ref="dhErrRef"></duihuanError>
+  <!-- 成功 -->
+  <duihuanSuccess ref="dhSucRef"></duihuanSuccess>
+</template>
+
+<script setup>
+import {ref} from 'vue';
+import duihuanError from "./duihuanError";
+import duihuanSuccess from "./duihuanSuccess";
+import {
+		duihuanmaCode,
+	} from '@/api/my.js'
+import cacheManager from '@/utils/cacheManager';
+
+const props = defineProps({
+  title: {
+    type: String,
+    default: '提示'
+  },
+  content: {
+    type: String,
+    require: true,
+    default: ''
+  },
+  userName: {
+    type: String,
+    default: ''
+  },
+  nickName: {
+    type: String,
+    default: ''
+  },
+  icon: {
+    type: String,
+  },
+});
+const tipSmallPopup = ref(null); // 索引
+const duihuamaValue = ref(''); // 索引
+const $emit = defineEmits(['confirm-btn'])
+const dhErrRef = ref(null);
+const dhSucRef = ref(null);
+
+
+function handleBack() {
+  handleClose();
+}
+
+// 打开弹窗
+function handleShow() {
+  tipSmallPopup.value.open('bottom');
+}
+
+// 取消
+function handleClose() {
+  duihuamaValue.value = ''
+  tipSmallPopup.value.close();
+}
+
+// 确认
+function confirmBtn() {
+	
+	let req = {
+		code: duihuamaValue.value
+	}
+	duihuanmaCode(req).then(res => {
+		if (res.code == 0) {
+			toast('兑换成功')
+
+			// 清空缓存
+			cacheManager.updateObject('auth', {})
+			
+			// 关窗清空
+			tipSmallPopup.value.close();
+			duihuamaValue.value = ''
+		} else {
+			toast('兑换失败请重试或联系管理员')
+			return false
+		}
+	})
+}
+
+defineExpose({
+  handleShow
+})
+</script>
+
+<style>
+</style>

+ 0 - 67
pages/chanpinMy/components/duihuanmaDialog.vue

@@ -1,67 +0,0 @@
-<!-- 小弹窗 一行文字 -->
-<template>
-	<uni-popup ref="tipSmallPopup" :animation="true" :is-mask-click="false"
-	 mask-background-color="rgba(255, 255, 255, 0.6);">
-	 <view class="ezy-tip-dialog tip-small-dialog duihuan-dialog"  style="height: 100vh">
-		<view class="tip-content-box">
-			<view class="icon-title-navBar-box">
-				<view class="nav-bar-title">{{title}}</view>
-		
-			</view>
-			<view>{{nickName}}</view>
-			<view>{{userName}}</view>
-				<input class="duihuan-input" type="text" focus v-model="duihuamaValue" placeholder="请输入兑换码" />
-				<view class="tip-btn-box">
-					<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: ''
-	  },
-	  userName: {
-		  type: String,
-		  default: ''
-	  },
-	  nickName: {
-		  type: String,
-		  default: ''
-	  },
-	});
-	const tipSmallPopup = ref(null); // 索引
-	const duihuamaValue = ref(''); // 索引
-	const $emit = defineEmits(['confirm-btn'])
-	// 打开弹窗
-	function handleShow() {
-		tipSmallPopup.value.open('bottom');
-	}
-	// 取消
-	function handleClose() {
-		duihuamaValue.value = ''
-		tipSmallPopup.value.close();
-	}
-	// 确认
-	function confirmBtn(){
-		$emit('confirm-btn',duihuamaValue.value);
-		tipSmallPopup.value.close();
-		duihuamaValue.value = ''
-	}
-	defineExpose({
-			handleShow
-		})
-</script>
-
-<style>
-</style>

+ 259 - 0
pages/chanpinMy/components/goLogin/goLogin.vue

@@ -0,0 +1,259 @@
+<template>
+	<uni-popup ref="dlRef" :animation="true" :is-mask-click="false" mask-background-color="rgba(255, 255, 255, 0.6);">
+		<!-- 返回 -->
+		<view class="icon-title-navBar-box">
+			<view @click="handleBack" class="nav-bar-icon"></view>
+			<text class="nav-bar-title">登录</text>
+		</view>
+		<!-- 用户名 -->
+		<view class="phone-input-box">
+			<view class="phone-prefix">+86</view>
+			<input class="phone-input" type="text" v-model="loginData.phoneNumber" placeholder="请输入手机号" maxlength="11"
+				@input="clearTelInput" />
+			<view class="close-btn" v-if="loginData.clearTelIcon" @click="clearTel"></view>
+		</view>
+
+		<!-- 隐私协议 -->
+		<view class="agreement-checkbox-box">
+			<checkbox-group @change="handleUpdateAgree">
+				<checkbox class="agreement-checkbox-input" color="#FFFFFF" value="agree" :checked="isAgreed" />
+			</checkbox-group>
+			<view class="agreement-text-box">
+				我已阅读并同意
+				<view class="agreement-text" @click="agreeBtn('yhxy')">《用户协议》</view>
+				和
+				<view @click="agreeBtn('ystk')" class="agreement-text">《隐私政策》</view>
+			</view>
+		</view>
+		<!-- 登录按钮 -->
+	</uni-popup>
+	<!-- 政策协议 -->
+	<agree-content-dialog ref="agreeContentDialogRef" :agreeType="agreeType"></agree-content-dialog>
+	<!-- 图形验证码 -->
+	<captcha ref="captcha" :config="config" @captchaSuccess="captchaSuccess" @captchaError="captchaError"
+		@captchaFail="captchaFail" @captchaReady="captchaReady" @captchaClose="captchaClose"></captcha>
+	<!-- 确认协议 -->
+	<agree-dialog ref="agreeDialogRef" @confirm-btn="confirmBtn"></agree-dialog>
+</template>
+
+<script setup>
+	import {
+		ref,
+		reactive
+	} from "vue"
+	import {
+		toast
+	} from "@/utils/common";
+	import {
+		login,
+		banbenImpinfo,sendCode
+	} from "@/api/login";
+	import cacheManager from "@/utils/cacheManager";
+
+	const emits = defineEmits(['success'])
+
+	const dlRef = ref(null)
+	const captcha = ref(null);
+	const agreeType = ref(null);
+	const agreeDialogRef = ref(null);
+	const agreeContentDialogRef = ref(null);
+
+	const isAgreed = ref(false);
+	const config = ref({
+		captchaId: "9d5837b0807b8de44da0de310a0b2813",
+	});
+
+	const loginData = reactive({
+		phoneNumber: null,
+		yzmNumber: null,
+		clearYzmIcon: false,
+		yzmStatus: 'login-btn-disabled',
+		timeLeft: 60, // 初始倒计时时间(秒)
+		intervalId: null, // 定时器ID
+		isDisabled: false, // 按钮是否禁用
+		buttonText: '', // 按钮文本
+	})
+
+	const sliderData = reactive({})
+
+	function showDl() {
+		dlRef.value.open('bottom');
+	}
+
+	function closeDl() {
+		loginData.phoneNumber = null;
+		loginData.yzmNumber = null;
+		loginData.clearYzmIcon = false;
+		loginData.yzmStatus = 'login-btn-disabled';
+		loginData.timeLeft = 60;
+		loginData.intervalId = null;
+		loginData.isDisabled = false;
+		loginData.buttonText = '';
+		config.value = null;
+		isAgreed.value = false;
+		dlRef.value.close();
+	}
+
+	// 返回
+	function handleBack() {
+		closeDl();
+	}
+
+	// 手机号校验规则
+	const validatePhoneNumber = (value) => {
+		const phoneRegex = /^1[3-9]\d{9}$/;
+		if (phoneRegex.test(value)) {
+			loginData.telStatus = 'login-btn-normal';
+		} else {
+			loginData.telStatus = 'login-btn-disabled';
+		}
+	}
+
+	function clearTelInput(event) {
+		if (event.detail.value.length > 0) {
+			loginData.clearTelIcon = true;
+			validatePhoneNumber(event.detail.value);
+		} else {
+			loginData.clearTelIcon = false;
+		}
+	}
+
+	function clearTel() {
+		loginData.phoneNumber = '';
+		loginData.telStatus = 'login-btn-disabled';
+		loginData.clearTelIcon = false;
+	}
+
+	// 登录
+	function handleLogin() {
+		// 用户名
+		if (!loginData.phoneNumber) {
+			toast('请输入手机号')
+			return;
+		}
+		// 协议
+		if (!isAgreed.value) {
+			agreeDialogRef.value.handleShow()
+			return;
+		}
+		let req = {
+			tel: loginData.phoneNumber,
+			code: loginData.yzmNumber,
+		}
+		login(req).then(res => {
+			if (res.code == 0) {
+				// 更新用户信息
+				cacheManager.set('auth', res.data)
+				setTimeout(() => {
+					banbenImpinfo({}).then(res => {
+						if (res.code == 0) {
+							cacheManager.updateObject("auth", {
+								banbenId: res.data.banbenId,
+								chanpinId: res.data.chanpinId,
+								danyuanId: res.data.danyuanId,
+								dengjiId: res.data.dengjiId,
+							})
+							// 更新学习信息 移除学习记录执通过后台更新记录
+							if (cacheManager.get('xuexi-shuxue')) {
+								cacheManager.remove("xuexi-shuxue")
+							}
+							// 关闭登录 返回支付
+							toast('登录成功')
+							// 返回支付
+							handleBack();
+							emits('success')
+						}
+					}).catch(() => {
+						toast('数据异常')
+						return false
+					})
+				})
+			}
+		})
+	}
+
+	// 更新协议
+	function handleUpdateAgree() {
+		isAgreed.value = !isAgreed.value
+	}
+
+	// 协议跳转
+	function agreeBtn(data) {
+		agreeType.value = data;
+		agreeContentDialogRef.value.handleShow();
+	}
+
+	function confirmBtn() {
+		isAgreed.value = true;
+		handleLogin();
+	}
+
+	// 图形验证码
+	function showCaptcha() {
+		captcha.value.showCaptcha();
+	}
+
+	function startCountdown() {
+		if (loginData.buttonText === '重新发送') {
+			showCaptcha();
+		}
+		loginData.isDisabled = true;
+		loginData.buttonText = `重新发送(${loginData.timeLeft}S)`;
+
+		// 清除之前的定时器(如果有)
+		if (loginData.intervalId) {
+			clearInterval(loginData.intervalId);
+			loginData.intervalId = null;
+		}
+
+		// 设置新的定时器
+		loginData.intervalId = setInterval(() => {
+			loginData.timeLeft--;
+			if (loginData.timeLeft <= 0) {
+				clearInterval(loginData.intervalId);
+				loginData.intervalId = null;
+				loginData.timeLeft = 60; // 重置倒计时
+				loginData.isDisabled = false;
+				loginData.buttonText = '重新发送';
+			} else {
+				loginData.buttonText = `重新发送(${loginData.timeLeft}S)`;
+			}
+		}, 1000);
+	}
+
+	function getYzmBtn() {
+		let req = {
+			phone: loginData.phoneNumber,
+			captchaOutput: sliderData.captcha_output,
+			genTime: sliderData.gen_time,
+			lotNumber: sliderData.lot_number,
+			passToken: sliderData.pass_token,
+		}
+		sendCode(req).then(res => {})
+	}
+
+	function captchaSuccess(result) {
+		startCountdown();
+		Object.assign(sliderData, result)
+		getYzmBtn();
+	}
+
+	function captchaError(e) {
+		toast(JSON.stringify(e))
+	}
+
+	function captchaFail() {
+		toast('验证失败!')
+	}
+
+	function captchaReady() {}
+
+	function captchaClose() {}
+
+	defineExpose({
+		showDl
+	})
+</script>
+
+<style>
+</style>

+ 11 - 52
pages/chanpinMy/my.vue

@@ -33,14 +33,15 @@
 					<text>兑换码</text>
 					<text>兑换码</text>
 				</view>
 				</view>
 
 
-				<view class="list-item" @click="test">
+<!--				<view class="list-item" @click="test">
 					<icon class="list-icon yysz-icon"></icon>
 					<icon class="list-icon yysz-icon"></icon>
 					<text>test</text>
 					<text>test</text>
-				</view>
+				</view>-->
 			</view>
 			</view>
 		</view>
 		</view>
 
 
-		<duihuanmaDialog ref="duihuanmaDialogRef" @confirm-btn="duihuanmaBtn" title="兑换" :userName="myInfoData.userName" :nickName="myInfoData.nickName"></duihuanmaDialog>
+		<duihuanmaDialog ref="duihuanmaDialogRef" :icon="myInfoData.icon" title="兑换" :userName="myInfoData.userName" :nickName="myInfoData.nickName"></duihuanmaDialog>
+		
 		<loginComp ref="loginRef"></loginComp>
 		<loginComp ref="loginRef"></loginComp>
 		<!-- 底部 -->
 		<!-- 底部 -->
 		<custom-tab-bar :show="true" :current-index="currentTabIndex" />
 		<custom-tab-bar :show="true" :current-index="currentTabIndex" />
@@ -48,8 +49,8 @@
 </template>
 </template>
 
 
 <script setup>
 <script setup>
-	import duihuanmaDialog from "./components/duihuanmaDialog.vue"
-	import cacheManager from '../../utils/cacheManager';
+	import duihuanmaDialog from "./components/duihuanma/duihuanmaDialog.vue"
+	import cacheManager from '@/utils/cacheManager';
 	import {
 	import {
 		myInfo,
 		myInfo,
 		zhuxiao,
 		zhuxiao,
@@ -155,55 +156,13 @@
 
 
 	function duihuamaDuihuan() {
 	function duihuamaDuihuan() {
 		// 兑换码兑换策略
 		// 兑换码兑换策略
-		if (currentPlatform.value == 'ios') {
-			// ios
-			if (authInfo.value.youke) {
-				// 非登录
-
-
-
-			} else {
-				// 已登录
-				duihuanmaDialogRef.value.handleShow();
-			}
+		if (authInfo.value.youke) {
+			// 非登录 -- 登录
+			
 		} else {
 		} else {
-			// android
-			if (authInfo.value.youke) {
-				// 非登录 -> 去登录
-
-
-
-			} else {
-				// 已登录
-				duihuanmaDialogRef.value.handleShow();
-			}
-		}
-
-
-	}
-
-	function duihuanmaBtn() {
-		let req = {
-			code: data
+			// 已登录
+			duihuanmaDialogRef.value.handleShow();
 		}
 		}
-		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) => {
 	onLoad((options) => {