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
e7098dec
Commit
e7098dec
authored
Nov 08, 2022
by
刘文虎
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
生成海报
parent
1ab2b027
Pipeline
#3963
canceled with stages
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
306 additions
and
47 deletions
+306
-47
save-poster-popup.vue
pages/mine/share/components/save-poster-popup.vue
+98
-34
index.vue
pages/mine/share/index.vue
+208
-13
No files found.
pages/mine/share/components/save-poster-popup.vue
View file @
e7098dec
<
template
>
<
template
>
<u
-popup
v-model=
"show"
:animation=
"false"
ref=
"uniPopup
"
border-radius=
"24"
type=
"center"
mode=
"center"
>
<u
ni-popup
v-model=
"show"
ref=
"uniPopup"
:animation=
"false
"
border-radius=
"24"
type=
"center"
mode=
"center"
>
<view
class=
"custom-popup"
>
<view
class=
"custom-popup"
>
<view
class=
"apply-refuse"
>
<view
class=
"apply-refuse"
>
<view
class=
"title"
>
本次服务收费金额
</view>
<view
class=
"user"
>
<view
class=
"user-avatar"
>
<image
:src=
"userInfo.avatar"
mode=
""
v-if=
"userInfo.avatar"
></image>
<image
:src=
"avatar"
v-else
></image>
</view>
<text>
{{
userInfo
.
nickname
||
'微信用户'
}}
</text>
</view>
<view
class=
"content-view"
>
<view
class=
"content-view"
>
<view
class=
"qrcode-view"
><image
:src=
"qrcode"
></image></view>
</view>
</view>
<view
class=
"btn"
>
</view>
<view
class=
"confirm"
hover-class=
"u-hover-class"
@
click=
"$u.throttle(handleClickSure, 500)"
>
确定
</view>
<view
class=
"btn"
>
<view
class=
"confirm"
@
click=
"$u.throttle(handleClickSure, 500)"
>
<view
class=
"image-view"
><image
:src=
"saveImage"
></image></view>
<text
hover-class=
"u-hover-class"
>
保存至相册
</text>
</view>
</view>
</view>
</view>
<u-toast
ref=
"uToast"
/>
</view>
</view>
</u-popup>
</u
ni
-popup>
</
template
>
</
template
>
<
script
>
<
script
>
import
UniPopup
from
'@/uni_modules/uni-popup/uni-popup.vue'
;
import
{
mineBaseUrl
}
from
'@/utils/config.js'
;
import
{
mapGetters
}
from
'vuex'
;
export
default
{
export
default
{
props
:[
'qrcode'
],
props
:
[
'qrcode'
],
components
:
{
UniPopup
},
data
()
{
data
()
{
return
{
return
{
show
:
false
,
show
:
false
,
saveImage
:
mineBaseUrl
+
'haibaobaocunxiangce@3x.png'
,
avatar
:
mineBaseUrl
+
'toxuiang@3x.png'
,
backgroundImage
:
mineBaseUrl
+
'min-share-haibao.jpg'
};
};
},
},
computed
:
{
...
mapGetters
([
'userInfo'
]),
},
methods
:
{
methods
:
{
open
()
{
open
()
{
this
.
show
=
true
;
this
.
show
=
true
;
this
.
$refs
.
uniPopup
.
open
();
},
},
close
()
{
close
()
{
this
.
show
=
false
;
this
.
show
=
false
;
this
.
$refs
.
uniPopup
.
close
();
},
},
handleClickSure
()
{
handleClickSure
()
{
this
.
close
();
this
.
$emit
(
'save'
);
this
.
$emit
(
'confirm'
,
this
.
text
);
}
},
}
}
};
};
</
script
>
</
script
>
<
style
lang=
"scss"
scoped
>
<
style
lang=
"scss"
scoped
>
.custom-popup
{
.custom-popup
{
position
:
relative
;
.apply-refuse
{
.apply-refuse
{
background
:
linear-gradient
(
180deg
,
#f4fffc
0%
,
#ffffff
50%
)
#fff
;
background-color
:
$default-color
;
width
:
622rpx
;
background
:
url('https://static-book.kaying.cc/icon/mine/min-share-haibao.jpg')
no-repeat
;
background-position
:
center
top
;
background-size
:
100%
;
width
:
620rpx
;
height
:
1010rpx
;
border-radius
:
12rpx
;
border-radius
:
12rpx
;
padding
:
0
24rpx
32rpx
;
padding
:
52rpx
36rpx
;
position
:
relative
;
.title
{
.user
{
padding
:
48rpx
0
40rpx
;
display
:
flex
;
text-align
:
center
;
align-items
:
center
;
font-size
:
32rpx
;
color
:
#FFFFFF
;
color
:
#333333
;
.user-avatar
{
width
:
44rpx
;
height
:
44rpx
;
border-radius
:
50%
;
background
:
#FFFFFF
;
padding
:
4rpx
;
display
:
flex
;
margin-right
:
12rpx
;
}
}
}
.content-view
{
.content-view
{
width
:
100%
;
position
:
absolute
;
top
:
550rpx
;
left
:
50%
;
transform
:
translateX
(
-50%
);
width
:
192rpx
;
height
:
192rpx
;
background
:
#FFFFFF
;
border-radius
:
16rpx
;
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
.qrcode-view
{
width
:
160rpx
;
height
:
160rpx
;
display
:
flex
;
}
}
}
}
.btn
{
.btn
{
margin-top
:
68rpx
;
position
:
absolute
;
font-size
:
32rpx
;
bottom
:
-146rpx
;
.confirm
{
left
:
50%
;
height
:
96rpx
;
transform
:
translateX
(
-50%
);
font-weight
:
bold
;
font-size
:
32rpx
;
background
:
$default-color
;
width
:
480rpx
;
border-radius
:
16rpx
;
.confirm
{
line-height
:
96rpx
;
width
:
100%
;
text-align
:
center
;
height
:
104rpx
;
margin-left
:
30rpx
;
font-weight
:
bold
;
color
:
#ffffff
;
background
:
#ffffff
;
border-radius
:
16rpx
;
line-height
:
104rpx
;
text-align
:
center
;
color
:
$default-color
;
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
.image-view
{
width
:
32rpx
;
height
:
32rpx
;
margin-right
:
16rpx
;
display
:
flex
;
}
}
}
}
}
}
...
...
pages/mine/share/index.vue
View file @
e7098dec
...
@@ -15,10 +15,10 @@
...
@@ -15,10 +15,10 @@
</view>
</view>
</view>
</view>
<view
class=
"bottom-view"
>
<view
class=
"bottom-view"
>
<u-button
type=
"success"
open-type=
"share"
:custom-style=
"customSave"
@
click=
"handleClick
Save"
>
<u-button
type=
"success"
:custom-style=
"customSave"
@
click=
"handle
Save"
>
<view
class=
"bottom-content"
>
<view
class=
"bottom-content
save-content
"
>
<view
class=
"icon-view"
><image
:src=
"s
har
eIcon"
></image></view>
<view
class=
"icon-view"
><image
:src=
"s
av
eIcon"
></image></view>
<view
class=
"share-view"
>
生成海报
</view>
<view
class=
"share-view
save-view
"
>
生成海报
</view>
</view>
</view>
</u-button>
</u-button>
<u-button
type=
"success"
open-type=
"share"
:custom-style=
"customShare"
@
click=
"handleClickShare"
>
<u-button
type=
"success"
open-type=
"share"
:custom-style=
"customShare"
@
click=
"handleClickShare"
>
...
@@ -28,30 +28,41 @@
...
@@ -28,30 +28,41 @@
</view>
</view>
</u-button>
</u-button>
</view>
</view>
<save-poster-popup
ref=
"save-poster-popup"
:qrcode=
"qrcode"
></save-poster-popup>
<u-toast
ref=
"uToast"
/>
<QRCodeView
:url=
"shareUrl"
@
canvas=
"handleCanvas"
/>
<SavePosterPopup
ref=
"save-poster-popup"
:qrcode=
"qrcode"
@
save=
"handleClickSave"
></SavePosterPopup>
<l-painter
:board=
"poster"
isCanvasToTempFilePath
@
success=
"handleCanvasSuccess"
@
fail=
"handleCanvasFail"
custom-style=
"position: fixed; left: 400%"
/>
</view>
</view>
</
template
>
</
template
>
<
script
>
<
script
>
import
NavbarRight
from
'@/components/navbar-right'
;
import
NavbarRight
from
'@/components/navbar-right'
;
import
QRCodeView
from
'@/components/qr-code-view'
;
import
SavePosterPopup
from
'./components/save-poster-popup.vue'
;
import
SavePosterPopup
from
'./components/save-poster-popup.vue'
;
import
{
mapGetters
}
from
'vuex'
;
import
{
mapGetters
}
from
'vuex'
;
import
{
wxMiniId
,
web
Url
}
from
'@/utils/config.js'
;
import
{
index_share_url
,
wxMiniId
,
webUrl
,
mineBase
Url
}
from
'@/utils/config.js'
;
import
{
shareInvited
}
from
'@/api/mine/share.js'
;
import
{
shareInvited
}
from
'@/api/mine/share.js'
;
import
{
getSetting
}
from
'@/utils/common.js'
;
export
default
{
export
default
{
components
:
{
components
:
{
NavbarRight
,
NavbarRight
,
SavePosterPopup
SavePosterPopup
,
QRCodeView
},
},
data
()
{
data
()
{
return
{
return
{
qrcode
:
''
,
avatar
:
mineBaseUrl
+
'toxuiang@3x.png'
,
saveIcon
:
mineBaseUrl
+
'shengcehnghaibaoanniu@3x.png'
,
qrcode
:
''
,
poster
:
{},
currentBlock
:
()
=>
{},
billImageUrl
:
''
,
customerId
:
''
};
};
},
},
computed
:
{
computed
:
{
...
mapGetters
([
'userInfo'
]),
...
mapGetters
([
'userInfo'
]),
baseUrl
()
{
baseUrl
()
{
return
process
.
uniEnv
.
qn_base_url
;
return
process
.
uniEnv
.
qn_base_url
;
},
},
...
@@ -84,13 +95,189 @@ export default {
...
@@ -84,13 +95,189 @@ export default {
padding
:
'0rpx'
padding
:
'0rpx'
};
};
},
},
shareTitle
()
{
return
'请客户微信扫码领取账单'
;
},
shareParams
()
{
return
`?shareUserId=
${
this
.
userInfo
.
id
}
`
;
},
shareUrl
()
{
return
index_share_url
+
this
.
shareParams
;
},
receive
()
{
return
this
.
customerId
!=
this
.
userInfo
.
id
;
}
},
},
onLoad
(
options
)
{},
onLoad
(
options
)
{},
onUnload
()
{},
onUnload
()
{},
onReady
()
{
setTimeout
(()
=>
{
console
.
log
(
'handleCanvas-qrcode---onReady'
,
this
.
qrcode
);
},
1500
);
},
methods
:
{
methods
:
{
handleClickSave
(){
handleCanvas
(
url
)
{
this
.
$refs
[
'save-poster-popup'
].
open
()
console
.
log
(
'handleCanvas-qrcode---'
,
url
);
this
.
qrcode
=
url
;
},
handleSave
()
{
this
.
$refs
[
'save-poster-popup'
].
open
();
},
handleCanvasSuccess
(
url
)
{
console
.
log
(
'---------handleCanvasSuccess--------'
,
url
);
this
.
billImageUrl
=
url
;
this
.
currentBlock
(
url
);
},
handleCanvasFail
(
err
)
{
console
.
log
(
'---------handleCanvasFail--------'
,
err
);
uni
.
hideLoading
();
this
.
$refs
.
uToast
.
show
({
title
:
'保存失败'
,
type
:
'error'
,
duration
:
1500
,
callback
:
()
=>
{}
});
},
handleClickSave
()
{
this
.
currentBlock
=
url
=>
{
uni
.
saveImageToPhotosAlbum
({
filePath
:
url
,
success
:
()
=>
{
this
.
$refs
.
uToast
.
show
({
title
:
'保存成功'
,
type
:
'success'
,
duration
:
1500
,
callback
:
()
=>
{}
});
},
fail
:
err
=>
{
// #ifdef APP-PLUS
if
(
err
.
errCode
==
2
)
{
uni
.
hideLoading
();
getSetting
(
'photoLibrary'
,
'检测到您没打开保存到相册功能权限,是否去设置打开?'
,
res
=>
{
this
.
handleClickSave
();
});
return
;
}
// #endif
var
str
=
err
&&
err
.
errMsg
;
if
(
str
&&
str
.
indexOf
(
'cancel'
)
!=
-
1
)
{
str
=
'取消保存'
;
}
this
.
$refs
.
uToast
.
show
({
title
:
str
,
type
:
'error'
,
duration
:
1500
,
callback
:
()
=>
{}
});
},
complete
:
res
=>
{
uni
.
hideLoading
();
}
});
};
// #ifdef APP-PLUS
if
(
this
.
isIOS
)
{
this
.
saveBillImage
();
}
else
{
getSetting
(
'android.permission.WRITE_EXTERNAL_STORAGE'
,
'检测到您没打开保存到相册功能权限,是否去设置打开?'
,
res
=>
{
this
.
saveBillImage
();
});
}
// #endif
// #ifdef MP-WEIXIN
getSetting
(
'scope.writePhotosAlbum'
,
'检测到您没打开保存到相册功能权限,是否去设置打开?'
,
res
=>
{
this
.
saveBillImage
();
});
// #endif
// #ifdef MP-TOUTIAO
getSetting
(
'scope.album'
,
'检测到您没打开保存到相册功能权限,是否去设置打开?'
,
res
=>
{
this
.
saveBillImage
();
});
// #endif
},
saveBillImage
(
tip
=
'保存中'
)
{
uni
.
showLoading
({
title
:
tip
});
if
(
this
.
billImageUrl
)
{
this
.
currentBlock
(
this
.
billImageUrl
);
}
else
{
this
.
saveReceipt
();
}
},
},
saveReceipt
()
{
console
.
log
(
'saveReceipt'
);
this
.
poster
=
{
css
:
{
width
:
'750rpx'
,
height
:
'1220rpx'
,
backgroundImage
:
'url(https://static-book.kaying.cc/icon/mine/min-share-haibao.jpg)'
,
'object-fit'
:
'fill'
},
views
:
[
{
type
:
'view'
,
css
:
{
marginTop
:
'60rpx'
,
marginLeft
:
'38rpx'
,
display
:
'flex'
,
'align-items'
:
'center'
,
fontSize
:
'24rpx'
,
color
:
'#ffffff'
,
'line-height'
:
'44rpx'
},
views
:
[
{
type
:
'image'
,
src
:
this
.
userInfo
.
avatar
?
this
.
userInfo
.
avatar
:
this
.
avatar
,
css
:
{
width
:
'44rpx'
,
height
:
'44rpx'
,
'border-radius'
:
'50%'
,
background
:
'#FFFFFF'
,
display
:
'flex'
,
'margin-right'
:
'12rpx'
,
boxSize
:
'border-box'
}
},
{
type
:
'text'
,
text
:
this
.
userInfo
.
nickname
||
'微信用户'
,
css
:
{}
}
]
},
{
type
:
'view'
,
css
:
{
margin
:
'600rpx auto 0 auto'
,
width
:
'192rpx'
,
height
:
'192rpx'
,
background
:
'#FFFFFF'
,
'border-radius'
:
'16rpx'
,
display
:
'flex'
,
'align-items'
:
'center'
,
'justify-content'
:
'center'
},
views
:
[
{
type
:
'image'
,
src
:
this
.
qrcode
,
css
:
{
width
:
'160rpx'
,
height
:
'160rpx'
,
textAlign
:
'center'
}
}
]
}
]
};
},
shareInvited
()
{
shareInvited
()
{
shareInvited
({})
shareInvited
({})
.
then
(
res
=>
{
.
then
(
res
=>
{
...
@@ -191,7 +378,7 @@ export default {
...
@@ -191,7 +378,7 @@ export default {
margin
:
16rpx
24rpx
36rpx
24rpx
;
margin
:
16rpx
24rpx
36rpx
24rpx
;
display
:
flex
;
display
:
flex
;
align-items
:
center
;
align-items
:
center
;
justify-content
:
center
;
justify-content
:
space-between
;
// background-color: #ffffff;
// background-color: #ffffff;
.bottom-content
{
.bottom-content
{
...
@@ -200,7 +387,7 @@ export default {
...
@@ -200,7 +387,7 @@ export default {
display
:
flex
;
display
:
flex
;
justify-content
:
center
;
justify-content
:
center
;
align-items
:
center
;
align-items
:
center
;
background
-image
:
linear-gradient
(
to
bottom
,
#ff8a20
0%
,
#eb172c
100%
);
background
:
linear-gradient
(
to
bottom
,
#ff8a20
0%
,
#eb172c
100%
);
overflow
:
hidden
;
overflow
:
hidden
;
border-radius
:
52rpx
;
border-radius
:
52rpx
;
...
@@ -222,6 +409,14 @@ export default {
...
@@ -222,6 +409,14 @@ export default {
height
:
100%
;
height
:
100%
;
line-height
:
104rpx
;
line-height
:
104rpx
;
}
}
.save-view
{
color
:
#eb172c
;
background-color
:
#ffffff
;
}
}
.save-content
{
border
:
2rpx
solid
#eb172c
;
background
:
#ffffff
;
}
}
}
}
}
}
...
...
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