Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas_plus
/
business-assistant
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 41033d8c
authored
Oct 25, 2022
by
luyt
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat:添加获取节点信息函数
1 parent
80478e51
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
110 additions
and
80 deletions
pages/tab/index/components/product/product.js
pages/tab/index/index.scss
utils/utils_wx.js
pages/tab/index/components/product/product.js
View file @
41033d8
...
...
@@ -53,7 +53,6 @@ Component({
},
lifetimes
:
{
ready
:
function
()
{
console
.
log
(
'window'
,
window
)
if
(
!
this
.
data
.
outshowVideo
){
this
.
setData
({
...
...
@@ -210,6 +209,21 @@ Component({
this
.
data
.
allHeight
=
heightArr
[
heightArr
.
length
-
1
];
})
.
exec
();
// let query = wx.createSelectorQuery().in(this);
// let heightArr = [];
// let s = 0;
// query
// .selectAll(".img-item")
// .boundingClientRect((react) => {
// react.forEach((item) => {
// // s += item.height;
// heightArr.push(item.top);
// });
// this.data.heightArr = heightArr;
// // console.log(heightArr[heightArr.length-1])
// this.data.allHeight = heightArr[heightArr.length - 1];
// })
// .exec();
},
// 获取用户信息
getUserInfo
({
detail
})
{
...
...
pages/tab/index/index.scss
View file @
41033d8
...
...
@@ -11,12 +11,7 @@ page {
width
:
100%
;
background-size
:
100%
100%
;
margin-bottom
:
32rpx
;
<<<<<<<
HEAD
z-index
:
1
;
=======
z-index
:
2
;
>>>>>>>
fb7f082be258d6f0662707ea191b5cbbe45ef678
.header
{
position
:
absolute
;
left
:
0
;
...
...
utils/utils_wx.js
View file @
41033d8
import
wxqrcode
from
'~/utils/lib/wxqrcode.js'
import
wxqrcode
from
"~/utils/lib/wxqrcode.js"
;
/**
* 微信校验通知类工具封装
*/
const
tipsObj
=
{
phone
:
{
icon
:
'error'
,
title
:
'请输入手机号'
icon
:
"error"
,
title
:
"请输入手机号"
,
},
username
:
{
icon
:
'error'
,
title
:
'请输入用户名'
icon
:
"error"
,
title
:
"请输入用户名"
,
},
password
:
{
icon
:
'error'
,
title
:
'请输入密码'
}
}
icon
:
"error"
,
title
:
"请输入密码"
,
}
,
}
;
/**
* 禁止滑动
*/
const
noScroll
=
()
=>
{}
const
noScroll
=
()
=>
{}
;
/**设置粘贴板内容 */
const
setCopyData
=
(
data
,
callBack
)
=>
{
wx
.
setClipboardData
({
data
:
data
,
success
(
res
)
{
if
(
callBack
&&
typeof
callBack
===
'function'
)
callBack
(
res
)
}
})
}
if
(
callBack
&&
typeof
callBack
===
"function"
)
callBack
(
res
);
}
,
})
;
}
;
/**
* 防止重复点击
*/
const
showLoading
=
(
title
=
''
)
=>
{
const
showLoading
=
(
title
=
""
)
=>
{
if
(
wx
.
showLoading
)
{
// 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理
wx
.
showLoading
({
title
,
mask
:
true
})
mask
:
true
,
})
;
}
else
{
// 低版本采用Toast兼容处理并将时间设为20秒以免自动消失
wx
.
showToast
({
title
,
icon
:
'loading'
,
icon
:
"loading"
,
mask
:
true
,
duration
:
20000
})
duration
:
20000
,
})
;
}
}
}
;
const
hideLoading
=
()
=>
{
if
(
wx
.
hideLoading
)
{
// 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理
wx
.
hideLoading
()
wx
.
hideLoading
()
;
}
else
{
wx
.
hideToast
()
wx
.
hideToast
()
;
}
}
const
showToast
=
val
=>
{
let
obj
=
{}
if
(
val
&&
typeof
val
===
'string'
)
{
obj
.
title
=
val
obj
.
icon
=
'none'
}
;
const
showToast
=
(
val
)
=>
{
let
obj
=
{}
;
if
(
val
&&
typeof
val
===
"string"
)
{
obj
.
title
=
val
;
obj
.
icon
=
"none"
;
}
else
{
obj
=
val
obj
=
val
;
}
return
wx
.
showToast
(
obj
)
}
return
wx
.
showToast
(
obj
)
;
}
;
/**
*
...
...
@@ -80,78 +80,98 @@ const showToast = val => {
const
wxShowToast
=
(
name
,
params
)
=>
{
if
(
arguments
.
length
==
2
)
{
wx
.
showToast
({
title
:
tipsObj
[
name
][
'title'
],
icon
:
tipsObj
[
name
][
'icon'
],
...
params
})
title
:
tipsObj
[
name
][
"title"
],
icon
:
tipsObj
[
name
][
"icon"
],
...
params
,
})
;
}
else
{
wx
.
showToast
({
...
params
})
...
params
,
})
;
}
}
}
;
/**获取设备信息 */
const
getSystemInfo
=
callBack
=>
{
const
getSystemInfo
=
(
callBack
)
=>
{
wx
.
getSystemInfo
({
success
(
res
)
{
callBack
(
res
)
callBack
(
res
)
;
},
fail
(
err
)
{
callBack
(
err
)
}
})
}
callBack
(
err
)
;
}
,
})
;
}
;
/**拨打电话 */
const
phoneCall
=
phoneNumber
=>
{
const
phoneCall
=
(
phoneNumber
)
=>
{
wx
.
makePhoneCall
({
phoneNumber
:
`
${
phoneNumber
}
`
})
}
phoneNumber
:
`
${
phoneNumber
}
`
,
})
;
}
;
/**查看大图 */
const
previewImage
=
params
=>
{
wx
.
previewImage
(
params
)
}
const
previewImage
=
(
params
)
=>
{
wx
.
previewImage
(
params
)
;
}
;
export
function
handleCopy
(
url
)
{
// var { idx } = e.currentTarget.dataset
// var currentItem = this.data.orderObj.activityList[idx]
var
qr
=
wxqrcode
.
createQrCodeImg
(
url
)
var
qr
=
wxqrcode
.
createQrCodeImg
(
url
)
;
const
base64src
=
function
(
base64data
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
const
[
a
,
format
,
bodyData
]
=
/data:image
\/(\w
+
)
;base64,
(
.*
)
/
.
exec
(
base64data
)
||
[]
if
(
!
format
)
reject
(
new
Error
(
'ERROR_BASE64SRC_PARSE'
))
const
filePath
=
`
${
wx
.
env
.
USER_DATA_PATH
}
/tmp_base64src.
${
format
}
`
const
buffer
=
wx
.
base64ToArrayBuffer
(
bodyData
)
const
[
a
,
format
,
bodyData
]
=
/data:image
\/(\w
+
)
;base64,
(
.*
)
/
.
exec
(
base64data
)
||
[];
if
(
!
format
)
reject
(
new
Error
(
"ERROR_BASE64SRC_PARSE"
));
const
filePath
=
`
${
wx
.
env
.
USER_DATA_PATH
}
/tmp_base64src.
${
format
}
`
;
const
buffer
=
wx
.
base64ToArrayBuffer
(
bodyData
);
wx
.
getFileSystemManager
().
writeFile
({
filePath
,
data
:
buffer
,
encoding
:
'binary'
,
encoding
:
"binary"
,
success
()
{
resolve
(
filePath
)
resolve
(
filePath
)
;
},
fail
()
{
reject
(
new
Error
(
'ERROR_BASE64SRC_WRITE'
))
}
})
})
}
base64src
(
qr
).
then
(
res
=>
{
console
.
log
(
res
)
reject
(
new
Error
(
"ERROR_BASE64SRC_WRITE"
));
}
,
})
;
})
;
}
;
base64src
(
qr
).
then
(
(
res
)
=>
{
console
.
log
(
res
)
;
wx
.
getImageInfo
({
src
:
res
,
success
(
obj
)
{
wx
.
showShareImageMenu
({
path
:
obj
.
path
})
path
:
obj
.
path
,
})
;
},
fail
()
{}
})
})
fail
()
{}
,
})
;
})
;
}
/**获取节点信息
* name(id获取class)
* callBack 回调函数
* isComponents是否在组件
*/
const
getViewInfo
=
(
name
,
callBack
,
isComponents
)
=>
{
const
query
=
!
isComponents
?
wx
.
createSelectorQuery
()
:
wx
.
createSelectorQuery
().
in
(
isComponents
);
query
.
selectAll
(
name
)
.
boundingClientRect
((
res
)
=>
{
console
.
log
(
'res: '
,
res
);
callBack
(
res
);
})
.
exec
();
};
const
wxApi
=
{
previewImage
,
getSystemInfo
,
...
...
@@ -160,7 +180,8 @@ const wxApi = {
setCopyData
,
showToast
,
phoneCall
,
noScroll
}
noScroll
,
getViewInfo
,
};
export
default
wxApi
export
default
wxApi
;
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