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 0e2bb35f
authored
Oct 10, 2022
by
张立顺
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
新增全局变量
1 parent
de5a8995
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
152 additions
and
220 deletions
api/usersApi/UsersApi.js
components/Calendar/Calendar_Function.js
pages/webView/webView.js
project.private.config.json
utils/util.js
utils/utils_wx.js
api/usersApi/UsersApi.js
View file @
0e2bb35
...
@@ -27,13 +27,13 @@ class UsersApi {
...
@@ -27,13 +27,13 @@ class UsersApi {
/**授权手机号 */
/**授权手机号 */
async
authUserPhone
(
detail
,
sessionId
)
{
async
authUserPhone
(
detail
,
sessionId
)
{
if
(
!
sessionId
)
{
if
(
!
sessionId
)
{
wx
.
$
util
.
showToast
(
'缺少sessionId'
)
wx
.
$
api
.
showToast
(
'缺少sessionId'
)
Promise
.
reject
()
Promise
.
reject
()
}
}
if
(
detail
.
errMsg
&&
detail
.
errMsg
==
'getPhoneNumber:fail user deny'
)
Promise
.
reject
()
if
(
detail
.
errMsg
&&
detail
.
errMsg
==
'getPhoneNumber:fail user deny'
)
Promise
.
reject
()
delete
detail
.
errMsg
delete
detail
.
errMsg
if
(
detail
.
iv
&&
detail
.
encryptedData
)
{
if
(
detail
.
iv
&&
detail
.
encryptedData
)
{
wx
.
$
util
.
showLoading
()
wx
.
$
api
.
showLoading
()
detail
.
sessionId
=
sessionId
detail
.
sessionId
=
sessionId
return
api
.
post
(
return
api
.
post
(
{
{
...
...
components/Calendar/Calendar_Function.js
View file @
0e2bb35
...
@@ -4,16 +4,13 @@ const _separator_ = Symbol('_separator_')
...
@@ -4,16 +4,13 @@ const _separator_ = Symbol('_separator_')
class
Calendar
{
class
Calendar
{
[
_CalendarObject_
]
=
{};
[
_CalendarObject_
]
=
{};
[
_nowDate_
]
=
new
Date
();
[
_nowDate_
]
=
new
Date
();
[
_separator_
]
=
'-'
;
[
_separator_
]
=
'-'
constructor
(
calendarObject
)
{
constructor
(
calendarObject
)
{
this
[
_CalendarObject_
]
=
calendarObject
this
[
_CalendarObject_
]
=
calendarObject
this
[
_separator_
]
=
calendarObject
.
data
.
separator
this
[
_separator_
]
=
calendarObject
.
data
.
separator
this
.
setCalenderHeight
()
this
.
setCalenderHeight
()
this
.
setMonthList
()
this
.
setMonthList
()
let
{
let
{
weekdays
,
firstDayOfWeek
}
=
calendarObject
.
data
weekdays
,
firstDayOfWeek
}
=
calendarObject
.
data
let
firstDay
=
weekdays
[
firstDayOfWeek
-
1
]
let
firstDay
=
weekdays
[
firstDayOfWeek
-
1
]
let
[
last
,
first
]
=
weekdays
.
join
(
''
).
split
(
firstDay
)
let
[
last
,
first
]
=
weekdays
.
join
(
''
).
split
(
firstDay
)
calendarObject
.
setData
({
calendarObject
.
setData
({
...
@@ -23,15 +20,11 @@ class Calendar {
...
@@ -23,15 +20,11 @@ class Calendar {
/**设置日历高度 */
/**设置日历高度 */
setCalenderHeight
()
{
setCalenderHeight
()
{
let
_this
=
this
[
_CalendarObject_
]
let
_this
=
this
[
_CalendarObject_
]
let
{
let
{
data
:
calenderHeight
}
=
_this
data
:
calenderHeight
}
=
_this
let
height
=
'80%'
let
height
=
'80%'
if
(
typeof
calenderHeight
===
'number'
)
{
if
(
typeof
calenderHeight
===
'number'
)
{
wx
.
$util
.
getPhoneInfo
(
res
=>
{
wx
.
$api
.
getSystemInfo
(
res
=>
{
let
{
let
{
windowHeight
}
=
res
windowHeight
}
=
res
if
(
calenderHeight
>
windowHeight
)
calenderHeight
=
windowHeight
if
(
calenderHeight
>
windowHeight
)
calenderHeight
=
windowHeight
if
(
calenderHeight
<
windowHeight
*
0.5
)
calenderHeight
=
windowHeight
*
0.5
if
(
calenderHeight
<
windowHeight
*
0.5
)
calenderHeight
=
windowHeight
*
0.5
height
=
`
${
calenderHeight
}
px`
height
=
`
${
calenderHeight
}
px`
...
@@ -56,25 +49,27 @@ class Calendar {
...
@@ -56,25 +49,27 @@ class Calendar {
/**设置日期高度 */
/**设置日期高度 */
setCalenderBodyHeight
()
{
setCalenderBodyHeight
()
{
let
_this
=
this
[
_CalendarObject_
]
let
_this
=
this
[
_CalendarObject_
]
wx
.
$util
.
getViewInfo
(
'.calender-header'
,
header
=>
{
wx
.
$util
.
getViewInfo
(
wx
.
$util
.
getViewInfo
(
'.calender-footer'
,
footer
=>
{
'.calender-header'
,
header
=>
{
wx
.
$util
.
getViewInfo
(
'.calender-footer'
,
footer
=>
{
let
headerHeight
=
header
.
height
let
headerHeight
=
header
.
height
let
footerHeight
=
footer
&&
footer
.
height
||
0
let
footerHeight
=
(
footer
&&
footer
.
height
)
||
0
_this
.
setData
({
_this
.
setData
({
calenderBodyHeight
:
`
${
headerHeight
+
footerHeight
}
px`
calenderBodyHeight
:
`
${
headerHeight
+
footerHeight
}
px`
})
})
},
_this
)
},
},
_this
)
_this
)
},
_this
)
}
}
/**设置日期列表 */
/**设置日期列表 */
setMonthList
()
{
setMonthList
()
{
let
{
let
{
separator
,
previous
,
minDate
,
maxDate
,
next
}
=
this
[
_CalendarObject_
].
data
separator
,
previous
,
minDate
,
maxDate
,
next
}
=
this
[
_CalendarObject_
].
data
if
(
maxDate
||
minDate
)
{
if
(
maxDate
||
minDate
)
{
if
(
!
minDate
)
{
if
(
!
minDate
)
{
let
nowMonth
=
new
Date
().
getMonth
()
let
nowMonth
=
new
Date
().
getMonth
()
...
@@ -98,19 +93,7 @@ class Calendar {
...
@@ -98,19 +93,7 @@ class Calendar {
/**初始化日期 */
/**初始化日期 */
init
(
date
)
{
init
(
date
)
{
let
_this
=
this
[
_CalendarObject_
]
let
_this
=
this
[
_CalendarObject_
]
let
{
let
{
firstDayOfWeek
,
allowSameDay
,
multipleDate
,
monthList
,
rangeDate
,
dateList
,
dateType
,
current
,
minDate
,
maxDate
,
value
}
=
_this
.
data
firstDayOfWeek
,
allowSameDay
,
multipleDate
,
monthList
,
rangeDate
,
dateList
,
dateType
,
current
,
minDate
,
maxDate
,
value
,
}
=
_this
.
data
let
separator
=
this
[
_separator_
]
let
separator
=
this
[
_separator_
]
let
[
year
,
month
]
=
new
Date
(
date
).
format
(
`yyyy
${
separator
}
MM`
).
split
(
separator
)
let
[
year
,
month
]
=
new
Date
(
date
).
format
(
`yyyy
${
separator
}
MM`
).
split
(
separator
)
let
days
=
this
.
getDayNumber
(
year
,
Number
(
month
))
let
days
=
this
.
getDayNumber
(
year
,
Number
(
month
))
...
@@ -127,7 +110,7 @@ class Calendar {
...
@@ -127,7 +110,7 @@ class Calendar {
let
[
next_year
,
next_month
,
next_day
]
=
allowSameDay
?
today
.
split
(
separator
)
:
nextDay
.
split
(
separator
)
let
[
next_year
,
next_month
,
next_day
]
=
allowSameDay
?
today
.
split
(
separator
)
:
nextDay
.
split
(
separator
)
for
(
let
i
=
1
;
i
<=
days
;
i
++
)
{
for
(
let
i
=
1
;
i
<=
days
;
i
++
)
{
let
todayStr
=
`
${
year
}${
separator
}${
month
}${
separator
}${
now_day
}
`
let
todayStr
=
`
${
year
}${
separator
}${
month
}${
separator
}${
now_day
}
`
let
dayStr
=
`
${
year
}${
separator
}${
month
}${
separator
}${
i
<
10
?
`0
${
i
}
`
:
i
}
`
let
dayStr
=
`
${
year
}${
separator
}${
month
}${
separator
}${
i
<
10
?
`0
${
i
}
`
:
i
}
`
let
obj
=
{
let
obj
=
{
day
:
i
,
day
:
i
,
data
:
dayStr
,
data
:
dayStr
,
...
@@ -180,17 +163,10 @@ class Calendar {
...
@@ -180,17 +163,10 @@ class Calendar {
/**单选 */
/**单选 */
single
(
e
)
{
single
(
e
)
{
let
_this
=
this
[
_CalendarObject_
]
let
_this
=
this
[
_CalendarObject_
]
let
{
let
{
index
,
data
,
ind
}
=
e
.
currentTarget
.
dataset
index
,
let
{
showConfirm
,
monthList
}
=
_this
.
data
data
,
ind
}
=
e
.
currentTarget
.
dataset
let
{
showConfirm
,
monthList
}
=
_this
.
data
monthList
.
map
(
x
=>
{
monthList
.
map
(
x
=>
{
x
.
data
.
map
(
i
=>
i
.
active
=
false
)
x
.
data
.
map
(
i
=>
(
i
.
active
=
false
)
)
})
})
monthList
[
index
].
data
[
ind
].
active
=
true
monthList
[
index
].
data
[
ind
].
active
=
true
_this
.
setData
({
_this
.
setData
({
...
@@ -202,18 +178,15 @@ class Calendar {
...
@@ -202,18 +178,15 @@ class Calendar {
/**多选 */
/**多选 */
multiple
(
e
)
{
multiple
(
e
)
{
let
_this
=
this
[
_CalendarObject_
]
let
_this
=
this
[
_CalendarObject_
]
let
{
let
{
index
,
ind
}
=
e
.
currentTarget
.
dataset
index
,
let
{
monthList
}
=
_this
.
data
ind
,
}
=
e
.
currentTarget
.
dataset
let
{
monthList
}
=
_this
.
data
let
arr
=
[]
let
arr
=
[]
monthList
[
index
].
data
[
ind
].
active
=
!
monthList
[
index
].
data
[
ind
].
active
monthList
[
index
].
data
[
ind
].
active
=
!
monthList
[
index
].
data
[
ind
].
active
monthList
.
map
(
x
=>
x
.
data
.
map
(
i
=>
{
monthList
.
map
(
x
=>
x
.
data
.
map
(
i
=>
{
if
(
i
.
active
)
arr
.
push
(
i
.
data
)
if
(
i
.
active
)
arr
.
push
(
i
.
data
)
}))
})
)
_this
.
setData
({
_this
.
setData
({
[
`monthList[
${
index
}
].data`
]:
monthList
[
index
].
data
,
[
`monthList[
${
index
}
].data`
]:
monthList
[
index
].
data
,
multipleDate
:
arr
multipleDate
:
arr
...
@@ -222,17 +195,8 @@ class Calendar {
...
@@ -222,17 +195,8 @@ class Calendar {
/**范围选择 */
/**范围选择 */
range
(
e
)
{
range
(
e
)
{
const
_this
=
this
[
_CalendarObject_
]
const
_this
=
this
[
_CalendarObject_
]
let
{
let
{
index
,
data
,
ind
}
=
e
.
currentTarget
.
dataset
index
,
let
{
allowSameDay
,
showConfirm
,
monthList
,
rangeDate
}
=
_this
.
data
data
,
ind
}
=
e
.
currentTarget
.
dataset
let
{
allowSameDay
,
showConfirm
,
monthList
,
rangeDate
}
=
_this
.
data
const
start
=
Date
.
parse
(
rangeDate
.
start
)
const
start
=
Date
.
parse
(
rangeDate
.
start
)
if
(
rangeDate
.
end
||
start
>
Date
.
parse
(
data
))
{
if
(
rangeDate
.
end
||
start
>
Date
.
parse
(
data
))
{
monthList
=
this
.
clearStatus
({
monthList
=
this
.
clearStatus
({
...
@@ -264,16 +228,11 @@ class Calendar {
...
@@ -264,16 +228,11 @@ class Calendar {
/**点击完成 */
/**点击完成 */
done
()
{
done
()
{
let
_this
=
this
[
_CalendarObject_
]
let
_this
=
this
[
_CalendarObject_
]
let
{
let
{
multipleDate
,
rangeDate
,
dateType
,
date
}
=
_this
.
data
multipleDate
,
rangeDate
,
dateType
,
date
}
=
_this
.
data
let
targer
=
{
let
targer
=
{
'single'
:
date
,
single
:
date
,
'multiple'
:
multipleDate
,
multiple
:
multipleDate
,
'range'
:
rangeDate
range
:
rangeDate
}
}
if
((
dateType
===
'multiple'
&&
multipleDate
.
length
<
1
)
||
(
dateType
===
'range'
&&
!
rangeDate
.
end
))
return
if
((
dateType
===
'multiple'
&&
multipleDate
.
length
<
1
)
||
(
dateType
===
'range'
&&
!
rangeDate
.
end
))
return
_this
.
triggerEvent
(
'select'
,
{
_this
.
triggerEvent
(
'select'
,
{
...
@@ -284,17 +243,15 @@ class Calendar {
...
@@ -284,17 +243,15 @@ class Calendar {
/**清空范围选择状态 */
/**清空范围选择状态 */
clearStatus
(
params
)
{
clearStatus
(
params
)
{
let
{
let
{
monthList
,
index
,
ind
}
=
params
monthList
,
monthList
.
map
(
x
=>
index
,
x
.
data
.
map
(
i
=>
{
ind
}
=
params
monthList
.
map
(
x
=>
x
.
data
.
map
(
i
=>
{
i
.
active
=
false
i
.
active
=
false
i
.
start
=
false
i
.
start
=
false
i
.
end
=
false
i
.
end
=
false
i
.
middle
=
false
i
.
middle
=
false
}))
})
)
monthList
[
index
].
data
[
ind
].
active
=
true
monthList
[
index
].
data
[
ind
].
active
=
true
monthList
[
index
].
data
[
ind
].
start
=
true
monthList
[
index
].
data
[
ind
].
start
=
true
return
monthList
return
monthList
...
@@ -307,24 +264,20 @@ class Calendar {
...
@@ -307,24 +264,20 @@ class Calendar {
switch
(
month
)
{
switch
(
month
)
{
case
2
:
case
2
:
days
=
(
year
%
4
==
0
&&
year
%
100
!==
0
)
||
year
%
400
==
0
?
29
:
28
days
=
(
year
%
4
==
0
&&
year
%
100
!==
0
)
||
year
%
400
==
0
?
29
:
28
break
;
break
case
4
:
case
4
:
case
6
:
case
6
:
case
9
:
case
9
:
case
11
:
case
11
:
days
=
30
days
=
30
break
;
break
}
}
return
days
return
days
}
}
/**日期范围 点击全选 */
/**日期范围 点击全选 */
chooseAll
()
{
chooseAll
()
{
let
_this
=
this
[
_CalendarObject_
]
let
_this
=
this
[
_CalendarObject_
]
let
{
let
{
monthList
,
minDate
,
maxDate
}
=
_this
.
data
monthList
,
minDate
,
maxDate
}
=
_this
.
data
monthList
.
map
((
e
,
index
)
=>
{
monthList
.
map
((
e
,
index
)
=>
{
e
.
data
.
map
((
i
,
ind
)
=>
{
e
.
data
.
map
((
i
,
ind
)
=>
{
let
obj
=
{
let
obj
=
{
...
@@ -337,11 +290,10 @@ class Calendar {
...
@@ -337,11 +290,10 @@ class Calendar {
}
}
}
}
if
(
i
.
data
==
minDate
)
this
.
range
(
obj
)
if
(
i
.
data
==
minDate
)
this
.
range
(
obj
)
if
(
i
.
data
==
maxDate
)
this
.
range
(
obj
)
if
(
i
.
data
==
maxDate
)
this
.
range
(
obj
)
})
})
})
})
}
}
}
}
export
default
Calendar
export
default
Calendar
pages/webView/webView.js
View file @
0e2bb35
// pages/webView/webView.js
// pages/webView/webView.js
Page
({
Page
({
/**
/**
* 页面的初始数据
* 页面的初始数据
*/
*/
...
@@ -24,16 +23,16 @@ Page({
...
@@ -24,16 +23,16 @@ Page({
/**
/**
* 生命周期函数--监听页面加载
* 生命周期函数--监听页面加载
*/
*/
onLoad
:
function
(
options
)
{
onLoad
:
function
(
options
)
{
wx
.
$
util
.
showLoading
(
'加载中...'
)
wx
.
$
api
.
showLoading
(
'加载中...'
)
let
decodeUrl
=
decodeURIComponent
(
options
.
url
)
;
let
decodeUrl
=
decodeURIComponent
(
options
.
url
)
let
param
=
this
.
getParams
(
decodeUrl
)
let
param
=
this
.
getParams
(
decodeUrl
)
if
(
param
.
urlParam
)
{
if
(
param
.
urlParam
)
{
let
query
=
JSON
.
parse
(
param
.
urlParam
)
let
query
=
JSON
.
parse
(
param
.
urlParam
)
this
.
data
.
refresh
=
query
.
refresh
this
.
data
.
refresh
=
query
.
refresh
}
}
this
.
setData
({
this
.
setData
({
url
:
decodeUrl
,
url
:
decodeUrl
})
})
wx
.
hideLoading
()
wx
.
hideLoading
()
},
},
...
@@ -41,29 +40,30 @@ Page({
...
@@ -41,29 +40,30 @@ Page({
/**
/**
* 生命周期函数--监听页面初次渲染完成
* 生命周期函数--监听页面初次渲染完成
*/
*/
onReady
:
function
()
{
onReady
:
function
()
{},
},
/**
/**
* 生命周期函数--监听页面显示
* 生命周期函数--监听页面显示
*/
*/
onShow
:
function
()
{
onShow
:
function
()
{
if
(
this
.
data
.
refresh
)
{
if
(
this
.
data
.
refresh
)
{
this
.
setData
({
this
.
setData
(
{
flag
:
true
flag
:
true
},
()
=>
{
},
()
=>
{
this
.
setData
({
this
.
setData
({
url
:
this
.
data
.
url
url
:
this
.
data
.
url
})
})
})
}
)
}
}
},
},
/**
/**
* 生命周期函数--监听页面隐藏
* 生命周期函数--监听页面隐藏
*/
*/
onHide
:
function
()
{
onHide
:
function
()
{
if
(
this
.
data
.
refresh
)
{
if
(
this
.
data
.
refresh
)
{
this
.
setData
({
this
.
setData
({
flag
:
false
flag
:
false
...
@@ -74,7 +74,7 @@ Page({
...
@@ -74,7 +74,7 @@ Page({
/**
/**
* 生命周期函数--监听页面卸载
* 生命周期函数--监听页面卸载
*/
*/
onUnload
:
function
()
{
onUnload
:
function
()
{
if
(
this
.
data
.
refresh
)
{
if
(
this
.
data
.
refresh
)
{
this
.
setData
({
this
.
setData
({
flag
:
false
flag
:
false
...
@@ -85,14 +85,10 @@ Page({
...
@@ -85,14 +85,10 @@ Page({
/**
/**
* 页面相关事件处理函数--监听用户下拉动作
* 页面相关事件处理函数--监听用户下拉动作
*/
*/
onPullDownRefresh
:
function
()
{
onPullDownRefresh
:
function
()
{},
},
/**
/**
* 页面上拉触底事件的处理函数
* 页面上拉触底事件的处理函数
*/
*/
onReachBottom
:
function
()
{
onReachBottom
:
function
()
{}
}
})
})
project.private.config.json
View file @
0e2bb35
{
{
"setting"
:
{
"setting"
:
{
"compileHotReLoad"
:
fals
e
,
"compileHotReLoad"
:
tru
e
,
"urlCheck"
:
false
,
"urlCheck"
:
false
,
"lazyloadPlaceholderEnable"
:
true
"lazyloadPlaceholderEnable"
:
true
},
},
"condition"
:
{},
"condition"
:
{},
"projectname"
:
"
miniprogram-template
"
,
"projectname"
:
"
business-assistant
"
,
"description"
:
"项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html"
,
"description"
:
"项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html"
,
"libVersion"
:
"2.24.4"
"libVersion"
:
"2.24.4"
}
}
\ No newline at end of file
\ No newline at end of file
utils/util.js
View file @
0e2bb35
...
@@ -30,59 +30,6 @@ Date.prototype.format = function (fmt) {
...
@@ -30,59 +30,6 @@ Date.prototype.format = function (fmt) {
return
fmt
return
fmt
}
}
/**
* 防止重复点击
*/
const
showLoading
=
(
title
=
''
)
=>
{
if
(
wx
.
showLoading
)
{
// 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理
wx
.
showLoading
({
title
,
mask
:
true
})
}
else
{
// 低版本采用Toast兼容处理并将时间设为20秒以免自动消失
wx
.
showToast
({
title
,
icon
:
'loading'
,
mask
:
true
,
duration
:
20000
})
}
}
const
hideLoading
=
()
=>
{
if
(
wx
.
hideLoading
)
{
// 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理
wx
.
hideLoading
()
}
else
{
wx
.
hideToast
()
}
}
const
showToast
=
val
=>
{
let
obj
=
{}
if
(
val
&&
typeof
val
===
'string'
)
{
obj
.
title
=
val
obj
.
icon
=
'none'
}
else
{
obj
=
val
}
return
wx
.
showToast
(
obj
)
}
/**获取节点信息
* name(id获取class)
* callBack 回调函数
* isComponents是否在组件
*/
const
getViewInfo
=
(
name
,
callBack
,
isComponents
)
=>
{
const
query
=
!
isComponents
?
wx
.
createSelectorQuery
()
:
wx
.
createSelectorQuery
().
in
(
isComponents
)
query
.
select
(
name
)
.
boundingClientRect
(
res
=>
{
callBack
(
res
)
})
.
exec
()
}
/**触底加载 */
/**触底加载 */
const
onReachBottom
=
(
obj
,
callBack
)
=>
{
const
onReachBottom
=
(
obj
,
callBack
)
=>
{
let
_this
=
$router
.
getPageInstance
()
let
_this
=
$router
.
getPageInstance
()
...
@@ -105,21 +52,6 @@ const onReachBottom = (obj, callBack) => {
...
@@ -105,21 +52,6 @@ const onReachBottom = (obj, callBack) => {
}
}
}
}
/**
* 禁止滑动
*/
const
noScroll
=
()
=>
{}
/**设置粘贴板内容 */
const
setCopyData
=
(
data
,
callBack
)
=>
{
wx
.
setClipboardData
({
data
:
data
,
success
(
res
)
{
if
(
callBack
&&
typeof
callBack
===
'function'
)
callBack
(
res
)
}
})
}
/**是否全面屏 */
/**是否全面屏 */
const
isFullSucreen
=
isComponents
=>
{
const
isFullSucreen
=
isComponents
=>
{
const
thisPage
=
$router
.
getPageInstance
()
const
thisPage
=
$router
.
getPageInstance
()
...
@@ -150,30 +82,6 @@ const isFullSucreen = isComponents => {
...
@@ -150,30 +82,6 @@ const isFullSucreen = isComponents => {
return
val
return
val
}
}
/**获取手机信息 */
const
getPhoneInfo
=
callBack
=>
{
wx
.
getSystemInfo
({
success
(
res
)
{
callBack
(
res
)
},
fail
(
err
)
{
callBack
(
err
)
}
})
}
/**拨打电话 */
const
phoneCall
=
phoneNumber
=>
{
wx
.
makePhoneCall
({
phoneNumber
:
`
${
phoneNumber
}
`
})
}
/**查看大图 */
const
previewImage
=
params
=>
{
wx
.
previewImage
(
params
)
}
/**节流 */
/**节流 */
const
throttle
=
(
fn
,
gapTime
)
=>
{
const
throttle
=
(
fn
,
gapTime
)
=>
{
if
(
gapTime
==
null
||
gapTime
==
undefined
)
{
if
(
gapTime
==
null
||
gapTime
==
undefined
)
{
...
@@ -212,21 +120,10 @@ const getImgVersion = () => {
...
@@ -212,21 +120,10 @@ const getImgVersion = () => {
}
}
const
Util
=
{
const
Util
=
{
// setNavigationBarTitleText,
// getNavigationBarTitleText,
getImgVersion
,
getImgVersion
,
onReachBottom
,
onReachBottom
,
isFullSucreen
,
isFullSucreen
,
previewImage
,
getPhoneInfo
,
clearObjNull
,
clearObjNull
,
showLoading
,
hideLoading
,
getViewInfo
,
setCopyData
,
showToast
,
phoneCall
,
noScroll
,
throttle
throttle
}
}
export
default
Util
export
default
Util
utils/utils_wx.js
0 → 100644
View file @
0e2bb35
/**
* 禁止滑动
*/
const
noScroll
=
()
=>
{}
/**设置粘贴板内容 */
const
setCopyData
=
(
data
,
callBack
)
=>
{
wx
.
setClipboardData
({
data
:
data
,
success
(
res
)
{
if
(
callBack
&&
typeof
callBack
===
'function'
)
callBack
(
res
)
}
})
}
/**
* 防止重复点击
*/
const
showLoading
=
(
title
=
''
)
=>
{
if
(
wx
.
showLoading
)
{
// 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理
wx
.
showLoading
({
title
,
mask
:
true
})
}
else
{
// 低版本采用Toast兼容处理并将时间设为20秒以免自动消失
wx
.
showToast
({
title
,
icon
:
'loading'
,
mask
:
true
,
duration
:
20000
})
}
}
const
hideLoading
=
()
=>
{
if
(
wx
.
hideLoading
)
{
// 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理
wx
.
hideLoading
()
}
else
{
wx
.
hideToast
()
}
}
const
showToast
=
val
=>
{
let
obj
=
{}
if
(
val
&&
typeof
val
===
'string'
)
{
obj
.
title
=
val
obj
.
icon
=
'none'
}
else
{
obj
=
val
}
return
wx
.
showToast
(
obj
)
}
/**获取设备信息 */
const
getSystemInfo
=
callBack
=>
{
wx
.
getSystemInfo
({
success
(
res
)
{
callBack
(
res
)
},
fail
(
err
)
{
callBack
(
err
)
}
})
}
/**拨打电话 */
const
phoneCall
=
phoneNumber
=>
{
wx
.
makePhoneCall
({
phoneNumber
:
`
${
phoneNumber
}
`
})
}
/**查看大图 */
const
previewImage
=
params
=>
{
wx
.
previewImage
(
params
)
}
const
wxApi
=
{
previewImage
,
getSystemInfo
,
showLoading
,
hideLoading
,
setCopyData
,
showToast
,
phoneCall
,
noScroll
}
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