@@ -1,337 +1,345 @@
< template >
< template >
< view class = "add-repair-container" >
< view class = "add-repair-container" >
<!-- 可滚动内容区 -- >
<!-- 可滚动内容区 -- >
< view class = "add-repair-scroll-content" >
< view class = "add-repair-scroll-content" >
<!-- 地址选择 -- >
<!-- 地址选择 -- >
<!-- < view class = "add-repair-section" >
<!-- < view class = "add-repair-section" >
< view class = "add-repair-detail" >
< view class = "add-repair-detail" >
< view class = "add-repair-detail1" > 详细地址 < / view >
< view class = "add-repair-detail1" > 详细地址 < / view >
< input type = "text" v-model = "repairInfo.location" placeholder="请输入地址" class="add-repair-detail2" / >
< input type = "text" v-model = "repairInfo.location" placeholder="请输入地址" class="add-repair-detail2" / >
< / view >
< / view >
< / view > -- >
< / view > -- >
<!-- 报事报修类型 -- >
<!-- 报事报修类型 -- >
< view class = "add-repair-section" >
< view class = "add-repair-section" >
< view class = "add-repair-label" > 详细地址 < / view >
< view class = "add-repair-label" > 详细地址 < / view >
< input type = "text" v-model = "repairInfo.location" placeholder="请输入地址" class="add-repair-detail2" / >
< input type = "text" v-model = "repairInfo.location" placeholder="请输入地址" class="add-repair-detail2" / >
< view class = "add-repair-label" > 报事报修 < / view >
< view class = "add-repair-label" > 报事报修 < / view >
< view class = "repair-type" @click ="chooseType" >
< view class = "repair-type" @click ="chooseType" >
< text class = "text-type" > { { selectedType } } < / text >
< text class = "text-type" > { { selectedType } } < / text >
< image class = "right-arrow" src = "/static/ic_right_arrow_g.png" / >
< image class = "right-arrow" src = "/static/ic_right_arrow_g.png" / >
< / view >
< / view >
< view class = "add-repair-label" > 问题详情 < text class = "add-repair-optional" > ( 非必填 ) < / text > < / view >
< view class = "add-repair-label" > 问题详情 < text class = "add-repair-optional" > ( 非必填 ) < / text > < / view >
< textarea v-model = "repairInfo.remark" class="add-repair-detail-textarea" placeholder="如果以上报事不能解决您的问题,可以在这里填写说明" / >
< textarea v-model = "repairInfo.remark" class="add-repair-detail-textarea"
placeholder = "如果以上报事不能解决您的问题,可以在这里填写说明" / >
< / view >
< / view >
<!-- 上传照片 -- >
< view class = "add-repair-section" >
<!-- 上传照片 -- >
< view class = "add-repair-label" > 上传照片 < text class = "add-repair-op tional " > ( 非必填 , 最多三张 ) < / text > < / view >
< view class = "add-repair-sec tion" >
< u-upload
< view class = "add-repair-label" > 上传照片 < text class = "add-repair-optional" > ( 非必填 , 最多三张 ) < / text > < / view >
:fileList = "selectedImages"
< u-upload :fileList = "selectedImages" @ on -list -change = " onListChange " @delete ="deletePic" name = "upload"
@ on -list -change = " onListChange "
multiple maxCount = "3" width = "180" height = "180" :autoUpload = "false" > < / u-upload >
@delete ="deletePic"
< / view >
name = "upload"
multiple
<!-- 提交按钮 -- >
maxCount = "3"
< button class = "add-repair-submit-btn" @click ="submit" > 提交 < / button >
width = "180"
< / view >
height = "180"
< / view >
:autoUpload = "false"
< / template >
> < / u-upload >
< / view >
< script >
// 导入MediaSelector和MediaType
<!-- 提交按钮 -- >
import MediaSelector , {
< button class = "add-repair-submit-btn" @click ="submit" > 提交 < / button >
MediaType
< / view >
} from '@/utils/mediaSelector' ;
< / view >
import {
< / template >
uploadFiles
} from '@/common/upload.js' ;
< script >
import toast from '../../../../uview-ui/libs/function/toast' ;
// 导入MediaSelector和MediaType
export default {
import MediaSelector , { MediaType } from '@/utils/mediaSelector' ;
data ( ) {
import {
return {
uploadFiles
repairInfo : {
} from '@/common/upload.js ';
location : ' ' ,
import toast from '../../../../uview-ui/libs/function/toast ';
type : '1942879389453230082 ' ,
export default {
orderImgUrl : '' ,
data ( ) {
remark : ''
return {
} ,
repairInfo : {
repairTypes : [ ] ,
location : '' ,
selectedType : '' ,
type : '1942879389453230082' ,
selectedImages : [ ] // 存储已选图片
orderImgUrl : '' ,
}
remark : ''
} ,
} ,
onLoad ( ) {
repairTypes : [ ] ,
this . getOrderType ( )
selectedType : '' ,
} ,
selectedImages : [ ] // 存储已选图片
methods : {
}
selectType ( item ) {
} ,
this . selectedType = item ;
onLoad ( ) {
} ,
this . getOrderType ( )
async getOrderType ( ) {
} ,
let params = {
methods : {
parentId : '1952989217332658178'
selectType ( item ) {
}
this . selectedType = item ;
let res = await this . $u . api . getRepairTypes ( params ) ;
} ,
if ( res . code == '200' ) {
async getOrderType ( ) {
this . repairTypes = res . data
let params = { parentId : '1952989217332658178' }
this . repairInfo . type = res . data [ 0 ] . id ;
let res = await this . $u . api . getRepairTypes ( par ams ) ;
this . selectType ( res . data [ 0 ] . orderTypeN ame )
if ( res . code == '200' ) {
}
this . repairTypes = res . data
} ,
this . repairInfo . type = res . data [ 0 ] . id ;
// 删除图片
this . selectType ( res . data [ 0 ] . orderTypeName )
deletePic ( event ) {
}
this . selectedImages . splice ( event . index , 1 ) ;
} ,
} ,
// 删除图片
deletePic ( event ) {
// 图片列表变化处理
this . selectedIma ges . splice ( event . index , 1 ) ;
onListChan ge( list ) {
} ,
this . selectedImages = list ;
} ,
// 图片列表变化处理
onListChange ( list ) {
async submit ( ) {
this . selectedImages = list ;
if ( ! this . repairInfo . location ) {
} ,
toast ( '请先填写地址' )
return
async submit ( ) {
}
if ( ! this . repairInfo . location ) {
toast ( '请先填写地址' )
if ( this . selectedImages . length <= 0 ) {
return
this . realSubmit ( )
}
return
}
if ( this . selectedImages . length <= 0 ) {
console . log ( "t1" , this . selectedImages )
this . realSubmit ( )
const images = this . selectedImages
return
. map ( item => item ? . path ? . replace ( 'file://' , '' ) || item ? . url || null )
}
. filter ( path => path !== null ) ;
console . log ( "t1" , this . selectedImages )
if ( images . length === 0 ) {
const images = this . selectedImages
this . realSubmit ( ) ;
. map ( item => item ? . path ? . replace ( 'file://' , '' ) || item ? . url || null )
return ;
. filter ( path => path !== null ) ;
}
if ( images . length === 0 ) {
this . realSubmit ( ) ;
const result = await uploadFiles ( {
return ;
files : images ,
}
url : this . vuex _config . baseUrl + '/resource/oss/upload' ,
name : 'file' ,
const result = await uploadFiles ( {
vm : this // 关键:用于注入 token 等
files : images ,
} ) ;
url : this . vuex _config . baseUrl + '/resource/oss/upload' ,
const allSuccess = result . every ( item => item . code == 200 ) ;
name : 'file' ,
if ( ! allSuccess ) {
vm : this // 关键:用于注入 token 等
uni . showToast ( {
} ) ;
title : '上传失败' ,
icon : 'none'
} ) ;
// 遍历result获取data.url加上,分割
return ;
const urls = result . map ( item => item . data ? . url || '' ) . filter ( url => url !== '' ) ;
}
this . repairInfo . orderImgUrl = urls . join ( ',' ) ;
this . realSubmit ( )
// 遍历result获取data.url加上,分割
const urls = result . map ( item => item . data ? . ossId || '' ) . filter ( ossId => ossId !== '' ) ;
} ,
this . repairInfo . orderImgUrl = urls . join ( ',' ) ;
this . realSubmit ( )
async realSubmit ( ) {
let res = await this . $u . api . addOrder2 ( this . repairInfo ) ;
} ,
if ( res . code == '200' ) {
// 关闭页面前发送事件通知前页面刷新
async realSubmit ( ) {
uni . $emit ( 'refreshData' , '' ) ;
let res = await this . $u . api . addOrder2 ( this . repairInfo ) ;
// 返回上一页
if ( res . code == '200' ) {
uni . navigateBack ( ) ;
// 关闭页面前发送事件通知前页面刷新
}
uni . $emit ( 'refreshData' , '' ) ;
} ,
// 返回上一页
uni . navigateBack ( ) ;
// 添加chooseType方法实现
}
chooseType ( ) {
} ,
uni . showActionSheet ( {
itemList : this . repairTypes . map ( item => item . orderTypeName ) ,
// 添加chooseType方法实现
success : ( res ) => {
chooseType ( ) {
this . selectedType = this . repairTypes [ res . tapIndex ] . orderTypeName ;
uni . showActionSheet ( {
this . repairInfo . type = this . repairTypes [ res . tapIndex ] . id ;
itemList : this . repairTypes . map ( item => item . orderTypeName ) ,
} ,
success : ( res ) => {
fail : ( err ) => {
this . selectedType = this . repairTypes [ res . tapIndex ] . orderTypeName ;
console . log ( '用户取消选择或出错' , err ) ;
this . repairInfo . type = this . repairTypes [ res . tapIndex ] . id ;
}
} ,
} ) ;
fail : ( err ) => {
} ,
console . log ( '用户取消选择或出错' , err ) ;
goRepaired ( ) {
}
uni . navigateTo ( { url : '/pages/sys/user/myRepair/repaired' } ) ;
} ) ;
} ,
} ,
goSelectLocation ( ) {
goRepaired ( ) {
uni . navigateTo ( { url : '/pages/sys/user/myRepair/selectLocation' } ) ;
uni . navigateTo ( {
}
url : '/pages/sys/user/myRepair/repaired'
} ) ;
}
} ,
}
goSelectLocation ( ) {
< / script >
uni . navigateTo ( {
url : '/pages/sys/user/myRepair/selectLocation'
< style scoped >
} ) ;
. add - repair - container {
}
height : 100 vh ;
background : # f7f7f7 ;
}
display : flex ;
}
flex - direction : column ;
< / script >
}
< style scoped >
. add - repair - container {
. add - repair - scroll - content {
height : 100 vh ;
flex : 1 ;
background : # f7f7f7 ;
overflow - y: auto ;
displa y: flex ;
padding - bottom : 40 rpx ;
flex - direction : column ;
}
}
. add - repair - section {
background : # fff ;
. add - repair - scroll - content {
border - radius : 12 rpx ;
flex : 1 ;
margin : 22 rpx 30 rpx 0 30 rpx ;
overflow - y : auto ;
padding : 24 rpx 46 rpx 24 rpx 44 rpx ;
padding - bottom : 40 rpx ;
}
}
. repair - type {
. add - repair- section {
width : 100 % ;
background : # fff ;
height : 98 rpx ;
border - radius : 12 rpx ;
background : # F7F8FA ;
margin : 22 rpx 30 rpx 0 30 rpx ;
border - radius : 10 rpx ;
padding : 24 rpx 46 rpx 24 rpx 44 rpx ;
padding : 0 20 rpx ;
}
display : flex ;
align - items : center ;
. repair - type {
justify - content : space - between ;
width : 100 % ;
margin - bottom : 40 rpx ;
height : 98 rpx ;
box - sizing : border - box ;
background : # F7F8FA ;
}
border - radius : 10 rpx ;
padding : 0 20 rpx ;
. text - type {
display : flex ;
font - size : 24 rpx ;
align - items : center ;
color : # 808080 ;
justify - content : space - between ;
}
margin - bottom : 40 rpx ;
. right - arrow {
box - sizing : border - box ;
width : 11 rpx ;
}
height : 21 rpx ;
}
. text - type {
font - size : 24 rpx ;
. add - repair - address - btn {
color : # 808080 ;
width : 100 % ;
}
height : 48 rpx ;
background : # fff ;
. right - arrow {
border : 2 rpx solid # 2186 FF ;
width : 11 rpx ;
border - radius : 8 rpx ;
height : 21 rpx ;
margin - bottom : 30 rpx ;
}
padding - left : 18 rpx ;
display : flex ;
. add - repair - address - btn {
align - items : center ;
width : 100 % ;
justify - content : center ;
height : 48 rpx ;
}
background : # fff ;
border : 2 rpx solid # 2186 FF ;
. add - repai r- address - text {
borde r - r adius : 8 rpx ;
font - size : 24 rpx ;
margin - bottom : 30 rpx ;
color : # 007 CFF ;
padding - left : 18 rpx ;
margin - right : 15 rp x;
display : fle x;
}
align - items : center ;
justify - content : center ;
. add - repair - address - img {
}
width : 11 rpx ;
height : 21 rpx ;
. add - repair - address - text {
}
font - size : 24 rpx ;
color : # 007 CFF ;
. add - repair - detail {
margin - right : 15 rpx ;
display : flex ;
}
flex - direction : row ;
align - items : center ;
. add - repair - address - img {
}
width : 11 rpx ;
height : 21 rpx ;
. add - repair - detail1 {
}
font - size : 26 rpx ;
font - weight : bold ;
. add - repair - detail {
color : # 000 ;
display : flex ;
}
flex - direction : row ;
align - items : center ;
. add - repair - detail2 {
}
width : 100 % ;
height : 98 rpx ;
. add - repair - detail1 {
background - color : # F7F8FA ;
font - size : 26 rpx ;
border - radius : 10 rpx ;
font - weight : bold ;
font - size : 24 rpx ;
color : # 000 ;
color : # 676767 ;
}
padding : 0 20 rpx ;
margin - bottom : 40 rpx ;
. add - repair - detail2 {
box - sizing : border - box ;
width : 100 % ;
}
height : 98 rpx ;
. add - repair - label {
background - color : # F7F8FA ;
font - size : 32 rpx ;
border - radius : 10 rpx ;
color : # 000000 ;
font - size : 24 rpx ;
font - weight : 500 ;
color : # 676767 ;
margin - bottom : 41 rpx ;
padding : 0 20 rpx ;
}
margin - bottom : 40 rpx ;
box - sizing : border - box ;
. add - repair - label2 {
}
font - size : 32 rpx ;
color : # 000000 ;
. add - repair - label {
font - weight : 500 ;
font - size : 32 rpx ;
margin - bottom : 25 rpx ;
color : # 000000 ;
margin - top : 25 rpx ;
font - weight : 500 ;
}
margin - bottom : 41 rpx ;
}
. add - repair - type - list {
. add - repair - label2 {
display : fle x;
font - size : 32 rp x;
flex - wrap : wrap ;
color : # 000000 ;
gap : 28 rpx 21 rpx ;
font - weight : 500 ;
}
margin - bottom : 25 rpx ;
margin - top : 25 rpx ;
. add - repair - type - btn {
}
flex : 0 0 calc ( ( 100 % - 42 rpx ) / 3 ) ;
box - sizing : border - box ;
height : 73 rpx ;
. add - repair - type - list {
background : # F2F7FF ;
display : flex ;
color : # 2186 FF ;
flex - wrap : wrap ;
font - size : 26 rpx ;
gap : 28 rpx 21 rpx ;
border - radius : 8 rpx ;
}
display : flex ;
align - items : center ;
. add - repair - type - btn {
justify - content : center ;
flex : 0 0 calc ( ( 100 % - 42 rpx ) / 3 ) ;
border : none ;
box - sizing : border - box ;
}
height : 73 rpx ;
background : # F2F7FF ;
. add - repair - type - btn . selected {
color : # 2186 FF ;
background : # 2186 FF ;
font - size : 26 rpx ;
color : # fff ;
border - radius : 8 rpx ;
border : 2 rpx solid # 2186 FF ;
display : flex ;
}
align - items : center ;
justify - content : center ;
. add - repair - type - btn . dashed {
border : none ;
border : 2 rpx dashed # BDBDBD ;
}
background : # fff ;
color : # 2186 FF ;
. add - repair - type - btn . selected {
}
background : # 2186 FF ;
color : # fff ;
. add - repair - optional {
border : 2 rpx solid # 2186 FF ;
color : # 888 ;
}
font - size : 24 rpx ;
font - weight : 400 ;
. add - repair - type - btn . dashed {
}
border : 2 rpx dashed # BDBDBD ;
background : # fff ;
. add - repair - detail - textarea {
color : # 2186 FF ;
width : 100 % ;
}
min - height : 120 rpx ;
background : # F7F8FA ;
. add - repair - optional {
border - radius : 10 rpx ;
color : # 888 ;
font - size : 28 rpx ;
font - size : 24 rpx ;
color : # 888 ;
font - weight : 400 ;
padding : 18 rpx ;
}
margin - top : 18 rpx ;
box - sizing : border - box ;
. add - repair - detail - textarea {
}
width : 100 % ;
min - height : 120 rpx ;
. add - repair - submit - btn {
background : # F7F8FA ;
width : 6 0vw ;
border - radius : 1 0rpx ;
height : 73 rpx ;
font - size : 28 rpx ;
background : linear - gradient ( 90 deg , # 005 DE9 0 % , # 4 B9BFF 100 % ) ;
color : # 888 ;
color : # fff ;
padding : 18 rpx ;
font - size : 32 rpx ;
margin - top : 18 rpx ;
border : none ;
box - sizing : border - box ;
border - radius : 40 rpx ;
}
margin : 100 rpx auto 0 auto ;
display : block ;
. add - repair - submit - btn {
font - weight : bold ;
width : 60 vw ;
box - shadow : 0 8 rpx 24 rpx rgba ( 0 , 0 , 0 , 0.18 ) ;
height : 73 rpx ;
}
background : linear - gradient ( 90 deg , # 005 DE9 0 % , # 4 B9BFF 100 % ) ;
color : # fff ;
font - size : 32 rpx ;
border : none ;
border - radius : 40 rpx ;
margin : 100 rpx auto 0 auto ;
display : block ;
font - weight : bold ;
box - shadow : 0 8 rpx 24 rpx rgba ( 0 , 0 , 0 , 0.18 ) ;
}
< / style >
< / style >