<template>
	<view class="container">
		<view class="header">
			<view class="segmented-control-item" :class="{ 'active': activeTab === 0 }" @click="switchTab(0)">上传
				<view class="underline" v-show="activeTab === 0"></view>
			</view>
			<view class="segmented-control-item" :class="{ 'active': activeTab === 1 }" @click="switchTab(1)">已上传
				<view class="underline" v-show="activeTab === 1"></view>
			</view>
		</view>

		<!-- <view class="absolute-element"> -->
		<swiper class="scroll-view swiper" :current="activeTab" duration="0" @change="handleSwiperChange">
			<swiper-item>
				<scroll-view scroll-y="true" :style="{'height': clientHeight + 'px'}">
					<!-- <scroll-view scroll-y="true" style="height: 100%;" > -->
					<view class="content" v-show="activeTab === 0">
						<view class="list" v-for="(item, index) in list" :key="index">
							<view class="list-item">
								<view style="padding-top: 5px;">
									<checkbox-group @change="toggleSelect(index)">
										<checkbox
											style="transform: scale(0.6,0.6);activeBackgroundColor: #253a6f;iconColor: #253a6f;"
											v-model="selected[index]" :checked="selected[index]" :key="item.id" />
									</checkbox-group>
								</view>
								<view>
									<view class="item" @click="goDetailPage(item.uid)">
										<image class="icon" src="/static/meeting.png" />
										<text class="text">{{ item.exhibitionName }}</text>
									</view>
									<view class="item" @click="goDetailPage(item.uid)">
										<image class="icon" src="/static/customer.png" />
										<text class="text">{{ item.customerName }}</text>
									</view>
									<view class="item" @click="goDetailPage(item.uid)">
										<image class="icon" src="/static/receiver.png" />
										<text class="text">{{ item.receiver }}</text>
									</view>
									<view class="item1" style=""
										:style="{ 'flex-wrap': item.fileSavePath.length <= 2 ? 'nowrap' : 'wrap' }">
										<u--image class="image-item" v-for="(element, i) in item.fileSavePath" :key="i"
											:src="element" width="80px" height="80px"
											@click="previewImage(item,i)"></u--image>
									</view>
									<view class="item">
										<text class="text">备注信息：{{ item.exhibitionNote }}</text>
									</view>
									<!-- 	<view  class="item">
								<button style="width:100%;background-color: #253a6f;color: white;height: 40px;font-size: 14px;line-height: 40px;
								text-align: center;margin-top: 50px;" @click="upload(index)">上传</button>
							</view> -->
								</view>
							</view>
							<button style="background-color: #253a6f;color: white;height: 40px;font-size: 14px;line-height: 40px;
						text-align: center;margin-top: 50px;margin-bottom: 10px;width: 90%;" :disabled="uploadingStatus[index]"
								@click="upload(index)"><span v-if="uploadingStatus[index]">上传中...</span>
								<span v-else>上传</span></button>
						</view>
					</view>
				</scroll-view>
			</swiper-item>
			<swiper-item>
				<!-- <scroll-view scroll-y="true" style="height: 100%;"> -->
				<scroll-view scroll-y="true" :style="{'height': clientHeight + 'px'}">
					<view class="content" v-show="activeTab === 1">
						<view class="list" v-for="(item, index) in uploadedList" :key="index">
							<view class="list-item">
								<view style="padding-top: 5px;">
									<checkbox-group @change="toggleSelect1(index)">
										<checkbox
											style="transform: scale(0.6,0.6);activeBackgroundColor: #253a6f;iconColor: #253a6f;"
											v-model="selected1[index]" :checked="selected1[index]" :key="item.id" />
									</checkbox-group>
								</view>
								<view>
									<view class="item" @click="goDetailPage(item.uid)">
										<image class="icon" src="/static/meeting.png" />
										<text class="text">{{ item.exhibitionName }}</text>
									</view>
									<view class="item" @click="goDetailPage(item.uid)">
										<image class="icon" src="/static/customer.png" />
										<text class="text">{{ item.customerName }}</text>
									</view>
									<view class="item" @click="goDetailPage(item.uid)">
										<image class="icon" src="/static/receiver.png" />
										<text class="text">{{ item.receiver }}</text>
									</view>
									<view class="item1"
										:style="{ 'flex-wrap': item.fileSavePath.length <= 2 ? 'nowrap' : 'wrap' }">
										<u--image class="image-item" v-for="(element, i) in item.fileSavePath" :key="i"
											:src="element" width="80px" height="80px"
											@click="previewImage(item,i)"></u--image>
									</view>
									<view class="item">
										<text class="text">备注信息：{{ item.exhibitionNote }}</text>
									</view>
								</view>
							</view>
						</view>
					</view>
				</scroll-view>
			</swiper-item>
		</swiper>
		<!-- 底部操作栏 -->
		<view class="bottom-bar" v-show="activeTab === 0">
			<view style="display: flex; width: 90%;margin: 0 auto;align-items: center;">
				<checkbox-group style="margin-left: 10px;" @change="toggleSelectAll">
					<view style="width: 300rpx;">
						<checkbox :value="selectAll" :checked="selectAll"
							style="transform: scale(0.5,0.5);activeBackgroundColor: #253a6f;iconColor: #253a6f;" />
						全选 已选{{selectedCount}}项
					</view>
				</checkbox-group>
				<!-- <view style="margin-left:90px;align-items: center;border: solid 1px red;"> -->
				<view style="margin-right: 10px;margin-left:5px;">
					<button type="default"
						style="color:#ffffff;backgroundColor:#27DBBB; border-radius: 50px;width:150rpx; height:65rpx;font-size: unset;display: flex;justify-content: center; align-items:center"
						@click="changeListData"><span>删除</span></button>

				</view>
				<view>
					<button
						style="color:#ffffff;backgroundColor:#253a6f; border-radius: 50px;width:150rpx; height:65rpx;font-size: unset;display: flex;justify-content: center; align-items:center"
						@click="uploadSelect" :disabled="isSubmitting"><span v-if="isSubmitting">...</span>
						<span v-else>上传</span></button>
				</view>
				<!-- </view> -->
			</view>
		</view>
		<view class="bottom-bar" v-show="activeTab === 1">
			<view style="display: flex; width: 90%;margin: 0 auto;align-items: center;">
				<checkbox-group style="margin-left: 10px;" @change="toggleSelectAll1">
					<view style="width: 300rpx;">
						<checkbox :value="selectAll1" :checked="selectAll1"
							style="transform: scale(0.5,0.5);activeBackgroundColor: #253a6f;iconColor: #253a6f;" />
						全选 已选{{selectedCount1}}项
					</view>
				</checkbox-group>
				<!-- <view style="display: flex;margin-left:70px;align-items: center;"> -->
				<view style="margin-right: 10px;">
					<button type="default"
						style="color:#ffffff;backgroundColor:#27DBBB; border-radius: 50px;width:150rpx; height:65rpx;font-size: unset;visibility: hidden;">删除</button>

				</view>
				<view>
					<button
						style="color:#ffffff;backgroundColor:#27DBBB; border-radius: 50px;width:150rpx; height:65rpx;font-size: unset;display: flex;justify-content: center; align-items:center"
						@click="deleteSelectedUploaded">删除</button>
				</view>
				<!-- </view> -->
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getToken,
		setToken
	} from '@/utils/auth'
	import {
		openSqlite,
		executeSql,
		closedb,
		getTable,
		isTable,
		getAllField,
		insertAll,
		addSql,
		getPageList,
		selectList,
		deleteSql,
		updateSql,
		selectSql,
		batchUpdate
	} from "@/utils/database";
	export default {
		data() {
			return {
				tableName: "public",
				options: {
					current: 1, // 分页默认为第1页
					size: 10,
				},
				list: [],
				uploadedList: [],
				activeTab: 0, // 当前选中的页面索引
				selected: [], // 保存每个数据项是否被选中的状态
				selectAll: false, // 全选状态
				selected1: [], // 保存每个数据项是否被选中的状态
				selectAll1: false, // 全选状态
				selectedCount: 0,
				selectedCount1: 0,
				clientHeight: '',
				isSubmitting: false, // 控制提交按钮状态
				uploadingStatus: [], // 用于存储上传状态的对象
				// a:1,
				// b:1
			};
		},
		watch: {
			selected: {
				handler() {
					this.selectedCount = this.selected.filter(value => value === true).length;
				},
				deep: true,
			},
			selected1: {
				handler() {
					this.selectedCount1 = this.selected1.filter(value => value === true).length;
				},
				deep: true,
			},
		},
		onShow() {
			this.getToBeUploadedData()
			this.getUploadedData()
			this.selected = new Array(this.list.length).fill(false)
			this.selected1 = new Array(this.uploadedList.length).fill(false)
			plus.key.hideSoftKeybord();
			const res = uni.getSystemInfo({
				success: (res => {
					console.log(res.windowHeight)
					// console.log(getApp().globalData.navHeight)
					this.clientHeight = res.windowHeight - 120;
				})
			});
			console.log('res', this.clientHeight)

		},
		// onLoad() {
		// 	this.getToBeUploadedData()
		// 	this.getUploadedData()
		// },
		mounted() {
			this.selected = new Array(this.list.length).fill(false)
			this.selected1 = new Array(this.uploadedList.length).fill(false)
			plus.key.hideSoftKeybord();
		},
		methods: {

			handleSwiperChange(event) {
				console.log(event.detail.current)
				this.activeTab = event.detail.current;
				if (event.detail.current == 1) {
					console.log(event.detail.current)
					setTimeout(() => {
						console.log('隐藏')
						plus.key.hideSoftKeybord();
						// uni.hideKeyboard()
					}, 700)
				}
			},
			toggleSelectAll(e) {
				console.log(e.detail)
				console.log(this.selectAll = !this.selectAll)
				this.selectAll = e.detail.value[0] == false ? true : false
				// console.log(this.selectAll)
				this.selected = this.list.map(() => this.selectAll);
				// console.log(this.selected)
			},
			toggleSelect(index) {
				console.log(index)
				this.selected[index] = !this.selected[index];
				this.selectAll = this.selected.every(item => item);
				console.log(this.selectAll)
				this.selectedCount = this.selected.filter(value => value === true).length;
			},
			toggleSelectAll1(e) {
				console.log(e.detail)
				console.log(this.selectAll1 = !this.selectAll1)
				this.selectAll1 = e.detail.value[0] == false ? true : false
				// console.log(this.selectAll1)
				this.selected1 = this.uploadedList.map(() => this.selectAll1);
				// console.log(this.selected)
			},
			toggleSelect1(index) {
				console.log(index)
				this.selected1[index] = !this.selected1[index];
				this.selectAll1 = this.selected1.every(item => item);
				console.log(this.selectAll1)
				this.selectedCount1 = this.selected1.filter(value => value === true).length;
			},
			deleteSelectedUploaded() {
				const listToDelete1 = this.uploadedList.filter((item, index) => this.selected1[index]).map(item => {
					return {
						id: item.id,
						deleted: 1
					};
				});
				// console.log(idsToDelete1)
				if (this.isEmptyObject(listToDelete1)) {
					uni.showToast({
						title: "请选择删除条目",
						icon: "none"
					});
					return
				}
				console.log(listToDelete1)
				console.log('selected', this.selected1)
				let self = this
				uni.showModal({
					// title: '提示',
					content: '确认删除选中的条目?',
					success: async function(res) {
						if (res.confirm) {
							console.log('用户点击确定')
							try {
								// const self = this
								await batchUpdate(self.tableName, listToDelete1, "id")
								// 过滤掉arr1中对应arr2中值为true的索引的元素
								self.uploadedList = self.uploadedList.filter((item, index) => !self.selected1[
									index])
								self.selectAll1 = false
								console.log(self.uploadedList)
								uni.showToast({
									title: "删除成功",
									icon: "none",
									success: function() {}
								});
							} catch (e) {
								console.error("批量修改数据，报错", e)
							}

						} else if (res.cancel) {
							console.log('用户点击取消')
						}
					}
				})

				// 调用接口删除数据项
				// console.log('需要删除的数据项ID：', idsToDelete);
				// // 删除选中的数据项后，重新获取数据列表
				// this.getList();
			},
			async getToBeUploadedData() {
				let where = {
					"deleted": 0,
					"uploaded": 0
				}
				this.list = await this.getData(where)
				console.log(this.list)
				this.selected = new Array(this.list.length).fill(false)
				// this.list = this.getData(where)
			},
			async getUploadedData() {
				let where = {
					"deleted": 0,
					"uploaded": 1
				}
				this.uploadedList = await this.getData(where)
				console.log(this.uploadedList)
				this.selected1 = new Array(this.uploadedList.length).fill(false)
				plus.key.hideSoftKeybord();
				// this.list = this.getData(where)
			},
			// 获取数据
			async getData(where) {
				try {
					// let where = {
					// 	"deleted": 0,
					// 	"uploaded": 0
					// }
					let res = await selectList(this.tableName, where, "createTime desc")
					console.log("加载数据", res)
					const result = res.map(({
						fileSavePath,
						...rest
					}) => ({
						fileSavePath: fileSavePath ? fileSavePath.split(',') : [],
						...rest
					}));
					// 清空原先的数据
					// this.list = [];
					// console.log(result);
					// this.list = result
					return result
				} catch (e) {
					uni.showToast({
						title: "报错，请查看控制台",
						icon: "none"
					});
					console.error("报错", e)
				}
			},
			isEmptyObject(obj) {
				return Object.keys(obj).length === 0;
			},
			// 批量修改数据
			async changeListData() {

				const listToDelete = this.list.filter((item, index) => this.selected[index]).map(item => {
					return {
						id: item.id,
						deleted: 1
					};
				});
				if (this.isEmptyObject(listToDelete)) {
					uni.showToast({
						title: "请选择删除条目",
						icon: "none"
					});
					return
				}
				console.log(listToDelete)
				console.log('selected', this.selected)
				let self = this
				uni.showModal({
					// title: '提示',
					content: '确认删除选中的条目?',
					success: async function(res) {
						if (res.confirm) {
							console.log('用户点击确定')
							try {
								// const self = this
								await batchUpdate(self.tableName, listToDelete, "id")
								// 过滤掉arr1中对应arr2中值为true的索引的元素
								self.list = self.list.filter((item, index) => !self.selected[index])
								self.selectAll = false
								console.log(self.list)
								uni.showToast({
									title: "修改成功",
									icon: "none",
									success: function() {}
								});
							} catch (e) {
								console.error("批量修改数据，报错", e)
							}

						} else if (res.cancel) {
							console.log('用户点击取消')
						}
					}
				})

			},
			//图片预览
			previewImage(item, i) {
				uni.previewImage({
					current: i,
					urls: item.fileSavePath
				});
			},
			switchTab(index) {
				this.activeTab = index; // 切换页面
			},
			goDetailPage(uid) {
				console.log(uid)
				uni.navigateTo({
					url: '/pages/collections/sample-collection-detail?uid=' + uid
				});
			},
			uploadSelect() {
				// this.a++
				// console.log("aaaaaaaa",this.a)
				

				console.log(getToken())
				if (!getToken()) {
					uni.showToast({
						title: "请先登录",
						icon: "none"
					});
					uni.reLaunch({
						url: '/pages/login/index'
					})
					return
				}
				if (this.isSubmitting) return; // 如果正在提交中，则直接返回


				const trueIndexes = this.selected.reduce((acc, val, index) => {
					if (val === true) {
						acc.push(index);
					}
					return acc;
				}, []);
				console.log(trueIndexes)
				// const listToDelete = this.list.filter((item, index) => this.selected[index]).map(item => item.id);
				// console.log(listToDelete)
				// return
				if (this.isEmptyObject(trueIndexes)) {
					uni.showToast({
						title: "请选择上传条目",
						icon: "none"
					});
					return
				}
				let self = this
				uni.showModal({
					// title: '提示',
					content: '确认上传选中的条目?',
					success: function(res) {
						if (res.confirm) {
							self.isSubmitting = true; // 设置提交中状态
							console.log('用户点击确定')
							// try {
							const uploadPromises = trueIndexes.map((item) => self.uploadData(item));
							console.log(uploadPromises)
							Promise.all(uploadPromises)
								.then(async (result) => {
									console.log(result)
									for (const obj of result) {
										if (obj.code == 200) {
											console.log(obj.data.uid);
											try {
												await updateSql('public', {
													uploaded: 1,
												}, {
													uid: obj.data.uid
												})
												// const self = this
												console.log("上传成功")
												const filteredData = self.list.filter(item => item
													.uid !== obj.data.uid);
												console.log(filteredData);
												self.list = filteredData
												self.getUploadedData()
												// console.log(self.list)
												// arr.splice(2, 1);
												// self.list = self.list.filter((item, index) => !self.selected[index])
												uni.showToast({
													title: "上传成功",
													icon: "none",
												});

											} catch (e) {
												uni.showToast({
													title: "修改报错，请联系开发人员",
													icon: "none"
												});
												console.error("修改报错", e)
											}
											//修改状态
										} else {
											console.log("上传失败")
											console.log("上传失败")
											if (obj.msg == "token 无效" || obj.msg == "未能读取到有效 token") {
												uni.showModal({
													content: "请重新登录",
													showCancel: false
												});
												uni.reLaunch({
													url: '/pages/login/index'
												})
											}
											if (obj.status === 500) {
												uni.showModal({
													content: "上传失败:" + obj.error,
													showCancel: false
												});
											}
										}
									}
									self.selected = new Array(self.list.length).fill(false)
									self.selectAll = false
									await self.getUploadedData()
									self.isSubmitting = false; // 恢复按钮可用状态
									// 所有文件上传完成
									console.log('所有文件上传完成');
								}, (errorMessage) => {
									self.isSubmitting = false; // 恢复按钮可用状态
									console.error("操作失败：" + errorMessage.errMsg);
									uni.showModal({
										content: "请检查网络",
										showCancel: false
									});
								})
								.catch((error) => {
									console.error('文件上传出错:', error);
									self.isSubmitting = false; // 恢复按钮可用状态
								});
							// }

							// for (let i = 0; i < trueIndexes.length; i++) {
							// 	self.uploadData(trueIndexes[i])

							// }
							// self.selected = new Array(self.list.length).fill(false)
							// self.selectAll = false
							// await self.getUploadedData()
							// } catch (e) {
							// 	console.error("批量修改数据，报错", e)
							// }

						} else if (res.cancel) {
							console.log('用户点击取消')
						}
					}
				})
				// console.log(listToDelete)
				// console.log('selected', this.selected)
				// for (let i = 0; i < trueIndexes.length; i++) {
				// 	this.upload(trueIndexes[i])

				// }

			},
			upload(index) {
				if (!getToken()) {
					uni.showToast({
						title: "请先登录",
						icon: "none"
					});
					uni.reLaunch({
						url: '/pages/login/index'
					})
					return
				}
				if (this.uploadingStatus[index]) return; // 如果正在上传中，则直接返回

				
				console.log(this.uploadingStatus[index])
				let self = this
				// this.b++
				// console.log("bbbbbb",this.b)
				uni.showModal({
					// title: '提示',
					content: '确认上传选中的条目?',
					success: function(res) {
						if (res.confirm) {
							self.uploadingStatus[index] = true; // 设置上传中状态
							self.$forceUpdate();
							console.log('用户点击确定')
							// try {

							// 	self.uploadData(index)
							// 	self.selected = new Array(self.list.length).fill(false)
							// 	self.selectAll = false
							// 	// self.switchTab(1)
							// } catch (e) {
							// 	console.error("上传，报错", e)
							// }
							self.uploadData(index)
								.then(async (result) => {
									 self.uploadingStatus[index] = false; // 恢复按钮可用状态
									console.log(result)
									console.log(result)
									// return
									if (result.code == 200) {
										console.log(result.data.uid);
										try {
											await updateSql('public', {
												uploaded: 1,
											}, {
												uid: result.data.uid
											})
											// const self = this
											console.log("上传成功")
											const filteredData = self.list.filter(item => item
												.uid !== result.data.uid);
											console.log(filteredData);
											self.list = filteredData
											self.getUploadedData()
											// console.log(self.list)
											// arr.splice(2, 1);
											// self.list = self.list.filter((item, index) => !self.selected[index])
											uni.showToast({
												title: "上传成功",
												icon: "none",
											});

										} catch (e) {
											uni.showToast({
												title: "修改报错，请联系开发人员",
												icon: "none"
											});
											console.error("修改报错", e)
										}


										//修改状态
									} else {
										console.log("上传失败")



										if (result.msg == "token 无效" || result.msg ==
											"未能读取到有效 token") {
											uni.showModal({
												content: "请重新登录",
												showCancel: false
											});
											uni.reLaunch({
												url: '/pages/login/index'
											})
										}
										if (result.status === 500) {
											uni.showModal({
												content: "上传失败:" + result.error,
												showCancel: false
											});
										}
									}
								}, (errorMessage) => {
									 self.uploadingStatus[index] = false; // 恢复按钮可用状态
									 self.$forceUpdate();
									 console.log('aaaaaaaa',self.uploadingStatus[index])
									console.error("操作失败：" + errorMessage.errMsg);
									uni.showModal({
										content: "请检查网络",
										showCancel: false
									});
								})
								.catch((error) => {
									 self.uploadingStatus[index] = false; // 恢复按钮可用状态
									 self.$forceUpdate();
									console.error('文件上传出错:', error);
								});
						} else if (res.cancel) {
							console.log('用户点击取消')
							self.uploadingStatus[index] = false; // 恢复按钮可用状态
							self.$forceUpdate();
						}
					}
				})
			},
			async uploadData(index) {
				console.log(this.list[index])
				let fileSavePath = this.list[index].fileSavePath;
				console.log(fileSavePath)
				// console.log(fileSavePath.length === 0)
				let result = []
				if (fileSavePath.length === 0) {
					result = []
				} else {
					result = fileSavePath.map(function(path, index) {
						return {
							name: "public" + index,
							uri: path
						};
					});
				}

				console.log('result', result);
				let detailList = await this.getDetailListByUid(this.list[index].uid)
				console.log('detailList', detailList)
				if (detailList.length === 0) {
					console.log('数组为空');
					var files = result;
				} else {
					var result2 = detailList.map(function(item) {
						if (item.fileSavePath) {
							var fileSavePath = item.fileSavePath;
							var fileSavePathArray = fileSavePath.split(',');
							return fileSavePathArray.map(function(path, index) {
								return {
									name: "detail-" + item.id + "-" + index,
									uri: path
								};
							});

						} else {
							return []

						}
					});
					console.log('result2', result2)
					var result3 = result2.reduce(function(acc, cur) {
						return acc.concat(cur);
					}, []);
					console.log('result3', result3)
					var files = result.concat(result3);
					console.log('数组不为空');
				}
				if (files.length === 0) {
					files = [{
						"uri": 'a'
					}]
				}
				const {
					uid,
					exhibitionName,
					customerName,
					receiver,
					exhibitionNote
				} = this.list[index];

				const mainObj = {
					uid,
					exhibitionName,
					customerName,
					receiver,
					exhibitionNote
				};
				const detailArr = detailList.map(obj => {
					return {
						id: obj.id,
						publicId: obj.publicId,
						barCode: obj.barCode,
						bpQuantity: obj.bpQuantity,
						gyQuantity: obj.gyQuantity,
						myQuantity: obj.myQuantity,
						note: obj.note,
					};
				});
				const mainStr = JSON.stringify(mainObj);
				const detailStr = JSON.stringify(detailArr);
				console.log('mainStr', mainStr)
				console.log('detailStr', detailStr)
				console.log('files', files)
				let self = this
				return new Promise((resolve, reject) => {
					uni.uploadFile({
						url: 'https://xyxt.lttc.cn/samplescan/api/input', //仅为示例，非真实的接口地址
						// url: 'http://10.20.70.228:8028/samplescan/api/input', //仅为示例，非真实的接口地址
						files: files,
						header: {
							'Content-Type': 'multipart/form-data',
							'Authorization': getToken()

						},
						formData: {
							'main': mainStr,
							'detail': detailStr
						},
						success: (res) => {
							// JSON.parse(uploadFileRes.data)
							resolve(JSON.parse(res.data));
							// success: async (uploadFileRes) => {
							// console.log(uploadFileRes.data);
							// const obj = JSON.parse(uploadFileRes.data);
							// console.log(obj.code);
							// if (obj.code == 200) {
							// 	console.log(obj.data.uid);
							// 	try {
							// 		await updateSql('public', {
							// 			uploaded: 1,
							// 		}, {
							// 			uid: obj.data.uid
							// 		})
							// 		console.log("上传成功")
							// 		const filteredData = self.list.filter(item => item.uid !== obj.data.uid);
							// 		console.log(filteredData);
							// 		self.list = filteredData
							// 		self.getUploadedData()
							// 		uni.showToast({
							// 			title: "上传成功",
							// 			icon: "none",
							// 		});
							// 	} catch (e) {
							// 		uni.showToast({
							// 			title: "修改报错，请联系开发人员",
							// 			icon: "none"
							// 		});
							// 		console.error("修改报错", e)
							// 	}
							// 	//修改状态
							// } else {
							// 	console.log("上传失败")
							// 	if(obj.msg == "token 无效"){
							// 		uni.reLaunch({
							// 			url: '/pages/login/index'
							// 		})
							// 	}

							// 	uni.showModal({
							// 		content: "请重新登录",
							// 		showCancel: false
							// 	});
							// }

						},
						fail: (err) => {
							reject(err);
							console.log(err);
							// uni.showModal({
							// 	content: "请检查网络",
							// 	showCancel: false
							// });
						}
					});
				});
				// })

			},
			async getDetailListByUid(uid) {
				try {

					let where = {
						"publicId": uid,
						'deleted': 0
					}
					// let res = await selectList(this.tableName, where)
					let res = await selectList('detail', where)
					console.log("加载数据", res)
					return res

					// this.total = res.data.data.total
				} catch (e) {
					uni.showToast({
						title: "报错，请查看控制台",
						icon: "none"
					});
					console.error("报错", e)
				}
			},
		},
	};
</script>

<style>
	button::after {
		border: 0; // 或者 border: none;
	}

	.container {
		position: relative;
		width: 100%;
		height: 100vh;
		overflow: hidden;
		background-color: #EDEDED
			/* 隐藏溢出内容，禁止滚动 */
	}

	.header {
		position: fixed;
		background-color: #253a6f;
		height: 170rpx;
		width: 100%;
		z-index: 1;
		display: flex;
	}

	.scroll-view {
		position: absolute;
		left: 50%;
		top: 60%;
		transform: translate(-50%, -50%);
		width: 90%;
		height: 100%;
		overflow: auto;
		/* 设置滚动 */
		background-color: white;
		border-radius: 5px;
		/* border: 1px solid red; */
		/* padding: 0 10px; */
		z-index: 998;

	}

	.content {
		width: 100%;
		margin-bottom: 150px;
		border-radius: 5px;
		background-color: #EDEDED;
		overflow-y: auto;
		z-index: 999;
		/* border: 1px solid blue; */
		/* 此处设置滚动区域的内容样式 */
	}


	.segmented-control-item {
		flex: 1;
		text-align: center;
		padding: 10px;
		color: white;
	}

	.underline {
		bottom: 0;
		left: 0;
		width: 20%;
		height: 1px;
		background-color: white;
		/* 设置下划线的颜色 */
		display: none;
		margin: 0 auto;
	}

	.segmented-control-item.active .underline {
		display: block;
	}


	.icon {
		width: 40rpx;
		height: 40rpx;
		margin-right: 20rpx;
	}

	.list {
		margin-bottom: 10px;
		border-radius: 5px;
		background-color: white;

	}

	.list-item {
		display: flex;
		margin-top: 2px;
		background-color: white;
	}

	.item {
		display: flex;
		align-items: center;
		padding-top: 10px;
	}

	.item1 {
		display: flex;
		/* flex-wrap: wrap; */
		justify-content: flex-start;
	}

	.upload-btn {
		justify-content: center;
		align-items: center;
	}

	.image-item {
		/* flex: 1; */
		/* width: 30%; */
		margin: 5px;
		border: solid 1px #dadbde;
	}

	.bottom-bar {
		position: fixed;
		/* 将底部操作栏固定在页面底部 */
		left: 0;
		bottom: 0;
		width: 100%;
		height: 80rpx;
		/* text-align: center; */
		background-color: white;
		/* color: #fff; */
		font-size: 32rpx;
		line-height: 80rpx;
		z-index: 999;
	}

	.text {
		color: #949494;
		margin-top: 3px;
	}

	uni-checkbox .uni-checkbox-input {
		border-radius: 80rpx !important;
		border: 2px solid #ccc;
	}

	/deep/ uni-checkbox .uni-checkbox-input.uni-checkbox-input-checked:before {
		font: normal normal normal 14px/1 uni;
		content: "EA08";
		font-size: 0;
		/* 重点使用这一步取消的默认样式 */
		position: absolute;
		top: 50%;
		left: 50%;
		transform: translate(-50%, -48%) scale(1);
		-webkit-transform: translate(-50%, -48%) scale(1);
	}

	/deep/ .uni-checkbox-input-checked::before {
		width: 19px;
		height: 19px;
		background: #253a6f;
		border-radius: 50%;
		/* background: url(../../static/img/seal.png) no-repeat center; */
	}
</style>