index.uvue 2.7 KB
Newer Older
DCloud_JSON's avatar
init  
DCloud_JSON 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
<template>
	<view class="content">
		<view class="userinfo" @click="toUserInfoPage">
      <uni-id-pages-x-avatar class="avatar" ref="avatar" width="45px" height="45px" :readOnly="true" :border="false"></uni-id-pages-x-avatar>
			<view class="openName">
				<text class="openName-text">{{openName}}</text>
			</view>
      <uni-id-pages-x-icons type="right-arrow" color="#999" />
		</view>
		<view class="list">
			<view class="list-item" hover-class="list-active" @click="toLogin('smsCode')">
				<text class="list-item-text">手机验证码登录</text>
				<uni-id-pages-x-icons type="right-arrow" color="#999" />
			</view>
			<view class="list-item" @click="toLogin('username')">
				<text class="list-item-text">账号密码登录</text>
				<uni-id-pages-x-icons type="right-arrow" color="#999" />
			</view>
		</view>
	</view>
</template>

<script>
	import { state } from '@/uni_modules/uni-id-pages-x/store.uts';
	export default {
		computed: {
			userInfo() : UTSJSONObject {
				return state.userInfo
			},
      isLogin() : boolean {
      	return state.isLogin
      },
      openName():string{
        if(this.isLogin){
DCloud_JSON's avatar
DCloud_JSON 已提交
35 36 37 38 39 40 41 42
          let nickname = userInfo.getString("nickname")
          let username = userInfo.getString("username")
          if(nickname == null){
            nickname = "";
          }
          if(username == null){
            username = "";
          }
DCloud_JSON's avatar
init  
DCloud_JSON 已提交
43 44 45
          if(nickname.length != 0){
            return nickname
          }else{
DCloud_JSON's avatar
DCloud_JSON 已提交
46
            return username
DCloud_JSON's avatar
init  
DCloud_JSON 已提交
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
          }
        }else{
          return '未登录'
        }
      }
		},
		data() {
			return {}
		},
		onLoad() {},
		methods: {
			toLogin(loginType:string) {
				uni.navigateTo({
					url: "/uni_modules/uni-id-pages-x/pages/login/login?type=" + loginType
				})
			},
			toUserInfoPage() {
				uni.navigateTo({
					url: "/uni_modules/uni-id-pages-x/pages/userinfo/userinfo?showLoginManage=true"
				})
			},
		}
	}
</script>

<style lang="scss">
	.content {
		height: 100%;
		background-color: #f5f5f5;
	}

	.userinfo {
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
		padding: 15px;
		// padding-bottom: 30px;
		background-color: #fff;

		.openName {
			flex: 1;
			padding: 0 10px;
			.openName-text {
				font-size: 14px;
				color: #333;
			}
		}
	}

	.list {
		background-color: #fff;
		margin-top: 15px;

		.list-item {
			display: flex;
			flex-direction: row;
			align-items: center;
			justify-content: space-between;
			padding: 0 15px;
			height: 50px;
			border-bottom: 1px #f5f5f5 solid;

			.list-item-text {
				font-size: 14px;
			}

		}
	}
	.arrow {
	}
</style>