diff --git a/pagesA/checkout/detail/detail.vue b/pagesA/checkout/detail/detail.vue index bde8dd1..73c513a 100644 --- a/pagesA/checkout/detail/detail.vue +++ b/pagesA/checkout/detail/detail.vue @@ -18,7 +18,8 @@ >{{ info.gender == 1 ? "男" : "女" }} 联系电话{{ maskPhoneNumber(info.telephone) }}联系电话{{ maskPhoneNumber(info.telephone) }} 居住日期{{ info.checkInDate }}至{{ @@ -91,18 +92,36 @@ 图片/视频 >>>>>> Stashed changes +======= +>>>>>>> Stashed changes + :max-count="10" + :multiple="true" + :preview-full-image="true" + :deletable="true" + :show-upload-list="true" +<<<<<<< Updated upstream +<<<<<<< Updated upstream +>>>>>>> Stashed changes +======= +>>>>>>> Stashed changes +======= +>>>>>>> Stashed changes :fileList="fileList" - @afterRead="afterRead" - @delete="deletePic" - multiple - :maxCount="10" - uploadIconColor="#12c3c3" - :previewImage="true" + :auto-upload="false" + accept="all" :maxSize="10 * 1024 * 1024" @oversize="oversize" + @delete="onDelete" + :disabled="true" > - + - - 最多10个 + 点击上传 @@ -174,11 +192,11 @@ export default { this.getFacilities(options.houseId); }, methods: { - maskPhoneNumber (phoneNumber) { + maskPhoneNumber(phoneNumber) { if (!phoneNumber || phoneNumber.length !== 11) { return phoneNumber; } - return phoneNumber.substr(0, 3) + '****' + phoneNumber.substr(7); + return phoneNumber.substr(0, 3) + "****" + phoneNumber.substr(7); }, getFacilities(id) { getRoomFacilities({ houseId: id }).then((res) => { @@ -193,66 +211,55 @@ export default { beforeRead(event) { console.log("event", event); }, + chooseImage() { + uni.chooseImage({ + count: 10 - this.fileList.length, + sizeType: ["original", "compressed"], + sourceType: ["album", "camera"], + success: async (res) => { + uni.showLoading({ title: "上传中...", mask: true }); + try { + const files = + res.tempFiles || res.tempFilePaths.map((path) => ({ path })); + for (let i = 0; i < files.length; i++) { + const filePath = files[i].path; + const uploadRes = await uploadImage(filePath); + this.fileList.push({ + url: uploadRes.data?.url || uploadRes.url || uploadRes.path, + name: uploadRes.data?.name || uploadRes.name || "", + type: uploadRes.data?.type || uploadRes.type || "image", + status: "success", + }); + } + this.img1 = this.fileList.map((v) => v.url); + } catch (e) { + uni.showToast({ title: "上传失败", icon: "none" }); + } finally { + uni.hideLoading(); + } + }, + fail: () => { + uni.hideLoading(); + }, + }); + }, //图片超过大小时取消上传 oversize(e) { this.$u.toast("请传10MB以内大小的图片/视频!"); return false; }, - - // 选择文件后上传 - async afterRead(event) { - let lists = [].concat(event.file); - let fileListLen = this[`fileList${event.name}`].length; - lists.map((item) => { - this[`fileList${event.name}`].push({ - ...item, - status: "uploading", - message: "上传中", - }); - }); - for (let i = 0; i < lists.length; i++) { - try { - const result = await uploadImage(lists[i].url); - let item = this[`fileList${event.name}`][fileListLen]; - this[`fileList${event.name}`].splice( - fileListLen, - 1, - Object.assign(item, { - status: "success", - message: "", - url: result.url, - }) - ); - fileListLen++; - } catch (err) { - // 处理接口异常 - let msg = (err && err.msg) || (err && err.message) || "上传失败"; - console.log('344',err); - - uni.showToast({ - title: msg, - icon: "none", - duration: 3000 - }); - // 失败时移除上传中的文件 - this[`fileList${event.name}`].splice(fileListLen, 1); - return; // 终止后续上传 - } - } - var arry = []; - this.fileList.filter((v, i) => { - arry.push(v.url); - }); - this.img1 = arry; - }, // 删除文件 - deletePic(event) { + onDelete(event) { this[`fileList${event.name}`].splice(event.index, 1); var arry = []; this.fileList.filter((v, i) => { - arry.push(v.url); + arry.push({ + name: v.name || "", + format: v.type, + url: v.url, + }); }); - this.img1 = arry; + this.form.imageList = arry; }, // 暂存提交 handleTempSave(formData) { @@ -270,33 +277,36 @@ export default { onSubmit() { // 校验设备检查是否全部完成 const uncheckedDevices = this.deviceList.filter((item, index) => { - return this.checkStatus[index] === undefined || this.checkStatus[index] === ''; + return ( + this.checkStatus[index] === undefined || + this.checkStatus[index] === "" + ); }); - + if (uncheckedDevices.length > 0) { uni.showToast({ - title: '请完成所有设备检查', - icon: 'none', - duration: 2000 + title: "请完成所有设备检查", + icon: "none", + duration: 2000, }); return; } // 校验水电表是否填写 - if (!this.waterMeterValue || this.waterMeterValue.trim() === '') { + if (!this.waterMeterValue || this.waterMeterValue.trim() === "") { uni.showToast({ - title: '请输入水表数', - icon: 'none', - duration: 2000 + title: "请输入水表数", + icon: "none", + duration: 2000, }); return; } - if (!this.energyMeterValue || this.energyMeterValue.trim() === '') { + if (!this.energyMeterValue || this.energyMeterValue.trim() === "") { uni.showToast({ - title: '请输入电表数', - icon: 'none', - duration: 2000 + title: "请输入电表数", + icon: "none", + duration: 2000, }); return; } diff --git a/pagesA/force/index/index.vue b/pagesA/force/index/index.vue index 148eb05..5ea07e9 100644 --- a/pagesA/force/index/index.vue +++ b/pagesA/force/index/index.vue @@ -61,7 +61,7 @@ @click="showDate = false" > {{ baseInfo.checkOutTime }} --> - 图片/视频 - - - - - - + - 点击上传 - @@ -185,53 +168,55 @@ export default { } }, methods: { - // 删除文件 - deletePic(event) { - this[`fileList${event.name}`].splice(event.index, 1); - var arry = []; - this.fileList.filter((v, i) => { - arry.push(v.url); + chooseImage() { + uni.chooseImage({ + count: 10 - this.fileList.length, + sizeType: ["original", "compressed"], + sourceType: ["album", "camera"], + success: async (res) => { + uni.showLoading({ title: "上传中...", mask: true }); + try { + const files = + res.tempFiles || res.tempFilePaths.map((path) => ({ path })); + for (let i = 0; i < files.length; i++) { + const filePath = files[i].path; + const uploadRes = await uploadImage(filePath); + this.fileList.push({ + url: uploadRes.data?.url || uploadRes.url || uploadRes.path, + name: uploadRes.data?.name || uploadRes.name || "", + type: uploadRes.data?.type || uploadRes.type || "image", + status: "success", + }); + } + this.img1 = this.fileList.map((v) => v.url); + } catch (e) { + uni.showToast({ title: "上传失败", icon: "none" }); + } finally { + uni.hideLoading(); + } + }, + fail: () => { + uni.hideLoading(); + }, }); - this.fileList = arry; }, //图片超过大小时取消上传 oversize(e) { this.$u.toast("请传10MB以内大小的图片/视频!"); return false; }, - // 选择文件后上传 - async afterRead(event) { - let lists = [].concat(event.file); - let fileListLen = this[`fileList${event.name}`].length; - lists.map((item) => { - this[`fileList${event.name}`].push({ - ...item, - status: "uploading", - message: "上传中", + // 删除文件 + onDelete(event) { + this[`fileList${event.name}`].splice(event.index, 1); + var arry = []; + this.fileList.filter((v, i) => { + arry.push({ + name: v.name || "", + format: v.type, + url: v.url, }); }); - for (let i = 0; i < lists.length; i++) { - const result = await uploadImage(lists[i].url); - let item = this[`fileList${event.name}`][fileListLen]; - - this[`fileList${event.name}`].splice( - fileListLen, - 1, - Object.assign(item, { - status: "success", - message: "", - url: result.url, - }) - ); - fileListLen++; - } - console.log(this.fileList); - - this.fileList = this.fileList.map((v) => ({ - url: v.url, - name: v.name, - type: v.type, - })); + this.form.imageList = arry; }, // 获取房间详情 async getRoomDetail() { diff --git a/pagesA/xjPage/xj.vue b/pagesA/xjPage/xj.vue index 7c704a1..095cf49 100644 --- a/pagesA/xjPage/xj.vue +++ b/pagesA/xjPage/xj.vue @@ -6,44 +6,99 @@ 请您填写相关问题 - - - + + - - + + - - + + - - + + - + - + - + 点击上传 @@ -52,12 +107,24 @@ - + - + - + @@ -65,117 +132,130 @@ 提交 - + - +