123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281 |
- <template>
- <view class="content">
- <view class="banner">
- <div class="custom-nav">我的</div>
- <div class="user-container">
- <view class="avatar">
- <image v-if="userAvatar" class="photo" :src="userAvatar" mode="widthFix" @error="userAvatar=defaultAvatar"></image>
- <image v-else class="photo" :src="defaultAvatar" mode="widthFix"></image>
- </view>
- <view class="bottom">
- <view class="name">
- <text>{{userName}}</text>
- </view>
- <div class="phone">{{phone}}</div>
- </view>
- </div>
- </view>
- <view class="zhcx-table">
- <uni-list>
- <uni-list-item title="个人资料"
- link="navigateTo" rightText="修改"
- to="/pages/myCenter/personalData/personalData"
- showArrow></uni-list-item>
- <uni-list-item title="所属院校"
- :rightText="school"
- link="navigateTo"
- to="/pages/myCenter/personalData/personalData"
- showArrow></uni-list-item>
- <uni-list-item title="人脸录入" @click="faceRecording" clickable showArrow></uni-list-item>
- </uni-list>
- </view>
- <div class="logoutBt" @click="logout" v-if="isLogin">退出登录</div>
- <getPhone ref="getPhone" v-if="!isLogin" showByPlatform />
- <view class="faceRecord-box" v-if="cameraModel">
- <camera device-position="front" flash="off" @error="error" class="camera"></camera>
- <button class="takePhotoBt" type="primary" @click="takePhoto">抓拍</button>
- <view>预览</view>
- <image class="facePhoto" mode="widthFix" :src="faceSrc"></image>
- <div class="camera-submit" @click="cameraSubmit">提交</div>
- <div class="camera-submit cancel" @click="cameraCancel">取消</div>
- </view>
- </view>
- </template>
- <script>
- import {logout} from '@/api/user.js'
- import getPhone from '@/components/getPhone.vue'
- export default{
- data(){
- return{
- defaultAvatar:"/static/components/avatar.png",
- userAvatar:"",
- userName:"--",
- phone:"--",
- school:"--",
- faceSrc:"",
- cameraModel:false,
- isLogin:true
- }
- },
- components:{
- getPhone
- },
- onShow() {
- this.init();
- },
- methods:{
- initPhoneModal(){
- const accountName=uni.getStorageSync('phone')
- if(!accountName){
- this.isLogin=false
- this.$nextTick(()=>{
- this.$refs['getPhone'].isAuthorize=false
- })
- }else{
- this.isLogin=true
- }
- },
- init(){
- this.initPhoneModal()
- let user=uni.getStorageSync('accountInfo');
- if(user){
- user=JSON.parse(user)
- this.userAvatar=user.avatar||this.defaultAvatar;
- this.userName=user.name;
- }
- },
- faceRecording(){
- this.cameraModel=true;
- },
- takePhoto(){
- const ctx = uni.createCameraContext();
- ctx.takePhoto({
- quality: 'high',
- success: (res) => {
- this.faceSrc = res.tempImagePath
- }
- });
- },
- cameraSubmit(){
- this.cameraModel=false;
- this.faceSrc = "";
- },
- cameraCancel(){
- this.cameraModel=false;
- this.faceSrc = "";
- },
- logout(){
- uni.showModal({
- title:'提示!',
- content:"是否要退出登录",
- success(res) {
- if (res.confirm) {
- logout().then(()=>{
- uni.clearStorageSync()
- uni.switchTab({
- url:'/pages/index/index'
- })
- })
- }
- }
- })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .content{
- position: relative;
- .banner{
- height: 580upx;
- background-image: url('/static/center/bg.png');
- background-repeat: no-repeat;
- background-size: 100% 100%;
- position: relative;
- &::after{
- position: absolute;
- content: "";
- display: block;
- width: 440rpx;
- height: 632rpx;
- right: 0;
- top: 20px;
- background-image:url('/static/center/bgmask.png');
- background-repeat: no-repeat;
- background-size: 100% 100%;
- z-index: 1;
- }
- .custom-nav{
- position: fixed;
- text-align: center;
- top: 24px;
- left: var(--window-left);
- right: var(--window-right);
- height: 88rpx;
- line-height: 88rpx;
- z-index: 998;
- color: #333333;
- background-color: transparent;
- font-size: 32rpx;
- font-weight: 400;
- box-sizing: border-box;
- font-family: PingFang SC;
- }
- .user-container{
- &{
- display: flex;
- justify-content: flex-start;
- align-items: center;
- position: absolute;
- bottom: 190rpx;
- left: 40rpx;
- }
- .avatar{
- width: 120rpx;
- height: 120rpx;
- border-radius: 50%;
- display: block;
- overflow: hidden;
- background: rgba(255,255,255,0.39);
- border: 2rpx solid #707070;
- .photo{
- width: 120rpx;
- height: 120rpx;
- border-radius: 50%;
- }
- }
- .bottom{
- &{
- padding-left: 20rpx;
- }
- .name{
- font-size: 36rpx;
- font-family: PingFang SC;
- font-weight: bold;
- line-height: 50rpx;
- color: #FFFFFF;
- }
- .phone{
- font-size: 28rpx;
- font-family: PingFang SC;
- font-weight: 400;
- line-height: 40rpx;
- color: #FFFFFF;
- padding-top: 14rpx;
- }
- }
- }
- }
- .zhcx-table{
- width: 710rpx;
- position: absolute;
- left: 20rpx;
- top: 440rpx;
- background-color: #fff;
- z-index: 99;
- border-radius: 12px;
- overflow: hidden;
- }
- .logoutBt{
- width: 424rpx;
- height: 72rpx;
- line-height: 72rpx;
- text-align: center;
- position: fixed;
- bottom: 130rpx;
- left: 50%;
- transform: translateX(-50%);
- background:#3D90F4;
- border-radius: 42rpx;
- font-size: 32rpx;
- font-family: PingFang SC;
- font-weight: 400;
- color: #FFFFFF;
- z-index: 999;
- }
- .faceRecord-box{
- position: fixed;
- top: 0;
- bottom: 0;
- left: 0;
- right: 0;
- z-index: 9999;
- background-color: #fff;
- display: flex;
- justify-content: center;
- align-items: center;
- flex-direction: column;
- .camera,.facePhoto{
- width: 450rpx;
- height: 450rpx;
- border-radius: 50%;
- border:2rpx solid #eaeaea;
- }
- .takePhotoBt{
- display: inline-block;
- margin: 40rpx 0;
- }
- .camera-submit{
- width: 424rpx;
- height: 72rpx;
- line-height: 72rpx;
- text-align: center;
- background:#3D90F4;
- border-radius: 42rpx;
- font-size: 32rpx;
- font-family: PingFang SC;
- font-weight: 400;
- color: #FFFFFF;
- margin: 40rpx auto;
- &.cancel{
- color: #fff;
- background-color: #ED834A;
- border-color: #ED834A;
- margin: 0 auto 50rpx;
- }
- }
- }
- }
- </style>
|