This commit is contained in:
Leo_Ding 2025-08-07 12:55:52 +08:00
commit eea635e7bd
25 changed files with 949 additions and 836 deletions

View File

@ -1,91 +0,0 @@
<template>
<view class="header">
<view class="header-content">
<view class="left" @click="goBack">
<u-icon name="arrow-left" color="#fff" size="36rpx"></u-icon>
</view>
<view class="center">
<text class="title">{{ title }}</text>
</view>
<view class="right">
<!-- 右侧占位 -->
</view>
</view>
</view>
</template>
<script>
export default {
props: {
title: {
type: String,
default: '标题'
}
},
methods: {
goBack() {
let pages = getCurrentPages(); //
console.log("-----pages",pages)
if (pages.length > 1) {
// 1
uni.navigateBack({
delta: 1
});
} else {
//
uni.showToast({
title: '已经是首页了',
icon: 'none'
});
}
}
}
};
</script>
<style lang="scss" scoped>
.header {
background-color: transparent;
/* 蓝色背景 */
padding: 20rpx 30rpx;
position: fixed;
top: 90rpx;
left: 0;
right: 0;
z-index: 999;
.header-content {
display: flex;
align-items: center;
justify-content: space-between;
.left {
flex: 1;
display: flex;
align-items: center;
.back-icon {
width: 40rpx;
height: 40rpx;
}
}
.center {
flex: 2;
text-align: center;
.title {
color: #2e2e2e;
font-size: 36rpx;
// font-weight: bold;
}
}
.right {
flex: 1;
text-align: right;
}
}
}
</style>

View File

@ -10,6 +10,10 @@
"usingComponents" : true, "usingComponents" : true,
"nvueStyleCompiler" : "uni-app", "nvueStyleCompiler" : "uni-app",
"compilerVersion" : 3, "compilerVersion" : 3,
"permissions": [
"camera",
"album"
],
"splashscreen" : { "splashscreen" : {
"alwaysShowBeforeRender" : true, "alwaysShowBeforeRender" : true,
"waiting" : true, "waiting" : true,
@ -68,6 +72,12 @@
"permission" : { "permission" : {
"scope.userLocation" : { "scope.userLocation" : {
"desc" : "你的位置信息将用于获取周边服务" "desc" : "你的位置信息将用于获取周边服务"
},
"scope.album": {
"desc": "需要您的相册权限以便选择图片"
},
"scope.camera": {
"desc": "需要您的相机权限以便拍照"
} }
} }
}, },

View File

@ -45,6 +45,8 @@
"style": { "style": {
"navigationBarTitleText": "近山社区", "navigationBarTitleText": "近山社区",
"navigationStyle": "default", "navigationStyle": "default",
"enableShareAppMessage": false, //
"enableShareTimeline": false, //
"usingComponents": {} "usingComponents": {}
} }
}, },

View File

@ -34,7 +34,7 @@
<view class="info-item"> <view class="info-item">
<u-icon name="clock" size="26" color="#5b9cf8"></u-icon> <u-icon name="clock" size="26" color="#5b9cf8"></u-icon>
<view class="info-text"><text class="info-label">活动时间</text>{{ activityInfo.openAt }}</view> <view class="info-text"><text class="info-label">开始时间</text>{{formatTime(activityInfo.startAt,"YYYY-MM-DD HH:mm:ss") }}</view>
</view> </view>
<view class="info-item"> <view class="info-item">

View File

@ -12,22 +12,26 @@
<u--textarea placeholder="请输入求助内容..." v-model="content" border height="300"></u--textarea> <u--textarea placeholder="请输入求助内容..." v-model="content" border height="300"></u--textarea>
</view> </view>
<!-- 图片上传 --> <!-- 图片上传 - 修改后的上传组件 -->
<view class="upload-section"> <view class="upload-section">
<u-upload <view class="label">
@afterRead="afterRead" <u-icon name="photo" color="#3B8CFF" size="38"></u-icon>
@delete="deletePic" 上传照片
:fileList="fileList"
:maxCount="9"
:previewFullImage="true"
:accept="'image/*'"
:capture="['album', 'camera']"
width="220"
height="220">
<view class="upload-btn" v-if="fileList.length < 1">
<u-icon name="plus" size="40" color="#666"></u-icon>
</view> </view>
</u-upload> <view class="upload-area">
<view class="upload-list">
<view class="upload-item" v-for="(item, index) in fileList" :key="index">
<image :src="item.url" mode="aspectFill" @click="previewImage(index)"></image>
<view class="delete-btn" @click="handleDelete(index)">
<u-icon name="close" color="#fff" size="24"></u-icon>
</view>
</view>
<view class="upload-btn" @click="showUploadAction" v-if="fileList.length < 9">
<u-icon name="plus" size="40" color="#c0c4cc"></u-icon>
</view>
</view>
</view>
<text class="note">照片支持分批上传但最大数量为9</text>
</view> </view>
<!-- 发布按钮 --> <!-- 发布按钮 -->
@ -35,11 +39,9 @@
<u-button type="primary" text="立即发布" @click="publish"></u-button> <u-button type="primary" text="立即发布" @click="publish"></u-button>
</view> </view>
</view> </view>
</view> </view>
<Footer></Footer> <Footer></Footer>
</view> </view>
</template> </template>
<script> <script>
@ -70,100 +72,132 @@
delta: 1 // delta: 1 //
}); });
}, },
async afterRead(event) {
//
const files = event.file; //
const uploadFiles = Array.isArray(files) ? files : [files];
// - //
for (const file of uploadFiles) { showUploadAction() {
// 1 uni.showActionSheet({
const fileExt = file.url.split('.').pop().toLowerCase(); itemList: ['拍照', '从相册选择'],
const allowedExts = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp']; success: (res) => {
if (res.tapIndex === 0) {
// 2MIME this.chooseMedia('camera');
const isImage = file.type?.startsWith('image/') || } else {
allowedExts.includes(fileExt); this.chooseMedia('album');
}
if (!isImage) { }
uni.showToast({
title: '只能上传图片文件(JPG/PNG等)',
icon: 'none',
duration: 2000
}); });
return; },
}
}
uni.showLoading({ title: '上传中...' });
//
async chooseMedia(sourceType) {
try { try {
// // 1.
const uploadPromises = uploadFiles.map(file => this.uploadAvatar(file.url)); const res = await new Promise((resolve, reject) => {
const uploadedUrls = await Promise.all(uploadPromises); uni.chooseImage({
count: 9 - this.fileList.length,
// URL sourceType: [sourceType === 'camera' ? 'camera' : 'album'],
this.uploadedImageUrls = [...this.uploadedImageUrls, ...uploadedUrls]; success: resolve,
fail: reject
//
this.fileList = [
...this.fileList,
...uploadFiles.map((file, index) => ({
url: file.url,
status: 'success',
uploadedUrl: uploadedUrls[index]
}))
];
uni.showToast({ title: '上传成功', icon: 'success' });
} catch (error) {
console.error('上传失败:', error);
uni.showToast({
title: '上传失败: ' + error.message,
icon: 'none',
duration: 2000
}); });
} finally { });
uni.hideLoading();
// 2.
const newFiles = res.tempFilePaths.map(url => ({
url,
status: 'uploading'
}));
this.fileList = [...this.fileList, ...newFiles];
// 3.
for (const file of newFiles) {
await this.uploadFile(file);
}
} catch (err) {
console.error('选择图片失败:', err);
uni.showToast({ title: '选择图片失败', icon: 'none' });
} }
}, },
deletePic(event) {
// URL
const deletedFile = this.fileList[event.index];
this.uploadedImageUrls = this.uploadedImageUrls.filter(
url => url !== deletedFile.uploadedUrl
);
// //
this.fileList.splice(event.index, 1); async uploadFile(file) {
}, try {
uploadAvatar(filePath) { const res = await new Promise((resolve, reject) => {
return new Promise((resolve, reject) => {
uni.uploadFile({ uni.uploadFile({
url: `${BASE_URL}/api/v1/upload`, url: `${BASE_URL}/api/v1/upload`,
filePath: filePath, filePath: file.url,
name: 'file', name: 'file',
header: { header: {
'Authorization': `Bearer ${uni.getStorageSync('token')}` 'Authorization': `Bearer ${uni.getStorageSync('token')}`,
'Content-Type': 'multipart/form-data'
}, },
success: (uploadRes) => { success: (uploadRes) => {
try { try {
const res = JSON.parse(uploadRes.data); const data = JSON.parse(uploadRes.data);
if (res && res.success) { if (data.success) {
resolve(res.data); resolve(data.data); // 使URL
} else { } else {
reject(new Error(res.message || '上传失败')); reject(data.message || '上传失败');
} }
} catch (e) { } catch (e) {
reject(new Error('解析响应失败')); reject('解析响应失败');
} }
}, },
fail: (err) => { fail: (err) => reject(err)
reject(new Error('上传失败: ' + JSON.stringify(err)));
}
}); });
}); });
//
const index = this.fileList.findIndex(f => f.url === file.url);
if (index !== -1) {
this.$set(this.fileList, index, {
...file,
status: 'success',
serverUrl: res // URL
});
//
this.uploadedImageUrls.push(res);
}
} catch (err) {
console.error('上传失败:', err);
const index = this.fileList.findIndex(f => f.url === file.url);
if (index !== -1) {
this.$set(this.fileList, index, {
...file,
status: 'failed',
error: err.message || err
});
}
uni.showToast({
title: `上传失败: ${err.message || err}`,
icon: 'none'
});
}
},
//
previewImage(index) {
const images = this.fileList.map(item => item.url);
uni.previewImage({
current: index,
urls: images
});
}, },
//
handleDelete(index) {
const file = this.fileList[index];
if (file.serverUrl) {
const imageIndex = this.uploadedImageUrls.indexOf(file.serverUrl);
if (imageIndex !== -1) this.uploadedImageUrls.splice(imageIndex, 1);
}
this.fileList.splice(index, 1);
},
async publish() { async publish() {
if (!this.title.trim()) { if (!this.title.trim()) {
uni.showToast({ uni.showToast({
@ -226,7 +260,6 @@
<style lang="scss" scoped> <style lang="scss" scoped>
.container { .container {
width: 100%; width: 100%;
height: 100vh; height: 100vh;
/* 占满整个视口高度 */ /* 占满整个视口高度 */
@ -263,20 +296,76 @@
margin-bottom: 30rpx; margin-bottom: 30rpx;
} }
.upload-btn { .upload-section {
width: 220rpx; .label {
height: 220rpx; font-size: 32rpx;
color: #333;
font-weight: 500;
margin-bottom: 24rpx;
display: flex; display: flex;
align-items: center; align-items: center;
.u-icon {
margin-right: 12rpx;
}
}
.upload-area {
margin-top: 16rpx;
.upload-list {
display: flex;
flex-wrap: wrap;
margin: -5rpx;
.upload-item, .upload-btn {
width: 160rpx;
height: 160rpx;
margin: 5rpx;
position: relative;
background: #f8f8f8;
border-radius: 8rpx;
display: flex;
justify-content: center; justify-content: center;
background-color: #f0f0f0; align-items: center;
border-radius: 10rpx; overflow: hidden;
image {
width: 100%;
height: 100%;
}
.delete-btn {
position: absolute;
right: 0;
top: 0;
width: 40rpx;
height: 40rpx;
background: rgba(0, 0, 0, 0.5);
border-radius: 0 0 0 8rpx;
display: flex;
justify-content: center;
align-items: center;
}
}
.upload-btn {
border: 1rpx dashed #c0c4cc;
}
}
}
.note {
font-size: 24rpx;
color: #999;
margin-top: 24rpx;
display: block;
}
} }
.publish-section { .publish-section {
text-align: center; text-align: center;
margin-top: 100rpx; margin-top: 100rpx;
} }
} }
</style> </style>

View File

@ -47,7 +47,7 @@
</view> </view>
<view class="temperature-range"> <view class="temperature-range">
<text class="temp-item">最高温 {{weather.highest}}°</text> <text class="temp-item">最高温 {{weather.highest}}°</text>
<text class="temp-item">{{weather.lowest}}°</text> <text class="temp-item">{{weather.lowest}}°</text>
</view> </view>
</view> </view>
<view class="weather-footer"> <view class="weather-footer">

View File

@ -2,41 +2,55 @@
<view class="work-order-detail"> <view class="work-order-detail">
<!-- 头部用户信息区域 --> <!-- 头部用户信息区域 -->
<view class="header"> <view class="header">
<image class="avatar" :src="detailObj.customerPortrait" mode="aspectFill"></image> <image class="avatar" :src="`${IMAGE_BASE_URL}`+detailObj.customerPortrait|| '/static/index/nav.png'" mode="aspectFill"></image>
<text class="username">{{detailObj.customerName}}</text> <text class="username">{{detailObj.customerName || '未知用户'}}</text>
</view> </view>
<!-- 图片区域 - 编辑状态下可修改 --> <!-- 图片区域 - 编辑状态下可修改 -->
<view class="image-area"> <view class="image-area">
<template v-if="!isEditing">
<template v-if="detailObj.images && detailObj.images.length > 0">
<image <image
class="work-order-img" class="work-order-img"
:src="`${IMAGE_BASE_URL}${detailObj.images && detailObj.images[0] ? detailObj.images[0] : ''}`" :src="`${IMAGE_BASE_URL}${detailObj.images[0]}`"
mode="widthFix" mode="aspectFit"
v-if="!isEditing && detailObj.images && detailObj.images.length > 0"> />
</image> </template>
<view v-else> <view class="empty-placeholder" v-else>
<u-icon name="photo" size="48" color="#c0c4cc"></u-icon>
<text class="empty-text">暂无图片</text>
</view>
</template>
<template v-else>
<image <image
:src="isEditing ? workOrderImg : `${IMAGE_BASE_URL}${detailObj.images && detailObj.images[0] ? detailObj.images[0] : ''}`" > class="work-order-img"
</image> :src="tempImagePath || (detailObj.images && detailObj.images[0] ? `${IMAGE_BASE_URL}${detailObj.images[0]}` : '')"
<view class="upload-btn" @click="uploadImage" v-if="isEditing"> mode="aspectFit"
v-if="tempImagePath || (detailObj.images && detailObj.images.length > 0)"
/>
<view class="empty-placeholder" v-else>
<u-icon name="photo" size="48" color="#c0c4cc"></u-icon>
<text class="empty-text">暂无图片</text>
</view>
<view class="upload-btn" @click="uploadImage">
<u-icon name="camera" size="40" color="#fff"></u-icon> <u-icon name="camera" size="40" color="#fff"></u-icon>
<text class="upload-text">更换图片</text> <text class="upload-text">{{tempImagePath ? '更换图片' : '上传图片'}}</text>
</view>
</view> </view>
</template>
</view> </view>
<!-- 标题与日期 --> <!-- 标题与日期 -->
<view class="title-area"> <view class="title-area" :class="{editing: isEditing}">
<text class="title" v-if="!isEditing">{{detailObj.title}}</text> <text class="title" v-if="!isEditing">{{detailObj.title || '无标题'}}</text>
<input class="title-input" v-model="editLabel" v-else placeholder="请输入标题" /> <input class="title-input" v-model="editLabel" v-else placeholder="请输入标题" />
<text class="date">{{formatTime(detailObj.createdAt,"YYYY-MM-DD")}}</text> <text class="date">{{formatTime(detailObj.createdAt,"YYYY-MM-DD") || '未知日期'}}</text>
</view> </view>
<!-- 工单详情内容 - 编辑状态下可修改 --> <!-- 工单详情内容 - 编辑状态下可修改 -->
<view class="content"> <view class="content" :class="{editing: isEditing}">
<view class="label"> <view class="label">
<text>求助内容</text> <text>求助内容</text>
<text v-if="!isEditing" style="font-weight: normal;">{{detailObj.content}}</text> <text v-if="!isEditing" class="content-text">{{detailObj.content || '无内容描述'}}</text>
<textarea <textarea
class="edit-textarea" class="edit-textarea"
v-model="editTitle" v-model="editTitle"
@ -51,16 +65,18 @@
<view class="btn-group"> <view class="btn-group">
<u-button <u-button
@click="handleModify" @click="handleModify"
:type="isEditing ? 'success' : 'primary'" :type="isEditing ? 'primary' : 'primary'"
class="action-btn" class="action-btn"
:loading="isLoading" :loading="isLoading"
:custom-style="btnStyle"
> >
{{isEditing ? '保存修改' : '修改'}} {{isEditing ? '保存修改' : '修改'}}
</u-button> </u-button>
<u-button <u-button
@click="handleWithdraw" @click="handleWithdraw"
:type="isEditing ? 'default' : 'primary'" :type="isEditing ? 'error' : 'error'"
class="action-btn" class="action-btn"
:custom-style="btnStyle"
> >
{{isEditing ? '取消编辑' : '撤回'}} {{isEditing ? '取消编辑' : '撤回'}}
</u-button> </u-button>
@ -81,47 +97,40 @@
formatTime, formatTime,
isEditing: false, // isEditing: false, //
isLoading: false, // isLoading: false, //
workOrderImg: '', // tempImagePath: '', //
// //
editLabel: '', editLabel: '',
editAddress: '',
editTitle: '', editTitle: '',
detailObj: { detailObj: {
images: [], // images images: [], // images
customerPortrait: '', customerPortrait: '',
customerName: '', customerName: '',
createdAt: '', createdAt: '',
label: '',
address: '',
title: '', title: '',
content: '',
id: '' id: ''
}, },
tempImagePath: '' // btnStyle: {
width: '45%',
height: '80rpx'
}
}; };
}, },
mounted() { mounted() {
let obj = uni.getStorageSync("Detail") || {}; let obj = uni.getStorageSync("Detail") || {};
console.log("===boj",obj)
this.detailObj = { this.detailObj = {
...obj // ...obj //
}; };
// workOrderImg
if (this.detailObj.images && this.detailObj.images.length > 0) {
this.workOrderImg = `${IMAGE_BASE_URL}${this.detailObj.images[0]}`;
}
}, },
methods: { methods: {
// //
uploadImage() { uploadImage() {
uni.chooseImage({ uni.chooseImage({
count: 1, count: 1,
success: (res) => { success: (res) => {
const tempFilePaths = res.tempFilePaths[0]; this.tempImagePath = res.tempFilePaths[0];
this.tempImagePath = tempFilePaths;
this.workOrderImg = tempFilePaths;
uni.showToast({ uni.showToast({
title: '图片已更换', title: '图片已选择',
icon: 'success' icon: 'success'
}); });
}, },
@ -161,7 +170,7 @@
}); });
if (res && res.success) { if (res && res.success) {
return res.data; // return res.data;
} else { } else {
throw new Error(res.message || '上传失败'); throw new Error(res.message || '上传失败');
} }
@ -180,11 +189,7 @@
if (!this.isEditing) { if (!this.isEditing) {
// //
this.editLabel = this.detailObj.title || ''; this.editLabel = this.detailObj.title || '';
this.editAddress = this.detailObj.address || '';
this.editTitle = this.detailObj.content || ''; this.editTitle = this.detailObj.content || '';
if (!this.workOrderImg && this.detailObj.images && this.detailObj.images.length > 0) {
this.workOrderImg = `${IMAGE_BASE_URL}${this.detailObj.images[0]}`;
}
this.isEditing = true; this.isEditing = true;
} else { } else {
// //
@ -196,8 +201,7 @@
// //
if (this.tempImagePath) { if (this.tempImagePath) {
const uploadedPath = await this.uploadImageToServer(this.tempImagePath); const uploadedPath = await this.uploadImageToServer(this.tempImagePath);
images = [uploadedPath]; // images = [uploadedPath];
this.workOrderImg = `${IMAGE_BASE_URL}${uploadedPath}`;
} }
const requestData = { const requestData = {
@ -210,7 +214,6 @@
const res = await put(`/api/v1/app_auth/reciprocities/${this.detailObj.id}`, requestData); const res = await put(`/api/v1/app_auth/reciprocities/${this.detailObj.id}`, requestData);
if (res && res.success) { if (res && res.success) {
//
this.detailObj = { this.detailObj = {
...this.detailObj, ...this.detailObj,
...requestData ...requestData
@ -222,12 +225,7 @@
}); });
this.isEditing = false; this.isEditing = false;
this.tempImagePath = ''; // this.tempImagePath = '';
// workOrderImg
if (images.length > 0) {
this.workOrderImg = `${IMAGE_BASE_URL}${images[0]}`;
}
} else { } else {
throw new Error(res.message || '修改失败'); throw new Error(res.message || '修改失败');
} }
@ -249,10 +247,6 @@
// //
this.isEditing = false; this.isEditing = false;
this.tempImagePath = ''; this.tempImagePath = '';
//
if (this.detailObj.images && this.detailObj.images.length > 0) {
this.workOrderImg = `${IMAGE_BASE_URL}${this.detailObj.images[0]}`;
}
} else { } else {
// //
try { try {
@ -264,7 +258,6 @@
title: '撤回成功', title: '撤回成功',
icon: 'success' icon: 'success'
}); });
//
uni.navigateBack(); uni.navigateBack();
} else { } else {
throw new Error(res.message || '撤回失败'); throw new Error(res.message || '撤回失败');
@ -285,39 +278,39 @@
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
/* 原有样式保持不变 */
// //
$primary-color: #007AFF; $primary-color: #007AFF;
$success-color: #4cd964; $success-color: #4cd964;
$warning-color: #FF9500; $warning-color: #FF9500;
$error-color: #dd524d;
$text-color: #333; $text-color: #333;
$subtext-color: #999; $subtext-color: #999;
$border-radius: 10rpx; $border-radius: 12rpx;
$padding-base: 15rpx; $padding-base: 20rpx;
$font-base: 32rpx; $font-base: 32rpx;
$shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.08);
// mixin
@mixin flex-center {
display: flex;
align-items: center;
}
.work-order-detail { .work-order-detail {
padding: $padding-base; padding: $padding-base;
width: 90%; width: 92%;
margin: 0 auto; margin: 20rpx auto;
border-radius: 10rpx; border-radius: $border-radius;
box-shadow: 0rpx 2rpx 10rpx rgba(0, 0, 0, 0.25); box-shadow: $shadow;
background-color: #fff;
.header { .header {
@include flex-center; display: flex;
align-items: center;
margin-bottom: $padding-base; margin-bottom: $padding-base;
padding-bottom: $padding-base;
border-bottom: 1rpx solid #f5f5f5;
.avatar { .avatar {
width: 80rpx; width: 80rpx;
height: 80rpx; height: 80rpx;
border-radius: 50%; border-radius: 50%;
margin-right: 10rpx; margin-right: 20rpx;
background-color: #f5f5f5;
} }
.username { .username {
@ -330,107 +323,141 @@
.image-area { .image-area {
position: relative; position: relative;
margin-bottom: $padding-base; margin-bottom: $padding-base;
min-height: 200rpx; height: 400rpx;
background-color: #f5f5f5; background-color: #f9f9f9;
border-radius: $border-radius;
overflow: hidden;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
}
.work-order-img { .work-order-img {
width: 100%; width: 100%;
border-radius: $border-radius; height: 100%;
max-height: 400rpx; object-fit: contain;
}
.empty-placeholder {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
color: #c0c4cc;
width: 100%;
height: 100%;
.empty-text {
font-size: 28rpx;
margin-top: 16rpx;
color: #c0c4cc;
}
} }
.upload-btn { .upload-btn {
position: absolute; position: absolute;
bottom: 20rpx; bottom: 30rpx;
right: 20rpx; right: 30rpx;
background: rgba(0, 0, 0, 0.6); background: rgba(0, 0, 0, 0.6);
padding: 8rpx 20rpx; padding: 12rpx 24rpx;
border-radius: 30rpx; border-radius: 40rpx;
@include flex-center; display: flex;
align-items: center;
justify-content: center;
.upload-text { .upload-text {
color: #fff; color: #fff;
font-size: 24rpx; font-size: 26rpx;
margin-left: 8rpx; margin-left: 10rpx;
}
} }
} }
.title-area { .title-area {
@include flex-center; display: flex;
align-items: center;
justify-content: space-between; justify-content: space-between;
margin-bottom: $padding-base; margin-bottom: $padding-base;
border-bottom: 2rpx solid $subtext-color; padding-bottom: $padding-base;
height: 70rpx; border-bottom: 1rpx solid #f5f5f5;
line-height: 70rpx;
&.editing {
border-bottom: 1rpx solid #eaeaea;
}
.title { .title {
font-size: $font-base + 2rpx; font-size: $font-base + 4rpx;
font-weight: bold; font-weight: bold;
color: $text-color; color: $text-color;
max-width: 70%; flex: 1;
} }
.title-input { .title-input {
font-size: $font-base + 2rpx; font-size: $font-base + 4rpx;
font-weight: bold; font-weight: bold;
color: $text-color; color: $text-color;
width: 70%; flex: 1;
padding: 10rpx; padding: 10rpx;
background: #f8f8f8; background: #f8f8f8;
border-radius: 8rpx; border-radius: 8rpx;
border: 1rpx solid #eaeaea;
} }
.date { .date {
font-size: $font-base - 4rpx; font-size: $font-base - 4rpx;
color: $subtext-color; color: $subtext-color;
margin-left: 20rpx;
} }
} }
.content { .content {
margin-bottom: $padding-base; margin-bottom: $padding-base * 2;
line-height: 50rpx; font-size: $font-base;
font-size: 24rpx;
&.editing {
padding: 10rpx;
background: #fafafa;
border-radius: $border-radius;
}
.label { .label {
display: flex;
flex-direction: column;
text { text {
font-weight: bold; font-weight: bold;
} margin-bottom: 10rpx;
margin-bottom: 20rpx;
} }
.edit-input { .content-text {
width: 95%; font-weight: normal;
padding: 10rpx; color: #666;
background: #f8f8f8; line-height: 1.6;
border-radius: 8rpx; }
margin-top: 5rpx;
} }
.edit-textarea { .edit-textarea {
width: 95%; width: 100%;
padding: 10rpx; padding: 16rpx;
background: #f8f8f8; background: #fff;
border-radius: 8rpx; border-radius: 8rpx;
margin-top: 5rpx; border: 1rpx solid #eaeaea;
min-height: 150rpx; min-height: 200rpx;
font-size: $font-base;
line-height: 1.5;
} }
} }
.btn-group { .btn-group {
@include flex-center; display: flex;
justify-content: space-around; justify-content: space-between;
margin-top: 30rpx; margin-top: 40rpx;
gap:30rpx; gap: 20rpx;
.action-btn { .action-btn {
width: 30%; // flex: 1;
height: 80rpx; border-radius: 50rpx;
border-radius: 40rpx; font-size: $font-base;
font-size: $font-base - 4rpx; font-weight: bold;
} }
} }
} }

View File

@ -3,7 +3,7 @@
<!-- 主帖内容 --> <!-- 主帖内容 -->
<view class="post-container"> <view class="post-container">
<view class="post-header"> <view class="post-header">
<image class="avatar" :src="postData.customerPortrait" mode="aspectFill"></image> <image class="avatar" :src="`${IMAGE_BASE_URL}`+postData.customerPortrait" mode="aspectFill"></image>
<view class="post-info"> <view class="post-info">
<text class="username">{{ postData.customerName }}</text> <text class="username">{{ postData.customerName }}</text>
<text class="time">{{ formatTime(postData.pushAt) }}</text> <text class="time">{{ formatTime(postData.pushAt) }}</text>
@ -32,7 +32,8 @@
<view v-for="comment in flatComments" :key="comment.id" class="comment-item" <view v-for="comment in flatComments" :key="comment.id" class="comment-item"
:class="{'is-reply': comment.toUserName}"> :class="{'is-reply': comment.toUserName}">
<view class="comment-header"> <view class="comment-header">
<image class="avatar" :src="comment.pusherPortrait" mode="aspectFill"></image> <image class="avatar"
:src="comment.pusherPortrait === '/static/imgs/index/nav.png' ? comment.pusherPortrait : `${IMAGE_BASE_URL}${comment.pusherPortrait}`" mode="aspectFill"></image>
<view class="comment-user-info"> <view class="comment-user-info">
<text class="username">{{ comment.pusherName }}</text> <text class="username">{{ comment.pusherName }}</text>
<view class="meta-info"> <view class="meta-info">

View File

@ -41,7 +41,7 @@
</view> </view>
<view class="item_right"> <view class="item_right">
<view class="right_nav"> <view class="right_nav">
<image :src="item.customerPortrait ?item.customerPortrait :`/static/imgs/index/nav.png`" class="nav"></image> <image :src="item.customerPortrait ?`${IMAGE_BASE_URL}`+item.customerPortrait :`/static/imgs/index/nav.png`" class="nav"></image>
<image src="/static/imgs/index/nav_bg.png" class="bg"></image> <image src="/static/imgs/index/nav_bg.png" class="bg"></image>
</view> </view>
<view class="right_name"> <view class="right_name">
@ -317,7 +317,7 @@
.bg { .bg {
position: absolute; position: absolute;
z-index: 1; z-index: 1;
top: 20rpx; top: 0rpx;
left: -118rpx; left: -118rpx;
width: 260rpx; width: 260rpx;
height: 260rpx; height: 260rpx;

View File

@ -37,9 +37,6 @@
工单内容 工单内容
</view> </view>
<textarea v-model="workOrderContent" placeholder="请输入工单详细内容..." class="textarea" /> <textarea v-model="workOrderContent" placeholder="请输入工单详细内容..." class="textarea" />
<view class="voice-icon">
<u-icon name="mic" color="#409EFF" size="36"></u-icon>
</view>
</view> </view>
<!-- 联系人信息 --> <!-- 联系人信息 -->
@ -56,7 +53,13 @@
<u-icon name="phone" color="#3B8CFF" size="38"></u-icon> <u-icon name="phone" color="#3B8CFF" size="38"></u-icon>
电话 电话
</view> </view>
<input v-model="customerPhone" placeholder="请输入联系人电话" class="contact-input" type="number" /> <input
v-model="customerPhone"
placeholder="请输入联系人电话"
class="contact-input"
type="number"
@blur="validatePhone"
/>
</view> </view>
</view> </view>
@ -80,14 +83,14 @@
</view> </view>
</view> </view>
</view> </view>
<text class="note">照片可识别工单内容支持分批上传但最大数量为8</text> <text class="note">照片支持分批上传但最大数量为8</text>
</view> </view>
<!-- 工单地点 --> <!-- 工单地点 -->
<view class="form-item"> <view class="form-item">
<view class="label"> <view class="label">
<u-icon name="map" color="#3B8CFF" size="38"></u-icon> <u-icon name="map" color="#3B8CFF" size="38"></u-icon>
工作地点 维修地点
</view> </view>
<textarea v-model="workOrderLocation" placeholder="请输入详细工作地点..." class="textarea" /> <textarea v-model="workOrderLocation" placeholder="请输入详细工作地点..." class="textarea" />
</view> </view>
@ -151,6 +154,19 @@ export default {
this.getOrderTypeList(); this.getOrderTypeList();
}, },
methods: { methods: {
//
validatePhone() {
if (!this.customerPhone) return true;
const phoneReg = /^1[3-9]\d{9}$/;
if (!phoneReg.test(this.customerPhone)) {
uni.showToast({
title: '请输入正确的手机号码',
icon: 'none'
});
return false;
}
return true;
},
// //
showUploadAction() { showUploadAction() {
uni.showActionSheet({ uni.showActionSheet({
@ -350,8 +366,11 @@ export default {
this.fileList.splice(index, 1); this.fileList.splice(index, 1);
}, },
// ...
async handleSubmit() { async handleSubmit() {
//
if (!this.validatePhone()) {
return;
}
if (!this.workOrderContent) { if (!this.workOrderContent) {
uni.showToast({ uni.showToast({
title: '请填写工单内容', title: '请填写工单内容',

Binary file not shown.

Before

Width:  |  Height:  |  Size: 628 B

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 429 B

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 616 B

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 930 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -1,13 +1,17 @@
import { BASE_URL } from "./config"; import { BASE_URL } from "./config";
// 获取本地Token的同步方法
// 获取本地 Token 的同步方法
const getToken = () => { const getToken = () => {
try { try {
return uni.getStorageSync('token') || null return uni.getStorageSync('token') || null;
} catch (e) { } catch (e) {
console.error('获取本地Token失败:', e) console.error('获取本地Token失败:', e);
return null return null;
} }
} };
// 是否正在跳转登录页,防止重复弹窗
let isRedirectingToLogin = false;
// 统一请求方法 // 统一请求方法
export const request = (options) => { export const request = (options) => {
@ -15,54 +19,106 @@ export const request = (options) => {
// 合并请求头 // 合并请求头
const header = { const header = {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
...(options.header || {}), // 允许覆盖默认header ...(options.header || {}), // 允许覆盖默认 header
Authorization: getToken() ? `Bearer ${getToken()}` : undefined Authorization: getToken() ? `Bearer ${getToken()}` : undefined,
} };
// 过滤掉undefined的header项 // 过滤掉 undefined header
const filteredHeader = Object.fromEntries( const filteredHeader = Object.fromEntries(
Object.entries(header).filter(([_, v]) => v !== undefined) Object.entries(header).filter(([_, v]) => v !== undefined)
) );
uni.request({ uni.request({
url: `${BASE_URL}${options.url}`, url: `${BASE_URL}${options.url}`,
method: options.method || 'GET', method: options.method || 'GET',
data: options.data || {}, data: options.data || {},
header: filteredHeader, header: filteredHeader,
timeout: options.timeout || 10000, // 建议设置超时时间
success: (res) => { success: (res) => {
// 处理401未授权 const { statusCode } = res;
if (res.statusCode === 401) {
uni.removeStorageSync('token') // 处理 401 未授权(登录过期/未登录)
// uni.showToast({ title: '请前往"个人中心页"登录', icon: 'none' }) if (statusCode === 401) {
// uni.navigateTo({ url: '/pages/mine/index' }) // 防止多次弹窗和重复跳转
return reject(new Error('登录状态已过期')) if (!isRedirectingToLogin) {
isRedirectingToLogin = true;
uni.removeStorageSync('token');
// 友好提示 + 延迟跳转
uni.showToast({
title: '暂未登录,请登录后使用',
icon: 'none',
duration: 1500,
});
setTimeout(() => {
isRedirectingToLogin = false;
uni.navigateTo({
url: '/pages/mine/index',
fail: () => {
uni.reLaunch({ url: '/pages/mine/index' });
}
});
}, 1500);
} }
// 处理其他错误状态码 return reject(new Error('未登录或登录已过期'));
if (res.statusCode < 200 || res.statusCode >= 300) {
const errorMsg = res.data?.message || `请求失败 (${res.statusCode})`
uni.showToast({ title: errorMsg, icon: 'none' })
return reject(new Error(errorMsg))
} }
resolve(res.data) // 处理其他非 2xx 状态码
if (statusCode < 200 || statusCode >= 300) {
const errorMsg = res.data?.message || `请求失败 (HTTP ${statusCode})`;
uni.showToast({ title: errorMsg, icon: 'none', duration: 2000 });
return reject(new Error(errorMsg));
}
const responseData = res.data;
if (responseData && typeof responseData === 'object' && 'code' in responseData) {
if (responseData.code !== 0) {
const bizMsg = responseData.message || '请求异常';
uni.showToast({ title: bizMsg, icon: 'none' });
return reject(new Error(bizMsg));
}
// 成功:返回 data 字段
resolve(responseData.data);
} else {
// 兼容没有统一响应格式的接口
resolve(responseData);
}
}, },
fail: (err) => { fail: (err) => {
const errorMsg = err.errMsg.includes('timeout') const errMsg = err.errMsg || '';
? '网络请求超时' let errorMsg = '网络连接失败';
: '网络连接失败'
uni.showToast({ title: errorMsg, icon: 'none' }) if (errMsg.includes('timeout')) {
reject(new Error(errorMsg)) errorMsg = '网络请求超时,请检查网络';
} else if (errMsg.includes('Network Error')) {
errorMsg = '网络异常,请检查网络设置';
} }
})
})
}
// 封装常用方法 uni.showToast({
export const get = (url, data, header) => request({ url, method: 'GET', data, header }) title: errorMsg,
icon: 'none',
duration: 2000,
});
export const post = (url, data, header) => request({ url, method: 'POST', data, header }) reject(new Error(errorMsg));
},
});
});
};
export const put = (url, data, header) => request({ url, method: 'PUT', data, header }) // 封装常用方法(支持传入额外配置,比如 timeout、skipAuth 等)
export const get = (url, data, header, options = {}) =>
request({ url, method: 'GET', data, header, ...options });
export const del = (url, data, header) => request({ url, method: 'DELETE', data, header }) export const post = (url, data, header, options = {}) =>
request({ url, method: 'POST', data, header, ...options });
export const put = (url, data, header, options = {}) =>
request({ url, method: 'PUT', data, header, ...options });
export const del = (url, data, header, options = {}) =>
request({ url, method: 'DELETE', data, header, ...options });