From 1fb1e9e3321102d23997551be7a5ad7d91b74015 Mon Sep 17 00:00:00 2001
From: MrShi <1878285526@qq.com>
Date: 星期四, 17 七月 2025 15:28:25 +0800
Subject: [PATCH] 对接口,新建富文本页面

---
 small-program/pages/index/index.vue |  129 ++++++++++++++++++++++++++++++------------
 1 files changed, 91 insertions(+), 38 deletions(-)

diff --git a/small-program/pages/index/index.vue b/small-program/pages/index/index.vue
index 5fc9317..02cd67c 100644
--- a/small-program/pages/index/index.vue
+++ b/small-program/pages/index/index.vue
@@ -1,7 +1,7 @@
 <template>
 	<view class="index">
 		<!-- 鎺ュ崟鏂� -->
-		<view class="index-j" v-if="type === 1">
+		<view class="index-j" v-if="typeViewId === 1">
 			<view class="index-j-head">
 				<view :style="{ width: '100%', height: statusbarHeight + 'px' }"></view>
 				<view class="index-c-title" :style="{ height: navHeight + 'px' }">
@@ -125,10 +125,11 @@
 				</view>
 			</view>
 		</view>
+		
 		<!-- 鍙戝崟鏂� -->
-		<view class="index-c" v-if="type === 0">
+		<view class="index-c" v-if="typeViewId === 0">
 			<view :style="{ width: '100%', height: statusbarHeight + 'px' }"></view>
-			<view class="index-c-title" :style="{ height: navHeight + 'px' }">
+			<view class="index-c-title" :style="{ height: navHeight + 'px' }" @click="selectAddress">
 				<text class="index-c-title-logo">杩戝揩</text>
 				<image class="dingwei" src="/static/icon/home_ic_location@2x.png" mode="widthFix"></image>
 				<text>瑗挎箹鍥介檯骞垮満</text>
@@ -145,7 +146,7 @@
 				</view>
 			</view>
 			
-			<template v-if="typeId === 3">
+			<template v-if="typeId === 2">
 				<view class="list">
 					<view class="list-item">
 						<view class="list-item-label">鏃堕棿鍦扮偣</view>
@@ -298,43 +299,43 @@
 				</view>
 			</template>
 			
-			<view class="box" v-if="typeId !== 3">
+			<view class="box" v-if="typeId !== 2">
 				<view class="box-hz" :style="{ minHeight: 'calc(100vh - env(safe-area-inset-bottom) - 94rpx - ' + ((navHeight + statusbarHeight) + 'px') + ')' }">
 					
 					<!-- 鐢ㄥ伐 -->
-					<template v-if="typeId === 1">
+					<template v-if="typeId === 0">
 						<view class="box-hz-cate">
-							<view :class="typeWorkId === item.id ? 'box-hz-cate-item active' : 'box-hz-cate-item'" v-for="(item, index) in typeWork" :key="index" @click="clickTypeWork(item.id)">
+							<view :class="form.workType === item.id ? 'box-hz-cate-item active' : 'box-hz-cate-item'" v-for="(item, index) in typeWork" :key="index" @click="clickTypeWork(item.id)">
 								<text>{{item.name}}</text>
-								<view class="box-hz-cate-item-x" v-if="typeWorkId === item.id"></view>
+								<view class="box-hz-cate-item-x" v-if="form.workType === item.id"></view>
 							</view>
 						</view>
 						<view class="box-hz-list">
-							<view class="box-hz-list-item">
+							<view class="box-hz-list-item" @click="show = true">
 								<view class="box-hz-list-item-label"><text>鐢ㄥ伐鏃堕棿锛�</text></view>
-								<view class="box-hz-list-item-val">
+								<view :class="form.startDate ? 'box-hz-list-item-val active' : 'box-hz-list-item-val'">
 									<view class="box-hz-list-item-val-left">
 										<image class="icon" src="/static/icon/ic_time@2x.png" mode="widthFix"></image>
-										<text>璇烽�夋嫨鐢ㄥ伐鏃堕棿</text>
+										<text>{{ form.startDate ? form.startDate + ' 鑷� ' + form.endDate : '璇烽�夋嫨鐢ㄥ伐鏃堕棿'}}</text>
 									</view>
-									<image class="icon1" src="/static/icon/home_ar_next@2x.png" mode="widthFix"></image>
+									<u-icon name="arrow-right" color="#111111" size="16"></u-icon>
 								</view>
 							</view>
-							<view class="box-hz-list-item">
+							<view class="box-hz-list-item" @click="selectAddress(1)">
 								<view class="box-hz-list-item-label"><text>鐢ㄥ伐鍦扮偣锛�</text></view>
-								<view class="box-hz-list-item-val">
+								<view :class="form.address ? 'box-hz-list-item-val active' :'box-hz-list-item-val'">
 									<view class="box-hz-list-item-val-left">
 										<image class="icon" src="/static/icon/ic_location@2x.png" mode="widthFix"></image>
-										<text>璇烽�夋嫨鐢ㄥ伐鍦扮偣</text>
+										<text>{{form.address ? form.address : '璇烽�夋嫨鐢ㄥ伐鍦扮偣'}}</text>
 									</view>
-									<image class="icon1" src="/static/icon/home_ar_next@2x.png" mode="widthFix"></image>
+									<u-icon name="arrow-right" color="#111111" size="16"></u-icon>
 								</view>
 							</view>
 						</view>
 					</template>
 					
 					<!-- 杩愯揣 -->
-					<template v-if="typeId === 2">
+					<template v-if="typeId === 1">
 						<view class="box-hz-cate">
 							<view :class="carId === item.id ? 'box-hz-cate-item active' : 'box-hz-cate-item'" v-for="(item, index) in car" :key="index" @click="clickCar(item.id)">
 								<text>{{item.name}}</text>
@@ -409,6 +410,10 @@
 				</view>
 			</view>
 		</view>
+		
+		<!-- 閫夋嫨鏃ユ湡鑼冨洿 -->
+		<u-calendar :show="show" color="#00BC12" mode="range" @close="show = false" @confirm="confirmDate"></u-calendar>
+		
 	</view>
 </template>
 
@@ -421,58 +426,111 @@
 			...mapState(['navHeight', 'statusbarHeight','userInfo','token','openid'])
 		},
 		onShow(options){
-			this.type = 0
+			this.typeViewId = 0
 			if(this.token &&this.token!='' && this.userInfo && JSON.stringify(this.userInfo) != '{}'){
 				this.isLogin=true
 			}
 			if (this.userInfo && this.userInfo.useIdentity == 1) {
-				this.type =1
+				this.typeViewId = 1
 			} 
 		},
 		data() {
 			return {
+				show: false,
 				isLogin: false,
-				typeId: 1,
-				typeWorkId: 1,
+				typeId: 0,
 				carId: 1,
 				type: [
-					{ name: '鐢ㄥ伐', id: 1 },
-					{ name: '杩愯揣', id: 2 },
-					{ name: '璁㈤', id: 3 }
+					{ name: '鐢ㄥ伐', id: 0 },
+					{ name: '杩愯揣', id: 1 },
+					{ name: '璁㈤', id: 2 }
 				],
 				typeWork: [
-					{ name: '閲囨憳宸�', id: 1 },
-					{ name: '鍒嗘嫞宸�', id: 2 },
-					{ name: '鍖呰宸�', id: 3 }
+					{ name: '閲囨憳宸�', id: 0 },
+					{ name: '鍒嗘嫞宸�', id: 1 },
+					{ name: '鍖呰宸�', id: 2 }
 				],
 				car: [
 					{ name: '涓夎疆杞�', id: 1 },
 					{ name: '灏忚揣杞�', id: 2 }
 				],
 				btn: require('@/static/image/btn.png'),
-				type: 0
+				typeViewId: 0,
+				
+				form: {
+					startDate: '',
+					endDate: '',
+					latitude: '',
+					longitude: '',
+					address: '',
+					workType: 0,
+					days: ''
+				}
 			}
 		},
 		methods: {
+			confirmDate(e) {
+				this.form.startDate = e[0]
+				this.form.endDate = e[e.length - 1]
+				this.form.days = e.length;
+				this.show = false
+			},
+			selectAddress(type) {
+				uni.chooseLocation({
+					success: (res) => {
+						if (type === 1) {
+							this.form.latitude = res.latitude
+							this.form.longitude = res.longitude
+							this.form.address = res.address
+						}
+					}
+				});
+				// uni.getLocation({
+				// 	type: 'gcj02',
+				// 	success: function (res) {
+				// 		console.log(res)
+				// 	}
+				// });
+			},
 			clickType(e) {
 				this.typeId = e
 			},
 			clickTypeWork(e) {
-				this.typeWorkId = e
+				this.form.workType = e
 			},
 			clickCar(e) {
 				this.carId = e
 			},
 			jump() {
-				console.log(this.userInfo,this.token,this.openid)
-				if(!this.userInfo  ||!this.token  ){
+				if(!this.userInfo || !this.token){
 					uni.navigateTo({
 						url: '/pages/login/login'
 					})
+					return
 				}
-				if (this.typeId === 1) {
+				
+				const { form } = this;
+				
+				if (!form.startDate || !form.endDate) {
+					return uni.showToast({ title: '璇烽�夋嫨鐢ㄥ伐鏃堕棿', icon: 'none' })
+				} else if (!form.latitude || !form.longitude) {
+					return uni.showToast({ title: '璇烽�夋嫨鐢ㄥ伐鍦扮偣', icon: 'none' })
+				}
+				
+				// 閲囨憳宸�
+				if (this.form.workType === 0) {
 					uni.navigateTo({
-						url: '/pages/using-workers/using-workers'
+						url: `/pages/using-workers/using-workers?days=${form.days}&startDate=${form.startDate}&endDate=${form.endDate}&latitude=${form.latitude}&longitude=${form.longitude}&address=${form.address}&workType=${form.workType}`
+					})
+				// 鍒嗘嫞宸�
+				} else if (this.form.workType === 1) {
+					uni.navigateTo({
+						url: `/pages/sorting/sorting?days=${form.days}&startDate=${form.startDate}&endDate=${form.endDate}&latitude=${form.latitude}&longitude=${form.longitude}&address=${form.address}&workType=${form.workType}`
+					})
+				// 鍖呰宸�
+				} else if (this.form.workType === 2) {
+					uni.navigateTo({
+						url: `/pages/packaging-worker/packaging-worker?days=${form.days}&startDate=${form.startDate}&endDate=${form.endDate}&latitude=${form.latitude}&longitude=${form.longitude}&address=${form.address}&workType=${form.workType}`
 					})
 				}
 			},
@@ -1275,11 +1333,6 @@
 										font-size: 32rpx;
 										color: #111111;
 									}
-								}
-								.icon1 {
-									flex-shrink: 0;
-									width: 30rpx;
-									height: 30rpx;
 								}
 							}
 						}

--
Gitblit v1.9.3