uploadResume.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const _sfc_main = {
  4. data() {
  5. return {
  6. fileType: ["pdf", "doc", "docx"],
  7. maxSize: 30 * 1024 * 1024
  8. // 30MB in bytes
  9. };
  10. },
  11. methods: {
  12. chooseFile() {
  13. common_vendor.index.chooseMessageFile({
  14. count: 1,
  15. type: "file",
  16. extension: this.fileType,
  17. success: (res) => {
  18. if (res.tempFiles[0].size > this.maxSize) {
  19. common_vendor.index.showToast({
  20. title: "文件大小不能超过30MB",
  21. icon: "none"
  22. });
  23. return;
  24. }
  25. this.uploadFile(res.tempFiles[0]);
  26. }
  27. });
  28. },
  29. uploadFile(file) {
  30. common_vendor.index.showLoading({
  31. title: "上传中..."
  32. });
  33. common_vendor.index.uploadFile({
  34. url: "YOUR_UPLOAD_API_URL",
  35. filePath: file.path,
  36. name: "file",
  37. success: (res) => {
  38. common_vendor.index.showToast({
  39. title: "上传成功",
  40. icon: "success"
  41. });
  42. },
  43. fail: (err) => {
  44. common_vendor.index.showToast({
  45. title: "上传失败",
  46. icon: "none"
  47. });
  48. },
  49. complete: () => {
  50. common_vendor.index.hideLoading();
  51. }
  52. });
  53. }
  54. }
  55. };
  56. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  57. return {
  58. a: common_vendor.o((...args) => $options.chooseFile && $options.chooseFile(...args))
  59. };
  60. }
  61. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
  62. wx.createPage(MiniProgramPage);