1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- "use strict";
- const common_vendor = require("../../common/vendor.js");
- const _sfc_main = {
- data() {
- return {
- fileType: ["pdf", "doc", "docx"],
- maxSize: 30 * 1024 * 1024
- // 30MB in bytes
- };
- },
- methods: {
- chooseFile() {
- common_vendor.index.chooseMessageFile({
- count: 1,
- type: "file",
- extension: this.fileType,
- success: (res) => {
- if (res.tempFiles[0].size > this.maxSize) {
- common_vendor.index.showToast({
- title: "文件大小不能超过30MB",
- icon: "none"
- });
- return;
- }
- this.uploadFile(res.tempFiles[0]);
- }
- });
- },
- uploadFile(file) {
- common_vendor.index.showLoading({
- title: "上传中..."
- });
- common_vendor.index.uploadFile({
- url: "YOUR_UPLOAD_API_URL",
- filePath: file.path,
- name: "file",
- success: (res) => {
- common_vendor.index.showToast({
- title: "上传成功",
- icon: "success"
- });
- },
- fail: (err) => {
- common_vendor.index.showToast({
- title: "上传失败",
- icon: "none"
- });
- },
- complete: () => {
- common_vendor.index.hideLoading();
- }
- });
- }
- }
- };
- function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
- return {
- a: common_vendor.o((...args) => $options.chooseFile && $options.chooseFile(...args))
- };
- }
- const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
- wx.createPage(MiniProgramPage);
|