From cf186b0a4de01261dea0870fd2a9529b5baee4e6 Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期五, 18 七月 2025 10:58:36 +0800
Subject: [PATCH] 前端
---
small-program/pages/index/index.vue | 272 ++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 204 insertions(+), 68 deletions(-)
diff --git a/small-program/pages/index/index.vue b/small-program/pages/index/index.vue
index 25baa21..e775a3e 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,103 +299,102 @@
</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.location ? '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.location ? form.location : '璇烽�夋嫨鐢ㄥ伐鍦扮偣'}}</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)">
+ <view :class="form.categoryId === item.id ? 'box-hz-cate-item active' : 'box-hz-cate-item'" v-for="(item, index) in car" :key="index" @click="clickCar(item)">
<text>{{item.name}}</text>
- <view class="box-hz-cate-item-x" v-if="carId === item.id"></view>
+ <view class="box-hz-cate-item-x" v-if="form.categoryId === item.id"></view>
</view>
</view>
<view class="box-hz-car">
<view class="box-hz-car-image">
- <image src="/static/image/ic_sanlunche@2x.png" mode="widthFix" v-if="carId === 1"></image>
- <image src="/static/image/ic_xiaohuoche@2x.png" mode="widthFix" v-else-if="carId === 2"></image>
+ <image :src="carImage" mode="widthFix"></image>
</view>
- <view class="box-hz-car-info" v-if="carId === 1">
- 鍘㈤暱3.8锝�4.0绫� 杞介噸1.5锝�2.0鍚� 杞芥柟12.3锝�18.4鏂�
- </view>
- <view class="box-hz-car-info" v-else-if="carId === 2">
- 鍘㈤暱3.8锝�4.0绫� 杞介噸1.5锝�2.0鍚� 杞芥柟12.3锝�18.4鏂�
+ <view class="box-hz-car-info" v-if="carRemark">
+ {{carRemark || ''}}
</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-label">
<text>鐢ㄨ溅鏃堕棿锛�</text>
- <text>+澧炲姞閫旂粡鐐�</text>
+ <text @click="addAddr">+澧炲姞閫旂粡鐐�</text>
</view>
<view class="item-d">
- <view class="item-d-row">
+ <view class="item-d-row" @click="selectAddress(2)">
<view class="item-d-row-icon">
<image src="/static/icon/ic_qidian@2x.png" mode="widthFix"></image>
</view>
<view class="item-d-row-val">
- <text>璇烽�夋嫨鐢ㄨ溅璧风偣</text>
- <image src="/static/icon/home_ar_next@2x.png" mode="widthFix"></image>
+ <text>{{form.address ? form.address : '璇烽�夋嫨鐢ㄨ溅璧风偣'}}</text>
+ <u-icon name="arrow-right" color="#111111" size="16"></u-icon>
</view>
</view>
- <view class="item-d-row">
+ <view class="item-d-row" v-for="(item, index) in form.wayInfoDTOList" :key="index" @click="selectAddress(4, index)">
<view class="item-d-row-icon">
<image src="/static/icon/ic_jingguo@2x.png" mode="widthFix"></image>
</view>
<view class="item-d-row-val">
- <text style="color: #999999;">璇烽�夋嫨閫旂粡鍦扮偣</text>
- <image src="/static/icon/home_ar_next@2x.png" mode="widthFix"></image>
+ <text>{{item.location ? item.location : '璇烽�夋嫨閫旂粡鍦扮偣'}}</text>
+ <view style="display: flex; align-items: center; flex-shrink: 0;">
+ <image src="/static/icon/ic_delete@2x.png" style="margin-right: 22rpx; width: 32rpx; height: 32rpx;" @click.stop="form.wayInfoDTOList.splice(index, 1)" mode="widthFix"></image>
+ <u-icon name="arrow-right" color="#111111" size="16"></u-icon>
+ </view>
</view>
</view>
- <view class="item-d-row">
+ <view class="item-d-row" @click="selectAddress(3)">
<view class="item-d-row-icon">
<image src="/static/icon/ic_zhongdian@2x.png" mode="widthFix"></image>
</view>
<view class="item-d-row-val">
- <text>璇烽�夋嫨鐢ㄨ溅缁堢偣</text>
- <image src="/static/icon/home_ar_next@2x.png" mode="widthFix"></image>
+ <text>{{form.locationEnd ? form.locationEnd : '璇烽�夋嫨鐢ㄨ溅缁堢偣'}}</text>
+ <u-icon name="arrow-right" color="#111111" size="16"></u-icon>
</view>
</view>
</view>
@@ -409,6 +409,10 @@
</view>
</view>
</view>
+
+ <!-- 閫夋嫨鏃ユ湡鑼冨洿 -->
+ <u-calendar :show="show" color="#00BC12" mode="range" @close="show = false" @confirm="confirmDate"></u-calendar>
+
</view>
</template>
@@ -418,50 +422,181 @@
export default {
components: { sunuiMverify },
computed: {
- ...mapState(['navHeight', 'statusbarHeight'])
+ ...mapState(['navHeight', 'statusbarHeight','userInfo','token','openid'])
+ },
+ onShow(options){
+ 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.typeViewId = 1
+ }
},
data() {
return {
- typeId: 1,
- typeWorkId: 1,
- carId: 1,
+ show: false,
+ isLogin: false,
+ typeId: 0,
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 }
- ],
+ car: [],
btn: require('@/static/image/btn.png'),
- type: 1
+ typeViewId: 0,
+ carImage: '',
+ carRemark: '',
+
+ form: {
+ startDate: '',
+ endDate: '',
+ latitude: '',
+ longitude: '',
+ location: '',
+ locationEnd: '',
+ wayInfoDTOList: [],
+ workType: 0,
+ categoryId: '',
+ categoryName: '',
+ days: ''
+ }
}
},
+ onLoad() {
+ this.getCategoryLists()
+ },
methods: {
+ addAddr() {
+ this.form.wayInfoDTOList.push({
+ lat: '',
+ lgt: '',
+ location: ''
+ })
+ },
+ confirmDate(e) {
+ this.form.startDate = e[0]
+ this.form.endDate = e[e.length - 1]
+ this.form.days = e.length;
+ this.show = false
+ },
+ selectAddress(type, index) {
+ uni.chooseLocation({
+ success: (res) => {
+ if ([1,2].includes(type)) {
+ this.form.latitude = res.latitude
+ this.form.longitude = res.longitude
+ this.form.address = res.address
+ } else if (type === 3) {
+ this.form.locationEnd = res.address
+ this.form.latEnd = res.latitude
+ this.form.lgtEnd = res.longitude
+ } else if (type === 4) {
+ this.form.wayInfoDTOList[0].lat = res.latitude
+ this.form.wayInfoDTOList[0].lgt = res.longitude
+ this.form.wayInfoDTOList[0].location = res.address
+ }
+ }
+ });
+ },
clickType(e) {
this.typeId = e
},
clickTypeWork(e) {
- this.typeWorkId = e
+ this.form.workType = e
},
- clickCar(e) {
- this.carId = e
+ clickCar(item) {
+ this.form.categoryId = item.id
+ this.form.categoryName = item.name
+ this.carImage = item.iconFull
+ this.carRemark = item.remark
},
jump() {
- if (this.typeId === 1) {
+ if(!this.userInfo || !this.token){
uni.navigateTo({
- url: '/pages/using-workers/using-workers'
+ url: '/pages/login/login'
+ })
+ return
+ }
+
+ const { form } = this;
+
+ // 鐢ㄥ伐
+ if (this.typeId === 0) {
+
+ 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?days=${form.days}&startDate=${form.startDate}&endDate=${form.endDate}&latitude=${form.latitude}&longitude=${form.longitude}&address=${form.location}&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.location}&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.location}&workType=${form.workType}`
+ })
+ }
+ // 杩愯揣
+ } else if (this.typeId === 1) {
+
+ if (!form.startDate || !form.endDate) {
+ return uni.showToast({ title: '璇烽�夋嫨鐢ㄨ溅鏃堕棿', icon: 'none' })
+ } else if (!form.latitude || !form.longitude) {
+ return uni.showToast({ title: '璇烽�夋嫨鐢ㄨ溅璧风偣', icon: 'none' })
+ } else if (!form.latEnd || !form.lgtEnd) {
+ return uni.showToast({ title: '璇烽�夋嫨鐢ㄨ溅缁堢偣', icon: 'none' })
+ }
+
+ let carData = {
+ startDate: form.startDate,
+ endDate: form.endDate,
+ lat: form.latitude,
+ lgt: form.longitude,
+ location: form.address,
+ latEnd: form.latEnd,
+ lgtEnd: form.lgtEnd,
+ locationEnd: form.locationEnd,
+ wayInfoDTOList: form.wayInfoDTOList,
+ categoryId: form.categoryId,
+ categoryName: form.categoryName,
+ days: form.days
+ }
+
+ uni.setStorageSync('carData', carData);
+
+ uni.navigateTo({
+ url: `/pages/freight/freight`
})
}
},
mverify(e){
console.log('楠岃瘉缁撴灉:',e);
+ },
+ getCategoryLists() {
+ this.$u.api.getCategoryList({ type: 1 })
+ .then(res => {
+ this.car = res.data
+ this.form.categoryId = res.data[0].id
+ this.form.categoryName = res.data[0].name
+ this.carRemark = res.data[0].remark
+ this.carImage = res.data[0].iconFull
+ })
}
}
}
@@ -1105,9 +1240,12 @@
.box-hz-car-image {
width: 432rpx;
height: 200rpx;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ overflow: hidden;
image {
width: 100%;
- height: 100%;
}
}
.box-hz-car-info {
@@ -1170,7 +1308,8 @@
border: 2rpx solid #FD9E24;
.item-d-row {
width: 100%;
- height: 100rpx;
+ // height: 100rpx;
+ height: auto;
display: flex;
align-items: center;
justify-content: space-between;
@@ -1186,7 +1325,9 @@
}
.item-d-row-val {
flex: 1;
- height: 100%;
+ // height: 100%;
+ padding: 30rpx 0;
+ box-sizing: border-box;
display: flex;
align-items: center;
justify-content: space-between;
@@ -1259,11 +1400,6 @@
font-size: 32rpx;
color: #111111;
}
- }
- .icon1 {
- flex-shrink: 0;
- width: 30rpx;
- height: 30rpx;
}
}
}
--
Gitblit v1.9.3