Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
self-support
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
李俊赕
self-support
Commits
967e44e1
Commit
967e44e1
authored
May 17, 2021
by
李超鹏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update:update
scope:self-support body:删除云开发相关代码
parent
4be9741b
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
436 additions
and
632 deletions
+436
-632
cloud_rules.js
src/common/api/cloud_rules.js
+0
-58
index.js
src/common/api/index.js
+0
-5
http.api.js
src/common/http.api.js
+1
-7
index.vue
src/pages/photo/index.vue
+221
-231
list.vue
src/pages/photo/list.vue
+0
-32
preview.vue
src/pages/photo/preview.vue
+214
-261
setting.vue
src/pages/photo/setting.vue
+0
-38
No files found.
src/common/api/cloud_rules.js
deleted
100644 → 0
View file @
4be9741b
const
db
=
uniCloud
.
database
({
spaceId
:
'tcb-nikbzhlwnpd5n913e1c5e-50f4bbo'
})
let
cloudRulesApiFun
=
function
(
vm
){
/* 查询所有产品 废弃*/
let
getAllProduct
=
async
()
=>
await
db
.
collection
(
"product"
).
get
();
/* 查询产品下的品牌 {product_code:"P0001"} 废弃*/
let
getBrand
=
async
(
params
=
{})
=>
await
db
.
collection
(
"brand"
).
where
(
params
).
get
();
/* 查询规范项目 {product_code:"P0001"} 废弃*/
let
getstandard
=
async
(
params
=
{})
=>
await
db
.
collection
(
"standard"
).
where
(
params
).
get
();
/* 查询分组规范项目 废弃*/
let
getGroupStandard
=
async
(
params
=
{})
=>
await
uniCloud
.
callFunction
({
name
:
'getGroupStandard'
,
data
:
params
});
/* 查询类别数据 */
let
getClassifyDictionary
=
async
()
=>
await
db
.
collection
(
"dictionary"
).
where
({
"type"
:
"classify"
}).
get
()
/* 查询有数据的系统 或者 品牌 数据 {"classify_id":"","system_id":"","field":"system_id|brand_id"}*/
let
getRelationDictionary
=
async
(
params
=
{})
=>
await
uniCloud
.
callFunction
({
name
:
'getRelationDictionary'
,
data
:
params
});
let
getRelationDictionaryV2
=
async
()
=>
await
uniCloud
.
callFunction
({
name
:
'getRelationDictionaryV2'
});
/* 查询规范 根据 分类、系统、品牌 {"token":"", "classify_id":"","system_id":"","brand_id":""} */
let
getGroupStandardV2
=
async
(
params
=
{})
=>
await
uniCloud
.
callFunction
({
name
:
'getGroupStandardV2'
,
data
:
params
});
/* 保存图片 {"token":"", "standardId":"", "url":""} */
let
saveImage
=
async
(
params
=
{})
=>
await
uniCloud
.
callFunction
({
name
:
'saveImage'
,
data
:
params
});
/* 获取用户水印,首次返回默认水印 {"token":"", "systemId":""} */
let
getUserWatermark
=
async
(
params
=
{})
=>
await
uniCloud
.
callFunction
({
name
:
'getUserWatermark'
,
data
:
params
});
/* 保存用户水印配置 {"token":"", "watermark": getUserWatemark返回的数据} */
let
saveUserWatermark
=
async
(
params
=
{})
=>
await
uniCloud
.
callFunction
({
name
:
'saveUserWatermark'
,
data
:
params
});
const
rulesApi
=
{
getAllProduct
,
getBrand
,
getstandard
,
getGroupStandard
,
// 新接口
getClassifyDictionary
,
getRelationDictionary
,
getRelationDictionaryV2
,
getGroupStandardV2
,
saveImage
,
getUserWatermark
,
saveUserWatermark
}
return
rulesApi
}
module
.
exports
=
{
cloudRulesApiFun
}
\ No newline at end of file
src/common/api/index.js
View file @
967e44e1
import
{
cloudRulesApiFun
}
from
"@/common/api/cloud_rules.js"
import
{
commonApiFun
}
from
'@/common/api/common.js'
;
...
...
@@ -14,7 +11,6 @@ import {certApiFun} from"@/common/api/cert.js"
let
apiFun
=
function
(
vm
)
{
let
commonApi
=
commonApiFun
(
vm
);
let
settledApi
=
settledApiFun
(
vm
)
let
cloudApi
=
cloudRulesApiFun
(
vm
)
let
learnApi
=
learnApiFun
(
vm
)
let
assessmentApi
=
assessmentApiFun
(
vm
)
let
orderApi
=
orderApiFun
(
vm
)
...
...
@@ -22,7 +18,6 @@ let apiFun = function(vm) {
let
apiUrl
=
{
...
commonApi
,
...
settledApi
,
...
cloudApi
,
...
learnApi
,
...
orderApi
,
...
assessmentApi
,
...
...
src/common/http.api.js
View file @
967e44e1
import
{
apiFun
}
from
'@/common/api/index.js'
;
import
{
cloudRulesApiFun
}
from
"@/common/api/cloud_rules.js"
const
install
=
(
Vue
,
vm
)
=>
{
let
apiUrls
=
apiFun
(
vm
)
...
...
@@ -9,10 +7,6 @@ const install = (Vue, vm) => {
vm
.
$u
.
api
=
{
...
apiUrls
,
};
let
cloudRules
=
cloudRulesApiFun
(
vm
)
vm
.
$u
.
cloudApi
=
{
...
cloudRules
}
}
export
default
{
...
...
src/pages/photo/index.vue
View file @
967e44e1
<
template
>
<view
class=
"backView"
>
<view
class=
"ph-pr-arr"
v-for=
"(dataItem, index) in list"
:key=
"index"
>
<template
v-if=
"dataItem.data.length > 0"
>
<view
class=
"topTitle"
><text>
{{
dataItem
.
title
}}
</text></view>
<view
class=
"ph-pr-content"
>
<view
v-for=
"(item,ikey) in dataItem.data"
:class=
"param[dataItem.type] === item.id ? 'select-item-view' : 'item-view'"
@
click=
"itemClick(dataItem.type, item, ikey)"
:key=
"item.id"
>
<text
class=
"itemTitle"
>
{{
item
.
name
}}
</text>
</view>
</view>
</
template
>
</view>
<u-button
class=
"ph-pr-button"
type=
"primary"
shape=
"circle"
@
click=
"handleClick"
:hover-class=
"selectedAll ? '' : 'none'"
:custom-style=
"buttonStyle"
>
下一步
</u-button>
</view>
</template>
<
script
>
export
default
{
data
()
{
return
{
classifyList
:
[],
systemList
:
[],
brandList
:
[],
param
:
{
classifyId
:
''
,
systemId
:
''
,
brandId
:
''
,
},
brandName
:
''
,
selectedAll
:
false
,
}
},
computed
:
{
list
()
{
return
[{
title
:
'请选择类别'
,
type
:
'classifyId'
,
data
:
this
.
classifyList
},
{
title
:
'请选择系统'
,
type
:
'systemId'
,
data
:
this
.
systemList
},
{
title
:
'请选择品牌'
,
type
:
'brandId'
,
data
:
this
.
brandList
}
]
},
buttonStyle
()
{
return
this
.
selectedAll
?
{
'color'
:
'#FFFFFF'
,
'background-color'
:
'#2272FF;'
,
'width'
:
'600rpx'
,
'height'
:
'104rpx'
}
:
{
'color'
:
'#FFFFFF'
,
'background-color'
:
'#D1D4D4;'
,
'width'
:
'600rpx'
,
'height'
:
'104rpx'
}
}
},
onLoad
(
e
)
{
getApp
().
trackPage
(
'选择产品页'
)
this
.
getRelationDictionaryV2
()
},
onShareAppMessage
(
res
)
{
let
shareObj
=
{
title
:
''
,
path
:
'/pages/photo/product'
,
imageUrl
:
''
,
success
()
{},
fail
()
{}
}
return
shareObj
},
methods
:
{
getRelationDictionaryV2
:
function
()
{
this
.
$u
.
cloudApi
.
getRelationDictionaryV2
().
then
(
res
=>
{
if
(
res
&&
res
.
result
)
{
this
.
classifyList
=
res
.
result
this
.
param
.
classifyId
=
res
.
result
[
0
].
id
this
.
systemList
=
res
.
result
[
0
].
child
}
})
},
//选择 点击
itemClick
:
function
(
type
,
item
,
ikey
)
{
switch
(
type
)
{
case
'classifyId'
:
this
.
param
=
{
classifyId
:
item
.
id
,
systemId
:
''
,
brandId
:
''
}
this
.
selectedAll
=
false
this
.
systemList
=
this
.
classifyList
[
ikey
].
child
this
.
brandList
=
[]
break
case
'systemId'
:
this
.
param
=
{
classifyId
:
this
.
param
.
classifyId
,
systemId
:
item
.
id
,
brandId
:
''
}
this
.
selectedAll
=
false
this
.
brandList
=
this
.
systemList
[
ikey
].
child
break
case
'brandId'
:
this
.
param
.
brandId
=
item
.
id
this
.
selectedAll
=
true
this
.
brandName
=
item
.
name
break
default
:
break
}
},
// 点击下一步
handleClick
()
{
// 点击下一步设置全局拍照品牌品类
if
(
!
this
.
selectedAll
)
{
return
}
const
globalData
=
getApp
().
globalData
// if (!globalData.token) {
// uni.navigateTo({
// url: '/pages/login/wxlogin'
// })
// return
// }
let
keys
=
[
'brandId'
,
'brandName'
,
'classifyId'
,
'systemId'
]
keys
.
map
(
key
=>
{
globalData
.
photo
.
product
[
key
]
=
this
[
key
]
||
this
.
param
[
key
]
<
template
>
<view
class=
"backView"
>
<view
class=
"ph-pr-arr"
v-for=
"(dataItem, index) in list"
:key=
"index"
>
<template
v-if=
"dataItem.data.length > 0"
>
<view
class=
"topTitle"
><text>
{{
dataItem
.
title
}}
</text></view>
<view
class=
"ph-pr-content"
>
<view
v-for=
"(item,ikey) in dataItem.data"
:class=
"param[dataItem.type] === item.id ? 'select-item-view' : 'item-view'"
@
click=
"itemClick(dataItem.type, item, ikey)"
:key=
"item.id"
>
<text
class=
"itemTitle"
>
{{
item
.
name
}}
</text>
</view>
</view>
</
template
>
</view>
<u-button
class=
"ph-pr-button"
type=
"primary"
shape=
"circle"
@
click=
"handleClick"
:hover-class=
"selectedAll ? '' : 'none'"
:custom-style=
"buttonStyle"
>
下一步
</u-button>
</view>
</template>
<
script
>
export
default
{
data
()
{
return
{
classifyList
:
[],
systemList
:
[],
brandList
:
[],
param
:
{
classifyId
:
''
,
systemId
:
''
,
brandId
:
''
,
},
brandName
:
''
,
selectedAll
:
false
,
}
},
computed
:
{
list
()
{
return
[{
title
:
'请选择类别'
,
type
:
'classifyId'
,
data
:
this
.
classifyList
},
{
title
:
'请选择系统'
,
type
:
'systemId'
,
data
:
this
.
systemList
},
{
title
:
'请选择品牌'
,
type
:
'brandId'
,
data
:
this
.
brandList
}
]
},
buttonStyle
()
{
return
this
.
selectedAll
?
{
'color'
:
'#FFFFFF'
,
'background-color'
:
'#2272FF;'
,
'width'
:
'600rpx'
,
'height'
:
'104rpx'
}
:
{
'color'
:
'#FFFFFF'
,
'background-color'
:
'#D1D4D4;'
,
'width'
:
'600rpx'
,
'height'
:
'104rpx'
}
}
},
onLoad
(
e
)
{
getApp
().
trackPage
(
'选择产品页'
)
this
.
getRelationDictionaryV2
()
},
onShareAppMessage
(
res
)
{
let
shareObj
=
{
title
:
''
,
path
:
'/pages/photo/product'
,
imageUrl
:
''
,
success
()
{},
fail
()
{}
}
return
shareObj
},
methods
:
{
//选择 点击
itemClick
:
function
(
type
,
item
,
ikey
)
{
switch
(
type
)
{
case
'classifyId'
:
this
.
param
=
{
classifyId
:
item
.
id
,
systemId
:
''
,
brandId
:
''
}
this
.
selectedAll
=
false
this
.
systemList
=
this
.
classifyList
[
ikey
].
child
this
.
brandList
=
[]
break
case
'systemId'
:
this
.
param
=
{
classifyId
:
this
.
param
.
classifyId
,
systemId
:
item
.
id
,
brandId
:
''
}
this
.
selectedAll
=
false
this
.
brandList
=
this
.
systemList
[
ikey
].
child
break
case
'brandId'
:
this
.
param
.
brandId
=
item
.
id
this
.
selectedAll
=
true
this
.
brandName
=
item
.
name
break
default
:
break
}
},
// 点击下一步
handleClick
()
{
// 点击下一步设置全局拍照品牌品类
if
(
!
this
.
selectedAll
)
{
return
}
const
globalData
=
getApp
().
globalData
// if (!globalData.token) {
// uni.navigateTo({
// url: '/pages/login/wxlogin'
// })
// return
// }
let
keys
=
[
'brandId'
,
'brandName'
,
'classifyId'
,
'systemId'
]
keys
.
map
(
key
=>
{
globalData
.
photo
.
product
[
key
]
=
this
[
key
]
||
this
.
param
[
key
]
})
uni
.
navigateTo
({
url
:
'/pages/photo/list'
+
'?brandId='
+
this
.
param
.
brandId
+
'&brand='
+
this
.
brandName
+
'&classifyId='
+
this
.
param
.
classifyId
+
'&systemId='
+
this
.
param
.
systemId
,
})
}
}
}
</
script
>
<
style
>
.backView
{
background-color
:
#F4f5f7
;
position
:
absolute
;
top
:
0
;
left
:
0
;
width
:
100%
;
display
:
flex
;
flex-direction
:
column
;
align-items
:
center
;
height
:
100%
;
}
.topTitle
{
margin-top
:
50
rpx
;
padding-left
:
30
rpx
;
font-size
:
36
rpx
;
font-weight
:
bold
;
color
:
#333333
;
}
.ph-pr-content
{
display
:
flex
;
flex-wrap
:
wrap
;
justify-content
:
flex-start
;
width
:
100%
;
padding
:
22
rpx
22
rpx
;
}
.ph-pr-arr
{
width
:
100%
;
}
.item-view
{
background-color
:
#FFFFFF
;
/* width: 548rpx; */
margin
:
0
rpx
8
rpx
24
rpx
8
rpx
;
/* flex: 1 1 0%;
max-width: 33%; */
width
:
222
rpx
;
height
:
76
rpx
;
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
border-style
:
solid
;
box-shadow
:
0px
2px
7px
0px
rgba
(
0
,
0
,
0
,
0.05
);
border-width
:
0
rpx
;
border-radius
:
12
rpx
;
font-size
:
26
rpx
;
color
:
#666666
;
}
.select-item-view
{
background-color
:
#2272FF
;
margin
:
0
rpx
8
rpx
24
rpx
8
rpx
;
/* flex: 1 1 0%;
max-width: 33%; */
width
:
222
rpx
;
height
:
76
rpx
;
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
border-style
:
solid
;
box-shadow
:
0px
2px
7px
0px
rgba
(
0
,
0
,
0
,
0.05
);
border-width
:
0
rpx
;
border-radius
:
12
rpx
;
font-size
:
26
rpx
;
color
:
#FFFFFF
;
}
.ph-pr-button
{
position
:
absolute
;
bottom
:
76
rpx
;
font-size
:
32
rpx
;
}
uni
.
navigateTo
({
url
:
'/pages/photo/list'
+
'?brandId='
+
this
.
param
.
brandId
+
'&brand='
+
this
.
brandName
+
'&classifyId='
+
this
.
param
.
classifyId
+
'&systemId='
+
this
.
param
.
systemId
,
})
}
}
}
</
script
>
<
style
>
.backView
{
background-color
:
#F4f5f7
;
position
:
absolute
;
top
:
0
;
left
:
0
;
width
:
100%
;
display
:
flex
;
flex-direction
:
column
;
align-items
:
center
;
height
:
100%
;
}
.topTitle
{
margin-top
:
50
rpx
;
padding-left
:
30
rpx
;
font-size
:
36
rpx
;
font-weight
:
bold
;
color
:
#333333
;
}
.ph-pr-content
{
display
:
flex
;
flex-wrap
:
wrap
;
justify-content
:
flex-start
;
width
:
100%
;
padding
:
22
rpx
22
rpx
;
}
.ph-pr-arr
{
width
:
100%
;
}
.item-view
{
background-color
:
#FFFFFF
;
/* width: 548rpx; */
margin
:
0
rpx
8
rpx
24
rpx
8
rpx
;
/* flex: 1 1 0%;
max-width: 33%; */
width
:
222
rpx
;
height
:
76
rpx
;
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
border-style
:
solid
;
box-shadow
:
0px
2px
7px
0px
rgba
(
0
,
0
,
0
,
0.05
);
border-width
:
0
rpx
;
border-radius
:
12
rpx
;
font-size
:
26
rpx
;
color
:
#666666
;
}
.select-item-view
{
background-color
:
#2272FF
;
margin
:
0
rpx
8
rpx
24
rpx
8
rpx
;
/* flex: 1 1 0%;
max-width: 33%; */
width
:
222
rpx
;
height
:
76
rpx
;
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
border-style
:
solid
;
box-shadow
:
0px
2px
7px
0px
rgba
(
0
,
0
,
0
,
0.05
);
border-width
:
0
rpx
;
border-radius
:
12
rpx
;
font-size
:
26
rpx
;
color
:
#FFFFFF
;
}
.ph-pr-button
{
position
:
absolute
;
bottom
:
76
rpx
;
font-size
:
32
rpx
;
}
</
style
>
src/pages/photo/list.vue
View file @
967e44e1
...
...
@@ -144,27 +144,6 @@
}
},
methods
:
{
getListData
:
function
()
{
this
.
loading
=
true
let
that
=
this
this
.
$u
.
cloudApi
.
getGroupStandardV2
({
'token'
:
this
.
vuex_token
,
'classify_id'
:
this
.
classifyId
,
'system_id'
:
this
.
systemId
,
'brand_id'
:
this
.
brandId
}).
then
(
res
=>
{
this
.
loading
=
false
if
(
res
&&
res
.
result
)
{
if
(
res
.
result
.
error_code
)
{
uni
.
showToast
({
title
:
res
.
result
.
error_msg
})
}
else
{
that
.
handleData
(
res
.
result
)
}
}
})
},
getListDataNew
()
{
this
.
loading
=
true
let
self
=
this
...
...
@@ -251,17 +230,6 @@
url
:
'/pages/photo/take'
})
},
// 清除图片
handleClickSure
:
function
()
{
this
.
$u
.
cloudApi
.
cleanImage
({
'token'
:
this
.
vuex_token
,
}).
then
(
res
=>
{
this
.
isPopShow
=
false
if
(
res
&&
res
.
result
)
{
this
.
getListData
()
}
})
},
take
(
item
,
ikey
)
{
this
.
currentItemDate
=
item
...
...
src/pages/photo/preview.vue
View file @
967e44e1
<
template
>
<view>
<view
class=
"contentView"
>
<u-image
class=
"pic"
:src=
"files[0]"
bg-color=
"transparent"
@
click=
"showPreviewFn"
></u-image>
<!--
<image
class=
"pic"
:src=
"files[0]"
v-lazy
mode=
"aspectFit"
></image>
-->
</view>
<view
class=
"bottomView"
>
<image
class=
"btn"
:src=
"btn_remake"
@
click=
"$u.throttle(remakePhoto, 3000)"
></image>
<image
class=
"btn"
:src=
"btn_continue"
@
click=
"$u.throttle(continuePhoto, 3000)"
></image>
</view>
<image
class=
"btn finish"
src=
"/static/photo/finish.png"
@
click=
"$u.throttle(finishPhoto, 3000)"
></image>
</view>
</
template
>
<
script
>
import
qiniup
from
'@/components/upload/qiniup'
;
const
app
=
getApp
()
export
default
{
mixins
:
[
qiniup
],
data
()
{
return
{
protocolContent
:
''
,
btn_remake
:
'https://qn-static.banshouhui.com/take_order/photo/remake.png'
,
btn_continue
:
'/static/photo/continue.png'
,
standardId
:
''
,
images
:
[],
files
:
[],
fileMaps
:
[],
keys
:
[],
token
:
''
,
product
:
''
,
}
},
onLoad
(
e
)
{
// 获取照片选项对象
const
product
=
app
.
globalData
.
photo
.
product
this
.
product
=
`?brandId=
${
product
.
brandId
}
&brand=
${
product
.
brandName
}
&classifyId=
${
product
.
classifyId
}
&systemId=
${
product
.
systemId
}
`
if
(
app
.
globalData
.
photo
.
currentItem
)
{
// 获取规格Id
this
.
standardId
=
app
.
globalData
.
photo
.
currentItem
.
_id
}
getApp
().
trackPage
(
'照片预览页'
)
const
globalTempPath
=
getApp
().
globalData
.
photo
.
tempPath
if
(
globalTempPath
&&
globalTempPath
.
mixWater
){
this
.
files
=
[
globalTempPath
.
mixWater
]
}
if
(
e
.
standardId
)
{
this
.
standardId
=
e
.
standardId
}
this
.
token
=
this
.
vuex_token
},
methods
:
{
// 保存照片到本地
async
saveTempToLocal
(
tempImagePath
)
{
//has_origin //是否保存原图
let
that
=
this
const
photo
=
getApp
().
globalData
.
photo
if
(
!
photo
.
tempPath
){
return
}
let
path
=
''
if
(
photo
.
tempPath
.
origin
&&
photo
.
waterSetting
&&
photo
.
waterSetting
.
has_origin
){
// 保存原图到本地
path
=
photo
.
tempPath
.
origin
let
result
=
await
this
.
saveLocal
(
path
)
if
(
result
){
uni
.
showToast
({
icon
:
'none'
,
title
:
'已将照片原图保存到本地相册'
})
}
}
if
(
photo
.
currentItem
){
photo
.
currentItem
.
imageList
.
unshift
(
photo
.
tempPath
.
mixWater
)
}
// if(photo.productList && photo.productList[photo.topIndex]){
// const topArr = photo.productList[photo.topIndex]
// if(topArr[photo.itemIndex]){
// topArr[photo.itemIndex].imageList.push(photo.tempPath.mixWater)
// }
// }
// photo.
if
(
photo
.
tempPath
.
mixWater
){
// 保存水印处理图片到本地
path
=
photo
.
tempPath
.
mixWater
let
result1
=
await
this
.
saveLocal
(
path
)
if
(
result1
){
uni
.
showToast
({
icon
:
'none'
,
title
:
'已将水印图片保存到本地相册'
})
}
}
},
saveLocal
(
path
){
return
new
Promise
((
resolve
,
reject
)
=>
{
uni
.
saveImageToPhotosAlbum
({
filePath
:
path
,
success
()
{
resolve
(
true
)
},
fail
()
{
reject
(
'保存失败'
)
}
})
})
},
showPreviewFn
(
img
)
{
uni
.
previewImage
({
current
:
0
,
urls
:
this
.
files
});
},
// 重拍图片
remakePhoto
()
{
uni
.
navigateBack
({
delta
:
1
})
},
finishPhoto
(){
const
photo
=
getApp
().
globalData
.
photo
photo
.
currentItemLength
=
10
this
.
continuePhoto
()
// 完成本项
// uni.navigateBack({
// delta:2
// })
},
// 确认图片
continuePhoto
()
{
let
self
=
this
uni
.
showLoading
({
title
:
'图片保存中…'
})
self
.
saveTempToLocal
()
self
.
confirmUpload
(
true
)
},
submitFile
()
{
let
self
=
this
if
(
self
.
keys
.
length
)
{
for
(
let
s
of
self
.
keys
)
{
self
.
$u
.
cloudApi
.
saveImage
({
"token"
:
self
.
token
,
"standardId"
:
self
.
standardId
,
"url"
:
s
,
}).
then
(
async
res
=>
{
console
.
log
(
res
,
"云服务保存图片"
);
if
(
res
.
result
.
code
)
{
// TODO 参数是否要来回传递
const
photo
=
getApp
().
globalData
.
photo
photo
.
currentItemLength
=
photo
.
currentItemLength
+
1
uni
.
hideLoading
()
// 当前项的图片显示
// 拍照项张数目增加 等于10张
if
(
photo
.
currentItemLength
<
10
){
uni
.
navigateBack
({
delta
:
1
})
}
else
{
uni
.
navigateBack
({
delta
:
2
})
}
// let timer = setTimeout(()=>{
// if(photo.currentItemLength
<
10
){
// uni.navigateBack({
// delta:1
// })
// }else{
// uni.navigateBack({
// delta:2
// })
// }
// },2000)
}
else
{
uni
.
showToast
({
title
:
'图片上传失败 '
+
res
.
result
.
msg
})
}
})
}
}
},
downloadImages
()
{
let
self
=
this
;
for
(
let
url
of
this
.
images
)
{
uni
.
downloadFile
({
url
:
url
,
//仅为示例,并非真实的资源
success
(
res
)
{
// 只要服务器有响应数据,就会把响应内容写入文件并进入 success 回调,业务需要自行判断是否下载到了想要的内容
if
(
res
.
statusCode
===
200
)
{
self
.
files
.
push
(
res
.
tempFilePath
)
}
},
fail
(
e
)
{
}
})
}
},
}
}
</
script
>
<
style
lang=
"scss"
>
.contentView
{
background-color
:
#333333
;
/* padding-top: 120rpx; */
padding-bottom
:
228rpx
;
height
:
100vh
;
display
:
flex
;
flex-direction
:
column
;
}
/
deep
/
.u-image
{
height
:
100vh
!
important
;
}
/
deep
/
.u-image__loading
{
background-color
:
transparent
!
important
;
}
/
deep
/
.u-image__error
{
background-color
:
transparent
!
important
;
}
.pic
{
flex
:
1
;
width
:
100%
;
/* height:auto */
/* height: 760rpx; */
}
.bottomView
{
box-shadow
:
0
0
1rpx
6rpx
rgba
(
255
,
255
,
255
,
0
.05
);
background-color
:
#333333
;
width
:
100%
;
padding
:
70rpx
0
;
position
:
fixed
;
bottom
:
0
;
display
:
flex
;
justify-content
:
space-around
;
align-items
:
center
;
.btn
{
display
:
block
;
width
:
200rpx
;
height
:
88rpx
;
}
}
.btn
{
display
:
block
;
width
:
232rpx
;
height
:
80rpx
;
&
.finish
{
position
:
fixed
;
top
:
30rpx
;
right
:
30rpx
;
}
}
</
style
>
<
template
>
<view>
<view
class=
"contentView"
>
<u-image
class=
"pic"
:src=
"files[0]"
bg-color=
"transparent"
@
click=
"showPreviewFn"
></u-image>
<!--
<image
class=
"pic"
:src=
"files[0]"
v-lazy
mode=
"aspectFit"
></image>
-->
</view>
<view
class=
"bottomView"
>
<image
class=
"btn"
:src=
"btn_remake"
@
click=
"$u.throttle(remakePhoto, 3000)"
></image>
<image
class=
"btn"
:src=
"btn_continue"
@
click=
"$u.throttle(continuePhoto, 3000)"
></image>
</view>
<image
class=
"btn finish"
src=
"/static/photo/finish.png"
@
click=
"$u.throttle(finishPhoto, 3000)"
></image>
</view>
</
template
>
<
script
>
import
qiniup
from
'@/components/upload/qiniup'
;
const
app
=
getApp
()
export
default
{
mixins
:
[
qiniup
],
data
()
{
return
{
protocolContent
:
''
,
btn_remake
:
'https://qn-static.banshouhui.com/take_order/photo/remake.png'
,
btn_continue
:
'/static/photo/continue.png'
,
standardId
:
''
,
images
:
[],
files
:
[],
fileMaps
:
[],
keys
:
[],
token
:
''
,
product
:
''
,
}
},
onLoad
(
e
)
{
// 获取照片选项对象
const
product
=
app
.
globalData
.
photo
.
product
this
.
product
=
`?brandId=
${
product
.
brandId
}
&brand=
${
product
.
brandName
}
&classifyId=
${
product
.
classifyId
}
&systemId=
${
product
.
systemId
}
`
if
(
app
.
globalData
.
photo
.
currentItem
)
{
// 获取规格Id
this
.
standardId
=
app
.
globalData
.
photo
.
currentItem
.
_id
}
getApp
().
trackPage
(
'照片预览页'
)
const
globalTempPath
=
getApp
().
globalData
.
photo
.
tempPath
if
(
globalTempPath
&&
globalTempPath
.
mixWater
){
this
.
files
=
[
globalTempPath
.
mixWater
]
}
if
(
e
.
standardId
)
{
this
.
standardId
=
e
.
standardId
}
this
.
token
=
this
.
vuex_token
},
methods
:
{
// 保存照片到本地
async
saveTempToLocal
(
tempImagePath
)
{
//has_origin //是否保存原图
let
that
=
this
const
photo
=
getApp
().
globalData
.
photo
if
(
!
photo
.
tempPath
){
return
}
let
path
=
''
if
(
photo
.
tempPath
.
origin
&&
photo
.
waterSetting
&&
photo
.
waterSetting
.
has_origin
){
// 保存原图到本地
path
=
photo
.
tempPath
.
origin
let
result
=
await
this
.
saveLocal
(
path
)
if
(
result
){
uni
.
showToast
({
icon
:
'none'
,
title
:
'已将照片原图保存到本地相册'
})
}
}
if
(
photo
.
currentItem
){
photo
.
currentItem
.
imageList
.
unshift
(
photo
.
tempPath
.
mixWater
)
}
// if(photo.productList && photo.productList[photo.topIndex]){
// const topArr = photo.productList[photo.topIndex]
// if(topArr[photo.itemIndex]){
// topArr[photo.itemIndex].imageList.push(photo.tempPath.mixWater)
// }
// }
// photo.
if
(
photo
.
tempPath
.
mixWater
){
// 保存水印处理图片到本地
path
=
photo
.
tempPath
.
mixWater
let
result1
=
await
this
.
saveLocal
(
path
)
if
(
result1
){
uni
.
showToast
({
icon
:
'none'
,
title
:
'已将水印图片保存到本地相册'
})
}
}
},
saveLocal
(
path
){
return
new
Promise
((
resolve
,
reject
)
=>
{
uni
.
saveImageToPhotosAlbum
({
filePath
:
path
,
success
()
{
resolve
(
true
)
},
fail
()
{
reject
(
'保存失败'
)
}
})
})
},
showPreviewFn
(
img
)
{
uni
.
previewImage
({
current
:
0
,
urls
:
this
.
files
});
},
// 重拍图片
remakePhoto
()
{
uni
.
navigateBack
({
delta
:
1
})
},
finishPhoto
(){
const
photo
=
getApp
().
globalData
.
photo
photo
.
currentItemLength
=
10
this
.
continuePhoto
()
// 完成本项
// uni.navigateBack({
// delta:2
// })
},
// 确认图片
continuePhoto
()
{
let
self
=
this
uni
.
showLoading
({
title
:
'图片保存中…'
})
self
.
saveTempToLocal
()
self
.
confirmUpload
(
true
)
},
downloadImages
()
{
let
self
=
this
;
for
(
let
url
of
this
.
images
)
{
uni
.
downloadFile
({
url
:
url
,
//仅为示例,并非真实的资源
success
(
res
)
{
// 只要服务器有响应数据,就会把响应内容写入文件并进入 success 回调,业务需要自行判断是否下载到了想要的内容
if
(
res
.
statusCode
===
200
)
{
self
.
files
.
push
(
res
.
tempFilePath
)
}
},
fail
(
e
)
{
}
})
}
},
}
}
</
script
>
<
style
lang=
"scss"
>
.contentView
{
background-color
:
#333333
;
/* padding-top: 120rpx; */
padding-bottom
:
228rpx
;
height
:
100vh
;
display
:
flex
;
flex-direction
:
column
;
}
/
deep
/
.u-image
{
height
:
100vh
!
important
;
}
/
deep
/
.u-image__loading
{
background-color
:
transparent
!
important
;
}
/
deep
/
.u-image__error
{
background-color
:
transparent
!
important
;
}
.pic
{
flex
:
1
;
width
:
100%
;
/* height:auto */
/* height: 760rpx; */
}
.bottomView
{
box-shadow
:
0
0
1rpx
6rpx
rgba
(
255
,
255
,
255
,
0
.05
);
background-color
:
#333333
;
width
:
100%
;
padding
:
70rpx
0
;
position
:
fixed
;
bottom
:
0
;
display
:
flex
;
justify-content
:
space-around
;
align-items
:
center
;
.btn
{
display
:
block
;
width
:
200rpx
;
height
:
88rpx
;
}
}
.btn
{
display
:
block
;
width
:
232rpx
;
height
:
80rpx
;
&
.finish
{
position
:
fixed
;
top
:
30rpx
;
right
:
30rpx
;
}
}
</
style
>
src/pages/photo/setting.vue
View file @
967e44e1
...
...
@@ -122,46 +122,8 @@
const
globalData
=
getApp
().
globalData
this
.
icon_close_new
=
globalData
.
icon_close_new
this
.
systemId
=
globalData
.
photo
.
product
.
systemId
this
.
getItemList
()
},
methods
:
{
getItemList
:
function
()
{
// this.systemId = '79550af260555cc20afb34156c94b32c' // 测试数据
this
.
loading
=
true
this
.
$u
.
cloudApi
.
getUserWatermark
({
'token'
:
this
.
vuex_token
,
'system_id'
:
this
.
systemId
}).
then
(
res
=>
{
if
(
res
&&
res
.
result
)
{
if
(
res
.
result
.
error_code
){
uni
.
showToast
({
title
:
res
.
result
.
error_msg
})
}
else
{
this
.
result
=
res
.
result
}
}
else
{
uni
.
showToast
({
title
:
'网络异常'
})
}
this
.
loading
=
false
})
},
saveUserWatermark
:
function
()
{
this
.
loading
=
true
this
.
$u
.
cloudApi
.
saveUserWatermark
({
'token'
:
this
.
vuex_token
,
'watermark'
:
this
.
result
}).
then
(
res
=>
{
if
(
res
.
result
.
code
==
true
)
{
const
photo
=
getApp
().
globalData
.
photo
photo
.
waterSetting
=
this
.
result
}
else
{
uni
.
showToast
({
title
:
res
.
result
.
msg
})
}
this
.
loading
=
false
})
},
//保存原图 开关
handleOrigineChange
:
function
(
e
)
{
this
.
result
[
'hasOrigin'
]
=
!
this
.
result
[
'hasOrigin'
]
...
...
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