en-head-img.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <template>
  2. <view>
  3. <view class="box" @click="editImg()">
  4. <image class="left" :src="value" mode="aspectFill"></image>
  5. <view class="right">
  6. <text>{{label}}</text>
  7. <image src="@/static/img/toRight.png" mode=""></image>
  8. </view>
  9. </view>
  10. <uni-popup>
  11. </uni-popup>
  12. </view>
  13. </template>
  14. <script>
  15. import { upLoadingFileOss } from "@/common/js/upLoadingFile";
  16. export default {
  17. props:{
  18. label: {
  19. type: String,
  20. default: '标题'
  21. },
  22. value:{
  23. type: String,
  24. default: ''
  25. },
  26. },
  27. data(){
  28. return{
  29. }
  30. },
  31. methods:{
  32. showsdasa(){
  33. let isH5=false
  34. // #ifdef H5
  35. isH5=true
  36. // #endif
  37. if(isH5){
  38. this.editImg(1)
  39. }else{
  40. }
  41. },
  42. editImg(type){
  43. uni.chooseImage({
  44. count: 1,
  45. sizeType: ["compressed", "camera"],
  46. sourceType: [type===1?"album":"camera"],
  47. success:(res)=>{
  48. if (res.errMsg == "chooseImage:ok"){
  49. this.upLoadOss(res.tempFiles[0].path)
  50. }else{
  51. // tools.error('头像选择失败')
  52. }
  53. }
  54. })
  55. },
  56. upLoadOss(path){
  57. let url = upLoadingFileOss(path)
  58. console.log(url);
  59. },
  60. },
  61. }
  62. </script>
  63. <style scoped lang="scss">
  64. .box{
  65. width: 100%;
  66. height: 152rpx;
  67. background-color: #fff;
  68. display: flex;
  69. align-items: center;
  70. justify-content: space-between;
  71. image{
  72. width: 96rpx;
  73. height: 96rpx;
  74. border-radius: 50%;
  75. }
  76. .left{
  77. font-size: 32rpx;
  78. }
  79. .right{
  80. display: flex;
  81. align-items: center;
  82. text{
  83. font-size: 32rpx;
  84. color: #333;
  85. }
  86. image{
  87. width: 40rpx;
  88. height: 40rpx;
  89. }
  90. }
  91. }
  92. </style>