职站学生端小程序版
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

102 lines
2.0 KiB

<template>
<view class="page">
<view class="tips">已为你展示{{ phone }}手机号关联的账号登录后可在切换账号列表快捷切换至其他账号</view>
<template v-if="accounts.length">
<ul class="list">
<li v-for="item in accounts">
<view class="left">
<image class="avatar" :src="item.userAvatars || require('@/static/image/avatar.png')" mode=""></image>
<view class="info">
<view class="name">{{ item.userName }}</view>
<view class="org">{{ item.schoolName }}</view>
</view>
</view>
<view class="btn" @click="login(item)">登录</view>
</li>
</ul>
</template>
</view>
</template>
<script>
import { weChatToken } from '@/apis/modules/user.js'
export default {
data() {
return {
openid: '',
phone: '',
accounts: JSON.parse(uni.getStorageSync('accounts')),
}
},
onShow() {
const pages = getCurrentPages()
const { options } = pages[pages.length - 1]
this.openid = options.openid
this.phone = options.phone
},
methods: {
// 登录
async login(item) {
const { data } = await weChatToken({
id: item.id,
openid: this.openid,
phone: this.phone,
platformId: 1,
})
uni.setStorageSync('token', data.token)
uni.switchTab({
url: '/pages/index/index'
})
}
}
}
</script>
<style scoped lang="scss">
.page {
padding: 30rpx;
}
.tips {
margin-bottom: 20rpx;
font-size: 24rpx;
color: #616161;
}
.list {
li {
display: flex;
justify-content: space-between;
align-items: center;
padding: 30rpx;
margin-bottom: 30rpx;
background-color: #fff;
border-radius: 8rpx;
}
.left {
display: inline-flex;
align-items: center;
}
.avatar {
width: 100rpx;
height: 100rpx;
margin-right: 30rpx;
border-radius: 50%;
}
.name {
margin-bottom: 6rpx;
font-size: 32rpx;
color: #333;
}
.org {
font-size: 28rpx;
color: #333;
}
.btn {
padding: 10rpx 36rpx;
font-size: 24rpx;
color: #fff;
background-color: #2979ff;
border-radius: 20px;
}
}
</style>