Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas
/
mini-program
/
ai-card
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit d89a0516
authored
Sep 05, 2022
by
李伟康
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
提交代码
1 parent
936a2e87
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
127 additions
and
2 deletions
pages/tab/index/index.js
utils/Draw.js
pages/tab/index/index.js
View file @
d89a051
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
* @LastEditTime: 2022-09-02 13:48:49
* @LastEditTime: 2022-09-02 13:48:49
*/
*/
// pages/tab/index/index.js
// pages/tab/index/index.js
import
Draw
from
'../../../utils/Draw'
Page
({
Page
({
/**
/**
* 页面的初始数据
* 页面的初始数据
...
@@ -49,7 +50,9 @@ Page({
...
@@ -49,7 +50,9 @@ Page({
/**
/**
* 生命周期函数--监听页面显示
* 生命周期函数--监听页面显示
*/
*/
onShow
()
{},
onShow
()
{
this
.
setShareInfo
()
},
/**
/**
* 生命周期函数--监听页面隐藏
* 生命周期函数--监听页面隐藏
...
@@ -74,5 +77,127 @@ Page({
...
@@ -74,5 +77,127 @@ Page({
/**
/**
* 用户点击右上角分享
* 用户点击右上角分享
*/
*/
onShareAppMessage
()
{},
onShareAppMessage
()
{
return
{
title
:
`您好,我向你推荐了广联数科的
${
'你的名字'
}
的智能名片~`
,
imageUrl
:
this
.
data
.
shareImg
}
},
setShareInfo
()
{
const
canvasWidth
=
208
,
canvasHeight
=
166
,
textBaseline
=
'top'
const
draw_function
=
new
Draw
(
this
,
{
width
:
canvasWidth
,
height
:
canvasHeight
,
// pixelRatio: 2,
// backgroundColor: '#096'
})
const
drawCard
=
callBack
=>
{
let
index
=
0
const
iconWidth
=
9
,
iconHeight
=
9
,
iconX
=
18
,
iconY
=
79
,
imgList
=
[{
url
:
'https://img02.glsx.com.cn/weapp/resource/miniprogram/ai-card/share/bg.png'
,
x
:
0
,
y
:
0
,
width
:
canvasWidth
,
height
:
124
},
{
url
:
'https://img02.glsx.com.cn/weapp/resource/miniprogram/ai-card/share/logo.png'
,
x
:
15
,
y
:
18
,
width
:
152
,
height
:
10
},
{
url
:
'https://img.zcool.cn/community/01e47e60ab5b4011013eaf70962e3f.jpg@520w_390h_1c_1e_2o_100sh.jpg'
,
x
:
154
,
y
:
36
,
width
:
36
,
height
:
36
},
{
url
:
'https://img02.glsx.com.cn/weapp/resource/miniprogram/ai-card/share/icon-phone.png'
,
x
:
iconX
,
y
:
iconY
,
width
:
iconWidth
,
height
:
iconHeight
},
{
url
:
'https://img02.glsx.com.cn/weapp/resource/miniprogram/ai-card/share/icon-address.png'
,
x
:
iconX
,
y
:
iconY
+
13
,
width
:
iconWidth
,
height
:
iconHeight
},
{
url
:
'https://img02.glsx.com.cn/weapp/resource/miniprogram/ai-card/share/btn.png'
,
x
:
64
,
y
:
138
,
width
:
80
,
height
:
24
}
],
textList
=
[{
text
:
'你的名字'
,
x
:
18
,
y
:
36
,
color
:
'#2D2D33'
,
fontWeight
:
600
,
fontSize
:
14
},
{
text
:
'市场总监'
,
x
:
22
+
draw_function
.
getTextWidth
(
'你的名字'
,
14
),
y
:
40
,
color
:
'#6E6E7A'
,
fontWeight
:
400
,
fontSize
:
8
},
{
text
:
'18888888888'
,
x
:
30
,
y
:
80
,
color
:
'#6E6E7A'
,
fontSize
:
7
},
{
text
:
'深圳市南山区留仙大道3370号南山智园崇文园区1号楼14层'
,
x
:
30
,
y
:
94
,
color
:
'#6E6E7A'
,
fontSize
:
7
,
lineNum
:
2
,
width
:
185
,
lineHeight
:
9
}
]
const
drawImages
=
callBack
=>
{
draw_function
.
drawImages
(
imgList
[
index
],
()
=>
{
index
+=
1
if
(
index
!=
imgList
.
length
)
drawImages
(
callBack
)
else
callBack
()
})
}
drawImages
(()
=>
{
try
{
textList
.
map
((
e
,
ind
)
=>
{
e
.
textBaseline
=
textBaseline
draw_function
.
drawText
(
e
)
if
(
ind
==
textList
.
length
-
1
)
throw
true
})
}
catch
(
error
)
{
draw_function
.
toDataURL
(({
path
})
=>
{
this
.
setData
({
shareImg
:
path
})
})
}
})
}
drawCard
()
}
});
});
\ No newline at end of file
\ No newline at end of file
utils/Draw.js
0 → 100644
View file @
d89a051
This diff is collapsed.
Click to expand it.
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