face.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <template>
  2. <view class="upload-face">
  3. <view v-if="value == ''" @click="uploadAct" class="upload-main">
  4. <view class="upload-btn">
  5. <text class="iconfont iconicon_photo cl-w"></text>
  6. </view>
  7. </view>
  8. <view v-else class="upload-show">
  9. <image @click="uploadAct"></image>
  10. <view @click="delPic" class="del">
  11. <text class="iconfont iconicon_close12 ft12"></text>
  12. </view>
  13. </view>
  14. </view>
  15. </template>
  16. <script>
  17. import qiniu from '../../static/js/qiniu.js';
  18. export default{
  19. props:{
  20. value:{
  21. type:String,
  22. default:'',
  23. }
  24. },
  25. data(){
  26. return {
  27. }
  28. },
  29. methods:{
  30. delPic(){
  31. this.$emit('input','');
  32. },
  33. uploadAct(){
  34. uni.chooseImage({
  35. count:1,
  36. success:(chooseImageRes)=>{
  37. if(chooseImageRes.tempFilePaths.length > 0){
  38. // this.$http.api('child.upload/imageAuth').then(auth=>{
  39. // let domain = auth.url;
  40. // let token = auth.token;
  41. // let region = auth.region_mini;
  42. // let file = chooseImageRes.tempFilePaths[0];
  43. // let index = file.lastIndexOf('/');
  44. // let len = file.length
  45. // let name = file.substring(index + 1, len);
  46. // qiniu.upload(file, (res) => {
  47. // let url = res.imageURL;
  48. // this.$emit('input',url);
  49. // }, (error) => {
  50. // console.log(error);
  51. // }, {
  52. // region: region,
  53. // key: name,
  54. // domain:domain,
  55. // uptoken: token,
  56. // });
  57. // }).catch(res=>{
  58. // console.log(res);
  59. // });
  60. }
  61. }
  62. })
  63. }
  64. }
  65. }
  66. </script>
  67. <style>
  68. .upload-face{
  69. width: 210rpx;
  70. height: 210rpx;
  71. background: rgba(94, 64, 255, 0.06);
  72. border-radius: 110rpx;
  73. }
  74. .upload-face .upload-main{
  75. width: 210rpx;
  76. height: 210rpx;
  77. display: flex;
  78. justify-content: center;
  79. align-items: center;
  80. }
  81. .upload-face .upload-btn{
  82. width: 64rpx;
  83. height: 64rpx;
  84. background: #5E40FF;
  85. border-radius: 32rpx;
  86. text-align: center;
  87. line-height: 64rpx;
  88. }
  89. .upload-face .upload-show{
  90. width: 210rpx;
  91. height: 210rpx;
  92. border-radius: 110rpx;
  93. position: relative;
  94. }
  95. .upload-face .upload-show image{
  96. width: 210rpx;
  97. height: 210rpx;
  98. border-radius: 110rpx;
  99. background: rgba(94, 64, 255, 0.06);
  100. }
  101. .upload-face .upload-show .del{
  102. position: absolute;
  103. right: 0;
  104. top: 0rpx;
  105. width: 56rpx;
  106. height: 56rpx;
  107. background: rgba(0,0,0,.4);
  108. border-radius: 28rpx;
  109. text-align: center;
  110. line-height: 56rpx;
  111. color:#FFFFFF;
  112. }
  113. </style>