uploadInvoice.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <template>
  2. <div class="uploadInvoice">
  3. <div class="ruleIntro">
  4. <div class="stitle">规则说明:</div>
  5. <div class="sdesc">1.领薪宝当前只接受专票</div>
  6. <div class="sdesc">2.发票票面额度必须和提现额度一致</div>
  7. <div class="sdesc">3.发票图片审核中,不能重新发起提现,审核失败/审核通过后才能重新发起提现</div>
  8. <div class="sdesc">4.发票图片审核通过后,请按照系统消息、邮件消息、短信通知,按相应提示,邮寄纸质发票</div>
  9. </div>
  10. <div class="imageUpload">
  11. <div class="stitle">发票图片(不超过5MB)</div>
  12. <div class="uploadInfo">
  13. <el-upload
  14. v-loading="uploading"
  15. class="avatar-uploader"
  16. action="#"
  17. :show-file-list="false"
  18. :multiple="false"
  19. :limit="1"
  20. accept="image/png, image/jpeg"
  21. :before-upload="handleFileChange"
  22. >
  23. <i v-if="invoiceImg" class="el-icon-delete avatar-uploader-icon"
  24. @click.stop="() => handleDeleteFile('invoiceImg') "></i>
  25. <img v-if="invoiceImg" :src="invoiceImg" class="avatar"/>
  26. <div v-else class="noneImage">
  27. <div class="desc">
  28. 添加电子发票
  29. </div>
  30. </div>
  31. </el-upload>
  32. </div>
  33. </div>
  34. <div class="button" @click="onSubmit">
  35. <p>提交审核</p>
  36. </div>
  37. </div>
  38. </template>
  39. <script>
  40. export default {
  41. name: "uploadInvoice",
  42. showCommonFooter: false,
  43. head() {
  44. let obj = {
  45. title: "领薪宝",
  46. meta: [{
  47. name: 'viewport',
  48. content: 'width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, viewport-fit=cover'
  49. }]
  50. }
  51. return obj
  52. },
  53. async asyncData({ app }) {
  54. return {
  55. mobile: app.$deviceType.isMobile()
  56. }
  57. },
  58. data() {
  59. return {
  60. invoiceImg: '',
  61. uploading: false
  62. }
  63. },
  64. created() {
  65. const {vCoins=1} = this.$route.query || {}
  66. this.vCoins = Number(vCoins) || 0
  67. },
  68. methods: {
  69. /** 图片文件上传 **/
  70. handleFileChange(file) {
  71. const isJPG = file.type === 'image/jpeg';
  72. const isPNG = file.type === 'image/png';
  73. const isLt2M = file.size / 1024 / 1024 < 5;
  74. if (!isJPG && !isPNG) {
  75. this._toast('上传头像图片只能是 JPG/PNG 格式!', 'error');
  76. return
  77. }
  78. if (!isLt2M) {
  79. this._toast('上传头像图片大小不能超过 5MB!', 'error');
  80. return
  81. }
  82. const formData = new FormData();
  83. formData.append("file", file);
  84. formData.append("original_filename", file.name);
  85. console.log("pre upload", formData)
  86. this.uploading = true;
  87. this.$axios
  88. .$post(`/upload_image`, formData, {
  89. headers: { "Content-Type": "multipart/form-data" }
  90. })
  91. .then(res => {
  92. this.invoiceImg = res.filename
  93. })
  94. .finally(() => {
  95. this.uploading = false;
  96. console.log('upload end')
  97. });
  98. return false
  99. },
  100. /** 删除问及爱你 **/
  101. handleDeleteFile() {
  102. this.invoiceImg = ""
  103. },
  104. onSubmit() {
  105. if (!this.invoiceImg) {
  106. this._toast('请上传发票', 'error')
  107. return
  108. }
  109. location.href = `/otherpage/money/withdraw?vCoins=${this.vCoins || ''
  110. }&fpUrl=${encodeURIComponent(this.invoiceImg)
  111. || ''}`
  112. }
  113. }
  114. }
  115. </script>
  116. <style lang="scss" scoped>
  117. @import "../../../assets/css/otherpage/money/uploadInvoice";
  118. </style>