Browse Source

Merge branch '2025鹅状元数学' of https://gogs.mtavip.com/wangguoyu/uniProject into 2025鹅状元数学

tanxue 1 month ago
parent
commit
2779f90852
4 changed files with 73 additions and 100 deletions
  1. 6 0
      pages/bindPhone/bindPhone.vue
  2. 27 37
      pages/chanpinMy/my.vue
  3. 39 62
      pages/chanpinMy/myInfo.vue
  4. 1 1
      pages/chanpinShop/usePay.js

+ 6 - 0
pages/bindPhone/bindPhone.vue

@@ -118,6 +118,8 @@
 		loginData.buttonText = '获取验证码';
 		loginData.buttonText = '获取验证码';
 		isAgreed.value = false;
 		isAgreed.value = false;
 		if (from.value = 'my') {
 		if (from.value = 'my') {
+
+
 			uni.switchTab({
 			uni.switchTab({
 				url: "/pages/chanpinMy/my"
 				url: "/pages/chanpinMy/my"
 			})
 			})
@@ -215,6 +217,10 @@
 				// 更新用户信息
 				// 更新用户信息
 				//	cacheManager.set('auth', res.data)
 				//	cacheManager.set('auth', res.data)
 				// 返回重新支付
 				// 返回重新支付
+				//绑定成功后更新缓存
+				cacheManager.updateObject('auth', {
+					userName: loginData.phoneNumber
+				})
 				handleBack();
 				handleBack();
 				toast("绑定成功")
 				toast("绑定成功")
 			}
 			}

+ 27 - 37
pages/chanpinMy/my.vue

@@ -27,11 +27,12 @@
 					<icon class="list-icon dd-icon"></icon>
 					<icon class="list-icon dd-icon"></icon>
 					<text>订单</text>
 					<text>订单</text>
 				</view>
 				</view>
-				<view v-if="appleCode=='true'&&currentPlatform=='ios' || currentPlatform=='android'" class="list-item" @click="duihuamaDuihuan">
+				<view v-if="appleCode=='true'&&currentPlatform=='ios' || currentPlatform=='android'" class="list-item"
+					@click="duihuamaDuihuan">
 					<icon class="list-icon dhm-icon"></icon>
 					<icon class="list-icon dhm-icon"></icon>
 					<text>兑换码</text>
 					<text>兑换码</text>
 				</view>
 				</view>
-				<view class="list-item" @click="bangPhone">
+				<view class="list-item" v-if="isShowBindPhone" @click="bangPhone">
 					<icon class="list-icon bdsjh-icon"></icon>
 					<icon class="list-icon bdsjh-icon"></icon>
 					<text>绑定手机号</text>
 					<text>绑定手机号</text>
 				</view>
 				</view>
@@ -79,6 +80,7 @@
 	let authInfo = ref(null);
 	let authInfo = ref(null);
 	let loginRef = ref(null);
 	let loginRef = ref(null);
 	let currentTabIndex = ref(3)
 	let currentTabIndex = ref(3)
+	let isShowBindPhone = ref(false);
 	let myInfoData = reactive({
 	let myInfoData = reactive({
 		userImg: '',
 		userImg: '',
 		userName: '',
 		userName: '',
@@ -90,10 +92,16 @@
 	let pageFrom = ref(null)
 	let pageFrom = ref(null)
 
 
 	onShow(() => {
 	onShow(() => {
+		console.log('pageFrom.value', pageFrom.value);
 		currentTabIndex.value = 3
 		currentTabIndex.value = 3
 		if (pageFrom.value === 'myInfo') {
 		if (pageFrom.value === 'myInfo') {
 			getMyInfo();
 			getMyInfo();
 		}
 		}
+		if (getUserIsYouke()) {
+			isShowBindPhone.value = true
+		} else {
+			isShowBindPhone.value = false
+		}
 	})
 	})
 	/***************** 测试 ******************/
 	/***************** 测试 ******************/
 	const testRef = ref(null)
 	const testRef = ref(null)
@@ -102,21 +110,17 @@
 		testRef.value.showPopup(7)
 		testRef.value.showPopup(7)
 	}
 	}
 	/***************** 测试 ******************/
 	/***************** 测试 ******************/
-	function bangPhone(){
+	function bangPhone() {
+		pageFrom.value = 'myInfo'
 		uni.navigateTo({
 		uni.navigateTo({
-			url: '/pages/bindPhone/bindPhone?from=my'   
+			url: '/pages/bindPhone/bindPhone?from=my'
 		})
 		})
 	}
 	}
 
 
-	function bingPhoneSuccess(flag, tel) {
-		toast("绑定成功")
-		cacheManager.updateObject('auth', {
-			userName: tel,
-		})
-	}
 	// 获取用户数据
 	// 获取用户数据
 	function getMyInfo() {
 	function getMyInfo() {
-		myInfo({}).then(res => {
+		return myInfo({}).then(res => {
+			console.log('res', res);
 			myInfoData.userName = res.data.userName;
 			myInfoData.userName = res.data.userName;
 			myInfoData.nickName = res.data.nickName;
 			myInfoData.nickName = res.data.nickName;
 			pageFrom.value = ''
 			pageFrom.value = ''
@@ -129,31 +133,14 @@
 			if (res.data.icon) {
 			if (res.data.icon) {
 				myInfoData.icon = res.data.icon;
 				myInfoData.icon = res.data.icon;
 			} else {
 			} else {
-				getUserImg(res.data.growthType)
+				getUserImg()
 			}
 			}
 		})
 		})
 	}
 	}
 
 
 	// 获取用户头像
 	// 获取用户头像
-	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 getUserImg() {
+		myInfoData.icon = 'static/images/my/head-img1.png'
 	}
 	}
 
 
 	function yingyongshezhi() {
 	function yingyongshezhi() {
@@ -184,11 +171,14 @@
 
 
 	function handleSuccess(authInfo) {
 	function handleSuccess(authInfo) {
 		// 登录成功更改用户名
 		// 登录成功更改用户名
-		myInfoData.userName = authInfo.userName;
-		// 前往兑换码
-		uni.navigateTo({
-			url: '/pages/chanpinMy/duihuanma'
-		})
+		// myInfoData.userName = authInfo.userName;
+		getMyInfo().then(() => {
+			// 前往兑换码
+			uni.navigateTo({
+				url: '/pages/chanpinMy/duihuanma'
+			})
+		});
+
 	}
 	}
 
 
 	onLoad((options) => {
 	onLoad((options) => {
@@ -218,4 +208,4 @@
 			url: '/pages/chanpinShop/index'
 			url: '/pages/chanpinShop/index'
 		})
 		})
 	}
 	}
-</script>
+</script>

+ 39 - 62
pages/chanpinMy/myInfo.vue

@@ -8,38 +8,34 @@
 			<view class="yysz-row-box">
 			<view class="yysz-row-box">
 				<view class="yysz-item img-item" @click="headClick">
 				<view class="yysz-item img-item" @click="headClick">
 					<text>头像</text>
 					<text>头像</text>
-					<icon class="yysz-img-box"
-						:style="{backgroundImage: 'url(' + myInfoData.icon + ')'}"></icon>
+					<icon class="yysz-img-box" :style="{backgroundImage: 'url(' + myInfoData.icon + ')'}"></icon>
 				</view>
 				</view>
-				<view class="yysz-item" @click="nichengClick">
-					<text>昵称</text>
-					<text class="item-text">{{myInfoData.nickName}}</text>
-				</view>
-			</view>	
-			<view class="yysz-row-box">
 				<view class="yysz-item" @click="telClick">
 				<view class="yysz-item" @click="telClick">
 					<text>手机号码</text>
 					<text>手机号码</text>
 					<text class="item-text">{{myInfoData.userName}}</text>
 					<text class="item-text">{{myInfoData.userName}}</text>
 				</view>
 				</view>
 			</view>
 			</view>
-			<view class="yysz-row-box">	
+			<view class="yysz-row-box">
+
+			</view>
+			<view class="yysz-row-box">
 				<view class="yysz-item border-item" @click="aboutClick">
 				<view class="yysz-item border-item" @click="aboutClick">
 					<text>关于我们</text>
 					<text>关于我们</text>
 				</view>
 				</view>
-				<view v-if="loginFlag" class="yysz-item border-item" @click="yinsizhengce">
+				<view class="yysz-item border-item" @click="yinsizhengce">
 					<text>隐私政策</text>
 					<text>隐私政策</text>
 				</view>
 				</view>
 				<view class="yysz-item border-item" @click="kefudianhua">
 				<view class="yysz-item border-item" @click="kefudianhua">
 					<text>客服与投诉</text>
 					<text>客服与投诉</text>
 					<text class="item-text">4001750778</text>
 					<text class="item-text">4001750778</text>
 				</view>
 				</view>
-				<view v-if="loginFlag" class="yysz-item border-item" @click="yonghuzhuxiao">
+				<view class="yysz-item border-item" @click="yonghuzhuxiao">
 					<text>用户注销</text>
 					<text>用户注销</text>
 				</view>
 				</view>
-				 <view class="yysz-item" @click="exitLogin">
+				<view class="yysz-item" @click="exitLogin">
 					<text>退出登录</text>
 					<text>退出登录</text>
 				</view>
 				</view>
-		</view>
+			</view>
 		</view>
 		</view>
 		<!-- <CustomTabBar  :currentTabNumber="3"> </CustomTabBar> -->
 		<!-- <CustomTabBar  :currentTabNumber="3"> </CustomTabBar> -->
 		<tip-small-dialog ref="exitDialogRef" @confirm-btn="exitBtn" :content="tipContent"></tip-small-dialog>
 		<tip-small-dialog ref="exitDialogRef" @confirm-btn="exitBtn" :content="tipContent"></tip-small-dialog>
@@ -56,6 +52,7 @@
 	import agreeContentDialog from '@/pages/login/agreeContentDialog.vue';
 	import agreeContentDialog from '@/pages/login/agreeContentDialog.vue';
 	import {
 	import {
 		toast,
 		toast,
+		getUserIsYouke
 	} from "@/utils/common";
 	} from "@/utils/common";
 	import cacheManager from '@/utils/cacheManager.js';
 	import cacheManager from '@/utils/cacheManager.js';
 	import {
 	import {
@@ -73,7 +70,8 @@
 	} from '@/api/my.js'
 	} from '@/api/my.js'
 	// import CustomTabBar from '@/components/custom-tabbar/custom-tabbar.vue';
 	// import CustomTabBar from '@/components/custom-tabbar/custom-tabbar.vue';
 	import {
 	import {
-		onLoad,onShow
+		onLoad,
+		onShow
 	} from '@dcloudio/uni-app';
 	} from '@dcloudio/uni-app';
 	import {
 	import {
 		reactive,
 		reactive,
@@ -85,16 +83,18 @@
 	import tipMiddleDialog from '@/components/dialog/tipMiddleDialog.vue';
 	import tipMiddleDialog from '@/components/dialog/tipMiddleDialog.vue';
 	import tipBigDialog from '@/components/dialog/tipBigDialog.vue';
 	import tipBigDialog from '@/components/dialog/tipBigDialog.vue';
 	import telDialog from './components/telDialog.vue'
 	import telDialog from './components/telDialog.vue'
-	
-	import { usePermission } from "@/store/permissionStore.js"
+
+	import {
+		usePermission
+	} from "@/store/permissionStore.js"
 	const permissionStore = usePermission()
 	const permissionStore = usePermission()
-	
+
 	const agreeType = ref(null);
 	const agreeType = ref(null);
 	const agreeContentDialogRef = ref(null);
 	const agreeContentDialogRef = ref(null);
 
 
 	const tipContent = '你确定要执行这个操作吗?';
 	const tipContent = '你确定要执行这个操作吗?';
 	const zhuxiaoContent = '你确定要执行这个操作吗?';
 	const zhuxiaoContent = '你确定要执行这个操作吗?';
-	let loginFlag = ref(false);
+	const isYouke = ref(false);
 	let telDialogFlag = ref(false);
 	let telDialogFlag = ref(false);
 	let myInfoData = reactive({
 	let myInfoData = reactive({
 		userImg: '',
 		userImg: '',
@@ -125,6 +125,10 @@
 	}
 	}
 
 
 	function headClick() {
 	function headClick() {
+		if (isYouke.value) {
+			return;
+		}
+		
 		chooseImage()
 		chooseImage()
 	}
 	}
 
 
@@ -138,14 +142,14 @@
 	}
 	}
 	const chooseImage = async () => {
 	const chooseImage = async () => {
 		try {
 		try {
-		//	await checkAlbumPermission()
+			//	await checkAlbumPermission()
 			/* #ifdef APP */
 			/* #ifdef APP */
 			const systemInfo = uni.getSystemInfoSync();
 			const systemInfo = uni.getSystemInfoSync();
 			if (systemInfo.platform != 'ios') {
 			if (systemInfo.platform != 'ios') {
 				if (!await permissionStore.requstPermission('READ_EXTERNAL_STORAGE')) return
 				if (!await permissionStore.requstPermission('READ_EXTERNAL_STORAGE')) return
 			}
 			}
 			/* #endif */
 			/* #endif */
-		
+
 			uni.chooseImage({
 			uni.chooseImage({
 				count: 1,
 				count: 1,
 				sizeType: ['compressed'],
 				sizeType: ['compressed'],
@@ -229,28 +233,17 @@
 		})
 		})
 
 
 	}
 	}
-
-	function nichengClick() {
-		nichengDialogRef.value.handleShow();
-	}
 	// 退出按钮
 	// 退出按钮
 	const exitBtn = () => {
 	const exitBtn = () => {
-		if (loginFlag.value) {
-			logout().then(res => {
-				toast('退出登录成功')
-				cacheManager.clearAll();
-				uni.reLaunch({
-					url: '/pages/login/index'
-				});
-			}).catch(err => {
-				toast('退出登录失败,请稍后重试')
-			})
-		} else {
+		logout().then(res => {
+			toast('退出登录成功')
+			cacheManager.clearAll();
 			uni.reLaunch({
 			uni.reLaunch({
 				url: '/pages/login/index'
 				url: '/pages/login/index'
 			});
 			});
-		}
-
+		}).catch(err => {
+			toast('退出登录失败,请稍后重试')
+		})
 	}
 	}
 	const zhuxiaoBtn = () => {
 	const zhuxiaoBtn = () => {
 		let req = {
 		let req = {
@@ -273,7 +266,7 @@
 
 
 	function nichengBtn(data) {
 	function nichengBtn(data) {
 		console.log('data', data);
 		console.log('data', data);
-		
+
 		let req = {
 		let req = {
 			nickName: data
 			nickName: data
 		}
 		}
@@ -307,12 +300,10 @@
 	}
 	}
 	// 手机号码
 	// 手机号码
 	function telClick() {
 	function telClick() {
-		if (loginFlag.value) {
-			telDialogFlag.value = true;
-		} else {
-			youkeDialogRef.value.handleShow();
+		if (isYouke.value) {
+			return;
 		}
 		}
-
+		telDialogFlag.value = true;
 	}
 	}
 	// 手机号码绑定
 	// 手机号码绑定
 	function bindBtn() {
 	function bindBtn() {
@@ -351,28 +342,14 @@
 	}
 	}
 
 
 	function getUserImg(data) {
 	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;
-
-		}
+		myInfoData.icon = 'static/images/my/head-img1.png'
 	}
 	}
 
 
 	onLoad((options) => {
 	onLoad((options) => {
-		loginFlag.value = true;
 		getMyInfo();
 		getMyInfo();
 	})
 	})
+
+	onShow(() => {
+		isYouke.value = getUserIsYouke()
+	})
 </script>
 </script>

+ 1 - 1
pages/chanpinShop/usePay.js

@@ -371,7 +371,7 @@ export function usePay(opt = {}) {
 		try {
 		try {
 			plus.payment.getChannels(
 			plus.payment.getChannels(
 				function(channels) {
 				function(channels) {
-					uni.hideLoading();
+				//	uni.hideLoading();
 					// 获取苹果内购通道,赋值给外层作用域的iapChannel
 					// 获取苹果内购通道,赋值给外层作用域的iapChannel
 					iapChannel = channels.find((item) => item.id == "appleiap");
 					iapChannel = channels.find((item) => item.id == "appleiap");
 					if (!iapChannel) {
 					if (!iapChannel) {