Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
account-book
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
刘文虎
account-book
Commits
4399ce35
Commit
4399ce35
authored
Jul 18, 2022
by
Facius
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 维修记账-填写
parent
2bedbe12
Pipeline
#2796
canceled with stages
Changes
8
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
1281 additions
and
47 deletions
+1281
-47
upload.js
common/upload.js
+202
-0
index.vue
components/navbar-right/index.vue
+9
-1
list.vue
components/upload-images/list.vue
+0
-0
index.vue
components/upload/index.vue
+20
-28
u-upload.vue
components/upload/u-upload.vue
+674
-0
create.vue
pages/maintain-bill/create.vue
+374
-16
detail.vue
pages/maintain-bill/detail.vue
+1
-1
index.vue
pages/maintain-bill/index.vue
+1
-1
No files found.
common/upload.js
0 → 100644
View file @
4399ce35
//吊起设备原生相机相册取得文件,并自动上传七牛,返回七牛key,domain,本地file信息
function
getPhoto
(
token
,
type
=
2
,
count
=
1
,
showLoading
=
true
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
let
types
=
[[
'camera'
],
[
'album'
]
,
[
'album'
,
'camera'
]]
let
sourceType
=
types
[
type
]
uni
.
chooseImage
({
count
:
count
,
//默认9
sizeType
:
[
'original'
,
'compressed'
],
//可以指定是原图还是压缩图,默认二者都有
sourceType
:
sourceType
,
//从相册选择
success
:
function
(
res
)
{
if
(
showLoading
)
{
uni
.
showLoading
({
title
:
'上传中...'
,
})
}
console
.
log
(
'-------------:'
,
res
)
uploads
(
res
.
tempFiles
,
token
)
.
then
((
result
)
=>
{
let
keys
=
[]
let
urls
=
[]
if
(
result
)
{
for
(
var
item
of
result
)
{
keys
.
push
(
item
.
key
)
urls
.
push
(
item
.
url
)
}
}
resolve
({
key
:
keys
,
files
:
urls
})
})
.
catch
((
msg
)
=>
{
reject
(
msg
)
})
// var state = 0 // 上传第几张图片
// var imgList = [] // 保存图片数组
// var uploadNum = res.tempFiles.length // 上传数组的长度
// //上传七牛
// for (let i = 0; i < uploadNum; i++) {
// let filePath = res.tempFiles[i].path //为需要上传的文件
// upload(filePath, token)
// .then((msg) => {
// //最后七牛返回的key
// state++
// imgList.push(msg)
// if (state == uploadNum) {
// resolve({
// key: imgList,
// files: res.tempFiles,
// })
// }
// })
// .catch((msg) => {
// reject(msg)
// })
// }
},
complete
:
function
()
{},
})
})
}
function
uploadOneWHPhoto
(
token
,
type
=
2
,
block
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
let
types
=
[[
'camera'
],
[
'album'
]
,
[
'album'
,
'camera'
]]
let
sourceType
=
types
[
type
]
uni
.
chooseImage
({
count
:
1
,
sizeType
:
[
'original'
,
'compressed'
],
//可以指定是原图还是压缩图,默认二者都有
sourceType
:
sourceType
,
//从相册选择
success
:
function
(
res
)
{
if
(
res
.
tempFilePaths
.
length
>
0
)
{
let
filePath
=
res
.
tempFilePaths
[
0
]
uni
.
getImageInfo
({
src
:
filePath
,
success
:
function
(
image
)
{
var
key
=
new
Date
().
getTime
()
+
Math
.
random
(
1000
)
+
filePath
.
split
(
'/'
).
pop
().
replace
(
/
\_
/g
,
''
)
//key为自定义文件名
key
=
key
.
replace
(
/
\.(?=
.*
\.)
/g
,
''
)
key
=
key
.
replace
(
/
\.
/
,
`_
${
image
.
width
}
_
${
image
.
height
}
_.`
)
if
(
block
)
block
(
filePath
,
key
)
uni
.
uploadFile
({
url
:
uploadUrl
,
// default ecn华北的地址,在七牛云中选择对应位置的网址
filePath
:
filePath
,
name
:
'file'
,
formData
:
{
token
:
token
,
key
:
key
,
},
complete
:
(
res
)
=>
{
if
(
res
.
statusCode
===
200
)
{
resolve
(
JSON
.
parse
(
res
.
data
).
key
||
JSON
.
parse
(
res
.
data
).
src
)
}
else
{
reject
(
res
.
errMsg
)
}
},
})
}
});
}
},
complete
:
function
()
{},
})
})
}
function
uploads
(
list
,
token
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
var
state
=
0
// 上传第几张图片
var
imgList
=
[]
// 保存图片数组
var
uploadNum
=
list
.
length
// 上传数组的长度
//上传七牛
for
(
let
i
=
0
;
i
<
uploadNum
;
i
++
)
{
let
filePath
=
list
[
i
].
path
||
list
[
i
].
url
//为需要上传的文件
upload
(
filePath
,
token
)
.
then
((
msg
)
=>
{
//最后七牛返回的key
state
++
imgList
.
push
({
key
:
msg
,
url
:
filePath
})
if
(
state
==
uploadNum
)
{
resolve
(
imgList
)
}
})
.
catch
((
msg
)
=>
{
reject
(
msg
)
})
}
})
}
function
uploadFiles
(
token
,
tempFilePaths
,
success
,
progress
,
error
)
{
var
count
=
0
// 上传第几张图片
var
fileList
=
[]
var
tasks
=
[]
for
(
let
i
=
0
;
i
<
tempFilePaths
.
length
;
i
++
)
{
let
item
=
{...
tempFilePaths
[
i
]}
let
filePath
=
item
.
path
var
key
=
new
Date
().
getTime
()
+
Math
.
random
(
1000
)
+
filePath
.
split
(
'/'
).
pop
().
replace
(
/
\=
/g
,
''
)
//key为自定义文件名
key
=
key
.
replace
(
/
\.(?=
.*
\.)
/g
,
''
)
var
task
=
uni
.
uploadFile
({
url
:
uploadUrl
,
// default ecn华北的地址,在七牛云中选择对应位置的网址
filePath
:
filePath
,
name
:
'file'
,
formData
:
{
token
:
token
,
key
:
key
,
},
complete
:
(
res
)
=>
{
if
(
res
.
statusCode
===
200
)
{
fileList
.
push
({
path
:
filePath
,
url
:
JSON
.
parse
(
res
.
data
).
key
||
JSON
.
parse
(
res
.
data
).
src
})
count
++
if
(
count
==
tempFilePaths
.
length
)
{
success
(
fileList
)
}
}
else
{
error
(
item
,
res
.
errMsg
)
}
}
})
task
.
onProgressUpdate
((
res
)
=>
{
progress
({...
item
,
progress
:
res
.
progress
,
task
:
task
})
});
tasks
[
i
]
=
task
}
}
const
uploadUrl
=
'https://up-z2.qiniup.com'
//上传七牛
function
upload
(
filePath
,
token
,
duration
=
''
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
var
key
=
new
Date
().
getTime
()
+
Math
.
random
(
1000
)
+
filePath
.
split
(
'/'
).
pop
().
replace
(
/
\=
/g
,
''
)
//key为自定义文件名
key
=
key
.
replace
(
/
\.(?=
.*
\.)
/g
,
''
)
if
(
duration
)
key
=
key
.
replace
(
/
\.
/
,
`durationTime=
${
duration
*
1000
}
.`
)
uni
.
uploadFile
({
url
:
uploadUrl
,
// default ecn华北的地址,在七牛云中选择对应位置的网址
filePath
:
filePath
,
name
:
'file'
,
formData
:
{
token
:
token
,
key
:
key
,
},
complete
:
(
res
)
=>
{
if
(
res
.
statusCode
===
200
)
{
resolve
(
JSON
.
parse
(
res
.
data
).
key
||
JSON
.
parse
(
res
.
data
).
src
)
}
else
{
reject
(
res
.
errMsg
)
}
},
})
})
}
export
default
{
uploadUrl
,
upload
,
uploads
,
getPhoto
,
uploadOneWHPhoto
,
uploadFiles
}
components/navbar-right/index.vue
View file @
4399ce35
<
template
>
<u-navbar
:back-text=
"title"
:title=
"title"
title-color=
"191C27"
title-bold
:back-text=
"backText"
:back-text-style=
"backTextStyle"
:background=
"background"
:border-bottom=
"false"
>
<view
v-if=
"text || image"
class=
"slot-wrap"
slot=
"right"
hover-class=
"u-hover-class"
...
...
@@ -24,6 +28,10 @@ export default {
type
:
String
,
default
:
''
,
},
backText
:
{
type
:
String
,
default
:
''
,
},
text
:
{
type
:
String
,
default
:
''
,
...
...
components/upload-images/list.vue
0 → 100644
View file @
4399ce35
components/upload
-images
/index.vue
→
components/upload/index.vue
View file @
4399ce35
<
template
>
<u-upload
<UploadImages
ref=
"upload-images"
:max-count=
"maxCount"
:width=
"width"
:height=
"height"
...
...
@@ -7,9 +8,7 @@
:file-list=
"fileList"
:auto-upload=
"autoUpload"
:show-progress=
"false"
:deletable=
"deletable"
:show-upload-list=
"showUploadList"
:preview-full-image=
"previewFullImage"
:show-add=
"showAdd"
@
on-list-change=
"handleListChange"
>
<view
...
...
@@ -19,16 +18,18 @@
:style=
"slotStyle"
hover-stay-time=
"150"
>
<u-icon
name=
"plus"
:size=
"addSize"
color=
"#
999999
"
></u-icon>
<u-icon
name=
"plus"
:size=
"addSize"
color=
"#
D8D8D8
"
></u-icon>
</view>
</
u-upload
>
</
UploadImages
>
</
template
>
<
script
>
import
upload
from
'@/utils/upload.js'
import
{
getQiNiuToken
}
from
"@/api/common/index.js"
import
upload
from
'@/common/upload'
import
UploadImages
from
'@/components/upload/u-upload'
export
default
{
components
:
{
UploadImages
,
},
props
:
{
// 给fileList赋初始值用
list
:
{
...
...
@@ -65,22 +66,10 @@ export default {
type
:
Boolean
,
default
:
false
},
hide
:{
type
:
Boolean
,
default
:
false
},
deletable
:{
type
:
Boolean
,
default
:
true
},
previewFullImage
:{
type
:
Boolean
,
default
:
false
},
showUploadList
:{
type
:
Boolean
,
default
:
true
}
showAdd
:
{
type
:
Boolean
,
default
:
true
},
},
data
()
{
return
{
...
...
@@ -172,10 +161,13 @@ export default {
}
},
getQiniuToken
()
{
getQiNiuToken
().
then
((
res
)
=>
{
this
.
qiniuToken
=
res
})
// this.$u.api.
getQiNiuToken().then((res) => {
//
this.qiniuToken = res
//
})
},
selectFile
()
{
// 触发选择图片;不能改文件名,外部要调
this
.
$refs
[
'upload-images'
].
selectFile
()
}
},
}
</
script
>
...
...
components/upload/u-upload.vue
0 → 100644
View file @
4399ce35
This diff is collapsed.
Click to expand it.
pages/maintain-bill/create.vue
View file @
4399ce35
This diff is collapsed.
Click to expand it.
pages/maintain-bill/detail.vue
View file @
4399ce35
<
template
>
<view
class=
"maintain-detail"
>
<NavbarRight
title
=
"详情"
backText
=
"详情"
text=
"删除"
:image=
"deleteImage"
@
click=
"handlClickDelete"
...
...
pages/maintain-bill/index.vue
View file @
4399ce35
<
template
>
<view
class=
"maintain-bill"
>
<NavbarRight
title
=
"维修记账"
backText
=
"维修记账"
text=
"导出账单"
imageWidth=
"20"
:image=
"outImage"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment