页面修改

This commit is contained in:
zmj 2023-11-16 16:00:13 +08:00
parent e23f57f911
commit a2d3d2e156

View File

@ -33,16 +33,22 @@
type='number' border="surround" v-model="amount"></u--input> type='number' border="surround" v-model="amount"></u--input>
</view> </view>
</view> </view>
<view class="" v-if="!file"> <view class="" :class="{hide:file}">
<lsjUpload ref="lsjUpload" childId="upload1" :size="10" :option="fileOption" height="200rpx" <view class="" :class="{hide:progress!=0}">
style="margin-top: 28rpx;" :debug="false" :formats="'png,jpg,jpeg,pdf,webp'" :multiple="false" <lsjUpload ref="lsjUpload" childId="upload1" :size="10" :option="fileOption" height="200rpx"
:count="1" :instantly="false" @change="changeFile" @uploadEnd="onuploadEnd"> style="margin-top: 28rpx;" :debug="false" :formats="'png,jpg,jpeg,pdf,webp'" :multiple="false"
<view class="change-file">上传凭证</view> :count="1" :instantly="false" @change="changeFile" @uploadEnd="onuploadEnd"
</lsjUpload> @progress="onprogress">
<view class="change-file">上传凭证</view>
</lsjUpload>
</view>
<view style="margin-top: 20rpx;" v-if="progress>0">
<u-loading-icon :text=" '正在上传中'+ progress+'%'" textSize="18"></u-loading-icon>
</view>
</view> </view>
<view class="file" v-else> <view class="file" v-if='file'>
<view class=""> <view class="">
<image :src="file" style="width: 150rpx;height: 150rpx;margin-right: 12rpx;" <image :src="local_src" style="width: 150rpx;height: 150rpx;margin-right: 12rpx;"
v-if="file_type=='image'"> v-if="file_type=='image'">
</image> </image>
<image src="@/static/img/contract/pdf.png" style="width: 150rpx;height: 150rpx;margin-right: 12rpx;" <image src="@/static/img/contract/pdf.png" style="width: 150rpx;height: 150rpx;margin-right: 12rpx;"
@ -53,9 +59,15 @@
<view class=""> <view class="">
{{fileTit}} {{fileTit}}
</view> </view>
<view class="" style="color: blue;" @click="navToContract"> <view class="" style="display: flex;">
查看 <view class="" style="color: blue;margin-right: 10rpx;" @click="navToContract">
查看
</view>
<view class="" style="color: red;" @click="delFn" v-if="!isDisabled">
删除
</view>
</view> </view>
</view> </view>
</view> </view>
@ -93,15 +105,14 @@
import { import {
Toast Toast
} from "../../libs/uniApi"; } from "../../libs/uniApi";
import {
nextTick
} from "vue";
export default { export default {
components: { components: {
lsjUpload lsjUpload
}, },
data() { data() {
return { return {
progress: 0,
imgTypeList: ["png", "jpg", "jpeg", "webp"], imgTypeList: ["png", "jpg", "jpeg", "webp"],
isDisabled: false, isDisabled: false,
amount: "", amount: "",
@ -109,6 +120,7 @@
task: {}, task: {},
task_id: -1, task_id: -1,
file: "", file: "",
local_src: "",
fileTit: "", fileTit: "",
file_type: "pdf", file_type: "pdf",
}; };
@ -128,7 +140,6 @@
methods: { methods: {
navToContract() { navToContract() {
let fileSrc = this.file let fileSrc = this.file
if (this.file_type == 'image') { if (this.file_type == 'image') {
uni.previewImage({ uni.previewImage({
urls: [fileSrc] urls: [fileSrc]
@ -142,24 +153,35 @@
async submitFn() { async submitFn() {
if (!this.amount) return Toast("请输入金额") if (!this.amount) return Toast("请输入金额")
if (Number(this.amount) < Number(this.task.extend.shareholder.money)) 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, id: this.task_id,
annex: this.file, annex: this.file,
amount: this.amount, amount: this.amount,
file_type: this.file_type file_type: this.file_type
}
let res = await commit_service_group_taskAPI({
...data
}) })
Toast("操作成功!") Toast("操作成功!")
return
setTimeout(() => { setTimeout(() => {
uni.navigateBack() uni.navigateBack()
}, 1000) }, 1000)
}, },
delFn() {
this.clear()
this.file = ""
this.file_type = "pdf"
this.progress = 0
},
clear() {
this.$refs.lsjUpload.clear();
},
/** /**
* 某文件上传结束回调(成功失败都回调) * 某文件上传结束回调(成功失败都回调)
* @param {Object} item 当前上传完成的文件 * @param {Object} item 当前上传完成的文件
*/ */
onuploadEnd(item) { onuploadEnd(item) {
let res = JSON.parse(item.responseText) let res = JSON.parse(item.responseText)
this.file = res.data.uri this.file = res.data.uri
this.fileTit = res.data.name this.fileTit = res.data.name
@ -170,18 +192,16 @@
* 如果网页上md文档没有渲染出事件名称onprogre请复制代码的小伙伴自行添加上哈没有哪个事件是只(item) * 如果网页上md文档没有渲染出事件名称onprogre请复制代码的小伙伴自行添加上哈没有哪个事件是只(item)
* @param {Object} item 当前正在上传的文件 * @param {Object} item 当前正在上传的文件
*/ */
onprogre(item) { onprogress(item) {
// this.progress = item.progress
this.files.set(item.name, item);
//
this.$forceUpdate();
}, },
/** /**
* 文件选择回调 * 文件选择回调
* @param {Object} files 已选择的所有文件Map集合 * @param {Object} files 已选择的所有文件Map集合
*/ */
async changeFile(files) { async changeFile(files) {
let type = [...files.values()][0].name let type = [...files.values()][0]?.name || null
if (!type) return
let isImage = null let isImage = null
this.imgTypeList.forEach(item => { this.imgTypeList.forEach(item => {
if (type.includes(item)) { if (type.includes(item)) {
@ -189,9 +209,11 @@
this.file_type = 'image' this.file_type = 'image'
} }
}) })
this.local_src = [...files.values()][0].path
if (isImage) { if (isImage) {
this.$refs.lsjUpload.setData("url", IMG_URL) this.$refs.lsjUpload.setData("url", IMG_URL)
} else {
this.$refs.lsjUpload.setData("url", FILE_URL)
} }
this.$refs.lsjUpload.upload() this.$refs.lsjUpload.upload()
// //
@ -199,21 +221,6 @@
// //
this.$forceUpdate(); 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() { async loadTask() {
let res = await taskShareholder({ let res = await taskShareholder({
id: this.task_id id: this.task_id
@ -297,4 +304,9 @@
flex-direction: column; flex-direction: column;
} }
} }
.hide {
height: 0;
overflow: hidden;
}
</style> </style>