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

106 lines
2.5 KiB

10 months ago
10 months ago
10 months ago
8 months ago
10 months ago
  1. <template>
  2. <view class="pageBgImg">
  3. <topNavbar title="上传头像"></topNavbar>
  4. <view class="pad">
  5. <view class="card">
  6. <view class="h2">请上传或拍摄一张五官清晰的照片</view>
  7. <view class="phone" @click="uploadTap" v-if="!avatar">
  8. <view class="phoneIcon">
  9. <image src="@/static/images/index/btn_tupian.png" mode=""></image>
  10. </view>
  11. <view class="lab">添加图片</view>
  12. </view>
  13. <view class="phone" v-else @click="uploadTap">
  14. <image :src="avatar" mode=""></image>
  15. </view>
  16. <view class="btnBg" @click="goPage">上传</view>
  17. </view>
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. import { APP_API, APP_HOST } from '@/config/site.config.js';;
  23. const _url = APP_HOST + APP_API + '/util/manage/uploadFile.do';
  24. import { uploadImgApi } from '@/config/utils.js'
  25. export default {
  26. data() {
  27. return {
  28. avatar: ''
  29. }
  30. },
  31. onLoad() {
  32. uni.$on('uAvatarCropper',(url)=>{
  33. // console.log('裁剪后的图片路径')
  34. this.avatar = url
  35. console.log(url)
  36. })
  37. },
  38. methods: {
  39. uploadTap() {
  40. const _this = this;
  41. uni.chooseImage({
  42. count: 1, // 默认9
  43. sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
  44. sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
  45. success: (res) => {
  46. let url = res.tempFilePaths[0];
  47. // 获取裁剪图片资源后,给data添加src属性及其值
  48. uni.navigateTo({
  49. url: '/pages/indexEntry/enroll/uploadAvatar/uAvatarCropper/uAvatarCropper?url=' + encodeURIComponent(url)
  50. })
  51. }
  52. });
  53. },
  54. // 跳转到报名
  55. async goPage() {
  56. const photoPath = await uploadImgApi(this.avatar, 'face')
  57. console.log(photoPath)
  58. this.vuex_userInfo.photoPath = photoPath
  59. this.$goPage('/pages/indexEntry/enroll/registInfo/registInfo')
  60. }
  61. }
  62. }
  63. </script>
  64. <style lang="scss" scoped>
  65. .card {
  66. display: flex;
  67. align-items: center;
  68. flex-direction: column;
  69. .h2 {
  70. padding: 126rpx 0 84rpx 0;
  71. font-size: 36rpx;
  72. font-weight: 600;
  73. }
  74. }
  75. .phone {
  76. border: 2rpx dashed #CDCED0;
  77. width: 290rpx;
  78. height: 290rpx;
  79. border-radius: 16rpx;
  80. overflow: hidden;
  81. display: flex;
  82. align-items: center;
  83. justify-content: center;
  84. flex-direction: column;
  85. .phoneIcon {
  86. width: 60rpx;
  87. height: 60rpx;
  88. }
  89. .lab {
  90. font-size: 20rpx;
  91. color: #686B73;
  92. margin-top: 8rpx;
  93. }
  94. }
  95. .btnBg {
  96. width: 396rpx;
  97. margin: 130rpx 0;
  98. }
  99. </style>