diff --git a/subpkg/buyShare/buyShare.vue b/subpkg/buyShare/buyShare.vue index a87c25b..c6ac615 100644 --- a/subpkg/buyShare/buyShare.vue +++ b/subpkg/buyShare/buyShare.vue @@ -33,16 +33,22 @@ type='number' border="surround" v-model="amount"> - - - 上传凭证 - + + + + 上传凭证 + + + + + - + - {{fileTit}} - - 查看 + + + 查看 + + + 删除 + + @@ -93,15 +105,14 @@ import { Toast } from "../../libs/uniApi"; - import { - nextTick - } from "vue"; + export default { components: { lsjUpload }, data() { return { + progress: 0, imgTypeList: ["png", "jpg", "jpeg", "webp"], isDisabled: false, amount: "", @@ -109,6 +120,7 @@ task: {}, task_id: -1, file: "", + local_src: "", fileTit: "", file_type: "pdf", }; @@ -128,7 +140,6 @@ methods: { navToContract() { let fileSrc = this.file - if (this.file_type == 'image') { uni.previewImage({ urls: [fileSrc] @@ -142,24 +153,35 @@ async submitFn() { if (!this.amount) return Toast("请输入金额") if (Number(this.amount) < Number(this.task.extend.shareholder.money)) return Toast("未达到目标入股金额,无法提交") - let res = await commit_service_group_taskAPI({ + let data = { id: this.task_id, annex: this.file, amount: this.amount, file_type: this.file_type + } + let res = await commit_service_group_taskAPI({ + ...data }) Toast("操作成功!") - return setTimeout(() => { uni.navigateBack() }, 1000) }, + delFn() { + this.clear() + this.file = "" + this.file_type = "pdf" + this.progress = 0 + + }, + clear() { + this.$refs.lsjUpload.clear(); + }, /** * 某文件上传结束回调(成功失败都回调) * @param {Object} item 当前上传完成的文件 */ onuploadEnd(item) { - let res = JSON.parse(item.responseText) this.file = res.data.uri this.fileTit = res.data.name @@ -170,18 +192,16 @@ * 如果网页上md文档没有渲染出事件名称onprogre,请复制代码的小伙伴自行添加上哈,没有哪个事件是只(item)的 * @param {Object} item 当前正在上传的文件 */ - onprogre(item) { - // 更新当前状态变化的文件 - this.files.set(item.name, item); - // 强制更新视图 - this.$forceUpdate(); + onprogress(item) { + this.progress = item.progress }, /** * 文件选择回调 * @param {Object} files 已选择的所有文件Map集合 */ async changeFile(files) { - let type = [...files.values()][0].name + let type = [...files.values()][0]?.name || null + if (!type) return let isImage = null this.imgTypeList.forEach(item => { if (type.includes(item)) { @@ -189,9 +209,11 @@ this.file_type = 'image' } }) - + this.local_src = [...files.values()][0].path if (isImage) { this.$refs.lsjUpload.setData("url", IMG_URL) + } else { + this.$refs.lsjUpload.setData("url", FILE_URL) } this.$refs.lsjUpload.upload() // 更新选择的文件 @@ -199,21 +221,6 @@ // 强制更新视图 this.$forceUpdate(); }, - /** - * 指定上传某个文件 - * @param {Object} name 带后缀名的文件名称 - */ - resetUpload(name) { - this.$refs.lsjUpload.upload(name); - }, - /** - * 移除某个文件 - * @param {Object} name 带后缀名的文件名称 - */ - clear(name) { - // name=指定文件名,不传name默认移除所有文件 - this.$refs.lsjUpload.clear(); - }, async loadTask() { let res = await taskShareholder({ id: this.task_id @@ -297,4 +304,9 @@ flex-direction: column; } } + + .hide { + height: 0; + overflow: hidden; + } \ No newline at end of file