Kaynağa Gözat

实物招领页面接口对接+页面细节优化

LiuShu_0203 3 gün önce
ebeveyn
işleme
fabbd67c08

+ 212 - 0
my/setting/LostandFound.vue

@@ -0,0 +1,212 @@
+<template>
+	<view class="lost-container">
+		<!-- 自定义导航栏 -->
+		<view class="custom-navbar">
+			<view class="nav-left">
+				<view class="back-btn" @click="goBack">‹</view>
+				<view class="title-box">
+					<view class="main-title">我捡到了</view>
+					<view class="sub-title">快速发布招领信息</view>
+				</view>
+			</view>
+			<view class="nav-right">
+				<!-- <image :src="globalImages + 'images/my/shiwu.png'" class="nav-icon" mode="aspectFit" /> -->
+			</view>
+		</view>
+
+		<view class="section-title">我拾获的物品</view>
+		<!-- 卡片列表 -->
+		<view class="card-list" style="padding: 0rpx 30rpx;">
+			<view class="card" v-for="(item, index) in lostItems" :key="index" @click="goToDetail(item)">
+				<image :src="item.image" class="item-img" mode="aspectFill" />
+				<view class="item-info">
+					<view class="flex" style="justify-content: space-between;">
+						<view class="item-title">{{ item.name }}</view>
+						<view class="status-tag" :class="'status-' + item.statusType">{{ item.statusText }}</view>
+					</view>
+					<view style="border-top: 1rpx solid #e4e7ed; margin-top: 10rpx;margin-bottom: 20rpx;"></view>
+					<view class="item-subtitle" style="margin-bottom: 10rpx;">{{ item.loss === 2 ? '丢失于' : ''}}:{{ item.carNum }}</view>
+					<view class="item-time">{{ item.foundTime }}</view>
+				</view>
+			</view>
+		</view>
+
+		<!-- 悬浮按钮 -->
+		<view class="float-button" @click="goNav('/my/setting/LostandFoundadd')">
+			<text class="plus">+</text>
+		</view>
+	</view>
+</template>
+
+<script>
+	export default {
+		data() {
+			return {
+				globalImages: getApp().globalData.globalImages || '', // 图片前缀路径
+				lostItems: []
+			};
+		},
+		onLoad() {
+			this.$Request.getT('/app/lostFound/select?type=2&loss=2').then(res => {
+				if (res.code === 0) {
+					this.lostItems = res.data;
+				}
+			});
+		},
+		methods: {
+			goNav(url) {
+				uni.navigateTo({
+					url
+				});
+			},
+			goBack() {
+				uni.navigateBack();
+			},
+			goToDetail(item) {
+				// 建议用 JSON.stringify 序列化数据传参
+				const encoded = encodeURIComponent(JSON.stringify(item));
+				uni.navigateTo({
+					url: `/my/setting/LostandFoundtext?data=${encoded}`
+				});
+			}
+		}
+	};
+</script>
+
+<style scoped>
+	.lost-container {
+		/* padding: 30rpx; */
+		background: #f8f8f8;
+		min-height: 100vh;
+		box-sizing: border-box;
+	}
+
+	.custom-navbar {
+		display: flex;
+		justify-content: space-between;
+		align-items: center;
+		padding: var(--status-bar-height, 30rpx) 30rpx 30rpx;
+		background: linear-gradient(to bottom, #00c18a, #c6feee);
+		/* 渐变背景 */
+		box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.03);
+		/* color: #fff; */
+		margin-bottom: 30rpx;
+	}
+
+	.nav-left {
+		/* display: flex; */
+		align-items: center;
+	}
+
+	.back-btn {
+		font-size: 40rpx;
+		margin-right: 20rpx;
+		margin-top: 40rpx;
+		padding-bottom: 40rpx;
+	}
+
+	.title-box {
+		display: flex;
+		flex-direction: column;
+	}
+
+	.main-title {
+		font-size: 46rpx;
+		font-weight: bold;
+	}
+
+	.sub-title {
+		font-size: 34rpx;
+		/* color: #f0f0f0; */
+		margin-top: 6rpx;
+	}
+
+	.nav-icon {
+		width: 80rpx;
+		height: 80rpx;
+	}
+
+
+	/* 卡片列表 */
+	
+	.section-title {
+		padding: 0 30rpx;
+		margin-bottom: 20rpx;
+	}
+	.card-list {
+		display: flex;
+		flex-wrap: wrap;
+		justify-content: space-between;
+	}
+
+	.card {
+		width: 47%;
+		background: #fff;
+		border-radius: 16rpx;
+		box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);
+		margin-bottom: 30rpx;
+		overflow: hidden;
+	}
+
+	.item-img {
+		width: 100%;
+		height: 280rpx;
+		object-fit: cover;
+	}
+
+	.item-info {
+		padding: 20rpx;
+	}
+
+	.item-title {
+		font-size: 28rpx;
+		font-weight: 500;
+		margin-bottom: 8rpx;
+	}
+
+	.status-tag {
+		display: inline-block;
+		padding: 4rpx 12rpx;
+		font-size: 20rpx;
+		border-radius: 20rpx;
+		margin-bottom: 12rpx;
+	}
+
+	.status-searching {
+		background: #ffe5e5;
+		color: #ff4b4b;
+	}
+
+	.status-found {
+		background: #e1f8f0;
+		color: #27c29b;
+	}
+
+	.status-pending {
+		background: #fff1e0;
+		color: #ffa03b;
+	}
+
+	.item-subtitle,
+	.item-time {
+		font-size: 24rpx;
+		color: #999;
+	}
+
+	/* 悬浮按钮 */
+	.float-button {
+		position: fixed;
+		bottom: 60rpx;
+		right: 60rpx;
+		width: 60rpx;
+		height: 60rpx;
+		background: #00c18a;
+		border-radius: 50%;
+		display: flex;
+		justify-content: center;
+		align-items: center;
+		color: #fff;
+		font-size: 50rpx;
+		z-index: 99;
+	}
+</style>

+ 158 - 0
my/setting/LostandFoundadd.vue

@@ -0,0 +1,158 @@
+<template>
+	<view class="padding">
+		<u-form labelPosition="top" :model="model1" :rules="rules" ref="uForm">
+			<u-form-item label="订单号码" prop="ordersId" borderBottom ref="item1">
+				<u-input v-model="model1.ordersId" border="none"></u-input>
+			</u-form-item>
+			<u-form-item label="联系人" prop="name" borderBottom ref="item1">
+				<u-input v-model="model1.name" border="none"></u-input>
+			</u-form-item>
+			<u-form-item label="联系方式" prop="phone" borderBottom ref="item1">
+				<u-input v-model="model1.phone" border="none"></u-input>
+			</u-form-item>
+			<u-form-item label="拾获时间" prop="foundTime" borderBottom ref="item1">
+				<view class="flex align-center addboxs bg" style="padding: 0 30rpx; justify-content: space-between;" @click="openTime()">
+					<view class="flex align-center">
+						<image v-if="globalImages" :src="globalImages + 'imgs/static/upload/time.png'" style="width: 34rpx;height: 34rpx;"></image>
+						<view class="add_tit margin-left-xs" v-if="!yuyueTime">选择预约时间</view>
+						<view class="add_tit margin-left-xs" v-else>{{yuyueTime}}</view>
+					</view>
+					<view class="margin-left-xs">
+						<image v-if="globalImages" :src="globalImages + 'imgs/static/image/right.png'" style="width: 12rpx;height: 20rpx;">
+						</image>
+					</view>
+				</view>
+			</u-form-item>
+			<u-form-item label="其他信息" prop="description" borderBottom>
+				<textarea placeholder="简要描述物品其他信息" v-model="model1.description"
+						class="feedback-textare" />
+			</u-form-item>
+		</u-form>
+		<u-picker v-model="Timeshow" mode="time" :params="params"
+					@confirm="timeConfirm"></u-picker>
+		<view class="">
+			<view class="flex" style="justify-content: space-between;">
+				<view>物品照片</view>
+				<view>请上传丢失的物品照片</view>
+			</view>
+			<u-upload
+				:action="uploadAction"
+				:file-list="fileList"
+				@on-success="handleUploadSuccess"
+				@on-error="handleUploadError"
+				:max-count="1"
+				:multiple="false"
+			></u-upload>
+		</view>
+		<view class="pay_btns" @click="submit">发布信息</view>
+	</view>
+</template>
+
+<script>
+	import { waitForGlobalImages } from '@/utils/globalImageLoader'
+	export default {
+		data() {
+			return {
+				model1: {
+					name: '',
+					ordersId: '',
+					phone: '',
+					description: '',
+					image: '',
+					loss: 2,
+					foundTime: ''
+				},
+				// 上传组件配置
+				uploadAction: 'http://192.168.50.122:8179/sqx_fast/alioss/upload', // 上传接口地址
+				fileList: [], // 已上传的文件列表
+				Timeshow: false,
+				params: {
+					year: true,
+					month: true,
+					day: true,
+					hour: true,
+					minute: true,
+					second: false
+				},
+				yuyueTime: '',
+				globalImages: ''
+			}
+		},
+		onLoad() {
+			waitForGlobalImages().then((path) => {
+			    console.log('✅ 全局图片路径:', path)
+			    this.globalImages = path
+			})
+		},
+		methods: {
+			// 上传成功回调
+			handleUploadSuccess(response) {
+				console.log('上传成功', response.data);
+				// 将上传成功的文件添加到 fileList
+				this.model1.image = response.data; // 保存图片 URL
+				this.fileList = response.data
+			},
+			// 上传失败回调
+			handleUploadError(error) {
+				console.error('上传失败', error);
+				uni.showToast({
+					title: '上传失败,请重试',
+					icon: 'none',
+				});
+			},
+			submit() {
+				this.model1.foundTime = this.yuyueTime
+				this.$Request.postT("/app/lostFound/insert", this.model1).then(res => {
+					if (res.code === 0) {
+						uni.showToast({
+							title: '新增成功',
+							icon: 'success',
+						});
+						uni.navigateBack(); // 返回上一页
+					}
+				});
+			},
+			timeConfirm(e) {
+				console.log(e, e.year);
+				this.yuyueTime = e.year + '/' + e.month + '/' + e.day + '/' + '' + e.hour + ':' + e.minute
+			},
+			openTime() {
+				this.Timeshow = true
+				console.log('123123123');
+			}
+		}
+	}
+</script>
+
+<style scoped>
+	.feedback-textare {
+		height: 200upx;
+		font-size: 24upx;
+		line-height: 50upx;
+		width: 100%;
+		box-sizing: border-box;
+		padding: 20upx 20upx 0;
+		border: #e4e7ed 1rpx solid;
+		background: #fff;
+		border-radius: 15rpx;
+		/* margin-top: 20rpx; */
+	}
+	
+	.pay_btns {
+		width: calc(100% - 60rpx);
+		margin: 0 auto 40rpx;
+		text-align: center;
+		background: #00c18a;
+		height: 80rpx;
+		border-radius: 16rpx;
+		color: #ffffff;
+		line-height: 80rpx;
+		margin-top: 20rpx;
+		position: fixed;
+		bottom: 0rpx;
+	}
+	
+	/deep/ .u-flex {
+		background: #fff !important;
+	}
+</style>

+ 184 - 0
my/setting/LostandFoundtext.vue

@@ -0,0 +1,184 @@
+<template>
+	<view class="padding">
+		<u-form labelPosition="top" :model="model1" :rules="rules" ref="uForm">
+			<u-form-item label="订单号码" prop="ordersId" borderBottom ref="item1">
+				<u-input v-model="model1.ordersId" border="none"></u-input>
+			</u-form-item>
+			<u-form-item label="联系人" prop="name" borderBottom ref="item1">
+				<u-input v-model="model1.name" border="none"></u-input>
+			</u-form-item>
+			<u-form-item label="联系方式" prop="phone" borderBottom ref="item1">
+				<u-input v-model="model1.phone" border="none"></u-input>
+			</u-form-item>
+			<u-form-item label="拾获时间" prop="foundTime" borderBottom ref="item1">
+				<view class="flex align-center addboxs bg" style="padding: 0 30rpx; justify-content: space-between;" @click="openTime()">
+					<view class="flex align-center">
+						<image v-if="globalImages" :src="globalImages + 'imgs/static/upload/time.png'" style="width: 34rpx;height: 34rpx;"></image>
+						<view class="add_tit margin-left-xs" v-if="!yuyueTime">选择预约时间</view>
+						<view class="add_tit margin-left-xs" v-else>{{yuyueTime}}</view>
+					</view>
+					<view class="margin-left-xs">
+						<image v-if="globalImages" :src="globalImages + 'imgs/static/image/right.png'" style="width: 12rpx;height: 20rpx;">
+						</image>
+					</view>
+				</view>
+			</u-form-item>
+			<u-form-item label="其他信息" prop="description" borderBottom>
+				<textarea placeholder="简要描述物品其他信息" v-model="model1.description"
+						class="feedback-textare" />
+			</u-form-item>
+		</u-form>
+		<u-picker v-model="Timeshow" mode="time" :params="params"
+					@confirm="timeConfirm"></u-picker>
+		<view class="">
+			<view class="flex" style="justify-content: space-between;">
+				<view>物品照片</view>
+				<view>请上传丢失的物品照片</view>
+			</view>
+			<u-upload
+				:action="uploadAction"
+				:file-list="fileList"
+				@on-success="handleUploadSuccess"
+				@on-error="handleUploadError"
+				:max-count="3"
+				:multiple="false"
+			></u-upload>
+		</view>
+		<view class="pay_btns" @click="submit">联系平台</view>
+		<u-popup v-model="show" mode="bottom" length="260rpx">
+			<view class="pay_btns1">
+				<image v-if="globalImages" :src="globalImages + 'images/my/chat2.png'" style="width: 26rpx;height: 26rpx; margin-right: 10rpx;" mode=""></image>
+				在线客服
+			</view>
+			<view class="pay_btns2">
+				<image v-if="globalImages" :src="globalImages + 'images/my/phone2.png'" style="width: 26rpx;height: 26rpx; margin-right: 10rpx;" mode=""></image>
+				热线电话
+			</view>
+		</u-popup>
+	</view>
+</template>
+
+<script>
+	import { waitForGlobalImages } from '@/utils/globalImageLoader'
+	export default {
+		data() {
+			return {
+				model1: {
+					name: '',
+					ordersId: '',
+					phone: '',
+					description: '',
+					image: '',
+					loss: 1,
+				},
+				action: 'http://www.example.com/upload',
+				fileList: [],
+				// 上传组件配置
+				uploadAction: 'http://192.168.50.122:8179/sqx_fast/alioss/upload', // 上传接口地址
+				fileList: [], // 已上传的文件列表
+				show: false,
+				globalImages: '',
+				Timeshow: false,
+				params: {
+					year: true,
+					month: true,
+					day: true,
+					hour: true,
+					minute: true,
+					second: false
+				},
+				yuyueTime: '',
+			}
+		},
+		onLoad(options) {
+			waitForGlobalImages().then((path) => {
+			    console.log('✅ 全局图片路径:', path)
+			    this.globalImages = path
+			  })
+			if (options.data) {
+				try {
+					const item = JSON.parse(decodeURIComponent(options.data));
+					this.model1 = { ...item }; // 填充表单数据
+					this.yuyueTime = item.foundTime
+					this.fileList = item.image ? [{ url: item.image, status: 'success', name: 'image' }] : [];
+				} catch (e) {
+					console.error('解析参数失败', e);
+				}
+			}
+		},
+		methods: {
+			submit() {
+				this.show = true
+			},
+			timeConfirm(e) {
+				console.log(e, e.year);
+				this.yuyueTime = e.year + '/' + e.month + '/' + e.day + '/' + '' + e.hour + ':' + e.minute
+			},
+			openTime() {
+				this.Timeshow = true
+				console.log('123123123');
+			}
+		}
+	}
+</script>
+
+<style scoped>
+	.feedback-textare {
+		height: 200upx;
+		font-size: 24upx;
+		line-height: 50upx;
+		width: 100%;
+		box-sizing: border-box;
+		padding: 20upx 20upx 0;
+		border: #e4e7ed 1rpx solid;
+		background: #fff;
+		border-radius: 15rpx;
+		/* margin-top: 20rpx; */
+	}
+	
+	.pay_btns {
+		width: calc(100% - 60rpx);
+		margin: 0 auto 40rpx;
+		text-align: center;
+		background: #00c18a;
+		height: 80rpx;
+		border-radius: 16rpx;
+		color: #ffffff;
+		line-height: 80rpx;
+		margin-top: 20rpx;
+		position: fixed;
+		bottom: 0rpx;
+	}
+	
+	.pay_btns1 {
+		width: calc(100% - 60rpx);
+		margin: 0rpx auto 40rpx;
+		text-align: center;
+		background: #e8fbf6;
+		height: 80rpx;
+		border-radius: 16rpx;
+		line-height: 80rpx;
+		margin-top: 20rpx;
+		position: absolute;
+		top: 20rpx;
+		left: 30rpx;
+	}
+	
+	.pay_btns2 {
+		width: calc(100% - 60rpx);
+		margin: 0rpx auto 40rpx;
+		text-align: center;
+		background: #fee8d9;
+		height: 80rpx;
+		border-radius: 16rpx;
+		line-height: 80rpx;
+		margin-top: 20rpx;
+		position: absolute;
+		bottom: 0rpx;
+		left: 30rpx;
+	}
+	
+	/deep/ .u-flex {
+		background: #fff !important;
+	}
+</style>

+ 19 - 0
pages.json

@@ -442,6 +442,25 @@
 				"style": {
 					"navigationBarTitleText": "安全考试"
 				}
+			}, {
+				"path": "setting/LostandFound",
+				"style": {
+					"navigationBarTitleText": "",
+					"navigationStyle": "custom",
+					"enablePullDownRefresh": false
+				}
+			}, {
+				"path": "setting/LostandFoundadd",
+				"style": {
+					"navigationBarTitleText": "发布招领物品信息",
+					"enablePullDownRefresh": false
+				}
+			},{
+				"path": "setting/LostandFoundtext",
+				"style": {
+					"navigationBarTitleText": "物品信息",
+					"enablePullDownRefresh": false
+				}
 			}
 		]
 	}],

+ 1 - 1
pages/riderMy/index.vue

@@ -188,7 +188,7 @@
 					<view class="text-sm">紧急联系人</view>
 					<!-- <view class="weinumber" v-if="order&&order.jxzOrders">{{order.jxzOrders}}</view> -->
 				</view>
-				<view class="text-center margin-tb-sm"  style="width: 20%;">
+				<view class="text-center margin-tb-sm"  style="width: 20%;" @click="navgo('/my/setting/LostandFound')">
 					<image v-if="globalImages" :src="globalImages + 'imgs/shuwu.png'" style="width: 56rpx;height: 56rpx;" mode=""></image>
 					<view class="text-sm">失物招领</view>
 					<!-- <view class="weinumber" v-if="order&&order.dzfOrders">{{order.dzfOrders}}</view> -->