businessLicense.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <template>
  2. <view class="page">
  3. <view class="businessLicense">
  4. <!-- 占位图 -->
  5. <image class="bg" v-if="!uploadImage" src="/static/image/businessLicense.png" mode="" @click="upload">
  6. </image>
  7. <image class="bg" v-else :src="uploadImage" mode=""></image>
  8. <view class="reupload dis a-c j-c " v-if="uploadImage" @click="upload">
  9. <image src="/static/icon/right.png" mode=""></image>
  10. <text>重新上传</text>
  11. </view>
  12. </view>
  13. <view class="btn mt-3 dis" v-if="uploadImage">
  14. <view class="dis a-c j-c mr-3">
  15. 删除
  16. </view>
  17. <view class="dis a-c j-c">
  18. 下载
  19. </view>
  20. </view>
  21. </view>
  22. </template>
  23. <script>
  24. import {
  25. mapState,
  26. mapMutations
  27. } from "vuex"
  28. import store from '@/store';
  29. export default {
  30. data() {
  31. return {
  32. uploadImage: null, //展业资格证
  33. }
  34. },
  35. onShow() {
  36. },
  37. onLoad(options) {
  38. if (options.list) {
  39. const list = JSON.parse(decodeURIComponent(options.list));
  40. list.forEach(val => {
  41. if (val.fileType == 'qualification') {
  42. this.uploadImage = val.fileUrl;
  43. }
  44. })
  45. }
  46. },
  47. computed: {
  48. ...mapState(['userInfo']),
  49. },
  50. methods: {
  51. //上传
  52. async upload() {
  53. let [chooseImageErr, chooseImageRes] = await uni.chooseImage({
  54. count: 1,
  55. sizeType: ['compressed']
  56. });
  57. let size = chooseImageRes.tempFiles[0].size / 1024 / 1024 < 5;
  58. if (!size) {
  59. this.$refs.uToast.show({
  60. title: '上传图片大小不能超过 5MB!',
  61. type: 'error',
  62. })
  63. return false
  64. }
  65. if (chooseImageRes) {
  66. this.uploadImage = chooseImageRes.tempFilePaths[0];
  67. uni.uploadFile({
  68. url: this.$base.baseUrl + '/file/upload',
  69. filePath: chooseImageRes.tempFilePaths[0],
  70. name: "file",
  71. formData: {
  72. 'type': 'image',
  73. },
  74. header: {
  75. Authorization: store.state.token,
  76. system_code: store.state.system_code ? store.state.system_code : ''
  77. },
  78. success: async (imgRes) => {
  79. let data = JSON.parse(imgRes.data);
  80. if (data.code == '200') {
  81. let res = await this.$http.post('/appUser/businessInfoAdd', {
  82. userId: this.userInfo.sysUser.userId,
  83. fileId: data.data.id,
  84. })
  85. }
  86. }
  87. });
  88. } else {}
  89. }
  90. }
  91. }
  92. </script>
  93. <style lang="scss" scoped>
  94. page {
  95. background-color: #f8f8f8;
  96. padding: 30rpx;
  97. box-sizing: border-box;
  98. }
  99. .businessLicense {
  100. position: relative;
  101. border-radius: 6rpx;
  102. height: 394rpx;
  103. .bg {
  104. width: 100%;
  105. height: 100%;
  106. border-radius: 6rpx;
  107. }
  108. .reupload {
  109. position: absolute;
  110. bottom: 0;
  111. width: 100%;
  112. height: 70rpx;
  113. background: rgba(0, 0, 0, 0.1);
  114. border-radius: 0 0 6rpx 6rpx;
  115. backdrop-filter: blur(20rpx);
  116. font-size: 28rpx;
  117. color: #fff;
  118. image {
  119. width: 26rpx;
  120. height: 26rpx;
  121. margin-right: 8rpx;
  122. }
  123. }
  124. }
  125. .btn {
  126. view {
  127. flex: 1;
  128. height: 80rpx;
  129. background: rgba(253, 233, 53, 0.2);
  130. border-radius: 45rpx 45rpx 45rpx 45rpx;
  131. border: 1rpx solid #FDE935;
  132. font-size: 30rpx;
  133. color: #1f1f1f;
  134. }
  135. }
  136. </style>