index.uvue 3.4 KB
Newer Older
DCloud_JSON's avatar
init  
DCloud_JSON 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14
<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>
DCloud_JSON's avatar
DCloud_JSON 已提交
15 16 17 18 19 20 21 22 23 24
			<view class="list-item" @click="toLogin('username')">
				<text class="list-item-text">账号密码登录</text>
				<uni-id-pages-x-icons type="right-arrow" color="#999" />
			</view>
      <!-- #ifdef uniVersion > 3.99 || uniVersion == 3.99 -->
      <view class="list-item" @click="toLogin('univerify')" v-if="hasUniverify">
      	<text class="list-item-text">一键登录</text>
      	<uni-id-pages-x-icons type="right-arrow" color="#999" />
      </view>
      <!-- #endif -->
DCloud_JSON's avatar
init  
DCloud_JSON 已提交
25 26 27 28 29
		</view>
	</view>
</template>

<script>
DCloud_JSON's avatar
DCloud_JSON 已提交
30 31 32
	import { state } from '@/uni_modules/uni-id-pages-x/store.uts';
  // 导入配置
  import config from '@/uni_modules/uni-id-pages-x/config.uts'
DCloud_JSON's avatar
init  
DCloud_JSON 已提交
33 34
	export default {
		computed: {
DCloud_JSON's avatar
DCloud_JSON 已提交
35
			userInfo() : UTSJSONObject {
DCloud_JSON's avatar
init  
DCloud_JSON 已提交
36 37 38 39 40 41 42
				return state.userInfo
			},
      isLogin() : boolean {
      	return state.isLogin
      },
      openName():string{
        if(this.isLogin){
雪洛's avatar
雪洛 已提交
43 44 45
          let nickname = this.userInfo.getString("nickname")
          let username = this.userInfo.getString("username")
          let mobile = this.userInfo.getString("mobile")
DCloud_JSON's avatar
DCloud_JSON 已提交
46

DCloud_JSON's avatar
DCloud_JSON 已提交
47 48 49 50 51 52
          if(nickname == null){
            nickname = "";
          }
          if(username == null){
            username = "";
          }
DCloud_JSON's avatar
DCloud_JSON 已提交
53 54 55 56
          if(mobile == null){
            mobile = "";
          }

DCloud_JSON's avatar
init  
DCloud_JSON 已提交
57 58
          if(nickname.length != 0){
            return nickname
DCloud_JSON's avatar
DCloud_JSON 已提交
59
          }else if(username.length != 0){
DCloud_JSON's avatar
DCloud_JSON 已提交
60
            return username
DCloud_JSON's avatar
DCloud_JSON 已提交
61 62
          }else {
            return mobile
DCloud_JSON's avatar
init  
DCloud_JSON 已提交
63 64 65 66
          }
        }else{
          return '未登录'
        }
DCloud_JSON's avatar
DCloud_JSON 已提交
67 68 69 70 71 72 73
      },
      hasUniverify():boolean{
        const loginTypes = config.getArray<string>('loginTypes')
        if(loginTypes != null){
          return loginTypes.includes('univerify');
        }
        return false
DCloud_JSON's avatar
init  
DCloud_JSON 已提交
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 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
      }
		},
		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 {
	}
DCloud_JSON's avatar
DCloud_JSON 已提交
141
</style>