en-head-img.vue 1.8 KB

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