Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
glsx
/
gl_tape
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
3
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 2d2a2b48
authored
Oct 04, 2025
by
cen
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix: 修复显示问题
1 parent
166d259f
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
319 additions
and
121 deletions
assets/.DS_Store
pages/evaluationForm/addEvaluationFrom.vue
pages/evaluationForm/components/ButtonModule.vue
pages/evaluationForm/components/FormCell.vue
pages/evaluationForm/components/evaluationCard.vue
pages/evaluationForm/components/searchBox.vue
pages/evaluationForm/components/uploadMedia.vue
pages/evaluationForm/evaluationFormDetails.vue
pages/evaluationForm/index.vue
utils/ossUpload.js
utils/ossUploadFile/uploadFile.js
assets/.DS_Store
View file @
2d2a2b4
No preview for this file type
pages/evaluationForm/addEvaluationFrom.vue
View file @
2d2a2b4
...
@@ -220,7 +220,7 @@ export default {
...
@@ -220,7 +220,7 @@ export default {
otherImagesData
:
{},
otherImagesData
:
{},
currentStep
:
1
,
// 当前步骤,默认为1
currentStep
:
1
,
// 当前步骤,默认为1
formFields
:
[
formFields
:
[
{
key
:
'sellerUserId'
,
label
:
'销售顾问'
,
required
:
true
,
fullWidth
:
false
,
targetNameKey
:
'sellerName'
,
sourceNameKey
:
'staffName'
,
sourceKey
:
'uuid'
,
targetKey
:
'sellerUserId'
,
targetObj
:
'evalOrderBasicReqDTO'
,
type
:
'select'
,
showText
:
'shopMerchantName'
},
{
key
:
'sellerUserId'
,
label
:
'销售顾问'
,
required
:
true
,
fullWidth
:
false
,
targetNameKey
:
'sellerName'
,
sourceNameKey
:
'staffName'
,
sourceKey
:
'uuid'
,
targetKey
:
'sellerUserId'
,
targetObj
:
'evalOrderBasicReqDTO'
,
type
:
'select'
},
{
key
:
'brandModel'
,
label
:
'品牌车型'
,
required
:
true
,
fullWidth
:
false
,
targetNameKey
:
'carBrand'
,
sourceNameKey
:
'staffName'
,
sourceKey
:
'uuid'
,
targetKey
:
'carBrandId'
,
targetObj
:
'carBaseReqDTO'
,
type
:
'select'
,
isCar
:
true
},
{
key
:
'brandModel'
,
label
:
'品牌车型'
,
required
:
true
,
fullWidth
:
false
,
targetNameKey
:
'carBrand'
,
sourceNameKey
:
'staffName'
,
sourceKey
:
'uuid'
,
targetKey
:
'carBrandId'
,
targetObj
:
'carBaseReqDTO'
,
type
:
'select'
,
isCar
:
true
},
{
key
:
'vin'
,
label
:
'车架号'
,
required
:
true
,
maxlength
:
17
,
fullWidth
:
false
,
targetNameKey
:
'sellerName'
,
sourceNameKey
:
'staffName'
,
sourceKey
:
'uuid'
,
targetKey
:
'vin'
,
targetObj
:
'carBaseReqDTO'
,
type
:
'input'
,
showText
:
'shopMerchantName'
,
isScan
:
true
,
pattern
:
'^[A-Z0-9]{17}$'
},
{
key
:
'vin'
,
label
:
'车架号'
,
required
:
true
,
maxlength
:
17
,
fullWidth
:
false
,
targetNameKey
:
'sellerName'
,
sourceNameKey
:
'staffName'
,
sourceKey
:
'uuid'
,
targetKey
:
'vin'
,
targetObj
:
'carBaseReqDTO'
,
type
:
'input'
,
showText
:
'shopMerchantName'
,
isScan
:
true
,
pattern
:
'^[A-Z0-9]{17}$'
},
{
key
:
'licensePlate'
,
label
:
'车牌号'
,
required
:
true
,
maxlength
:
10
,
fullWidth
:
false
,
targetNameKey
:
'sellerName'
,
sourceNameKey
:
'staffName'
,
sourceKey
:
'uuid'
,
targetKey
:
'licensePlate'
,
targetObj
:
'carBaseReqDTO'
,
type
:
'input'
,
showText
:
'shopMerchantName'
},
{
key
:
'licensePlate'
,
label
:
'车牌号'
,
required
:
true
,
maxlength
:
10
,
fullWidth
:
false
,
targetNameKey
:
'sellerName'
,
sourceNameKey
:
'staffName'
,
sourceKey
:
'uuid'
,
targetKey
:
'licensePlate'
,
targetObj
:
'carBaseReqDTO'
,
type
:
'input'
,
showText
:
'shopMerchantName'
},
...
@@ -454,7 +454,7 @@ export default {
...
@@ -454,7 +454,7 @@ export default {
targetKey
:
'conditionDescription'
,
targetKey
:
'conditionDescription'
,
targetObj
:
'carBaseReqDTO'
,
targetObj
:
'carBaseReqDTO'
,
type
:
'textarea'
,
type
:
'textarea'
,
maxlength
:
10
00
maxlength
:
2
00
}
}
],
],
licenseFormFields
:
[
licenseFormFields
:
[
...
@@ -1011,6 +1011,7 @@ export default {
...
@@ -1011,6 +1011,7 @@ export default {
if
(
res
.
data
.
code
==
0
)
{
if
(
res
.
data
.
code
==
0
)
{
if
(
res
.
data
.
data
.
status
==
1
)
{
if
(
res
.
data
.
data
.
status
==
1
)
{
this
.
formData
.
carBaseReqDTO
.
vin
=
res
.
data
.
data
.
vin
this
.
formData
.
carBaseReqDTO
.
vin
=
res
.
data
.
data
.
vin
uni
.
showToast
({
title
:
'车架号识别完成并已自动填写到表单中'
,
icon
:
'none'
})
uni
.
hideLoading
()
uni
.
hideLoading
()
}
else
{
}
else
{
uni
.
showToast
({
title
:
res
.
data
.
data
.
errorMessage
,
icon
:
'none'
})
uni
.
showToast
({
title
:
res
.
data
.
data
.
errorMessage
,
icon
:
'none'
})
...
@@ -1038,6 +1039,7 @@ export default {
...
@@ -1038,6 +1039,7 @@ export default {
console
.
log
(
'res:'
,
res
)
console
.
log
(
'res:'
,
res
)
uni
.
hideLoading
()
uni
.
hideLoading
()
if
(
res
.
data
.
code
==
0
)
{
if
(
res
.
data
.
code
==
0
)
{
uni
.
showToast
({
title
:
'行驶证信息识别完成,已自动填写到表单中'
,
icon
:
'none'
})
if
(
res
.
data
.
data
.
status
==
1
)
{
if
(
res
.
data
.
data
.
status
==
1
)
{
this
.
formData
.
carBaseReqDTO
.
engineNumber
=
res
.
data
.
data
.
engineNumber
this
.
formData
.
carBaseReqDTO
.
engineNumber
=
res
.
data
.
data
.
engineNumber
if
(
this
.
title
==
'新增评估单'
)
{
if
(
this
.
title
==
'新增评估单'
)
{
...
...
pages/evaluationForm/components/ButtonModule.vue
View file @
2d2a2b4
<
template
>
<
template
>
<div
class=
"button-module flex"
>
<div
class=
"button-module flex"
>
<view
class=
"common-btn"
@
click
.
stop=
"handleClick('details')"
>
详情
</view>
<view
class=
"common-btn"
@
click
.
stop=
"handleClick('details')"
>
详情
</view>
<view
v-if=
"!subStatus && status != 100"
class=
"common-btn ml-24"
@
click
.
stop=
"handleClick('edit')"
>
编辑
</view>
<view
v-if=
"!subStatus && status != 100
&& status != '-1'
"
class=
"common-btn ml-24"
@
click
.
stop=
"handleClick('edit')"
>
编辑
</view>
<view
v-if=
"status == 20 && !subStatus"
class=
"common-btn ml-24"
@
click
.
stop=
"handleClick('requote','app_evaluate_requote')"
>
重新报价
</view>
<view
v-if=
"status == 20 && !subStatus"
class=
"common-btn ml-24"
@
click
.
stop=
"handleClick('requote',
'app_evaluate_requote')"
>
重新报价
</view>
<view
v-if=
"status == 20 && !subStatus"
class=
"common-btn blue-btn ml-24"
@
click
.
stop=
"handleClick('sign','app_evaluate_sign')"
>
客户签约
</view>
<view
v-if=
"status == 20 && !subStatus"
class=
"common-btn blue-btn ml-24"
@
click
.
stop=
"handleClick('sign',
'app_evaluate_sign')"
>
客户签约
</view>
<view
v-if=
"status == 20 && subStatus == 1"
class=
"common-btn gray-btn ml-24"
@
click
.
stop=
"handleClick('signing')"
>
签约中
</view>
<view
v-if=
"status == 20 && subStatus == 1"
class=
"common-btn gray-btn ml-24"
@
click
.
stop=
"handleClick('signing')"
>
签约中
</view>
<view
v-if=
"status == 30 && !subStatus"
class=
"common-btn ml-24"
@
click
.
stop=
"handleClick('cancelSign','app_evaluate_cancel_sign')"
>
取消签约
</view>
<view
v-if=
"status == 30 && !subStatus"
class=
"common-btn ml-24"
@
click
.
stop=
"handleClick('cancelSign',
'app_evaluate_cancel_sign')"
>
取消签约
</view>
<view
v-if=
"status == 30 && !subStatus && paymentType == 1"
class=
"common-btn blue-btn ml-24"
@
click
.
stop=
"handleClick('payDeposit','app_evaluate_pay_deposit')"
>
支付定金
</view>
<view
v-if=
"status == 30 && !subStatus && paymentType == 1"
class=
"common-btn blue-btn ml-24"
@
click
.
stop=
"handleClick('payDeposit',
'app_evaluate_pay_deposit')"
>
支付定金
</view>
<view
v-if=
"status == 30 && !subStatus && paymentType == 2"
class=
"common-btn blue-btn ml-24"
@
click
.
stop=
"handleClick('payFull','app_evaluate_pay_full')"
>
支付全款
</view>
<view
v-if=
"status == 30 && !subStatus && paymentType == 2"
class=
"common-btn blue-btn ml-24"
@
click
.
stop=
"handleClick('payFull',
'app_evaluate_pay_full')"
>
支付全款
</view>
<view
v-if=
"subStatus == 2 || subStatus == 3"
class=
"common-btn gray-btn ml-24"
@
click
.
stop=
"handleClick('paying')"
>
支付中
</view>
<view
v-if=
"subStatus == 2 || subStatus == 3"
class=
"common-btn gray-btn ml-24"
@
click
.
stop=
"handleClick('paying')"
>
支付中
</view>
<view
v-if=
"status == 40 && !subStatus && paymentType == 1"
class=
"common-btn blue-btn ml-24"
@
click
.
stop=
"handleClick('payFull','app_evaluate_pay_final')"
>
支付尾款
</view>
<view
v-if=
"status == 40 && !subStatus && paymentType == 1"
class=
"common-btn blue-btn ml-24"
@
click
.
stop=
"handleClick('payFull',
'app_evaluate_pay_final')"
>
支付尾款
</view>
<view
v-if=
"status == 50 && !subStatus"
class=
"common-btn blue-btn ml-24"
@
click
.
stop=
"handleClick('confirmDelivery','app_evaluate_confirm_delivery')"
>
确认交车
</view>
<view
v-if=
"status == 50 && !subStatus"
class=
"common-btn blue-btn ml-24"
@
click
.
stop=
"handleClick('confirmDelivery',
'app_evaluate_confirm_delivery')"
>
确认交车
</view>
<view
v-if=
"status == '-1'"
class=
"common-btn blue-btn ml-24"
@
click
.
stop=
"handleClick('reSubmit','app_evaluate_re_submit')"
>
重新提交
</view>
<view
v-if=
"status == '-1'"
class=
"common-btn blue-btn ml-24"
@
click
.
stop=
"handleClick('reSubmit',
'app_evaluate_re_submit')"
>
重新提交
</view>
</div>
</div>
</
template
>
</
template
>
...
@@ -38,13 +38,14 @@ export default {
...
@@ -38,13 +38,14 @@ export default {
}
}
},
},
methods
:
{
methods
:
{
handleClick
(
buttonType
,
eventCode
)
{
handleClick
(
buttonType
,
eventCode
)
{
this
.
$emit
(
'button-click'
,
{
this
.
$emit
(
'button-click'
,
{
type
:
buttonType
type
:
buttonType
})
})
if
(
eventCode
)
uni
.
$track
.
add
({
if
(
eventCode
)
eventCode
uni
.
$track
.
add
({
})
//点击埋点
eventCode
})
//点击埋点
}
}
}
}
}
}
...
...
pages/evaluationForm/components/FormCell.vue
View file @
2d2a2b4
...
@@ -24,7 +24,7 @@
...
@@ -24,7 +24,7 @@
{{ field.targetObj ? formData[field.targetObj][field.targetNameKey] : formData[field.targetNameKey] }}
{{ field.targetObj ? formData[field.targetObj][field.targetNameKey] : formData[field.targetNameKey] }}
</view>
</view>
<view
v-else-if=
"field.isCar"
>
<view
v-else-if=
"field.isCar"
>
{{ formData.carBaseReqDTO.car
Series
Name + ' ' + formData.carBaseReqDTO.carTypeName }}
{{ formData.carBaseReqDTO.car
ChildsBrand
Name + ' ' + formData.carBaseReqDTO.carTypeName }}
</view>
</view>
<view
v-else-if=
"field.isCity"
>
<view
v-else-if=
"field.isCity"
>
{{ formData.carBaseReqDTO.registrationProvinceName + ' ' + formData.carBaseReqDTO.registrationCityName }}
{{ formData.carBaseReqDTO.registrationProvinceName + ' ' + formData.carBaseReqDTO.registrationCityName }}
...
@@ -272,6 +272,9 @@ export default {
...
@@ -272,6 +272,9 @@ export default {
text-align
:
right
;
text-align
:
right
;
outline
:
none
;
outline
:
none
;
}
}
.formInput
:disabled
{
color
:
#999999
;
}
.cellLabel
{
.cellLabel
{
color
:
#333333
;
color
:
#333333
;
font-size
:
toRpx
(
28
);
font-size
:
toRpx
(
28
);
...
...
pages/evaluationForm/components/evaluationCard.vue
View file @
2d2a2b4
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
<image
:src=
"carInfo.coverImage"
alt=
""
/>
<image
:src=
"carInfo.coverImage"
alt=
""
/>
<view
class=
"ml-32 flex-1"
>
<view
class=
"ml-32 flex-1"
>
<view
class=
"flex align-center car-type-name mb-16"
>
<view
class=
"flex align-center car-type-name mb-16"
>
{{
carInfo
.
car
Series
Name
+
' '
+
carInfo
.
carTypeName
}}
{{
carInfo
.
car
ChildsBrand
Name
+
' '
+
carInfo
.
carTypeName
}}
<view
class=
"common-label ml-20"
>
{{
carInfo
.
previousOwnerName
}}
{{
carInfo
.
previousOwnerPhone
}}
</view>
<view
class=
"common-label ml-20"
>
{{
carInfo
.
previousOwnerName
}}
{{
carInfo
.
previousOwnerPhone
}}
</view>
</view>
</view>
<view
class=
"flex mb-20"
>
<view
class=
"flex mb-20"
>
...
...
pages/evaluationForm/components/searchBox.vue
View file @
2d2a2b4
...
@@ -59,7 +59,7 @@ export default {
...
@@ -59,7 +59,7 @@ export default {
popKey
:
'licensePlate'
popKey
:
'licensePlate'
},
},
{
{
placeholder
:
'
评估单
号'
,
placeholder
:
'
工单编
号'
,
key
:
'carModel'
,
key
:
'carModel'
,
type
:
'input'
,
type
:
'input'
,
popKey
:
'evalOrderNo'
popKey
:
'evalOrderNo'
...
...
pages/evaluationForm/components/uploadMedia.vue
View file @
2d2a2b4
...
@@ -35,7 +35,8 @@
...
@@ -35,7 +35,8 @@
</view>
</view>
</
template
>
</
template
>
<
script
>
<
script
>
import
{
uploadFile
}
from
'@/utils/ossUploadFile/uploadFile.js'
// import { uploadFile } from '@/utils/ossUploadFile/uploadFile.js'
import
{
uploadFile
}
from
'@/utils/ossUpload.js'
export
default
{
export
default
{
name
:
'UploadMedia'
,
name
:
'UploadMedia'
,
...
@@ -117,6 +118,13 @@ export default {
...
@@ -117,6 +118,13 @@ export default {
sourceType
:
[
'camera'
],
sourceType
:
[
'camera'
],
success
:
async
res
=>
{
success
:
async
res
=>
{
try
{
try
{
const
MAX_IMAGE_SIZE
=
10
*
1024
*
1024
// 10MB
for
(
const
file
of
res
.
tempFiles
)
{
if
(
file
.
size
>
MAX_IMAGE_SIZE
)
{
uni
.
showToast
({
title
:
'图片上传最大10MB'
,
icon
:
'none'
})
return
}
}
uni
.
showLoading
({
title
:
'上传中...'
})
uni
.
showLoading
({
title
:
'上传中...'
})
// 上传所有选择的图片
// 上传所有选择的图片
for
(
const
tempFilePath
of
res
.
tempFilePaths
)
{
for
(
const
tempFilePath
of
res
.
tempFilePaths
)
{
...
@@ -129,7 +137,7 @@ export default {
...
@@ -129,7 +137,7 @@ export default {
}
}
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
log
(
'上传图片失败'
,
error
)
console
.
log
(
'上传图片失败'
,
error
)
uni
.
showToast
({
title
:
'
上传图片失败
'
,
icon
:
'none'
})
uni
.
showToast
({
title
:
'
图片上传失败,请重试
'
,
icon
:
'none'
})
}
}
},
},
fail
:
err
=>
{
fail
:
err
=>
{
...
@@ -149,12 +157,19 @@ export default {
...
@@ -149,12 +157,19 @@ export default {
sizeType
:
[
'compressed'
],
sizeType
:
[
'compressed'
],
sourceType
:
[
'album'
],
sourceType
:
[
'album'
],
success
:
async
res
=>
{
success
:
async
res
=>
{
console
.
log
(
res
,
'选择图片'
)
try
{
try
{
const
MAX_IMAGE_SIZE
=
10
*
1024
*
1024
// 10MB
for
(
const
file
of
res
.
tempFiles
)
{
if
(
file
.
size
>
MAX_IMAGE_SIZE
)
{
uni
.
showToast
({
title
:
'图片上传最大10MB'
,
icon
:
'none'
})
return
}
}
uni
.
showLoading
({
title
:
'上传中...'
})
uni
.
showLoading
({
title
:
'上传中...'
})
// 上传所有选择的图片
// 上传所有选择的图片
for
(
const
tempFilePath
of
res
.
tempFilePaths
)
{
for
(
let
i
=
0
;
i
<
res
.
tempFilePaths
.
length
;
i
++
)
{
console
.
log
(
res
,
'上传所有选择的图片'
)
const
url
=
await
uploadFile
(
res
.
tempFiles
[
i
],
res
.
tempFilePaths
[
i
])
const
url
=
await
uploadFile
(
tempFilePath
)
console
.
log
(
'上传图片成功'
,
url
)
console
.
log
(
'上传图片成功'
,
url
)
uni
.
hideLoading
()
uni
.
hideLoading
()
// const fileExtension = res.tempFiles[0]?.name ? res.tempFiles[0]?.name.split('.').pop().toLowerCase() : res.tempFiles[0]?.path.split('.').pop().toLowerCase()
// const fileExtension = res.tempFiles[0]?.name ? res.tempFiles[0]?.name.split('.').pop().toLowerCase() : res.tempFiles[0]?.path.split('.').pop().toLowerCase()
...
@@ -162,7 +177,7 @@ export default {
...
@@ -162,7 +177,7 @@ export default {
}
}
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
log
(
'上传图片失败'
,
error
)
console
.
log
(
'上传图片失败'
,
error
)
uni
.
showToast
({
title
:
'
上传图片失败
'
,
icon
:
'none'
})
uni
.
showToast
({
title
:
'
图片上传失败,请重试
'
,
icon
:
'none'
})
}
}
},
},
fail
:
err
=>
{
fail
:
err
=>
{
...
@@ -184,8 +199,18 @@ export default {
...
@@ -184,8 +199,18 @@ export default {
success
:
async
res
=>
{
success
:
async
res
=>
{
console
.
log
(
'拍摄视频成功'
,
res
)
console
.
log
(
'拍摄视频成功'
,
res
)
try
{
try
{
const
MAX_VIDEO_SIZE
=
100
*
1024
*
1024
// 100MB
if
(
res
.
size
>
MAX_VIDEO_SIZE
)
{
uni
.
showToast
({
title
:
'视频上传最大100MB'
,
icon
:
'none'
})
return
}
uni
.
showLoading
({
title
:
'上传中...'
})
uni
.
showLoading
({
title
:
'上传中...'
})
const
url
=
await
uploadFile
(
res
.
tempFilePath
)
// #ifdef H5
const
url
=
await
uploadFile
(
res
.
tempFile
,
res
.
tempFilePath
)
// #endif
// #ifdef APP-PLUS
const
url
=
await
uploadFile
(
null
,
res
.
tempFilePath
)
// #endif
console
.
log
(
'上传视频成功'
,
url
)
console
.
log
(
'上传视频成功'
,
url
)
// const fileExtension = res.name ? res.name.split('.').pop().toLowerCase() : res.tempFilePath.split('.').pop().toLowerCase()
// const fileExtension = res.name ? res.name.split('.').pop().toLowerCase() : res.tempFilePath.split('.').pop().toLowerCase()
this
.
addMedia
(
field
,
{
this
.
addMedia
(
field
,
{
...
@@ -200,7 +225,7 @@ export default {
...
@@ -200,7 +225,7 @@ export default {
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
log
(
'上传视频失败'
,
error
)
console
.
log
(
'上传视频失败'
,
error
)
uni
.
hideLoading
()
uni
.
hideLoading
()
uni
.
showToast
({
title
:
'
上传视频失败
'
,
icon
:
'none'
})
uni
.
showToast
({
title
:
'
视频上传失败,请重试
'
,
icon
:
'none'
})
}
}
},
},
fail
:
err
=>
{
fail
:
err
=>
{
...
@@ -221,8 +246,19 @@ export default {
...
@@ -221,8 +246,19 @@ export default {
success
:
async
res
=>
{
success
:
async
res
=>
{
console
.
log
(
'选择视频成功'
,
res
)
console
.
log
(
'选择视频成功'
,
res
)
try
{
try
{
const
MAX_VIDEO_SIZE
=
100
*
1024
*
1024
// 100MB
if
(
res
.
size
>
MAX_VIDEO_SIZE
)
{
uni
.
showToast
({
title
:
'视频上传最大100MB'
,
icon
:
'none'
})
return
}
uni
.
showLoading
({
title
:
'上传中...'
})
uni
.
showLoading
({
title
:
'上传中...'
})
const
url
=
await
uploadFile
(
res
.
tempFilePath
)
// #ifdef H5
const
url
=
await
uploadFile
(
res
.
tempFile
,
res
.
tempFilePath
)
// #endif
// #ifdef APP-PLUS
const
url
=
await
uploadFile
(
null
,
res
.
tempFilePath
)
// #endif
console
.
log
(
'上传视频成功'
,
url
)
console
.
log
(
'上传视频成功'
,
url
)
// const fileExtension = res.name ? res.name.split('.').pop().toLowerCase() : res.tempFilePath.split('.').pop().toLowerCase()
// const fileExtension = res.name ? res.name.split('.').pop().toLowerCase() : res.tempFilePath.split('.').pop().toLowerCase()
this
.
addMedia
(
field
,
{
this
.
addMedia
(
field
,
{
...
@@ -237,7 +273,7 @@ export default {
...
@@ -237,7 +273,7 @@ export default {
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
log
(
'上传视频失败'
,
error
)
console
.
log
(
'上传视频失败'
,
error
)
uni
.
hideLoading
()
uni
.
hideLoading
()
uni
.
showToast
({
title
:
'
上传视频失败
'
,
icon
:
'none'
})
uni
.
showToast
({
title
:
'
视频上传失败,请重试
'
,
icon
:
'none'
})
}
}
},
},
fail
:
err
=>
{
fail
:
err
=>
{
...
...
pages/evaluationForm/evaluationFormDetails.vue
View file @
2d2a2b4
...
@@ -37,13 +37,16 @@
...
@@ -37,13 +37,16 @@
<view
v-if=
"activeTabKey == 'carInfo'"
class=
"gridBox"
>
<view
v-if=
"activeTabKey == 'carInfo'"
class=
"gridBox"
>
<view
v-for=
"(item, index) in carInfoItems"
:key=
"index"
:class=
"['flex align-center', { 'full-width': item.fullWidth }]"
>
<view
v-for=
"(item, index) in carInfoItems"
:key=
"index"
:class=
"['flex align-center', { 'full-width': item.fullWidth }]"
>
<view
class=
"title-label-see mr-16"
>
{{ item.label }}
</view>
<view
class=
"title-label-see mr-16"
>
{{ item.label }}
</view>
<view
class=
"flex-1"
>
{{ formatValue(item, detailsInfo) || '-' }}
</view>
<view
class=
"flex-1"
>
{{ formatValue(item, detailsInfo) }}
<text>
{{ item.cell }}
</text>
</view>
</view>
</view>
</view>
</view>
<view
v-else-if=
"activeTabKey == 'carLicense'"
class=
"gridBox mb-32"
>
<view
v-else-if=
"activeTabKey == 'carLicense'"
class=
"gridBox mb-32"
>
<view
v-for=
"(item, index) in carLicenseItems"
:key=
"index"
:class=
"['flex align-center', { 'full-width': item.fullWidth }]"
>
<view
v-for=
"(item, index) in carLicenseItems"
:key=
"index"
:class=
"['flex align-center', { 'full-width': item.fullWidth }]"
>
<view
class=
"title-label-see mr-16"
>
{{ item.label }}
</view>
<view
class=
"title-label-see mr-16"
>
{{ item.label }}
</view>
<view
class=
"flex-1"
>
{{ formatValue(item, detailsInfo)
|| '-'
}}
</view>
<view
class=
"flex-1"
>
{{ formatValue(item, detailsInfo) }}
</view>
</view>
</view>
</view>
</view>
<view
v-else-if=
"activeTabKey == 'images'"
>
<view
v-else-if=
"activeTabKey == 'images'"
>
...
@@ -155,7 +158,7 @@
...
@@ -155,7 +158,7 @@
</view>
</view>
</view>
</view>
</view>
</view>
<view
v-else
>
{{ formatValue(item, detailsInfo)
|| '-'
}}
</view>
<view
v-else
>
{{ formatValue(item, detailsInfo) }}
</view>
</view>
</view>
</view>
</view>
</view>
</view>
...
@@ -176,7 +179,7 @@
...
@@ -176,7 +179,7 @@
</view>
</view>
</view>
</view>
</view>
</view>
<view
v-else
>
{{
formatValue
(
item
,
detailsInfo
)
||
'-'
}}
</view>
<view
v-else
>
{{
formatValue
(
item
,
detailsInfo
)
}}
</view>
</view>
</view>
</
template
>
</
template
>
</view>
</view>
...
@@ -198,7 +201,7 @@
...
@@ -198,7 +201,7 @@
</view>
</view>
</view>
</view>
</view>
</view>
<view
v-else
>
{{
formatValue
(
item
,
detailsInfo
)
||
'-'
}}
</view>
<view
v-else
>
{{
formatValue
(
item
,
detailsInfo
)
}}
</view>
</view>
</view>
</
template
>
</
template
>
</view>
</view>
...
@@ -431,14 +434,14 @@ export default {
...
@@ -431,14 +434,14 @@ export default {
],
],
carInfoItems
:
[
carInfoItems
:
[
{
label
:
'销售顾问'
,
key
:
'basic.sellerName'
},
{
label
:
'销售顾问'
,
key
:
'basic.sellerName'
},
{
label
:
'品牌车型'
,
key
:
'carInfo.car
Series
Name'
,
formatter
:
(
val
,
data
)
=>
`
${
val
}
${
data
.
carInfo
.
carTypeName
}
`
},
{
label
:
'品牌车型'
,
key
:
'carInfo.car
ChildsBrand
Name'
,
formatter
:
(
val
,
data
)
=>
`
${
val
}
${
data
.
carInfo
.
carTypeName
}
`
},
{
label
:
'车架号'
,
key
:
'carInfo.vin'
},
{
label
:
'车架号'
,
key
:
'carInfo.vin'
},
{
label
:
'车牌号'
,
key
:
'carInfo.licensePlate'
},
{
label
:
'车牌号'
,
key
:
'carInfo.licensePlate'
},
{
label
:
'发动机号'
,
key
:
'carInfo.engineNumber'
},
{
label
:
'发动机号'
,
key
:
'carInfo.engineNumber'
},
{
label
:
'上牌时间'
,
key
:
'carInfo.registrationDate'
},
{
label
:
'上牌时间'
,
key
:
'carInfo.registrationDate'
},
{
label
:
'上牌城市'
,
key
:
'carInfo.registrationCityName'
},
{
label
:
'上牌城市'
,
key
:
'carInfo.registrationCityName'
},
{
label
:
'车辆所在地'
,
key
:
'carInfo.carProvinceName'
,
formatter
:
(
val
,
data
)
=>
`
${
val
}
-
${
data
.
carInfo
.
carCityName
}
`
},
{
label
:
'车辆所在地'
,
key
:
'carInfo.carProvinceName'
,
formatter
:
(
val
,
data
)
=>
`
${
val
}
-
${
data
.
carInfo
.
carCityName
}
`
},
{
label
:
'表显里程'
,
key
:
'carInfo.mileage'
},
{
label
:
'表显里程'
,
key
:
'carInfo.mileage'
,
cell
:
'公里'
},
{
label
:
'使用性质'
,
key
:
'carInfo.usageType'
,
map
:
'usageTypeMap'
},
{
label
:
'使用性质'
,
key
:
'carInfo.usageType'
,
map
:
'usageTypeMap'
},
{
label
:
'所有人性质'
,
key
:
'carInfo.ownerType'
,
map
:
'ownerTypeMap'
},
{
label
:
'所有人性质'
,
key
:
'carInfo.ownerType'
,
map
:
'ownerTypeMap'
},
{
label
:
'天窗'
,
key
:
'carInfo.sunroof'
,
map
:
'sunroofMap'
},
{
label
:
'天窗'
,
key
:
'carInfo.sunroof'
,
map
:
'sunroofMap'
},
...
@@ -447,7 +450,7 @@ export default {
...
@@ -447,7 +450,7 @@ export default {
{
label
:
'外观颜色'
,
key
:
'carInfo.exteriorColor'
},
{
label
:
'外观颜色'
,
key
:
'carInfo.exteriorColor'
},
{
label
:
'内饰颜色'
,
key
:
'carInfo.interiorColor'
},
{
label
:
'内饰颜色'
,
key
:
'carInfo.interiorColor'
},
{
label
:
'生产日期'
,
key
:
'carInfo.productionDate'
},
{
label
:
'生产日期'
,
key
:
'carInfo.productionDate'
},
{
label
:
'指导价'
,
key
:
'carInfo.guidePrice'
},
{
label
:
'指导价'
,
key
:
'carInfo.guidePrice'
,
cell
:
'元'
},
{
label
:
'是否购买新车'
,
key
:
'carInfo.buyNewCar'
,
map
:
'buyNewCarMap'
},
{
label
:
'是否购买新车'
,
key
:
'carInfo.buyNewCar'
,
map
:
'buyNewCarMap'
},
{
label
:
'是否事故车'
,
key
:
'carInfo.hasAccident'
,
map
:
'hasAccidentMap'
},
{
label
:
'是否事故车'
,
key
:
'carInfo.hasAccident'
,
map
:
'hasAccidentMap'
},
{
label
:
'综合评价'
,
key
:
'carInfo.overallRating'
,
map
:
'overallRatingMap'
,
fullWidth
:
true
},
{
label
:
'综合评价'
,
key
:
'carInfo.overallRating'
,
map
:
'overallRatingMap'
,
fullWidth
:
true
},
...
@@ -664,33 +667,26 @@ export default {
...
@@ -664,33 +667,26 @@ export default {
formatValue
(
item
,
data
)
{
formatValue
(
item
,
data
)
{
const
rawValue
=
this
.
getFieldValue
(
data
,
item
.
key
)
const
rawValue
=
this
.
getFieldValue
(
data
,
item
.
key
)
// 如果有自定义格式化器,使用它
if
(
item
.
formatter
&&
typeof
item
.
formatter
===
'function'
)
{
if
(
item
.
formatter
&&
typeof
item
.
formatter
===
'function'
)
{
return
item
.
formatter
(
rawValue
,
data
)
return
item
.
formatter
(
rawValue
,
data
)
}
}
// 如果有映射表,使用映射表
if
(
item
.
map
&&
this
[
item
.
map
])
{
if
(
item
.
map
&&
this
[
item
.
map
])
{
return
this
[
item
.
map
][
rawValue
]
||
rawValue
return
this
[
item
.
map
][
rawValue
]
||
rawValue
}
}
console
.
log
(
'rawValue:'
,
rawValue
,
item
.
key
)
console
.
log
(
'rawValue:'
,
rawValue
,
item
.
key
)
// 返回原始值(如果为空则返回空字符串)
return
rawValue
||
''
return
rawValue
==
0
?
0
:
rawValue
||
''
},
},
// 根据fileSubtype获取图片
getImageBySubtype
(
subtype
)
{
getImageBySubtype
(
subtype
)
{
if
(
!
this
.
detailsInfo
.
images
)
return
[]
if
(
!
this
.
detailsInfo
.
images
)
return
[]
// 对于fileSubtype=41,返回所有匹配的图片数组
if
(
subtype
===
41
)
{
if
(
subtype
===
41
)
{
return
this
.
detailsInfo
.
images
.
filter
(
img
=>
img
.
fileSubtype
===
subtype
)
return
this
.
detailsInfo
.
images
.
filter
(
img
=>
img
.
fileSubtype
===
subtype
)
}
}
// 对于其他subtype,保持原有行为返回第一个匹配的图片
const
obj
=
this
.
detailsInfo
.
images
.
find
(
img
=>
img
.
fileSubtype
===
subtype
)
||
null
const
obj
=
this
.
detailsInfo
.
images
.
find
(
img
=>
img
.
fileSubtype
===
subtype
)
||
null
return
obj
return
obj
},
},
// 获取图片标签名称
getImageLabel
(
fileSubtype
)
{
getImageLabel
(
fileSubtype
)
{
// 这里使用已有的fileSuibtype映射
return
this
.
fileSuibtype
[
fileSubtype
]?.
name
||
`未知类型(
${
fileSubtype
}
)`
return
this
.
fileSuibtype
[
fileSubtype
]?.
name
||
`未知类型(
${
fileSubtype
}
)`
},
},
previewMedia
(
media
,
type
)
{
previewMedia
(
media
,
type
)
{
...
...
pages/evaluationForm/index.vue
View file @
2d2a2b4
...
@@ -24,7 +24,7 @@
...
@@ -24,7 +24,7 @@
<view
class=
"addBtn"
@
click
.
stop=
"addEvaluationForm({ type: 'add' })"
>
<view
class=
"addBtn"
@
click
.
stop=
"addEvaluationForm({ type: 'add' })"
>
<view
class=
"sprite-icon icon-addEvaluationFrom"
></view>
<view
class=
"sprite-icon icon-addEvaluationFrom"
></view>
</view>
</view>
<GeneralPopup
ref=
"requotePopup"
popupClass=
"requotePopup"
title=
"重新报价"
confirmText=
"重新报价"
type=
"center"
:showClose=
"true"
:isShowCancel=
"false"
:autoClose=
"false"
@
confirm=
"confirmRequote"
>
<GeneralPopup
ref=
"requotePopup"
popupClass=
"requotePopup"
title=
"重新报价"
confirmText=
"
申请
重新报价"
type=
"center"
:showClose=
"true"
:isShowCancel=
"false"
:autoClose=
"false"
@
confirm=
"confirmRequote"
>
<
template
#
content
>
<
template
#
content
>
<view
class=
"requote-content"
>
<view
class=
"requote-content"
>
<view
class=
"requote-label mb-24"
>
<view
class=
"requote-label mb-24"
>
...
@@ -32,12 +32,12 @@
...
@@ -32,12 +32,12 @@
<text
class=
"requiredLabel"
>
*
</text>
<text
class=
"requiredLabel"
>
*
</text>
</view>
</view>
<view
class=
"flex align-center intention-input-cell mb-48"
>
<view
class=
"flex align-center intention-input-cell mb-48"
>
<input
class=
"flex-1"
type=
"number"
maxlength=
"6"
placeholder=
"请输入"
v-model=
"requoteObj.customerTargetPrice
"
/>
<input
class=
"flex-1"
type=
"number"
maxlength=
"6"
placeholder=
"请输入"
:value=
"requoteObj.customerTargetPrice"
@
input=
"handlePriceInput
"
/>
<text>
元
</text>
<text>
元
</text>
</view>
</view>
<view
class=
"requote-label mb-24"
>
<view
class=
"requote-label mb-24"
>
客户
意向报价
客户
报价反馈
<text
class=
"requiredLabel"
>
*
</text>
<text
class=
"requiredLabel"
>
*
</text>
</view>
</view>
<textarea
class=
"feedback-textarea"
placeholder-style=
"color:#999999"
placeholder=
"请输入 (200字以内)"
maxlength=
"200"
v-model=
"requoteObj.customerTargetPriceFeedback"
/>
<textarea
class=
"feedback-textarea"
placeholder-style=
"color:#999999"
placeholder=
"请输入 (200字以内)"
maxlength=
"200"
v-model=
"requoteObj.customerTargetPriceFeedback"
/>
...
@@ -156,6 +156,7 @@ import EvaluationCard from './components/evaluationCard.vue'
...
@@ -156,6 +156,7 @@ import EvaluationCard from './components/evaluationCard.vue'
import
ZPMixin
from
'@/uni_modules/z-paging/components/z-paging/js/z-paging-mixin'
import
ZPMixin
from
'@/uni_modules/z-paging/components/z-paging/js/z-paging-mixin'
import
GeneralPopup
from
'./components/GeneralPopup.vue'
import
GeneralPopup
from
'./components/GeneralPopup.vue'
import
OrderPopup
from
'@/components/OrderPopup/index.vue'
import
OrderPopup
from
'@/components/OrderPopup/index.vue'
import
{
set
}
from
'lodash'
export
default
{
export
default
{
name
:
'EvaluationFormList'
,
name
:
'EvaluationFormList'
,
mixins
:
[
ZPMixin
],
mixins
:
[
ZPMixin
],
...
@@ -266,8 +267,10 @@ export default {
...
@@ -266,8 +267,10 @@ export default {
if
(
pageNo
==
1
)
{
if
(
pageNo
==
1
)
{
this
.
getStatByStatus
()
this
.
getStatByStatus
()
}
}
const
userInfo
=
uni
.
$storage
.
get
(
'userInfo'
),
{
shopMerchantId
}
=
userInfo
const
res
=
await
uni
.
$api
.
evaluationApi
.
evalOrderList
({
const
res
=
await
uni
.
$api
.
evaluationApi
.
evalOrderList
({
t
:
{
...
this
.
searchValue
,
status
:
this
.
typeList
[
this
.
tabIndex
].
key
},
t
:
{
...
this
.
searchValue
,
status
:
this
.
typeList
[
this
.
tabIndex
].
key
,
sellerMerchantId
:
shopMerchantId
},
currentPage
:
pageNo
,
currentPage
:
pageNo
,
pageSize
:
10
pageSize
:
10
})
})
...
@@ -312,6 +315,12 @@ export default {
...
@@ -312,6 +315,12 @@ export default {
}
}
})
})
},
},
handlePriceInput
(
e
)
{
console
.
log
(
e
)
const
value
=
e
.
target
?
e
.
target
.
value
.
replace
(
/
[^
0-9
]
/g
,
''
)
:
e
.
detail
.
value
.
replace
(
/
[^
0-9
]
/g
,
''
)
console
.
log
(
'value:'
,
value
)
this
.
$set
(
this
.
requoteObj
,
'customerTargetPrice'
,
value
)
},
addEvaluationForm
(
e
)
{
addEvaluationForm
(
e
)
{
console
.
log
(
'addEvaluationForm'
,
e
.
type
)
console
.
log
(
'addEvaluationForm'
,
e
.
type
)
uni
.
navigateTo
({
uni
.
navigateTo
({
...
@@ -352,12 +361,14 @@ export default {
...
@@ -352,12 +361,14 @@ export default {
if
(
res
.
data
.
code
==
0
)
{
if
(
res
.
data
.
code
==
0
)
{
uni
.
hideLoading
()
uni
.
hideLoading
()
uni
.
showToast
({
uni
.
showToast
({
title
:
res
.
data
.
data
||
'请求成功
'
,
title
:
'订单已重置回「评估中」
'
,
icon
:
'none'
,
icon
:
'none'
,
duration
:
3000
duration
:
3000
})
})
this
.
currentPage
=
1
setTimeout
(()
=>
{
this
.
search
()
this
.
currentPage
=
1
this
.
search
()
},
500
)
}
else
{
}
else
{
uni
.
hideLoading
()
uni
.
hideLoading
()
uni
.
showToast
({
uni
.
showToast
({
...
@@ -394,8 +405,10 @@ export default {
...
@@ -394,8 +405,10 @@ export default {
title
:
'定金已申请,请等待付款审批'
,
title
:
'定金已申请,请等待付款审批'
,
icon
:
'none'
icon
:
'none'
})
})
that
.
currentPage
=
1
setTimeout
(()
=>
{
that
.
search
()
that
.
currentPage
=
1
that
.
search
()
},
500
)
}
}
}
else
{
}
else
{
uni
.
showLoading
()
uni
.
showLoading
()
...
@@ -416,7 +429,7 @@ export default {
...
@@ -416,7 +429,7 @@ export default {
if
(
res
.
data
.
code
==
0
)
{
if
(
res
.
data
.
code
==
0
)
{
uni
.
hideLoading
()
uni
.
hideLoading
()
uni
.
showToast
({
uni
.
showToast
({
title
:
'
代保管协议已发送
'
,
title
:
'
电子签约已发送,请注意查收短信
'
,
icon
:
'none'
icon
:
'none'
})
})
that
.
currentPage
=
1
that
.
currentPage
=
1
...
@@ -488,15 +501,18 @@ export default {
...
@@ -488,15 +501,18 @@ export default {
return
return
}
}
const
res
=
await
uni
.
$api
.
evaluationApi
.
evalOrderOwnerReQuote
(
this
.
requoteObj
)
const
res
=
await
uni
.
$api
.
evaluationApi
.
evalOrderOwnerReQuote
(
this
.
requoteObj
)
console
.
log
(
'res:'
,
res
)
if
(
res
.
data
.
code
==
0
)
{
if
(
res
.
data
.
code
==
0
)
{
uni
.
showToast
({
uni
.
showToast
({
title
:
'重新报价
成功
'
,
title
:
'重新报价
已提交,请等待报价更新
'
,
icon
:
'none'
,
icon
:
'none'
,
duration
:
3000
duration
:
3000
})
})
this
.
$refs
.
requotePopup
.
closePopup
()
this
.
$refs
.
requotePopup
.
closePopup
()
this
.
currentPage
=
1
setTimeout
(()
=>
{
this
.
search
()
this
.
currentPage
=
1
this
.
search
()
},
500
)
}
else
{
}
else
{
uni
.
hideLoading
()
uni
.
hideLoading
()
uni
.
showToast
({
uni
.
showToast
({
...
...
utils/ossUpload.js
0 → 100644
View file @
2d2a2b4
import
config
from
'./ossUploadFile/config.js'
import
base64
from
'./ossUploadFile/base64.js'
import
Hmac
from
'./ossUploadFile/hmac.js'
import
Sha1
from
'./ossUploadFile/sha1.js'
import
Crypto
from
'./ossUploadFile/crypto.js'
/**
* 上传文件到阿里云oss
* @param {string} file 图片信息
* @param {string} dir 表示要传到哪个目录下
* @return 完整的图片地址
*/
const
uploadFile
=
function
(
file
,
filePath
)
{
console
.
log
(
'上传文件到阿里云oss'
,
file
,
filePath
)
return
new
Promise
(
async
(
resolve
,
reject
)
=>
{
// 添加文件大小限制检查
if
(
file
&&
file
.
size
)
{
// 定义文件类型和大小限制
const
imageTypes
=
[
'jpg'
,
'jpeg'
,
'png'
,
'gif'
,
'bmp'
]
const
videoTypes
=
[
'mp4'
,
'avi'
,
'mov'
,
'wmv'
,
'flv'
,
'mkv'
]
// 提取文件后缀
const
fileExtension
=
file
?
(
file
.
name
?
file
.
name
.
split
(
'.'
).
pop
().
toLowerCase
()
:
file
.
path
.
split
(
'.'
).
pop
().
toLowerCase
())
:
filePath
.
split
(
'.'
).
pop
().
toLowerCase
()
// 检查文件大小
const
fileSizeMB
=
file
.
size
/
(
1024
*
1024
)
// 转换为MB
// 图片文件大小限制10MB
if
(
imageTypes
.
includes
(
fileExtension
)
&&
fileSizeMB
>
10
)
{
uni
.
showToast
({
title
:
'图片上传最大10MB'
,
icon
:
'none'
})
reject
(
new
Error
(
'图片上传最大10MB'
))
return
}
// 视频文件大小限制100MB
if
(
videoTypes
.
includes
(
fileExtension
)
&&
fileSizeMB
>
100
)
{
uni
.
showToast
({
title
:
'视频上传最大100MB'
,
icon
:
'none'
})
reject
(
new
Error
(
'视频上传最大100MB'
))
return
}
}
// 提取文件后缀
const
fileExtension
=
file
?
(
file
.
name
?
file
.
name
.
split
(
'.'
).
pop
().
toLowerCase
()
:
file
.
path
.
split
(
'.'
).
pop
().
toLowerCase
())
:
filePath
.
split
(
'.'
).
pop
().
toLowerCase
()
// 生成随机数(使用时间戳+随机字符串)
const
timestamp
=
Date
.
now
()
const
randomStr
=
Math
.
random
().
toString
(
36
).
substring
(
2
,
10
)
const
randomNum
=
timestamp
+
'_'
+
randomStr
let
aliyunFileKey
=
config
.
folder
+
randomNum
+
'.'
+
fileExtension
console
.
log
(
aliyunFileKey
,
'aliyunFileKey'
)
const
aliyunServerURL
=
config
.
uploadUrl
// OSS地址
const
policyBase64
=
getPolicyBase64
()
const
{
signature
,
securityToken
,
lsaccessKeyId
}
=
await
getSignature
(
policyBase64
)
// 获取签名
uni
.
uploadFile
({
url
:
aliyunServerURL
,
// 开发者服务器url
filePath
:
filePath
,
// 要上传文件资源的路径
name
:
'file'
,
// 必须填file
formData
:
{
key
:
aliyunFileKey
,
policy
:
policyBase64
,
OSSAccessKeyId
:
lsaccessKeyId
,
success_action_status
:
'200'
,
// 让服务端返回200, 不然默认会返回204
signature
:
signature
,
'x-oss-security-token'
:
securityToken
// 使用STS签名时必传。
},
success
:
function
(
res
)
{
console
.
log
(
res
,
444
)
if
(
res
.
statusCode
!=
200
)
{
reject
(
new
Error
(
'上传错误:'
+
JSON
.
stringify
({
statusCode
:
res
.
statusCode
,
file
:
file
,
key
:
aliyunFileKey
,
policy
:
policyBase64
,
OSSAccessKeyId
:
lsaccessKeyId
,
signature
:
signature
,
'x-oss-security-token'
:
securityToken
})
)
)
}
else
{
uni
.
removeSavedFile
({
file
:
file
,
complete
:
function
(
res
)
{
console
.
log
(
res
)
}
})
}
resolve
(
aliyunServerURL
+
aliyunFileKey
)
},
fail
:
function
(
err
)
{
console
.
log
(
err
,
555
)
err
.
domainName
=
aliyunServerURL
reject
(
err
)
}
})
})
}
const
getPolicyBase64
=
function
()
{
let
date
=
new
Date
()
date
.
setHours
(
date
.
getHours
()
+
config
.
timeout
)
let
srcT
=
date
.
toISOString
()
const
policyText
=
{
expiration
:
srcT
,
//设置该Policy的失效时间,超过这个失效时间之后,就没有办法通过这个policy上传文件了
conditions
:
[
[
'content-length-range'
,
0
,
1024
*
1024
*
1024
]
// 设置上传文件的大小限制(5m)
]
}
const
policyBase64
=
base64
.
encode
(
JSON
.
stringify
(
policyText
))
return
policyBase64
}
const
getOssToken
=
async
function
()
{
console
.
log
(
'getOssToken'
)
const
{
lsaccessKeySecret
,
securityToken
,
lsaccessKeyId
}
=
await
uni
.
$api
.
commonApi
.
getToken
({})
return
{
lsaccessKeySecret
,
securityToken
,
lsaccessKeyId
}
}
// 生成签名
const
getSignature
=
function
(
policyBase64
)
{
return
new
Promise
(
async
reslove
=>
{
const
result
=
uni
.
$api
.
commonApi
.
getToken
({}).
then
(
res
=>
{
const
{
lsaccessKeySecret
,
securityToken
,
lsaccessKeyId
}
=
res
const
bytes
=
Crypto
.
HmacSHA1
(
policyBase64
,
lsaccessKeySecret
)
const
signature
=
Crypto
.
enc
.
Base64
.
stringify
(
bytes
)
reslove
({
signature
,
securityToken
,
lsaccessKeyId
})
})
})
}
module
.
exports
=
{
uploadFile
}
utils/ossUploadFile/uploadFile.js
View file @
2d2a2b4
...
@@ -7,11 +7,11 @@
...
@@ -7,11 +7,11 @@
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
*/
// base64,Hmac,Sha1,Crypto 相关算法
// base64,Hmac,Sha1,Crypto 相关算法
import
config
from
"./config.js"
;
import
config
from
'./config.js'
import
base64
from
"./base64.js"
;
import
base64
from
'./base64.js'
import
Hmac
from
"./hmac.js"
;
import
Hmac
from
'./hmac.js'
import
Sha1
from
"./sha1.js"
;
import
Sha1
from
'./sha1.js'
import
Crypto
from
"./crypto.js"
;
import
Crypto
from
'./crypto.js'
/**
/**
* 上传文件到阿里云oss
* 上传文件到阿里云oss
* @param {string} filePath 图片的本地资源路径
* @param {string} filePath 图片的本地资源路径
...
@@ -19,44 +19,44 @@ import Crypto from "./crypto.js";
...
@@ -19,44 +19,44 @@ import Crypto from "./crypto.js";
* @return 完整的图片地址
* @return 完整的图片地址
*/
*/
const
uploadFile
=
function
(
filePath
)
{
const
uploadFile
=
function
(
filePath
)
{
console
.
log
(
'上传文件到阿里云oss'
,
filePath
)
return
new
Promise
(
async
(
resolve
,
reject
)
=>
{
return
new
Promise
(
async
(
resolve
,
reject
)
=>
{
if
(
!
filePath
||
filePath
.
length
<
9
)
{
if
(
!
filePath
||
filePath
.
length
<
9
)
{
uni
.
showModal
({
uni
.
showModal
({
title
:
"文件错误"
,
title
:
'文件错误'
,
content
:
"请重试"
,
content
:
'请重试'
,
showCancel
:
false
,
showCancel
:
false
})
;
})
reject
(
"文件错误"
);
reject
(
'文件错误'
)
}
}
// 获取上传的文件类型
// 获取上传的文件类型
let
fileTypeIndex
=
filePath
.
lastIndexOf
(
"/"
);
let
fileTypeIndex
=
filePath
.
lastIndexOf
(
'/'
)
let
fileType
=
filePath
.
substring
(
fileTypeIndex
+
1
);
let
fileType
=
filePath
.
substring
(
fileTypeIndex
+
1
)
let
aliyunFileKey
=
config
.
folder
+
fileType
;
console
.
log
(
fileType
,
'获取上传的文件类型'
)
const
aliyunServerURL
=
config
.
uploadUrl
;
// OSS地址
let
aliyunFileKey
=
config
.
folder
+
fileType
const
accessid
=
config
.
OSSAccessKeyId
;
const
aliyunServerURL
=
config
.
uploadUrl
// OSS地址
const
policyBase64
=
getPolicyBase64
();
const
accessid
=
config
.
OSSAccessKeyId
const
{
signature
,
securityToken
,
lsaccessKeyId
}
=
await
getSignature
(
const
policyBase64
=
getPolicyBase64
()
policyBase64
const
{
signature
,
securityToken
,
lsaccessKeyId
}
=
await
getSignature
(
policyBase64
)
// 获取签名
);
// 获取签名
uni
.
uploadFile
({
uni
.
uploadFile
({
url
:
aliyunServerURL
,
// 开发者服务器url
url
:
aliyunServerURL
,
// 开发者服务器url
filePath
:
filePath
,
// 要上传文件资源的路径
filePath
:
filePath
,
// 要上传文件资源的路径
name
:
"file"
,
// 必须填file
name
:
'file'
,
// 必须填file
formData
:
{
formData
:
{
key
:
aliyunFileKey
,
key
:
aliyunFileKey
,
policy
:
policyBase64
,
policy
:
policyBase64
,
OSSAccessKeyId
:
lsaccessKeyId
,
OSSAccessKeyId
:
lsaccessKeyId
,
success_action_status
:
"200"
,
// 让服务端返回200, 不然默认会返回204
success_action_status
:
'200'
,
// 让服务端返回200, 不然默认会返回204
signature
:
signature
,
signature
:
signature
,
"x-oss-security-token"
:
securityToken
,
// 使用STS签名时必传。
'x-oss-security-token'
:
securityToken
// 使用STS签名时必传。
},
},
success
:
function
(
res
)
{
success
:
function
(
res
)
{
console
.
log
(
res
,
444
)
;
console
.
log
(
res
,
444
)
if
(
res
.
statusCode
!=
200
)
{
if
(
res
.
statusCode
!=
200
)
{
reject
(
reject
(
new
Error
(
new
Error
(
"上传错误:"
+
'上传错误:'
+
JSON
.
stringify
({
JSON
.
stringify
({
statusCode
:
res
.
statusCode
,
statusCode
:
res
.
statusCode
,
filePath
,
filePath
,
...
@@ -64,65 +64,64 @@ const uploadFile = function (filePath) {
...
@@ -64,65 +64,64 @@ const uploadFile = function (filePath) {
policy
:
policyBase64
,
policy
:
policyBase64
,
OSSAccessKeyId
:
lsaccessKeyId
,
OSSAccessKeyId
:
lsaccessKeyId
,
signature
:
signature
,
signature
:
signature
,
"x-oss-security-token"
:
securityToken
,
'x-oss-security-token'
:
securityToken
})
})
)
)
)
;
)
}
else
{
}
else
{
uni
.
removeSavedFile
({
uni
.
removeSavedFile
({
filePath
,
filePath
,
complete
:
function
(
res
)
{
complete
:
function
(
res
)
{
console
.
log
(
res
)
;
console
.
log
(
res
)
}
,
}
})
;
})
}
}
resolve
(
aliyunServerURL
+
aliyunFileKey
)
;
resolve
(
aliyunServerURL
+
aliyunFileKey
)
},
},
fail
:
function
(
err
)
{
fail
:
function
(
err
)
{
err
.
domainName
=
aliyunServerURL
;
err
.
domainName
=
aliyunServerURL
reject
(
err
)
;
reject
(
err
)
}
,
}
})
;
})
})
;
})
}
;
}
const
getPolicyBase64
=
function
()
{
const
getPolicyBase64
=
function
()
{
let
date
=
new
Date
()
;
let
date
=
new
Date
()
date
.
setHours
(
date
.
getHours
()
+
config
.
timeout
)
;
date
.
setHours
(
date
.
getHours
()
+
config
.
timeout
)
let
srcT
=
date
.
toISOString
()
;
let
srcT
=
date
.
toISOString
()
const
policyText
=
{
const
policyText
=
{
expiration
:
srcT
,
//设置该Policy的失效时间,超过这个失效时间之后,就没有办法通过这个policy上传文件了
expiration
:
srcT
,
//设置该Policy的失效时间,超过这个失效时间之后,就没有办法通过这个policy上传文件了
conditions
:
[
conditions
:
[
[
"content-length-range"
,
0
,
1024
*
1024
*
1024
],
// 设置上传文件的大小限制(5m)
[
'content-length-range'
,
0
,
1024
*
1024
*
1024
]
// 设置上传文件的大小限制(5m)
]
,
]
}
;
}
const
policyBase64
=
base64
.
encode
(
JSON
.
stringify
(
policyText
))
;
const
policyBase64
=
base64
.
encode
(
JSON
.
stringify
(
policyText
))
return
policyBase64
;
return
policyBase64
}
;
}
const
getOssToken
=
async
function
()
{
const
getOssToken
=
async
function
()
{
console
.
log
(
"getOssToken"
);
console
.
log
(
'getOssToken'
)
const
{
lsaccessKeySecret
,
securityToken
,
lsaccessKeyId
}
=
const
{
lsaccessKeySecret
,
securityToken
,
lsaccessKeyId
}
=
await
uni
.
$api
.
commonApi
.
getToken
({})
await
uni
.
$api
.
commonApi
.
getToken
({});
return
{
return
{
lsaccessKeySecret
,
lsaccessKeySecret
,
securityToken
,
securityToken
,
lsaccessKeyId
,
lsaccessKeyId
}
;
}
}
;
}
// 生成签名
// 生成签名
const
getSignature
=
function
(
policyBase64
)
{
const
getSignature
=
function
(
policyBase64
)
{
return
new
Promise
(
async
(
reslove
)
=>
{
return
new
Promise
(
async
reslove
=>
{
const
result
=
uni
.
$api
.
commonApi
.
getToken
({}).
then
(
(
res
)
=>
{
const
result
=
uni
.
$api
.
commonApi
.
getToken
({}).
then
(
res
=>
{
const
{
lsaccessKeySecret
,
securityToken
,
lsaccessKeyId
}
=
res
;
const
{
lsaccessKeySecret
,
securityToken
,
lsaccessKeyId
}
=
res
const
bytes
=
Crypto
.
HmacSHA1
(
policyBase64
,
lsaccessKeySecret
)
;
const
bytes
=
Crypto
.
HmacSHA1
(
policyBase64
,
lsaccessKeySecret
)
const
signature
=
Crypto
.
enc
.
Base64
.
stringify
(
bytes
)
;
const
signature
=
Crypto
.
enc
.
Base64
.
stringify
(
bytes
)
reslove
({
reslove
({
signature
,
signature
,
securityToken
,
securityToken
,
lsaccessKeyId
,
lsaccessKeyId
})
;
})
})
;
})
// const result = await uni.request({
// const result = await uni.request({
// url: 'https://dj.test.glsx.com.cn/rop-dj-smartcarlife/router',
// url: 'https://dj.test.glsx.com.cn/rop-dj-smartcarlife/router',
// data: {
// data: {
...
@@ -150,7 +149,7 @@ const getSignature = function (policyBase64) {
...
@@ -150,7 +149,7 @@ const getSignature = function (policyBase64) {
// })
// })
// }
// }
// })
// })
})
;
})
}
;
}
module
.
exports
=
{
uploadFile
,
getOssToken
}
;
module
.
exports
=
{
uploadFile
,
getOssToken
}
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment