洛阳学员端
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.
 
 
 
 
 

107 lines
2.5 KiB

<template>
<view class="pageBgImg">
<topNavbar title="上传头像"></topNavbar>
<view class="pad">
<view class="card">
<view class="h2">请上传或拍摄一张五官清晰的照片</view>
<view class="phone" @click="uploadTap" v-if="!avatar">
<view class="phoneIcon">
<image src="@/static/images/index/btn_tupian.png" mode=""></image>
</view>
<view class="lab">添加图片</view>
</view>
<view class="phone" v-else @click="uploadTap">
<image :src="avatar" mode=""></image>
</view>
<view class="btnBg" @click="goPage">上传</view>
</view>
</view>
</view>
</template>
<script>
import { APP_API, APP_HOST } from '@/config/site.config.js';;
const _url = APP_HOST + APP_API + '/util/manage/uploadFile.do';
import { uploadImgApi } from '@/config/utils.js'
export default {
data() {
return {
avatar: ''
}
},
onLoad() {
uni.$on('uAvatarCropper',(url)=>{
// console.log('裁剪后的图片路径')
this.avatar = url
console.log(url)
})
},
methods: {
uploadTap() {
const _this = this;
uni.chooseImage({
count: 1, // 默认9
sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
success: (res) => {
let url = res.tempFilePaths[0];
// 获取裁剪图片资源后,给data添加src属性及其值
uni.navigateTo({
url: '/pages/indexEntry/enroll/uploadAvatar/uAvatarCropper/uAvatarCropper?url=' + encodeURIComponent(url)
})
}
});
},
// 跳转到报名
async goPage() {
const photoPath = await uploadImgApi(this.avatar, 'face')
console.log(photoPath)
this.vuex_userInfo.photoPath = photoPath
this.$goPage('/pages/indexEntry/enroll/registInfo/registInfo')
}
}
}
</script>
<style lang="scss" scoped>
.card {
display: flex;
align-items: center;
flex-direction: column;
.h2 {
padding: 126rpx 0 84rpx 0;
font-size: 36rpx;
font-weight: 600;
}
}
.phone {
border: 2rpx dashed #CDCED0;
width: 290rpx;
height: 290rpx;
border-radius: 16rpx;
overflow: hidden;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
.phoneIcon {
width: 60rpx;
height: 60rpx;
}
.lab {
font-size: 20rpx;
color: #686B73;
margin-top: 8rpx;
}
}
.btnBg {
width: 396rpx;
margin: 130rpx 0;
}
</style>