Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
lumastoreapp
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xieyishang
lumastoreapp
Commits
a9f20e26
Commit
a9f20e26
authored
Dec 25, 2020
by
haitao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fd
parent
2151123d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
666 additions
and
397 deletions
+666
-397
pages/storeqrcode/storeqrcode.vue
pages/storeqrcode/storeqrcode.vue
+282
-395
pages/storeqrcode/storeqrcode2.vue
pages/storeqrcode/storeqrcode2.vue
+382
-0
utils/debug.js
utils/debug.js
+2
-2
No files found.
pages/storeqrcode/storeqrcode.vue
View file @
a9f20e26
<
template
>
<
template
>
<!-- 商家二维码 -->
<view
:style=
"
{height:windowHeight+'px',background:show?'#EC6919':''}">
<!-- 商家码 -->
<!-- 只要他得高度 -->
<view
class=
"content yocode"
>
<image
:src=
"avaterSrc"
class=
"w1005 posf"
style=
"left: -1000px;"
mode=
"widthFix"
@
load=
'imgH'
></image>
<view
class=
"submitbtn active"
@
tap=
"shareQrcode"
v-if=
"!qrShow"
>
生成
</view>
<!--
<view
class=
"submitbtn active"
@
tap=
"shareFc"
v-if=
"!qrShow"
>
生成
</view>
-->
<!-- @tap=" saveImage()" -->
<view
class=
"w1005"
>
<view
class=
"flex_row_c_c modalView"
v-if=
"qrShow"
:class=
"qrShow?'show':''"
>
<canvas
:style=
"
{height:bgHeight+'px',width:'100%'}" class="bgf" canvas-id="myCanvas">
</canvas>
<view
class=
"flex_column"
>
</view>
<!-- backgroundColor-white -->
<view
class=
" padding1vh border_radius_10px"
>
<image
:src=
"poster.finalPath"
mode=
"widthFix"
class=
"posterImage"
></image>
<image
class=
"bctpbtns"
v-if=
'show'
src=
"/static/bctp.png"
@
tap.prevent.stop=
"saveImage()"
></image>
<image
class=
"bctpbtns"
src=
"/static/bctp.png"
mode=
""
@
tap.prevent.stop=
"saveImage()"
></image>
<image
class=
"fxhbbtns"
v-if=
'show'
src=
"/static/fxhb.png"
@
tap.prevent.stop=
"share()"
></image>
<image
class=
"fxhbbtns"
src=
"/static/fxhb.png"
mode=
""
@
tap.prevent.stop=
"share()"
></image>
</view>
<uni-popup
type=
'bottom'
:show=
'popupShow'
@
change=
"change"
style=
"z-index: 999999999 !important;"
>
<view
class=
"flex_row marginTop2vh"
>
<view
class=
"bgf mb-10"
style=
"border-radius: 20upx;z-index: 999999999 !important;"
>
<!--
<button
type=
"primary"
class=
"buttons"
size=
"mini"
@
tap.prevent.stop=
"saveImage()"
>
保存图片
</button>
<view
class=
"tc s30 lh90 br-b"
@
tap.stop=
"shareToFriend(1)"
>
微信好友
</view>
<button
type=
"primary"
class=
"buttons"
size=
"mini"
@
tap.prevent.stop=
"hideQr()"
>
关闭
</button>
-->
<view
class=
"tc s30 lh90 br-b"
@
tap.stop=
"shareToFriend(2)"
>
微信朋友圈
</view>
<!--
<button
type=
"primary"
class=
"buttons"
size=
"mini"
@
tap.prevent.stop=
"share()"
>
分享图片
</button>
-->
<view
class=
"tc s30 lh90"
@
tap.stop=
"shareToFriend(3)"
>
微信收藏
</view>
</view>
</view>
</view>
</uni-popup>
</view>
<!--
<button
type=
"primary"
class=
"buttons mt-40 ml-20 mr-20"
@
tap=
"shareFc()"
>
生成店铺二维码
</button>
-->
</view>
<view
class=
"hideCanvasView"
>
</
template
>
<canvas
class=
"hideCanvas"
canvas-id=
"default_PosterCanvasId"
<
script
>
:style=
"
{width: (poster.width||0) + 'px', height: (poster.height||0) + 'px'}">
</canvas>
import
{
createQrcode
as
shareQrcode
}
from
"
@/utils/api/api.js
"
;
</view>
import
uniPopup
from
'
@/components/uni-popup/uni-popup.vue
'
;
</view>
export
default
{
</
template
>
components
:{
uniPopup
<
script
>
},
import
_app
from
'
@/utils/QS-SharePoster/app.js
'
;
data
()
{
import
getSharePoster
from
'
@/utils/QS-SharePoster/QS-SharePoster.js
'
;
return
{
// import {usersEquity} from "@/utils/api/partner_center.js";
show
:
false
,
//是否显示隐藏
// import {shareQrcode} from "@/utils/api/user.js"
qrcode_url
:
''
,
//二维码路径
avaterSrc
:
''
,
//本地背景图片
import
{
createQrcode
as
shareQrcode
}
from
"
@/utils/api/api.js
"
;
qrcodeurl
:
''
,
//生成的二维码
export
default
{
bgHeight
:
667
,
//背景图的高度
data
()
{
windowHeight
:
0
,
//可视区域高度
return
{
windowWidth
:
375
,
//屏幕宽度
poster
:
{},
imgUrl
:
''
,
//生成的canvas图片
qrShow
:
false
,
popupShow
:
false
,
//底部弹窗
canvasId
:
'
default_PosterCanvasId
'
,
rpx
:
0
,
type
:
"
1
"
,
shopname
:
''
url
:
""
,
}
shopInfo
:{},
},
shop_name
:
""
,
computed
:
{
shop_id
:
0
,
//url传过来的
staticUrl
()
{
//静态资源地址 正式
}
return
this
.
$store
.
state
.
staticUrl
;
},
},
computed
:
{
staticUrl1
()
{
//静态资源地址 测试
staticUrl
()
{
//静态资源地址 正式
return
this
.
$store
.
state
.
staticUrl1
;
return
this
.
$store
.
state
.
staticUrl
;
},
},
statictowUrl
(){
staticUrl1
()
{
//静态资源地址 测试
return
this
.
$store
.
state
.
statictowUrl
;
return
this
.
$store
.
state
.
staticUrl1
;
},
},
userInfo
()
{
statictowUrl
(){
return
this
.
$store
.
state
.
userInfo
;
return
this
.
$store
.
state
.
statictowUrl
;
},
},
uploadurl
(){
userInfo
()
{
return
this
.
$store
.
state
.
uploadurl
;
return
this
.
$store
.
state
.
userInfo
;
}
},
},
uploadurl
(){
onLoad
(
opdata
)
{
return
this
.
$store
.
state
.
uploadurl
;
this
.
windowWidth
=
uni
.
getSystemInfoSync
().
windowWidth
;
}
this
.
windowHeight
=
uni
.
getSystemInfoSync
().
windowHeight
;
},
this
.
rpx
=
uni
.
getSystemInfoSync
().
windowWidth
/
375
;
onLoad
(
opdata
)
{
this
.
shop_id
=
opdata
.
shop_id
;
this
.
type
=
opdata
.
type
;
this
.
shopname
=
opdata
.
shop_name
;
//商品名称
this
.
shop_id
=
opdata
.
shop_id
;
this
.
createGoodsQrcode
();
},
//this.shareFc();//自动生成
methods
:
{
filePath
(
type
,
wxType
){
this
.
shopInfo
=
uni
.
getStorageSync
(
'
userInfo
'
);
if
(
this
.
imgUrl
==
''
){
///没保存
this
.
shop_name
=
this
.
shopInfo
.
shop_name
;
uni
.
showLoading
({
title
:
'
正在保图片...
'
});
uni
.
canvasToTempFilePath
({
//保存canvas
this
.
shareQrcode
();
canvasId
:
'
myCanvas
'
,
},
success
:(
res
)
=>
{
methods
:
{
uni
.
hideLoading
();
//生成二维码
this
.
imgUrl
=
res
.
tempFilePath
;
async
shareQrcode
(){
// uni.showLoading({
// title: '加载中'
// });
let
res
=
await
shareQrcode
({
type
:
3
,
//固定的
//shareid: app.globalData.storeInfo.shop_id
shareid
:
this
.
$store
.
state
.
userInfo
.
shop_id
,
//店铺id
})
if
(
res
.
code
==
0
){
this
.
url
=
res
.
data
.
file
;
// let qrcodeurl = window.location.port=="8080"?this.staticUrl1+this.url:this.staticUrl+this.url;
// let qrcodeurl = window.location.port=="8080"?this.staticUrl1+this.url:this.staticUrl1+this.url;
// let qrcodeurl = this.staticUrl1+this.url;
let
qrcodeurl
=
this
.
staticUrl1
+
this
.
url
;
this
.
url
=
qrcodeurl
;
// https://zxluma.jxdsy.cn/attachs/
//console.info(res.data.file,"路径");
// uni.showLoading({
// title: '生成成功'
// });
this
.
shareFc
();
}
else
{
uni
.
showLoading
({
title
:
'
生成失败
'
});
this
.
$api
.
msg
(
res
.
msg
);
}
setTimeout
(
function
()
{
uni
.
hideLoading
();
},
2000
);
},
//生成海报
async
shareFc
()
{
//debugger
try
{
if
(
!
this
.
poster
.
finalPath
)
{
let
backgroundImage
;
let
rqcodeobj
=
{}
// 二维码
rqcodeobj
=
{
text
:
'
开发测试
'
,
size
:
150
,
//bgObj.width*0.2
dx
:
380
,
//bgObj.width*0.05
dy
:
765
//bgObj.height - bgObj.width*0.25
}
//计算名称的x轴
let
len
=
this
.
shop_name
.
length
;
let
cha
=
0
;
//差值
let
dxsss
=
0
;
//xy 坐标
if
(
len
<=
10
){
//小于
cha
=
10
-
len
;
dxsss
=
160
+
cha
*
12
;
}
else
{
//大于
cha
=
len
-
10
;
dxsss
=
160
-
cha
*
12
;
}
console
.
log
(
"
计算出来的dx
"
,
dxsss
);
const
d
=
await
getSharePoster
({
// backgroundImage:"/static/news/sjrwm.png",
//#ifdef APP-PLUS
backgroundImage
:
this
.
statictowUrl
+
"
static/applet5/images/uts/sjrwm.png
"
,
uni
.
showLoading
({
title
:
'
请稍后...
'
,
mask
:
true
});
uni
.
share
({
//分享给朋友圈
//暂时使用这个
provider
:
'
weixin
'
,
// backgroundImage:"http://q37tb0wtc.bkt.clouddn.com/sjrwm.png",
scene
:
wxType
,
//WXSceneSession聊天界面 WXSenceTimeline朋友圈
type
:
2
,
imageUrl
:
res
.
tempFilePath
,
// backgroundImage:"https://www.baidu.com/img/superlogo_c4d7df0a003d3db9b65e9ef0fe6da1ec.png?where=super",
success
:
ret
=>
{
// backgroundImage:"https://luma.jxdsy.cn/attachs/2019/07/29/thumb_5d3ecaa81b681.jpg",
uni
.
hideLoading
();
},
type
:
'
testShareType
'
,
fail
:
err
=>
{
posterCanvasId
:
this
.
canvasId
,
console
.
log
(
err
)
// qrCodeArray: ({bgObj, type, bgScale}) => {
}
// return [rqcodeobj]
});
// },
//#endif
imagesArray
:
({
bgObj
,
type
,
bgScale
})
=>
{
//接收的第一个参数为背景图片的信息, 第二个参数是自定义标识(感觉这里用不到), 图片为示例图片
},
const
dx
=
bgObj
.
width
*
0.3
;
fail
:(
err
)
=>
{
return
[
uni
.
hideLoading
();
//二维码
this
.
$api
.
msg
(
'
图片保存失败
'
);
//二维码放进去
},
{
},
this
)
url
:
this
.
url
,
// //"https://www.baidu.com/img/superlogo_c4d7df0a003d3db9b65e9ef0fe6da1ec.png?qua=high&where=super",//
}
else
{
//保存过了
dx
:
155
,
//bgObj.width*0.05
//#ifdef APP-PLUS
dy
:
350
,
//bgObj.height - bgObj.width*0.25
uni
.
showLoading
({
title
:
'
请稍后...
'
,
mask
:
true
});
dWidth
:
250
,
// 因为设置了圆形图片 所以要乘以2
uni
.
share
({
//分享给朋友圈
dHeight
:
250
provider
:
'
weixin
'
,
},
scene
:
wxType
,
//WXSceneSession聊天界面 WXSenceTimeline朋友圈
]
type
:
2
,
},
imageUrl
:
this
.
imgUrl
,
textArray
:
({
bgObj
,
type
,
bgScale
})
=>
{
success
:
ret
=>
{
const
fontSize
=
bgObj
.
width
*
0.045
;
uni
.
hideLoading
();
const
lineHeight
=
bgObj
.
height
*
0.04
;
},
return
[
fail
:
err
=>
{
/**
console
.
log
(
err
)
* 商家名称居中 10个字 160/640 刚刚好
}
* 11个字
});
*
//#endif
* 10个以后 每多加一个字 大概要 160- 多出来的个数- 12
}
*
*
},
* 10个以下 每少一个字 大概要 160 + 12
shareToFriend
(
type
){
*
let
wxType
=
''
;
* ***/
if
(
type
==
3
){
//收藏
wxType
=
'
WXSceneFavorite
'
;
}
else
{
//1聊天界面 2朋友圈
// 文字 先干了
if
(
type
==
1
){
{
wxType
=
'
WXSceneSession
'
;
text
:
this
.
shop_name
,
//,`测试商家名称测试商家是遭`,//10个字正好
}
else
{
fontWeight
:
'
bold
'
,
wxType
=
'
WXSenceTimeline
'
;
size
:
24
,
}
color
:
'
#ffffff
'
,
}
alpha
:
1
,
textAlign
:
'
left
'
,
this
.
filePath
(
type
,
wxType
);
textBaseline
:
'
middle
'
,
infoCallBack
(
textLength
)
{
},
//dx 160是侧面对齐
change
(
e
)
{
return
{
if
(
!
e
.
show
)
{
dx
:
dxsss
,
//136,//bgObj.width - textLength - fontSize
this
.
popupShow
=
false
dy
:
635
//bgObj.height - lineHeight*2
}
}
},
}
share
()
{
//分享到
},
this
.
popupShow
=
true
;
},
saveImage
(){
//保存图片
uni
.
showLoading
({
title
:
'
正在保存图片...
'
,
mask
:
true
});
if
(
this
.
imgUrl
==
''
){
uni
.
canvasToTempFilePath
({
//保存canvas
]
canvasId
:
'
myCanvas
'
,
},
success
:(
res
)
=>
{
setCanvasWH
:
({
bgObj
,
type
,
bgScale
})
=>
{
// 为动态设置画布宽高的方法,
uni
.
hideLoading
();
this
.
poster
=
bgObj
;
this
.
imgUrl
=
res
.
tempFilePath
;
},
console
.
log
(
this
.
imgUrl
)
setDraw
:
({
Context
,
bgObj
,
type
,
bgScale
})
=>
{
uni
.
saveImageToPhotosAlbum
({
//保存到相册
// Context.setFillStyle('black');
filePath
:
res
.
tempFilePath
,
// Context.setGlobalAlpha(0.3);
success
:(
res
)
=>
{
// Context.fillRect(0, bgObj.height - bgObj.height*0.2, bgObj.width, bgObj.height*0.2);
uni
.
showToast
({
title
:
'
图片保存成功
'
,
icon
:
'
none
'
});
},
},
fail
:
function
(
err
){
});
console
.
log
(
err
)
this
.
$api
.
msg
(
'
图片保存失败
'
);
}
console
.
log
(
'
海报生成成功, 临时路径:
'
+
d
.
poster
.
tempFilePath
)
})
},
fail
:(
err
)
=>
{
this
.
poster
.
finalPath
=
d
.
poster
.
tempFilePath
;
uni
.
hideLoading
();
console
.
log
(
this
.
poster
.
finalPath
)
this
.
$api
.
msg
(
'
图片保存失败
'
);
}
},
this
.
qrShow
=
true
;
},
this
)
}
catch
(
e
)
{
}
else
{
_app
.
hideLoading
();
uni
.
saveImageToPhotosAlbum
({
//保存到相册
_app
.
showToast
(
JSON
.
stringify
(
e
));
filePath
:
this
.
imgUrl
,
console
.
log
(
JSON
.
stringify
(
e
));
success
:(
res
)
=>
{
console
.
log
(
'
海报生成成功, 临时路径:
'
+
d
.
poster
.
tempFilePath
)
uni
.
hideLoading
();
}
uni
.
showToast
({
title
:
'
图片保存成功
'
,
icon
:
'
none
'
,
duration
:
2000
});
},
},
saveImage
()
{
fail
:
function
(
res
){
// #ifndef H5
uni
.
hideLoading
();
uni
.
saveImageToPhotosAlbum
({
this
.
$api
.
msg
(
'
图片保存失败
'
);
filePath
:
this
.
poster
.
finalPath
,
}
success
(
res
)
{
})
_app
.
showToast
(
'
保存成功
'
);
}
}
})
},
// #endif
imgH
(
e
){
// #ifdef H5
this
.
bgHeight
=
e
.
detail
.
height
/
2
;
//得到背景图高度
_app
.
showToast
(
'
保存了
'
);
},
// #endif
createGoodsQrcode
(){
//生成二维码
},
uni
.
showLoading
({
title
:
'
二维码生成中...
'
,
mask
:
true
});
share
()
{
shareQrcode
({
// #ifdef APP-PLUS
type
:
3
,
//店铺二维码
_app
.
getShare
(
false
,
false
,
2
,
''
,
''
,
''
,
this
.
poster
.
finalPath
,
false
,
false
);
shareid
:
this
.
shop_id
,
//店铺id
// #endif
}).
then
(
res
=>
{
uni
.
hideLoading
();
// #ifndef APP-PLUS
if
(
res
.
code
==
0
){
_app
.
showToast
(
'
分享了
'
);
this
.
qrcodeurl
=
this
.
staticUrl1
+
res
.
data
.
file
;
// #endif
this
.
avater
();
},
}
else
{
hideQr
()
{
this
.
qrcodeurl
=
''
;
this
.
qrShow
=
false
;
this
.
$api
.
msg
(
"
生成二维码失败
"
);
}
this
.
avater
();
}
}
}
})
},
avater
(){
//主图下载
console
.
log
(
this
.
statictowUrl
+
"
static/applet5/images/uts/sjrwm.png
"
,)
uni
.
showLoading
({
title
:
'
图片下载中...
'
,
mask
:
true
});
uni
.
downloadFile
({
//下载图片到本地
url
:
this
.
statictowUrl
+
"
static/applet5/images/uts/sjrwm.png
"
,
//背景主图片, //主图
success
:
res
=>
{
uni
.
hideLoading
();
if
(
res
.
statusCode
==
200
){
//下载成功
this
.
avaterSrc
=
res
.
tempFilePath
;
this
.
drawPosters
(
this
.
avaterSrc
)
}
else
{
this
.
avaterSrc
=
''
;
this
.
drawPosters
(
this
.
avaterSrc
)
}
},
fail
:
err
=>
{
uni
.
hideLoading
();
this
.
avaterSrc
=
''
;
this
.
drawPosters
(
avaterSrc
);
this
.
$api
.
msg
(
"
图片下载失败
"
);
}
})
},
drawPosters
(
avaterSrc
){
let
rpx
=
this
.
rpx
;
uni
.
showLoading
({
title
:
'
正在绘制海报...
'
,
mask
:
true
});
const
ctx
=
uni
.
createCanvasContext
(
'
myCanvas
'
,
this
);
//创建画布
ctx
.
setFillStyle
(
'
#FFFFFF
'
);
ctx
.
fillRect
(
0
,
0
,
this
.
windowWidth
,
this
.
bgHeight
);
if
(
avaterSrc
){
//主图
ctx
.
drawImage
(
avaterSrc
,
0
,
0
,
this
.
windowWidth
,
this
.
bgHeight
);
}
if
(
this
.
qrcodeurl
){
//二维码
ctx
.
drawImage
(
this
.
qrcodeurl
,
(
this
.
windowWidth
-
210
*
rpx
)
/
2
,
220
,
210
*
rpx
,
220
*
rpx
);
}
if
(
this
.
shopname
){
//店铺名字
ctx
.
setFillStyle
(
'
#ffffff
'
);
ctx
.
setFontSize
((
18
*
rpx
).
toFixed
(
0
));
ctx
.
fillText
(
this
.
shopname
,(
this
.
windowWidth
-
ctx
.
measureText
(
this
.
shopname
).
width
)
/
2
,
470
);
}
uni
.
hideLoading
();
ctx
.
draw
();
this
.
show
=
true
;
},
}
}
</
script
>
</
script
>
<
style
>
<
style
lang=
"scss"
>
.posf
{
.hideCanvasView
{
position
:
fixed
;
position
:
relative
;
}
}
.bctpbtns
{
position
:
absolute
;
.hideCanvas
{
z-index
:
10000
;
position
:
fixed
;
right
:
0
;
top
:
-99999upx
;
bottom
:
240px
;
left
:
-99999upx
;
width
:
57
upx
;
z-index
:
-99999
;
height
:
189
upx
;
}
}
.fxhbbtns
{
.flex_row_c_c
{
position
:
absolute
;
display
:
flex
;
z-index
:
10000
;
flex-direction
:
row
;
right
:
0
;
justify-content
:
center
;
bottom
:
130px
;
align-items
:
center
;
width
:
57
upx
;
}
height
:
189
upx
;
}
.modalView
{
.br-b
{
width
:
100%
;
border-bottom
:
1px
solid
#BCBCBC
;
height
:
100%
;
}
// position: fixed;
top
:
0
;
</
style
>
left
:
0
;
right
:
0
;
bottom
:
0
;
opacity
:
0
;
outline
:
0
;
transform
:
scale
(
3
);
perspective
:
2500upx
;
// background: rgba(0, 0, 0, 0.6);
transition
:
all
.3s
ease-in-out
;
pointer-events
:
none
;
backface-visibility
:
hidden
;
z-index
:
999
;
}
.modalView.show
{
opacity
:
1
;
transform
:
scale
(
1
);
pointer-events
:
auto
;
}
.flex_column
{
display
:
flex
;
flex-direction
:
column
;
}
.backgroundColor-white
{
background-color
:
white
;
}
.border_radius_10px
{
border-radius
:
10px
;
position
:
relative
;
.bctpbtns
{
position
:
absolute
;
z-index
:
10000
;
right
:
0
;
bottom
:
200px
;
width
:
57upx
;
height
:
189upx
;
}
.fxhbbtns
{
position
:
absolute
;
z-index
:
10000
;
right
:
0
;
bottom
:
100px
;
width
:
57upx
;
height
:
189upx
;
}
}
.padding1vh
{
/* padding: 1vh; */
}
.posterImage
{
/* width: 60vw; */
width
:
100vw
;
height
:
100vh
;
}
.flex_row
{
display
:
flex
;
flex-direction
:
row
;
}
.marginTop2vh
{
margin-top
:
2vh
;
}
.buttons
{
background
:
#ff6900
!
important
;
line-height
:
40px
!
important
;
}
</
style
>
pages/storeqrcode/storeqrcode2.vue
0 → 100644
View file @
a9f20e26
<
template
>
<!-- 商家二维码 -->
<!-- 商家码 -->
<view
class=
"content yocode"
>
<view
class=
"submitbtn active"
@
tap=
"shareQrcode"
v-if=
"!qrShow"
>
生成
</view>
<!--
<view
class=
"submitbtn active"
@
tap=
"shareFc"
v-if=
"!qrShow"
>
生成
</view>
-->
<!-- @tap=" saveImage()" -->
<view
class=
"flex_row_c_c modalView"
v-if=
"qrShow"
:class=
"qrShow?'show':''"
>
<view
class=
"flex_column"
>
<!-- backgroundColor-white -->
<view
class=
" padding1vh border_radius_10px"
>
<image
:src=
"poster.finalPath"
mode=
"widthFix"
class=
"posterImage"
></image>
<image
class=
"bctpbtns"
src=
"/static/bctp.png"
mode=
""
@
tap.prevent.stop=
"saveImage()"
></image>
<image
class=
"fxhbbtns"
src=
"/static/fxhb.png"
mode=
""
@
tap.prevent.stop=
"share()"
></image>
</view>
<view
class=
"flex_row marginTop2vh"
>
<!--
<button
type=
"primary"
class=
"buttons"
size=
"mini"
@
tap.prevent.stop=
"saveImage()"
>
保存图片
</button>
<button
type=
"primary"
class=
"buttons"
size=
"mini"
@
tap.prevent.stop=
"hideQr()"
>
关闭
</button>
-->
<!--
<button
type=
"primary"
class=
"buttons"
size=
"mini"
@
tap.prevent.stop=
"share()"
>
分享图片
</button>
-->
</view>
</view>
</view>
<!--
<button
type=
"primary"
class=
"buttons mt-40 ml-20 mr-20"
@
tap=
"shareFc()"
>
生成店铺二维码
</button>
-->
<view
class=
"hideCanvasView"
>
<canvas
class=
"hideCanvas"
canvas-id=
"default_PosterCanvasId"
:style=
"
{width: (poster.width||0) + 'px', height: (poster.height||0) + 'px'}">
</canvas>
</view>
</view>
</
template
>
<
script
>
import
_app
from
'
@/utils/QS-SharePoster/app.js
'
;
import
getSharePoster
from
'
@/utils/QS-SharePoster/QS-SharePoster.js
'
;
// import {usersEquity} from "@/utils/api/partner_center.js";
// import {shareQrcode} from "@/utils/api/user.js"
import
{
createQrcode
as
shareQrcode
}
from
"
@/utils/api/api.js
"
;
export
default
{
data
()
{
return
{
poster
:
{},
qrShow
:
false
,
canvasId
:
'
default_PosterCanvasId
'
,
type
:
"
1
"
,
url
:
""
,
shopInfo
:{},
shop_name
:
""
,
shop_id
:
0
,
//url传过来的
}
},
onLoad
(
opdata
)
{
this
.
type
=
opdata
.
type
;
this
.
shop_id
=
opdata
.
shop_id
;
//this.shareFc();//自动生成
this
.
shopInfo
=
uni
.
getStorageSync
(
'
userInfo
'
);
this
.
shop_name
=
this
.
shopInfo
.
shop_name
;
this
.
shareQrcode
();
},
methods
:
{
//生成二维码
async
shareQrcode
(){
// uni.showLoading({
// title: '加载中'
// });
let
res
=
await
shareQrcode
({
type
:
3
,
//固定的
//shareid: app.globalData.storeInfo.shop_id
shareid
:
this
.
$store
.
state
.
userInfo
.
shop_id
,
//店铺id
})
if
(
res
.
code
==
0
){
this
.
url
=
res
.
data
.
file
;
// let qrcodeurl = window.location.port=="8080"?this.staticUrl1+this.url:this.staticUrl+this.url;
// let qrcodeurl = window.location.port=="8080"?this.staticUrl1+this.url:this.staticUrl1+this.url;
// let qrcodeurl = this.staticUrl1+this.url;
let
qrcodeurl
=
this
.
staticUrl1
+
this
.
url
;
this
.
url
=
qrcodeurl
;
// https://zxluma.jxdsy.cn/attachs/
//console.info(res.data.file,"路径");
// uni.showLoading({
// title: '生成成功'
// });
this
.
shareFc
();
}
else
{
uni
.
showLoading
({
title
:
'
生成失败
'
});
this
.
$api
.
msg
(
res
.
msg
);
}
setTimeout
(
function
()
{
uni
.
hideLoading
();
},
2000
);
},
//生成海报
async
shareFc
()
{
//debugger
try
{
if
(
!
this
.
poster
.
finalPath
)
{
let
backgroundImage
;
let
rqcodeobj
=
{}
// 二维码
rqcodeobj
=
{
text
:
'
开发测试
'
,
size
:
150
,
//bgObj.width*0.2
dx
:
380
,
//bgObj.width*0.05
dy
:
765
//bgObj.height - bgObj.width*0.25
}
//计算名称的x轴
let
len
=
this
.
shop_name
.
length
;
let
cha
=
0
;
//差值
let
dxsss
=
0
;
//xy 坐标
if
(
len
<=
10
){
//小于
cha
=
10
-
len
;
dxsss
=
160
+
cha
*
12
;
}
else
{
//大于
cha
=
len
-
10
;
dxsss
=
160
-
cha
*
12
;
}
console
.
log
(
"
计算出来的dx
"
,
dxsss
);
const
d
=
await
getSharePoster
({
// backgroundImage:"/static/news/sjrwm.png",
backgroundImage
:
this
.
statictowUrl
+
"
static/applet5/images/uts/sjrwm.png
"
,
//暂时使用这个
// backgroundImage:"http://q37tb0wtc.bkt.clouddn.com/sjrwm.png",
// backgroundImage:"https://www.baidu.com/img/superlogo_c4d7df0a003d3db9b65e9ef0fe6da1ec.png?where=super",
// backgroundImage:"https://luma.jxdsy.cn/attachs/2019/07/29/thumb_5d3ecaa81b681.jpg",
type
:
'
testShareType
'
,
posterCanvasId
:
this
.
canvasId
,
// qrCodeArray: ({bgObj, type, bgScale}) => {
// return [rqcodeobj]
// },
imagesArray
:
({
bgObj
,
type
,
bgScale
})
=>
{
//接收的第一个参数为背景图片的信息, 第二个参数是自定义标识(感觉这里用不到), 图片为示例图片
const
dx
=
bgObj
.
width
*
0.3
;
return
[
//二维码
//二维码放进去
{
url
:
this
.
url
,
// //"https://www.baidu.com/img/superlogo_c4d7df0a003d3db9b65e9ef0fe6da1ec.png?qua=high&where=super",//
dx
:
155
,
//bgObj.width*0.05
dy
:
350
,
//bgObj.height - bgObj.width*0.25
dWidth
:
250
,
// 因为设置了圆形图片 所以要乘以2
dHeight
:
250
},
]
},
textArray
:
({
bgObj
,
type
,
bgScale
})
=>
{
const
fontSize
=
bgObj
.
width
*
0.045
;
const
lineHeight
=
bgObj
.
height
*
0.04
;
return
[
/**
* 商家名称居中 10个字 160/640 刚刚好
* 11个字
*
* 10个以后 每多加一个字 大概要 160- 多出来的个数- 12
*
*
* 10个以下 每少一个字 大概要 160 + 12
*
* ***/
// 文字 先干了
{
text
:
this
.
shop_name
,
//,`测试商家名称测试商家是遭`,//10个字正好
fontWeight
:
'
bold
'
,
size
:
24
,
color
:
'
#ffffff
'
,
alpha
:
1
,
textAlign
:
'
left
'
,
textBaseline
:
'
middle
'
,
infoCallBack
(
textLength
)
{
//dx 160是侧面对齐
return
{
dx
:
dxsss
,
//136,//bgObj.width - textLength - fontSize
dy
:
635
//bgObj.height - lineHeight*2
}
}
},
]
},
setCanvasWH
:
({
bgObj
,
type
,
bgScale
})
=>
{
// 为动态设置画布宽高的方法,
this
.
poster
=
bgObj
;
},
setDraw
:
({
Context
,
bgObj
,
type
,
bgScale
})
=>
{
// Context.setFillStyle('black');
// Context.setGlobalAlpha(0.3);
// Context.fillRect(0, bgObj.height - bgObj.height*0.2, bgObj.width, bgObj.height*0.2);
},
});
console
.
log
(
'
海报生成成功, 临时路径:
'
+
d
.
poster
.
tempFilePath
)
this
.
poster
.
finalPath
=
d
.
poster
.
tempFilePath
;
console
.
log
(
this
.
poster
.
finalPath
)
}
this
.
qrShow
=
true
;
}
catch
(
e
)
{
_app
.
hideLoading
();
_app
.
showToast
(
JSON
.
stringify
(
e
));
console
.
log
(
JSON
.
stringify
(
e
));
console
.
log
(
'
海报生成成功, 临时路径:
'
+
d
.
poster
.
tempFilePath
)
}
},
saveImage
()
{
// #ifndef H5
uni
.
saveImageToPhotosAlbum
({
filePath
:
this
.
poster
.
finalPath
,
success
(
res
)
{
_app
.
showToast
(
'
保存成功
'
);
}
})
// #endif
// #ifdef H5
_app
.
showToast
(
'
保存了
'
);
// #endif
},
share
()
{
// #ifdef APP-PLUS
_app
.
getShare
(
false
,
false
,
2
,
''
,
''
,
''
,
this
.
poster
.
finalPath
,
false
,
false
);
// #endif
// #ifndef APP-PLUS
_app
.
showToast
(
'
分享了
'
);
// #endif
},
hideQr
()
{
this
.
qrShow
=
false
;
}
}
}
</
script
>
<
style
lang=
"scss"
>
.hideCanvasView
{
position
:
relative
;
}
.hideCanvas
{
position
:
fixed
;
top
:
-99999upx
;
left
:
-99999upx
;
z-index
:
-99999
;
}
.flex_row_c_c
{
display
:
flex
;
flex-direction
:
row
;
justify-content
:
center
;
align-items
:
center
;
}
.modalView
{
width
:
100%
;
height
:
100%
;
// position: fixed;
top
:
0
;
left
:
0
;
right
:
0
;
bottom
:
0
;
opacity
:
0
;
outline
:
0
;
transform
:
scale
(
3
);
perspective
:
2500upx
;
// background: rgba(0, 0, 0, 0.6);
transition
:
all
.3s
ease-in-out
;
pointer-events
:
none
;
backface-visibility
:
hidden
;
z-index
:
999
;
}
.modalView.show
{
opacity
:
1
;
transform
:
scale
(
1
);
pointer-events
:
auto
;
}
.flex_column
{
display
:
flex
;
flex-direction
:
column
;
}
.backgroundColor-white
{
background-color
:
white
;
}
.border_radius_10px
{
border-radius
:
10px
;
position
:
relative
;
.bctpbtns
{
position
:
absolute
;
z-index
:
10000
;
right
:
0
;
bottom
:
200px
;
width
:
57upx
;
height
:
189upx
;
}
.fxhbbtns
{
position
:
absolute
;
z-index
:
10000
;
right
:
0
;
bottom
:
100px
;
width
:
57upx
;
height
:
189upx
;
}
}
.padding1vh
{
/* padding: 1vh; */
}
.posterImage
{
/* width: 60vw; */
width
:
100vw
;
height
:
100vh
;
}
.flex_row
{
display
:
flex
;
flex-direction
:
row
;
}
.marginTop2vh
{
margin-top
:
2vh
;
}
.buttons
{
background
:
#ff6900
!
important
;
line-height
:
40px
!
important
;
}
</
style
>
utils/debug.js
View file @
a9f20e26
...
@@ -4,8 +4,8 @@ module.exports = {
...
@@ -4,8 +4,8 @@ module.exports = {
//是否为开发调试环境 true为本地环境 false 为正式环境
//是否为开发调试环境 true为本地环境 false 为正式环境
//
isdebug:false,//正式
isdebug
:
false
,
//正式
isdebug
:
true
,
//测试
//
isdebug:true,//测试
// xqdebug:false,//正式权限
// xqdebug:false,//正式权限
xqdebug
:
true
,
//发布审核权限 也是测试环境的 主要用于ios
xqdebug
:
true
,
//发布审核权限 也是测试环境的 主要用于ios
...
...
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