Explorar el Código

添加退出登录

achao hace 1 año
padre
commit
b929565994
Se han modificado 1 ficheros con 25 adiciones y 6 borrados
  1. 25 6
      uni_applet/pages/my/my.vue

+ 25 - 6
uni_applet/pages/my/my.vue

@@ -4,18 +4,19 @@
 			<view class='flex userWrap justify-space-between'>
 				<view class='flex'>
 					<view style='margin-right:20rpx;'>
-						<u--image width='60' height='60' :src="userInfo.head" shape="circle" @click="editHead"></u--image>
+						<u--image width='60' height='60' :src="userInfo.head" shape="circle"
+							@click="editHead"></u--image>
 					</view>
 					<view>
 						<view class='flex'>
 							<view @click='login' style="font-weight: bold;font-size: 32rpx;">
 								{{userInfo.nickname?userInfo.nickname:'请点击登录'}}
 							</view>
-						<!-- 	<view v-else>
+							<!-- 	<view v-else>
 								<u--input placeholder="请输入内容" border="bottom" v-model='userInfo.nickname'
 									clearable></u--input>
 							</view> -->
-						<!-- 	<u-icon v-if='!edit&&userInfo.phone' @click='edit = true' name="edit-pen-fill"
+							<!-- 	<u-icon v-if='!edit&&userInfo.phone' @click='edit = true' name="edit-pen-fill"
 								color="#eaad1a" size="24"></u-icon>
 							<u-icon v-if='edit&&userInfo.phone' @click='editNickName' name="checkbox-mark"
 								color="#eaad1a" size="24"></u-icon> -->
@@ -97,13 +98,16 @@
 				</u-cell-group>
 			</view>
 		</view>
+		<view class="exit" @click="exit" v-if="userInfo.phone">
+			退出账号
+		</view>
 		<login-pop-up ref='loginpopup' :content='"手机登录后才能查看我的哦~"'></login-pop-up>
 	</view>
 </template>
 
 <script>
 	var that;
-		import uploadImage from '@/components/ossutil/uploadFile.js';
+	import uploadImage from '@/components/ossutil/uploadFile.js';
 	import loginPopUp from "@/components/loginPopUp/index.vue"
 	export default {
 		components: {
@@ -123,10 +127,11 @@
 			that = this
 		},
 		onShow() {
-			if (!uni.getStorageSync("userInfo").phone) {
+			this.userInfo = uni.getStorageSync("userInfo")
+			if (!this.userInfo.phone) {
 				this.$refs.loginpopup.open()
 			} else {
-				this.userInfo = uni.getStorageSync("userInfo")
+
 				var reg = /1(\d{2})\d{4}(\d{4})/g;
 				this.userInfo.phone1 = this.userInfo.phone.replace(reg, "1$1****$2");
 				console.log(this.userInfo)
@@ -156,6 +161,11 @@
 					})
 				}
 			},
+			exit() {
+				uni.setStorageSync("userInfo", {})
+				this.userInfo = {}
+				this.$forceUpdate()
+			},
 			editHead() {
 				if (this.userInfo.phone) {
 					uni.chooseImage({
@@ -287,4 +297,13 @@
 	.left-btn:after {
 		border: none !important;
 	}
+
+	.exit {
+		width: 100vw;
+		background-color: #fff;
+		font-size: 30rpx;
+		margin-top: 20rpx;
+		text-align: center;
+		padding: 20rpx;
+	}
 </style>