Selaa lähdekoodia

我的页面+修改手机号弹窗

tanxue 6 kuukautta sitten
vanhempi
commit
f7d4552520
4 muutettua tiedostoa jossa 66 lisäystä ja 44 poistoa
  1. 1 1
      api/login.js
  2. 2 2
      common/styles/global/pages.scss
  3. 50 28
      pages/my/index.vue
  4. 13 13
      pages/my/telDialog.vue

+ 1 - 1
api/login.js

@@ -23,7 +23,7 @@ export function login(data = {}) {
 }
 export function logout(data = {}) {
   return request({
-    'url': '/app/user/logout',
+    'url': '/app/user/my/logout',
     headers: {
       isToken: false
     },

+ 2 - 2
common/styles/global/pages.scss

@@ -585,7 +585,7 @@
 			background-image: url("@/static/images/my/list-jt.png");
 			position: absolute;right: 20rpx;
 		}
-		.list-row:last-child::after{display: none;}
+		.no-jt::after,.no-jt::after{display: none;}
 		.list-icon{width: 42rpx;height: 42rpx;@include ezy-no-repeat-cover;margin-right: 10rpx;}
 		.tel-icon{background-image: url("@/static/images/my/list-icon1.png");}
 		.error-icon{background-image: url("@/static/images/my/list-icon2.png");}
@@ -683,7 +683,7 @@
 	// 滑块
 	.nc-container{
 		position: unset;padding: 24rpx 0 36rpx;box-sizing: border-box;
-		#nc_1_wrapper{width: 100%;}
+		.nc_wrapper{width: 100%!important;}
 		.nc_iconfont.btn_ok{font-family: unset;font-size: 0;}
 		.nc_iconfont.btn_ok::before{content: '';width: 20px;height:20px;display: block;position: absolute;top: 50%;left: 50%;transform: translate(-50%,-50%);
 		@include ezy-no-repeat-cover;background-image: url("@/static/images/login/slider-right-icon.png");z-index: 4;}

+ 50 - 28
pages/my/index.vue

@@ -14,34 +14,35 @@
 			<view class="hyqy-btn" @click="hyqyBtn" v-if="!myInfoData.vipFlag"></view>
 		</view>
 		<view class="my-list-box">
-			<view class="list-row" @click="telClick">
+			<view class="list-row" @click="telClick" v-if="loginFlag">
 				<icon class="list-icon tel-icon"></icon>
 				<text>手机号码</text>
 			</view>
-			<view class="list-row" @click="checkWrong">
+			<view class="list-row" @click="checkWrong" v-if="loginFlag">
 				<icon class="list-icon error-icon"></icon>
 				<text>我的错题</text>
 			</view>
-			<view class="list-row" @click="orderClick">
+			<view class="list-row" @click="orderClick" v-if="loginFlag">
 				<icon class="list-icon order-icon"></icon>
 				<text>我的订单</text>
 			</view>
-			<view class="list-row" @click="aboutClick">
+			<view class="list-row no-jt" @click="aboutClick">
 				<icon class="list-icon about-icon"></icon>
 				<text>关于我们</text>
 			</view>
-			<view class="list-row" @click="exitLogin">
+			<view class="list-row no-jt" @click="exitLogin">
 				<icon class="list-icon login-out-icon"></icon>
 				<text>退出登录</text>
 			</view>
 		</view>
 		<CustomTabBar :cardId="cardId" :nianji="nianji" :zhangId="zhangId"></CustomTabBar>
 		<tip-small-dialog ref="exitDialogRef" @confirm-btn="exitBtn" :content="tipContent"></tip-small-dialog>
-		<tel-dialog @telClose="telClose" v-if="telDialogFlag"></tel-dialog>
+		<tel-dialog @telClose="telClose" @bindBtn="bindBtn" v-if="telDialogFlag"></tel-dialog>
 	</view>
 </template>
 
 <script setup>
+	import {toast,getUserIdentity} from "@/utils/common";
 	import cacheManager from '@/utils/cacheManager.js';
 	import {logout} from '@/api/login.js'
 	import {myInfo} from '@/api/my.js'
@@ -49,7 +50,6 @@
 	import {getCurrentInstance} from 'vue';
 	import {onLoad} from '@dcloudio/uni-app';
 	import {reactive,ref} from "vue";
-	import { toast } from "../../utils/common";
 	import tipSmallDialog from '@/components/dialog/tipSmallDialog.vue';
 	import telDialog from './telDialog.vue'
 	import {MESSAGE_VISITER_TO_LOGIN} from "@/utils/constant.js"
@@ -66,6 +66,7 @@
 		credit: '',
 		vipFlag: '',
 	});
+	let routerOpt  = ref(false);
 	const exitDialogRef = ref(null);
 	
 	const exitLogin = () => {
@@ -73,22 +74,29 @@
 	}
 
 	const exitBtn = () => {
-		cacheManager.clearAll();
-		uni.redirectTo({
-			url: '/pages/login/index'
-		});
+		logout().then(res => {
+			cacheManager.clearAll();
+			uni.redirectTo({
+				url: '/pages/login/index'
+			});
+		}).catch(err => {
+			toast('退出登录失败,请稍后重试')
+		})
+		
 	}
 	
 	// 手机号码
 	function telClick(){
-		console.log('telClick');
 		telDialogFlag.value = true;
-		console.log(telDialogFlag.value,'telDialogFlag.value');
+	}
+	
+	// 手机号码绑定
+	function bindBtn(){
+		myGetAuth()
 	}
 	
 	// 关闭手机号码弹窗
 	function telClose(){
-		console.log('telClose');
 		telDialogFlag.value = false;
 	}
 	
@@ -156,24 +164,38 @@
 		let LocalStorage = cacheManager.get('auth');
 		if (LocalStorage) {
 			// 非游客
-			loginFlag.value = true;
-			getMyInfo();
+			noYoukeFun()
+		}else{
+			youkeFun();
 		}
 	}
 	
+	// 游客
+	function youkeFun(){
+		zhangId.value = routerOpt.zhangId
+		nianji.value = routerOpt.nianji
+		cardId.value = routerOpt.cardId
+		// my游客
+		loginFlag.value = false;
+		myInfoData.userName = '游客';
+		myInfoData.userImg = 'static/images/my/head-unlogin-img.png'
+	}
+	
+	// 非游客
+	function noYoukeFun(){
+		loginFlag.value = true;
+		getMyInfo();
+	}
+	
 	onLoad((options) => {
-		if(options){
-					zhangId.value = options.zhangId
-					nianji.value = options.nianji
-					cardId.value = options.cardId
-					// my游客
-					loginFlag.value = false;
-					myInfoData.userName = '游客';
-					myInfoData.userImg = 'static/images/my/head-unlogin-img.png'
-				}else{
-					myGetAuth();
-				}
-		// console.log(instance.appContext.config.globalProperties,'instance.appContext.config.globalProperties')
+		if(!cacheManager.get('auth')){
+			// 游客
+			routerOpt = options;
+			youkeFun();
+		}else{
+			// 非游客
+			noYoukeFun();
+		}
 	})
 
   function checkWrong() {

+ 13 - 13
pages/my/telDialog.vue

@@ -68,6 +68,7 @@
 				this.bindObj.telNumber = '';
 				this.bindObj.isDisabled = true;
 				this.bindObj.clearTelIcon = false;
+				this.bindObj.getYzmFlag = false;
 			},
 			
 			// 判断是否输入手机号
@@ -115,7 +116,7 @@
 					token: this.sliderObj.token,
 				}
 				sendCode(req).then(res => {
-				
+					this.bindObj.getYzmFlag = true;
 				}).catch(err => {
 					toast('验证码获取失败:'+ err)
 				})
@@ -167,13 +168,6 @@
 			
 			// 绑定按钮
 			bindBtn(){
-				cacheManager.updateArrayInObject('userName', 'hobbies', (hobbies) => {
-					hobbies.push('123');
-					hobbies = 'coding';
-					hobbies.pop();
-				});
-				// cacheManager.updateObject('userName','123');
-				/* console.log(this.bindObj.telNumber,'this.bindObj.telNumber');
 				if(this.bindObj.telNumber===''){
 					toast('手机号不能为空')
 					return;
@@ -190,12 +184,19 @@
 				telBind(req).then(res => {
 					if (res.code == 0) {
 						toast('手机号绑定成功')
-						telClose(); 
+						this.updataTel(this.bindObj.telNumber);
+						this.telClose();
+						this.$emit('bindBtn')
 					}
-				}).catch(err => {
-					toast('手机号绑定失败:'+ err)
-				}) */
+				})
 			},
+			
+			// 在缓存中修改手机号
+			updataTel(data){
+				cacheManager.updateObject('auth', {
+					userName: data
+				})
+			}
 		}
 	}
 </script>
@@ -256,7 +257,6 @@
 				this.sig = '';
 				this.token = '';
 				this.nc.reset();
-				console.log(this.nc.reset(),'nc');
 			},
 			getSliderData(e, ownerInstance) {
 				if(this.sessionId){