Commit f3540216f4ad5ac8cd451b5ddbec94420840fe81

Authored by lichao
1 parent 8e19ef49

用户问题调整

Too many changes to show.

To preserve performance only 7 of 8 files are displayed.

garbage-removal/.env.local
1 -VITE_BASE_URL=http://192.169.1.97:8080/workflow 1 +VITE_BASE_URL=http://192.169.1.90:8080/workflow
2 VITE_BASE_FILE_UPLOAD_PREFIX=/order/upload 2 VITE_BASE_FILE_UPLOAD_PREFIX=/order/upload
3 -VITE_STOMP_URL=http://192.169.1.97:8080/ws 3 +VITE_STOMP_URL=http://192.169.1.90:8080/ws
garbage-removal/src/pages/login/code.vue
@@ -71,7 +71,7 @@ const noCaptcha = () => { @@ -71,7 +71,7 @@ const noCaptcha = () => {
71 // 校验验证码 71 // 校验验证码
72 const checkVerifyNum = (code) => { 72 const checkVerifyNum = (code) => {
73 userLogin({ loginType: 0, tel: iphoneNumber.value, code: code }).then(res => { 73 userLogin({ loginType: 0, tel: iphoneNumber.value, code: code }).then(res => {
74 - // console.log(res); 74 + console.log(res);
75 // 登录成功 75 // 登录成功
76 if (res.data.code===200) { 76 if (res.data.code===200) {
77 verifyFlag.value = false; 77 verifyFlag.value = false;
@@ -79,7 +79,8 @@ const checkVerifyNum = (code) => { @@ -79,7 +79,8 @@ const checkVerifyNum = (code) => {
79 if (res.data.data.token) { 79 if (res.data.data.token) {
80 setRequestToken(res.data.data.token) 80 setRequestToken(res.data.data.token)
81 } 81 }
82 - store.userName = res.data.data.name; 82 + store.userInfo = {};
  83 + store.userName = res.data.data.name !=null ? res.data.data.name : "";
83 store.userInfo.userName = res.data.data.name; 84 store.userInfo.userName = res.data.data.name;
84 store.userPhone = res.data.data.loginPhone; 85 store.userPhone = res.data.data.loginPhone;
85 if(res.data.data.testUser){ 86 if(res.data.data.testUser){
garbage-removal/src/pages/order-info/order-driver/detail/index.vue
@@ -142,9 +142,13 @@ @@ -142,9 +142,13 @@
142 </view> 142 </view>
143 <view class="order-detail-container-header-item"> 143 <view class="order-detail-container-header-item">
144 <text class=" order-detail-container-header-title">装车照片:</text> 144 <text class=" order-detail-container-header-title">装车照片:</text>
145 - <view class="order-detail-container-header-content">  
146 - <u-upload width="180" height="130" :fileList="putOnImages" name="3" multiple :maxCount="20"  
147 - :previewFullImage="true" :isReadOnly="true"></u-upload> 145 +
  146 + <view class="order-detail-container-header-content" style="flex-direction: column;">
  147 + <view v-for="group in putOnImagesGrouped" :key="group.index" class="image-group">
  148 + <view class="image-group-title">第 {{ group.index }} 次上传</view>
  149 + <u-upload width="180" height="130" :fileList="group.images" name="3" multiple :maxCount="20"
  150 + :previewFullImage="true" :isReadOnly="true"></u-upload>
  151 + </view>
148 </view> 152 </view>
149 </view> 153 </view>
150 <!-- <view class="order-detail-container-header-item"> 154 <!-- <view class="order-detail-container-header-item">
@@ -179,9 +183,13 @@ @@ -179,9 +183,13 @@
179 <u-button @click="handleOrder(orderId)" 183 <u-button @click="handleOrder(orderId)"
180 v-if="dataGram.garOrderHandlerStatus === 0 && dataGram.handleFlag && dataGram.garCancelFlag === 0 && userType === '运输企业负责人'" 184 v-if="dataGram.garOrderHandlerStatus === 0 && dataGram.handleFlag && dataGram.garCancelFlag === 0 && userType === '运输企业负责人'"
181 shape="square" color="#a9e08f" text="处理订单"></u-button> 185 shape="square" color="#a9e08f" text="处理订单"></u-button>
  186 +
  187 +
182 <u-button @click="handleUploadImage(orderId, 'putOnImages')" 188 <u-button @click="handleUploadImage(orderId, 'putOnImages')"
183 v-if="dataGram.garOrderHandlerStatus === 1 && dataGram.garCancelFlag === 0 && userType === '清运车辆驾驶员'" 189 v-if="dataGram.garOrderHandlerStatus === 1 && dataGram.garCancelFlag === 0 && userType === '清运车辆驾驶员'"
184 shape="square" color="#a9e08f" text="上传图片"></u-button> 190 shape="square" color="#a9e08f" text="上传图片"></u-button>
  191 +
  192 +
185 <u-button @click="handleEvaluate(orderId, userType)" 193 <u-button @click="handleEvaluate(orderId, userType)"
186 v-if="dataGram.garEvaluateFlag === 0 && userType === '用户'" shape="square" color="#a9e08f" 194 v-if="dataGram.garEvaluateFlag === 0 && userType === '用户'" shape="square" color="#a9e08f"
187 text="去评价"></u-button> 195 text="去评价"></u-button>
@@ -220,6 +228,7 @@ const dataGram = ref(); @@ -220,6 +228,7 @@ const dataGram = ref();
220 const orderId = ref(null) 228 const orderId = ref(null)
221 const currentImages = ref([]) 229 const currentImages = ref([])
222 const putOnImages = ref([]) 230 const putOnImages = ref([])
  231 +const putOnImagesGrouped = ref([]) // 新增这个变量
223 const putDownImages = ref([]) 232 const putDownImages = ref([])
224 const emptyBase64Image = ref(zStatic.base64Empty) 233 const emptyBase64Image = ref(zStatic.base64Empty)
225 const showUQRcode = ref(false) 234 const showUQRcode = ref(false)
@@ -282,13 +291,44 @@ const selectClick = (index) =&gt; { @@ -282,13 +291,44 @@ const selectClick = (index) =&gt; {
282 const handleOrderDetail = (orderId) => { 291 const handleOrderDetail = (orderId) => {
283 queryOrderDetail(orderId).then(res => { 292 queryOrderDetail(orderId).then(res => {
284 dataGram.value = res.data.data; 293 dataGram.value = res.data.data;
285 - console.log(res.data.data);  
286 currentImages.value = res.data.data.currentImages.map(item => { 294 currentImages.value = res.data.data.currentImages.map(item => {
287 - return { url: import.meta.env.VITE_BASE_URL + item }; 295 + return { url: import.meta.env.VITE_BASE_URL + item};
288 }); 296 });
  297 +
289 putOnImages.value = res.data.data.putOnImages.map(item => { 298 putOnImages.value = res.data.data.putOnImages.map(item => {
290 - return { url: import.meta.env.VITE_BASE_URL + item }; 299 + const newItem = item.substring(0, item.length - 6);
  300 + const newIndex = item.substring(item.length - 6);
  301 + return { url: import.meta.env.VITE_BASE_URL + newItem, newIndex };
  302 + });
  303 +
  304 +
  305 + // 按照newIndex升序排序
  306 + putOnImages.value.sort((a, b) => {
  307 + return parseInt(a.newIndex) - parseInt(b.newIndex);
  308 + });
  309 +
  310 + // 重新组织数据,将相同newIndex的图片放在一起
  311 + const groupedImages = {};
  312 + putOnImages.value.forEach(item => {
  313 + if (!groupedImages[item.newIndex]) {
  314 + groupedImages[item.newIndex] = [];
  315 + }
  316 + groupedImages[item.newIndex].push(item);
  317 + });
  318 +
  319 + // 转换newIndex为1,2,3的连续数字
  320 + const sortedKeys = Object.keys(groupedImages).sort((a, b) => parseInt(a) - parseInt(b));
  321 + const newGroupedImages = {};
  322 + sortedKeys.forEach((key, index) => {
  323 + newGroupedImages[index + 1] = groupedImages[key];
291 }); 324 });
  325 +
  326 + // 转换为数组形式,方便在模板中遍历
  327 + putOnImagesGrouped.value = Object.keys(newGroupedImages).map(key => ({
  328 + index: key,
  329 + images: newGroupedImages[key]
  330 + }));
  331 + console.log('putOnImagesGrouped.value:', putOnImagesGrouped.value);
292 putDownImages.value = res.data.data.putDownImages.map(item => { 332 putDownImages.value = res.data.data.putDownImages.map(item => {
293 return { url: import.meta.env.VITE_BASE_URL + item }; 333 return { url: import.meta.env.VITE_BASE_URL + item };
294 }); 334 });
@@ -373,7 +413,13 @@ const cleanStatus = (status) =&gt; { @@ -373,7 +413,13 @@ const cleanStatus = (status) =&gt; {
373 const createQrCodeValid = (val) => { 413 const createQrCodeValid = (val) => {
374 createHandlerQrCode(val).then(res => { 414 createHandlerQrCode(val).then(res => {
375 // 获取本地地址拼接订单id 415 // 获取本地地址拼接订单id
376 - showUQRcode.value = true; 416 + //修改点
  417 + if(putOnImages.value.length == 0){
  418 + uni.$u.toast('请先上传装车图片');
  419 + }else{
  420 + console.log('putOnImages:', putOnImages.value);
  421 + showUQRcode.value = true;
  422 + }
377 // const localAddress = `http://localhost:5173`; 423 // const localAddress = `http://localhost:5173`;
378 qrCodeText.value = res.data.data; 424 qrCodeText.value = res.data.data;
379 }) 425 })
@@ -383,6 +429,7 @@ const createQrCodeValid = (val) =&gt; { @@ -383,6 +429,7 @@ const createQrCodeValid = (val) =&gt; {
383 * @param {string} orderId 429 * @param {string} orderId
384 * @param {string} putType 430 * @param {string} putType
385 */ 431 */
  432 +
386 const handleUploadImage = (orderId, putType) => { 433 const handleUploadImage = (orderId, putType) => {
387 const data = dataGram.value; 434 const data = dataGram.value;
388 uni.showActionSheet({ 435 uni.showActionSheet({
@@ -578,4 +625,22 @@ $custom-bottom-height: 200rpx; @@ -578,4 +625,22 @@ $custom-bottom-height: 200rpx;
578 align-items: center; 625 align-items: center;
579 justify-content: center; 626 justify-content: center;
580 } 627 }
  628 +.image-group {
  629 + margin-bottom: 20px;
  630 + padding: 10px;
  631 + background-color: #f5f5f5;
  632 + border-radius: 5px;
  633 +}
  634 +
  635 +.image-group-title {
  636 + margin-bottom: 10px;
  637 + font-weight: bold;
  638 + color: #333;
  639 +}
  640 +
  641 +/* 确保u-upload组件内的图片水平排列 */
  642 +.image-group .u-upload {
  643 + display: flex;
  644 + flex-wrap: wrap;
  645 +}
581 </style> 646 </style>
garbage-removal/src/pages/order-info/order-driver/upload/index.vue
@@ -89,51 +89,90 @@ @@ -89,51 +89,90 @@
89 } 89 }
90 // 新增图片 90 // 新增图片
91 const afterRead = async (event) => { 91 const afterRead = async (event) => {
92 - // 获取定位信息  
93 - takeLocation();  
94 - // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式  
95 - let lists = [].concat(event.file);  
96 - let fileListLen = fileList.value.length;  
97 - lists.map((item) => {  
98 - fileList.value.push({  
99 - ...item,  
100 - status: 'uploading',  
101 - message: '上传中',  
102 - }); 92 + // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
  93 + let lists = [].concat(event.file);
  94 + let fileListLen = fileList.value.length;
  95 + lists.map((item) => {
  96 + fileList.value.push({
  97 + ...item,
  98 + status: 'uploading',
  99 + message: '上传中',
103 }); 100 });
104 - // 将blob转为file对象的方法  
105 - function blobToFile(blob, fileName) {  
106 - return new File([blob], fileName, {  
107 - type: 'image/png'  
108 - })  
109 - }  
110 - for (let i = 0; i < lists.length; i++) {  
111 - // 获取blob对象  
112 - fetch(lists[i].url)  
113 - .then(response => response.blob())  
114 - .then(blob => {  
115 - // 将blob转换为file  
116 - let fileN = blobToFile(blob, lists[i].name)  
117 - // 上传file对象  
118 - let requestPath = import.meta.env.VITE_BASE_URL + import.meta.env  
119 - .VITE_BASE_FILE_UPLOAD_PREFIX;  
120 - uploadFilePromise(requestPath, fileN).then(result => {  
121 - let item = fileList.value[fileListLen];  
122 - fileList.value.splice(fileListLen, 1, {  
123 - ...item,  
124 - status: 'success',  
125 - message: '',  
126 - url: result.data.fileName,  
127 - });  
128 - fileListLen++;  
129 - }); 101 + });
130 102
131 - })  
132 - } 103 + for (let i = 0; i < lists.length; i++) {
  104 + // 图片压缩逻辑
  105 + const compressImage = async (file) => {
  106 + return new Promise((resolve) => {
  107 + // 创建图片对象
  108 + const img = new Image();
  109 + img.onload = () => {
  110 + // 创建canvas
  111 + const canvas = document.createElement('canvas');
  112 + const ctx = canvas.getContext('2d');
  113 +
  114 + // 设置压缩后的宽度和高度
  115 + const maxWidth = 800;
  116 + const maxHeight = 600;
  117 + let width = img.width;
  118 + let height = img.height;
  119 +
  120 + // 计算压缩后的尺寸
  121 + if (width > maxWidth) {
  122 + height = Math.round((height * maxWidth) / width);
  123 + width = maxWidth;
  124 + }
  125 + if (height > maxHeight) {
  126 + width = Math.round((width * maxHeight) / height);
  127 + height = maxHeight;
  128 + }
  129 +
  130 + // 设置canvas尺寸
  131 + canvas.width = width;
  132 + canvas.height = height;
  133 +
  134 + // 绘制图片
  135 + ctx.drawImage(img, 0, 0, width, height);
  136 +
  137 + // 转换为blob
  138 + canvas.toBlob(
  139 + (blob) => {
  140 + // 转换为file
  141 + const compressedFile = new File([blob], file.name, {
  142 + type: 'image/jpeg',
  143 + });
  144 + resolve(compressedFile);
  145 + },
  146 + 'image/jpeg',
  147 + 0.6 // 压缩质量 0-1
  148 + );
  149 + };
  150 + img.src = file.url;
  151 + });
  152 + };
  153 +
  154 + // 压缩图片
  155 + const compressedFile = await compressImage(lists[i]);
  156 +
  157 + // 上传压缩后的文件
  158 + let requestPath = import.meta.env.VITE_BASE_URL + import.meta.env
  159 + .VITE_BASE_FILE_UPLOAD_PREFIX;
  160 + uploadFilePromise(requestPath, compressedFile).then(result => {
  161 + let item = fileList.value[fileListLen];
  162 + fileList.value.splice(fileListLen, 1, {
  163 + ...item,
  164 + status: 'success',
  165 + message: '',
  166 + url: result.data.fileName,
  167 + });
  168 + fileListLen++;
  169 + });
  170 + }
133 }; 171 };
134 // 提交图片 172 // 提交图片
135 const handleSubmit = async (id, type, driver, carPlate) => { 173 const handleSubmit = async (id, type, driver, carPlate) => {
136 174
  175 +
137 if (!validateImage()) { 176 if (!validateImage()) {
138 uni.$u.toast("请等待图片上传~") 177 uni.$u.toast("请等待图片上传~")
139 return 178 return
@@ -225,6 +264,8 @@ @@ -225,6 +264,8 @@
225 driver.value = options.driver; 264 driver.value = options.driver;
226 console.log(options.putType); 265 console.log(options.putType);
227 putType.value = options.putType === "putOnImages" ? "装车图片" : "卸车图片"; 266 putType.value = options.putType === "putOnImages" ? "装车图片" : "卸车图片";
  267 + // 获取定位信息
  268 + takeLocation();
228 }) 269 })
229 </script> 270 </script>
230 271
garbage-removal/src/pages/order-info/order-other/detail/index.vue
@@ -182,9 +182,12 @@ @@ -182,9 +182,12 @@
182 <view v-if="putDownImages.length || putOnImages.length" style="width: 100%;"> 182 <view v-if="putDownImages.length || putOnImages.length" style="width: 100%;">
183 <view class="order-detail-container-header-item"> 183 <view class="order-detail-container-header-item">
184 <text class=" order-detail-container-header-title">装车照片:</text> 184 <text class=" order-detail-container-header-title">装车照片:</text>
185 - <view class="order-detail-container-header-content">  
186 - <u-upload width="180" height="130" :fileList="putOnImages" name="3" multiple :maxCount="20" 185 + <view class="order-detail-container-header-content" style="flex-direction: column">
  186 + <view v-for="group in putOnImagesGrouped" :key="group.index" class="image-group">
  187 + <view class="image-group-title">第 {{ group.index }} 次上传</view>
  188 + <u-upload width="180" height="130" :fileList="group.images" name="3" multiple :maxCount="20"
187 :previewFullImage="true" :isReadOnly="true"></u-upload> 189 :previewFullImage="true" :isReadOnly="true"></u-upload>
  190 + </view>
188 </view> 191 </view>
189 </view> 192 </view>
190 <!-- <view class="order-detail-container-header-item"> 193 <!-- <view class="order-detail-container-header-item">
@@ -299,6 +302,7 @@ @@ -299,6 +302,7 @@
299 const orderId = ref(null) 302 const orderId = ref(null)
300 const currentImages = ref([]) 303 const currentImages = ref([])
301 const putOnImages = ref([]) 304 const putOnImages = ref([])
  305 + const putOnImagesGrouped = ref([]) // 新增这个变量
302 const putDownImages = ref([]) 306 const putDownImages = ref([])
303 const emptyBase64Image = ref(zStatic.base64Empty) 307 const emptyBase64Image = ref(zStatic.base64Empty)
304 const showUQRcode = ref(false) 308 const showUQRcode = ref(false)
@@ -419,17 +423,44 @@ @@ -419,17 +423,44 @@
419 const handleOrderDetail = (orderId) => { 423 const handleOrderDetail = (orderId) => {
420 queryOrderDetail(orderId).then(res => { 424 queryOrderDetail(orderId).then(res => {
421 dataGram.value = res.data.data; 425 dataGram.value = res.data.data;
422 - console.log(res.data.data);  
423 currentImages.value = res.data.data.currentImages.map(item => { 426 currentImages.value = res.data.data.currentImages.map(item => {
424 return { 427 return {
425 url: import.meta.env.VITE_BASE_URL + item 428 url: import.meta.env.VITE_BASE_URL + item
426 }; 429 };
427 }); 430 });
428 putOnImages.value = res.data.data.putOnImages.map(item => { 431 putOnImages.value = res.data.data.putOnImages.map(item => {
429 - return {  
430 - url: import.meta.env.VITE_BASE_URL + item  
431 - }; 432 + const newItem = item.substring(0, item.length - 6);
  433 + const newIndex = item.substring(item.length - 6);
  434 + return { url: import.meta.env.VITE_BASE_URL + newItem, newIndex };
  435 + });
  436 +
  437 + // 按照newIndex升序排序
  438 + putOnImages.value.sort((a, b) => {
  439 + return parseInt(a.newIndex) - parseInt(b.newIndex);
  440 + });
  441 +
  442 + // 重新组织数据,将相同newIndex的图片放在一起
  443 + const groupedImages = {};
  444 + putOnImages.value.forEach(item => {
  445 + if (!groupedImages[item.newIndex]) {
  446 + groupedImages[item.newIndex] = [];
  447 + }
  448 + groupedImages[item.newIndex].push(item);
432 }); 449 });
  450 +
  451 + // 转换newIndex为1,2,3的连续数字
  452 + const sortedKeys = Object.keys(groupedImages).sort((a, b) => parseInt(a) - parseInt(b));
  453 + const newGroupedImages = {};
  454 + sortedKeys.forEach((key, index) => {
  455 + newGroupedImages[index + 1] = groupedImages[key];
  456 + });
  457 +
  458 + // 转换为数组形式,方便在模板中遍历
  459 + putOnImagesGrouped.value = Object.keys(newGroupedImages).map(key => ({
  460 + index: key,
  461 + images: newGroupedImages[key]
  462 + }));
  463 + console.log('putOnImagesGrouped.value:', putOnImagesGrouped.value);
433 putDownImages.value = res.data.data.putDownImages.map(item => { 464 putDownImages.value = res.data.data.putDownImages.map(item => {
434 return { 465 return {
435 url: import.meta.env.VITE_BASE_URL + item 466 url: import.meta.env.VITE_BASE_URL + item
@@ -953,4 +984,22 @@ @@ -953,4 +984,22 @@
953 } 984 }
954 } 985 }
955 } 986 }
  987 + .image-group {
  988 + margin-bottom: 20px;
  989 + padding: 10px;
  990 + background-color: #f5f5f5;
  991 + border-radius: 5px;
  992 + }
  993 +
  994 + .image-group-title {
  995 + margin-bottom: 10px;
  996 + font-weight: bold;
  997 + color: #333;
  998 + }
  999 +
  1000 +/* 确保u-upload组件内的图片水平排列 */
  1001 + .image-group .u-upload {
  1002 + display: flex;
  1003 + flex-wrap: wrap;
  1004 + }
956 </style> 1005 </style>
957 \ No newline at end of file 1006 \ No newline at end of file
garbage-removal/src/stores/main.js
@@ -6,10 +6,12 @@ export const useMainStore = defineStore( @@ -6,10 +6,12 @@ export const useMainStore = defineStore(
6 const token = ref(null); 6 const token = ref(null);
7 const tempToken = ref(null); 7 const tempToken = ref(null);
8 const userType = ref("") 8 const userType = ref("")
9 - const userInfo = ref("")  
10 - const userPhone = ref(""); 9 + const userInfo = ref({})
  10 + // 或者保留初始对象定义,添加数据验证
  11 + const userPhone = ref("");
  12 + const userName = ref("");
11 13
12 - return { token,tempToken,userType,userInfo,userPhone }; 14 + return { token,tempToken,userType,userInfo,userPhone,userName };
13 }, 15 },
14 { 16 {
15 persist: { 17 persist: {
garbage-removal/vite.config.js
@@ -8,7 +8,7 @@ export default defineConfig({ @@ -8,7 +8,7 @@ export default defineConfig({
8 plugins: [ 8 plugins: [
9 uni(), 9 uni(),
10 //本地环境开启https 10 //本地环境开启https
11 - basicSsl() 11 + // basicSsl()
12 ], 12 ],
13 resolve: { 13 resolve: {
14 alias: { 14 alias: {
@@ -19,6 +19,6 @@ export default defineConfig({ @@ -19,6 +19,6 @@ export default defineConfig({
19 server: { 19 server: {
20 port: 9000, 20 port: 9000,
21 //本地环境开启https 21 //本地环境开启https
22 - https: true 22 + // https: true
23 } 23 }
24 }) 24 })