Browse Source

修改详情页面

wangxy 1 month ago
parent
commit
140af17ca4
2 changed files with 51 additions and 88 deletions
  1. 12 26
      pages/chanpinMy/my.vue
  2. 39 62
      pages/chanpinMy/myInfo.vue

+ 12 - 26
pages/chanpinMy/my.vue

@@ -119,7 +119,7 @@
 
 	// 获取用户数据
 	function getMyInfo() {
-		myInfo({}).then(res => {
+		return myInfo({}).then(res => {
 			console.log('res', res);
 			myInfoData.userName = res.data.userName;
 			myInfoData.nickName = res.data.nickName;
@@ -133,31 +133,14 @@
 			if (res.data.icon) {
 				myInfoData.icon = res.data.icon;
 			} 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() {
@@ -188,11 +171,14 @@
 
 	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) => {

+ 39 - 62
pages/chanpinMy/myInfo.vue

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