2025-04-08 13:33:16 +08:00
|
|
|
|
<template>
|
|
|
|
|
<view class="content">
|
|
|
|
|
<!-- 遮罩层 -->
|
|
|
|
|
<view class="mask" v-if="showMenu" @click="toggleMenu"></view>
|
|
|
|
|
|
|
|
|
|
<!-- 下拉菜单 -->
|
|
|
|
|
<view class="dropdown-menu" v-if="showMenu">
|
|
|
|
|
<view
|
|
|
|
|
class="menu-item"
|
|
|
|
|
v-for="(item, index) in menuItems"
|
|
|
|
|
:key="index"
|
|
|
|
|
@click="selectMenuItem(item)"
|
|
|
|
|
>
|
|
|
|
|
<text>{{ item }}</text>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
|
|
|
|
|
<u-navbar
|
|
|
|
|
:is-back="true"
|
|
|
|
|
title="上传图片"
|
|
|
|
|
title-color="black"
|
|
|
|
|
:background="{ backgroundColor: '#F7F8FC' }"
|
|
|
|
|
:border-bottom="false"
|
|
|
|
|
>
|
2025-04-14 15:10:19 +08:00
|
|
|
|
<!-- <view slot="right">
|
2025-04-08 13:33:16 +08:00
|
|
|
|
<view class="menu-wrapper">
|
|
|
|
|
<image
|
|
|
|
|
src="/static/iconfont/more.svg"
|
|
|
|
|
mode="scaleToFill"
|
2025-04-10 14:21:16 +08:00
|
|
|
|
style="width: 48rpx; height: 48rpx; margin-right: 32rpx"
|
2025-04-08 13:33:16 +08:00
|
|
|
|
@click="toggleMenu"
|
|
|
|
|
/>
|
|
|
|
|
</view>
|
2025-04-14 15:10:19 +08:00
|
|
|
|
</view> -->
|
2025-04-08 13:33:16 +08:00
|
|
|
|
</u-navbar>
|
|
|
|
|
|
|
|
|
|
<view class="content-header">
|
2025-04-10 14:21:16 +08:00
|
|
|
|
<view class="content-header-title">
|
2025-04-11 11:50:55 +08:00
|
|
|
|
{{ params.aeraNmae }} — {{ params.planName }}
|
2025-04-10 14:21:16 +08:00
|
|
|
|
</view>
|
2025-04-08 13:33:16 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
|
|
|
|
<view class="planList">
|
|
|
|
|
<view class="plan-header">
|
|
|
|
|
<text>请上传区域图片</text>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="plan-content">
|
|
|
|
|
<view class="plan-content-top">
|
2025-04-10 14:21:16 +08:00
|
|
|
|
<view class="plan-content-top-uploadBox" @click="takePhoto">
|
|
|
|
|
<image
|
|
|
|
|
src="/static/images/icon-camera.png"
|
|
|
|
|
mode="aspectFit"
|
|
|
|
|
style="width: 49rpx; height: 43rpx"
|
|
|
|
|
/>
|
|
|
|
|
<view class="plan-content-top-uploadBox-text">添加照片</view>
|
|
|
|
|
</view>
|
|
|
|
|
|
|
|
|
|
<view
|
|
|
|
|
class="plan-content-top-imgList"
|
|
|
|
|
v-for="(item, index) in imageList"
|
|
|
|
|
:key="index"
|
|
|
|
|
>
|
|
|
|
|
<image
|
|
|
|
|
:src="item"
|
|
|
|
|
mode="scaleToFill"
|
|
|
|
|
style="width: 180rpx; height: 180rpx"
|
|
|
|
|
@click="previewImage(index)"
|
|
|
|
|
/>
|
|
|
|
|
<view class="delete-icon" @click="handleDelete(index)">×</view>
|
|
|
|
|
</view>
|
2025-04-08 13:33:16 +08:00
|
|
|
|
</view>
|
|
|
|
|
<view class="plan-content-remark">
|
|
|
|
|
<view class="plan-content-remark-title">备注</view>
|
2025-04-10 14:21:16 +08:00
|
|
|
|
<!-- <view class="plan-content-remark-text">
|
|
|
|
|
备注备注备注备注备注备注备注备注备注备注备注备注
|
|
|
|
|
</view> -->
|
|
|
|
|
<u-input
|
|
|
|
|
v-model="remark"
|
|
|
|
|
type="textarea"
|
|
|
|
|
placeholder="请输入"
|
|
|
|
|
:border="false"
|
|
|
|
|
/>
|
2025-04-08 13:33:16 +08:00
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
|
|
|
|
|
<u-button
|
|
|
|
|
class="bottom-btn"
|
|
|
|
|
shape="circle"
|
|
|
|
|
type="primary"
|
|
|
|
|
@click="submitForm"
|
|
|
|
|
>上传</u-button
|
|
|
|
|
>
|
|
|
|
|
</view>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2025-04-10 14:21:16 +08:00
|
|
|
|
import { UploadFiles, UploadArea } from "@/api/apiList";
|
|
|
|
|
|
2025-04-08 13:33:16 +08:00
|
|
|
|
export default {
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
activeTab: "completed",
|
|
|
|
|
showMenu: false,
|
2025-04-10 14:21:16 +08:00
|
|
|
|
menuItems: ["教学楼楼道", "南广场跑道", "食堂大厅"],
|
|
|
|
|
// 区域名称
|
|
|
|
|
areaName: "操场",
|
|
|
|
|
// 所属计划
|
|
|
|
|
planName: "保洁计划",
|
|
|
|
|
|
|
|
|
|
// 备注
|
|
|
|
|
remark: "",
|
|
|
|
|
|
2025-04-11 11:50:55 +08:00
|
|
|
|
imageList: [], // 存储图片临时路径
|
|
|
|
|
|
|
|
|
|
params: {},
|
2025-04-08 13:33:16 +08:00
|
|
|
|
};
|
|
|
|
|
},
|
2025-04-11 11:50:55 +08:00
|
|
|
|
onLoad(options) {
|
|
|
|
|
console.log("options", JSON.parse(decodeURIComponent(options.params)));
|
|
|
|
|
this.params = JSON.parse(decodeURIComponent(options.params));
|
|
|
|
|
},
|
2025-04-08 13:33:16 +08:00
|
|
|
|
created() {},
|
|
|
|
|
methods: {
|
|
|
|
|
switchTab(tab) {
|
|
|
|
|
this.activeTab = tab;
|
|
|
|
|
},
|
|
|
|
|
toggleMenu() {
|
|
|
|
|
this.showMenu = !this.showMenu;
|
|
|
|
|
},
|
|
|
|
|
selectMenuItem(item) {
|
|
|
|
|
// 处理菜单项选择
|
|
|
|
|
console.log("选择了:", item);
|
2025-04-10 14:21:16 +08:00
|
|
|
|
this.areaName = item;
|
2025-04-08 13:33:16 +08:00
|
|
|
|
// 这里可以添加选择后的逻辑
|
|
|
|
|
this.showMenu = false;
|
|
|
|
|
},
|
2025-04-10 14:21:16 +08:00
|
|
|
|
|
|
|
|
|
// 拍照获取图片
|
|
|
|
|
takePhoto() {
|
|
|
|
|
uni.chooseImage({
|
|
|
|
|
count: 1, // 每次拍摄1张
|
|
|
|
|
sourceType: ["camera"], // 仅限拍照
|
2025-04-11 17:24:07 +08:00
|
|
|
|
sizeType: ["compressed", "original"],
|
2025-04-10 14:21:16 +08:00
|
|
|
|
success: async (res) => {
|
2025-04-11 11:50:55 +08:00
|
|
|
|
// console.log("拍照成功", res);
|
|
|
|
|
this.imageList = [...this.imageList, res.tempFilePaths[0]];
|
2025-04-10 14:21:16 +08:00
|
|
|
|
},
|
|
|
|
|
fail: (err) => {
|
|
|
|
|
uni.showToast({ title: "拍照失败,请重试", icon: "none" });
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 上传图片
|
2025-04-11 17:24:07 +08:00
|
|
|
|
async uploadFiles() {
|
|
|
|
|
const res = await UploadFiles(this.imageList);
|
2025-04-10 14:21:16 +08:00
|
|
|
|
if (res.succeed) {
|
|
|
|
|
this.imageList = [...this.imageList, res.data];
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 删除图片
|
|
|
|
|
handleDelete(index) {
|
|
|
|
|
this.imageList.splice(index, 1);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 图片预览
|
|
|
|
|
previewImage(index) {
|
|
|
|
|
uni.previewImage({
|
|
|
|
|
urls: this.imageList,
|
|
|
|
|
current: index,
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 提交表单
|
|
|
|
|
async submitForm() {
|
|
|
|
|
if (this.imageList.length === 0) {
|
|
|
|
|
uni.showToast({ title: "请上传图片", icon: "none" });
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-11 17:24:07 +08:00
|
|
|
|
const params = {
|
2025-04-14 15:10:19 +08:00
|
|
|
|
id: this.params.id,
|
2025-04-11 17:24:07 +08:00
|
|
|
|
note: this.remark,
|
|
|
|
|
picturesDto: [],
|
|
|
|
|
};
|
2025-04-10 14:21:16 +08:00
|
|
|
|
|
2025-04-11 17:24:07 +08:00
|
|
|
|
const res = await UploadFiles(this.imageList);
|
2025-04-14 15:10:19 +08:00
|
|
|
|
if (!res.succeed) return;
|
|
|
|
|
params.picturesDto = res.data;
|
2025-04-11 17:24:07 +08:00
|
|
|
|
|
|
|
|
|
const res2 = await UploadArea(params);
|
|
|
|
|
if (res2.succeed) {
|
2025-04-10 14:21:16 +08:00
|
|
|
|
// 成功的处理
|
2025-04-14 15:10:19 +08:00
|
|
|
|
uni.showToast({ title: "上传成功", icon: "success", duration: 1500 });
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
uni.switchTab({
|
|
|
|
|
url: "/pages/index/index",
|
|
|
|
|
});
|
|
|
|
|
}, 1500);
|
2025-04-10 14:21:16 +08:00
|
|
|
|
}
|
2025-04-14 15:10:19 +08:00
|
|
|
|
// else {
|
|
|
|
|
// uni.showToast({ title: res2.error || "上传失败", icon: "none" });
|
|
|
|
|
// }
|
2025-04-10 14:21:16 +08:00
|
|
|
|
},
|
2025-04-08 13:33:16 +08:00
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2025-04-10 14:21:16 +08:00
|
|
|
|
page {
|
|
|
|
|
background: #f7f8fc;
|
|
|
|
|
}
|
2025-04-08 13:33:16 +08:00
|
|
|
|
.content {
|
|
|
|
|
position: relative;
|
2025-04-10 14:21:16 +08:00
|
|
|
|
// height: 100vh;
|
|
|
|
|
padding-bottom: 32rpx;
|
2025-04-08 13:33:16 +08:00
|
|
|
|
background: #f7f8fc;
|
|
|
|
|
|
|
|
|
|
.mask {
|
|
|
|
|
position: fixed;
|
|
|
|
|
top: 0;
|
|
|
|
|
left: 0;
|
|
|
|
|
right: 0;
|
|
|
|
|
bottom: 0;
|
|
|
|
|
background-color: rgba(0, 0, 0, 0.2);
|
|
|
|
|
z-index: 999;
|
|
|
|
|
}
|
2025-04-10 14:21:16 +08:00
|
|
|
|
|
2025-04-08 13:33:16 +08:00
|
|
|
|
.content-header {
|
2025-04-10 14:21:16 +08:00
|
|
|
|
height: 180rpx;
|
2025-04-08 13:33:16 +08:00
|
|
|
|
border-radius: 16rpx;
|
|
|
|
|
margin: 32rpx;
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column-reverse;
|
2025-04-10 14:21:16 +08:00
|
|
|
|
background: url("/static/images/region-bg.png") no-repeat center center;
|
|
|
|
|
background-size: 100% 100%;
|
2025-04-08 13:33:16 +08:00
|
|
|
|
|
|
|
|
|
&-title {
|
|
|
|
|
font-size: 32rpx;
|
|
|
|
|
color: #333;
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
height: 60rpx;
|
|
|
|
|
line-height: 60rpx;
|
|
|
|
|
text-align: center;
|
|
|
|
|
background-color: #fff;
|
|
|
|
|
border-radius: 32rpx;
|
2025-04-10 14:21:16 +08:00
|
|
|
|
min-width: 80%;
|
|
|
|
|
padding: 0 32rpx;
|
2025-04-08 13:33:16 +08:00
|
|
|
|
margin: 0 auto 32rpx;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
.planList {
|
|
|
|
|
margin: 0 32rpx;
|
|
|
|
|
border-radius: 16rpx;
|
|
|
|
|
background-color: #fff;
|
|
|
|
|
|
|
|
|
|
.plan-header {
|
|
|
|
|
font-size: 32rpx;
|
|
|
|
|
color: #333;
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
padding: 32rpx;
|
|
|
|
|
border-bottom: 1px solid #f2f2f2;
|
|
|
|
|
}
|
|
|
|
|
.plan-content {
|
|
|
|
|
padding: 32rpx;
|
|
|
|
|
&-top {
|
|
|
|
|
display: flex;
|
2025-04-10 14:21:16 +08:00
|
|
|
|
flex-wrap: wrap;
|
|
|
|
|
gap: 32rpx;
|
|
|
|
|
|
|
|
|
|
&-uploadBox {
|
|
|
|
|
border: 1px dashed #526fa3;
|
|
|
|
|
width: 180rpx;
|
|
|
|
|
height: 180rpx;
|
|
|
|
|
background-color: #edf2ff;
|
|
|
|
|
border-radius: 16rpx;
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
gap: 20rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&-imgList {
|
|
|
|
|
position: relative;
|
|
|
|
|
.delete-icon {
|
|
|
|
|
position: absolute;
|
|
|
|
|
right: -10rpx;
|
|
|
|
|
top: -10rpx;
|
|
|
|
|
width: 36rpx;
|
|
|
|
|
height: 36rpx;
|
2025-04-10 16:29:39 +08:00
|
|
|
|
background: rgba(110, 110, 110, 0.6);
|
2025-04-10 14:21:16 +08:00
|
|
|
|
border-radius: 50%;
|
|
|
|
|
color: white;
|
|
|
|
|
text-align: center;
|
|
|
|
|
line-height: 36rpx;
|
|
|
|
|
font-size: 28rpx;
|
|
|
|
|
}
|
2025-04-08 13:33:16 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
&-remark {
|
|
|
|
|
margin-top: 32rpx;
|
|
|
|
|
border-radius: 16rpx;
|
|
|
|
|
&-title {
|
2025-04-10 14:21:16 +08:00
|
|
|
|
margin-bottom: 16rpx;
|
2025-04-08 13:33:16 +08:00
|
|
|
|
font-size: 32rpx;
|
|
|
|
|
color: #333;
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
}
|
|
|
|
|
&-text {
|
|
|
|
|
font-size: 28rpx;
|
|
|
|
|
color: #666;
|
|
|
|
|
margin-top: 16rpx;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
&.activeList {
|
|
|
|
|
.plan-item {
|
|
|
|
|
background: linear-gradient(
|
|
|
|
|
to bottom,
|
|
|
|
|
#fef7ec 0%,
|
|
|
|
|
#fffdfa 30%,
|
|
|
|
|
#ffffff 100%
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.bottom-btn {
|
2025-04-10 14:21:16 +08:00
|
|
|
|
margin: 60rpx 32rpx 0rpx;
|
|
|
|
|
// position: fixed;
|
|
|
|
|
// bottom: 32rpx;
|
|
|
|
|
// left: 0;
|
|
|
|
|
// right: 0;
|
2025-04-08 13:33:16 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.header {
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
align-items: center;
|
|
|
|
|
padding: 20rpx 32rpx;
|
|
|
|
|
position: relative;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.title {
|
|
|
|
|
font-size: 36rpx;
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.menu-wrapper {
|
|
|
|
|
position: relative;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.dropdown-menu {
|
|
|
|
|
position: absolute;
|
|
|
|
|
top: 80rpx;
|
|
|
|
|
right: 32rpx;
|
|
|
|
|
background-color: #ffffff;
|
|
|
|
|
border-radius: 12rpx;
|
|
|
|
|
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.1);
|
|
|
|
|
width: 280rpx;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
z-index: 1000;
|
|
|
|
|
|
|
|
|
|
.menu-item {
|
|
|
|
|
padding: 24rpx 32rpx;
|
|
|
|
|
font-size: 28rpx;
|
|
|
|
|
color: #333333;
|
|
|
|
|
border-bottom: 1px solid #f5f5f5;
|
|
|
|
|
|
|
|
|
|
.menu-item:last-child {
|
|
|
|
|
border-bottom: none;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.menu-item:active {
|
|
|
|
|
background-color: #f8f8f8;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|