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 6a79d2ed
authored
Apr 12, 2024
by
张立顺
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge branch 'develop' into 'V4.37.6-0417'
Develop See merge request
!57
2 parents
8dd98318
8c9d2429
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
433 additions
and
332 deletions
packagesList/packageOutput/components/OutputLine/OutputLine.scss
packagesList/packageOutput/components/equity-value/index.wxml
packagesList/packageOutput/pages/monthReport/monthReport.js
packagesList/packageOutput/pages/monthReport/monthReport.scss
packagesList/packageOutput/pages/monthReport/monthReport.wxml
packagesList/packageOutput/pages/summary.js
utils/util.js
packagesList/packageOutput/components/OutputLine/OutputLine.scss
View file @
6a79d2e
...
@@ -31,11 +31,10 @@
...
@@ -31,11 +31,10 @@
}
}
.searchTime
{
.searchTime
{
margin-top
:
24
rpx
;
padding
:
24rpx
0
rpx
;
display
:
flex
;
display
:
flex
;
align-items
:
center
;
align-items
:
center
;
z-index
:
9999
;
z-index
:
9999
;
margin-bottom
:
20rpx
;
position
:
relative
;
position
:
relative
;
.time
{
.time
{
...
@@ -43,7 +42,7 @@
...
@@ -43,7 +42,7 @@
// border: 2rpx solid #EBEBEB;
// border: 2rpx solid #EBEBEB;
// border-radius: 32rpx;
// border-radius: 32rpx;
background
:
#FFFFFF
;
background
:
#FFFFFF
;
border
:
1
rpx
solid
#C3C3C3
;
border
:
2
rpx
solid
#C3C3C3
;
border-radius
:
6rpx
;
border-radius
:
6rpx
;
font-weight
:
400
;
font-weight
:
400
;
font-size
:
20rpx
;
font-size
:
20rpx
;
...
@@ -57,7 +56,7 @@
...
@@ -57,7 +56,7 @@
// color: #4466F0;
// color: #4466F0;
color
:
#fff
;
color
:
#fff
;
background
:
#3582EE
;
background
:
#3582EE
;
border
:
1pr
x
solid
#3582EE
;
border
:
2rp
x
solid
#3582EE
;
}
}
.time
+
.time
{
.time
+
.time
{
...
...
packagesList/packageOutput/components/equity-value/index.wxml
View file @
6a79d2e
...
@@ -80,6 +80,6 @@
...
@@ -80,6 +80,6 @@
</scroll-view>
</scroll-view>
<view wx:if="{{calendarLoading}}">
<view wx:if="{{calendarLoading}}">
<van-calendar max-range="{{ 3
0
}}" min-date="{{ minDate }}" max-date="{{ maxDate }}" show="{{ isShow }}"
<van-calendar max-range="{{ 3
1
}}" min-date="{{ minDate }}" max-date="{{ maxDate }}" show="{{ isShow }}"
type="range" color="#4466F0" bind:confirm="onConfirm" bind:close="onClose" />
type="range" color="#4466F0" bind:confirm="onConfirm" bind:close="onClose" />
</view>
</view>
\ No newline at end of file
\ No newline at end of file
packagesList/packageOutput/pages/monthReport/monthReport.js
View file @
6a79d2e
...
@@ -6,6 +6,22 @@ Page({
...
@@ -6,6 +6,22 @@ Page({
* 页面的初始数据
* 页面的初始数据
*/
*/
data
:
{
data
:
{
typeShow
:
true
,
selectTxt
:
'产值'
,
selectValue
:
1
,
dataType
:
[{
label
:
'产值'
,
value
:
1
},
{
label
:
'成交量'
,
value
:
2
},
{
label
:
'报价量'
,
value
:
3
},
{
label
:
'转化率'
,
value
:
4
}],
show
:
false
,
show
:
false
,
date
:
'2023年4月10日'
,
date
:
'2023年4月10日'
,
maxDate
:
new
Date
().
getTime
(),
maxDate
:
new
Date
().
getTime
(),
...
@@ -17,48 +33,48 @@ Page({
...
@@ -17,48 +33,48 @@ Page({
label
:
'报价量(单)'
,
label
:
'报价量(单)'
,
name
:
'quotationCount'
,
name
:
'quotationCount'
,
unit
:
''
,
unit
:
''
,
iconUrl
:
'
output/icon02.png'
iconUrl
:
'store-assistant-assemble/
output/icon02.png'
},
{
},
{
label
:
'成交量(单)'
,
label
:
'成交量(单)'
,
name
:
'successCount'
,
name
:
'successCount'
,
unit
:
''
,
unit
:
''
,
iconUrl
:
'
output/icon07.png'
iconUrl
:
'store-assistant-assemble/
output/icon07.png'
},
{
},
{
label
:
'产值(元)'
,
label
:
'产值(元)'
,
name
:
'outputValue'
,
name
:
'outputValue'
,
_unit
:
'¥'
,
_unit
:
'¥'
,
iconUrl
:
'
output/icon05.png'
iconUrl
:
'store-assistant-assemble/
output/icon05.png'
}],
}],
outputValueBoutique
:
[
outputValueBoutique
:
[
// {
// {
// label: '发券量(总)/张',
// label: '发券量(总)/张',
// name: 'sendCouponTotal',
// name: 'sendCouponTotal',
// unit: ''
// unit: ''
// },
// },
// {
// {
// label: '营业额(总)/元',
// label: '营业额(总)/元',
// name: 'orderMoneyTotal',
// name: 'orderMoneyTotal',
// _unit: '¥'
// _unit: '¥'
// },
// },
{
{
label
:
'升级订单(单)'
,
label
:
'升级订单(单)'
,
name
:
'upgradeCountTotal'
,
name
:
'upgradeCountTotal'
,
unit
:
''
,
unit
:
''
,
iconUrl
:
'
output/icon02.png'
iconUrl
:
'store-assistant-assemble/
output/icon02.png'
},
},
{
{
label
:
'转化率'
,
label
:
'转化率'
,
name
:
'upgradeRatio'
,
name
:
'upgradeRatio'
,
unit_
:
'%'
,
unit_
:
'%'
,
iconUrl
:
'
output/icon07.png'
iconUrl
:
'store-assistant-assemble/
output/icon07.png'
},
},
{
{
label
:
'客单价(元)'
,
label
:
'客单价(元)'
,
name
:
'averagePrice'
,
name
:
'averagePrice'
,
_unit
:
'¥'
,
_unit
:
'¥'
,
iconUrl
:
'
output/icon05.png'
iconUrl
:
'store-assistant-assemble/
output/icon05.png'
},
},
],
],
}
}
},
},
...
@@ -66,11 +82,28 @@ Page({
...
@@ -66,11 +82,28 @@ Page({
* 生命周期函数--监听页面加载
* 生命周期函数--监听页面加载
*/
*/
onLoad
(
options
)
{
onLoad
(
options
)
{
const
{
time
,
type
,
merchantId
,
merchantName
}
=
options
const
{
time
,
type
,
merchantId
,
merchantName
}
=
options
this
.
setData
({
timeType
:
time
,
type
,
merchantId
,
merchantName
})
this
.
setData
({
timeType
:
time
,
type
,
merchantId
,
merchantName
})
this
.
getReport
()
this
.
getReport
()
},
},
//选择排序
selectType
(
e
)
{
const
{
value
,
label
}
=
e
.
target
.
dataset
this
.
setData
({
selectValue
:
value
,
typeShow
:
true
,
selectTxt
:
label
})
this
.
getReport
()
},
showUp
()
{
this
.
setData
({
typeShow
:
false
})
},
onDisplay
()
{
onDisplay
()
{
this
.
setData
({
show
:
true
});
this
.
setData
({
show
:
true
});
},
},
...
@@ -79,8 +112,8 @@ Page({
...
@@ -79,8 +112,8 @@ Page({
},
},
//查看报表
//查看报表
getReport
()
{
getReport
()
{
const
{
type
,
timeType
,
merchantId
,
time
Value
}
=
this
.
data
const
{
type
,
timeType
,
merchantId
,
timeValue
,
select
Value
}
=
this
.
data
let
apiName
,
params
let
apiName
,
params
const
dataT
=
{
const
dataT
=
{
1
:
{
1
:
{
day
:
()
=>
{
day
:
()
=>
{
...
@@ -94,7 +127,7 @@ Page({
...
@@ -94,7 +127,7 @@ Page({
apiName
=
'boutiquecouponQueryByMonthReport'
,
apiName
=
'boutiquecouponQueryByMonthReport'
,
params
=
{
params
=
{
merchantId
,
merchantId
,
reportMonth
:
timeValue
.
substring
(
0
,
7
)
reportMonth
:
timeValue
.
substring
(
0
,
7
)
}
}
}
}
},
},
...
@@ -110,28 +143,40 @@ Page({
...
@@ -110,28 +143,40 @@ Page({
month
:
()
=>
{
month
:
()
=>
{
apiName
=
'merchantsOutputReport'
,
apiName
=
'merchantsOutputReport'
,
params
=
{
params
=
{
orderBy
:
selectValue
,
merchantIds
:
[
merchantId
],
merchantIds
:
[
merchantId
],
startTime
:
new
Date
(
timeValue
).
format
(
'yyyy-MM'
)
+
'-01'
+
' 00:00:00'
,
startTime
:
new
Date
(
timeValue
).
format
(
'yyyy-MM'
)
+
'-01'
+
' 00:00:00'
,
endTime
:
new
Date
(
this
.
getNextMonth
(
timeValue
)).
format
(
'yyyy-MM'
)
+
'-01'
+
' 00:00:00'
,
endTime
:
new
Date
(
this
.
getNextMonth
(
timeValue
)).
format
(
'yyyy-MM'
)
+
'-01'
+
' 00:00:00'
,
}
}
}
}
}
}
}
}
let
orderValue
=
{
1
:
{
unit
:
'¥'
,
value
:
'outputValue'
,
mult
:
1
},
2
:
{
unit
:
''
,
value
:
'successCount'
,
mult
:
1
},
3
:
{
unit
:
''
,
value
:
'quotationCount'
,
mult
:
1
},
4
:
{
sign
:
'%'
,
value
:
'conversionRate'
,
mult
:
100
}
}
dataT
[
type
][
timeType
]()
dataT
[
type
][
timeType
]()
ActivityApi
[
apiName
](
params
).
then
(
res
=>
{
ActivityApi
[
apiName
](
params
).
then
(
res
=>
{
const
list
=
res
.
employeeOutputList
||
res
.
staffList
const
list
=
res
.
employeeOutputList
||
res
.
staffList
const
arr
=
[]
const
arr
=
[]
const
staffList
=
list
.
length
?
Object
.
assign
(
arr
,
list
.
splice
(
0
,
3
)):
arr
const
staffList
=
list
.
length
?
Object
.
assign
(
arr
,
list
.
splice
(
0
,
3
))
:
arr
const
billboard
=
staffList
.
map
((
item
,
idx
)
=>
{
const
billboard
=
staffList
.
map
((
item
,
idx
)
=>
{
return
{
return
{
sort
:
idx
+
1
,
sort
:
idx
+
1
,
value
:
item
.
outputValue
||
item
.
orderMoneyTotal
||
0
,
unit
:
(
type
==
2
&&
timeType
==
'month'
)?
orderValue
[
selectValue
].
unit
:
'¥'
,
name
:
item
.
transferName
||
item
.
employeeName
sign
:
(
type
==
2
&&
timeType
==
'month'
)?
orderValue
[
selectValue
].
sign
:
''
,
value
:
(
type
==
2
&&
timeType
==
'month'
)
?
item
[
orderValue
[
selectValue
].
value
]
*
orderValue
[
selectValue
].
mult
:
(
item
.
outputValue
||
item
.
orderMoneyTotal
||
0
),
name
:
item
.
transferName
||
item
.
employeeName
}
}
})
})
this
.
setData
({
this
.
setData
({
outputData
:
res
||
{},
outputData
:
res
||
{},
triggered
:
false
,
triggered
:
false
,
billboard
billboard
})
})
})
})
...
@@ -149,7 +194,7 @@ Page({
...
@@ -149,7 +194,7 @@ Page({
if
(
month
<
10
)
{
if
(
month
<
10
)
{
month
=
"0"
+
month
;
month
=
"0"
+
month
;
}
}
const
nextMonth
=
year
+
"-"
+
month
+
"-"
+
day
;
const
nextMonth
=
year
+
"-"
+
month
+
"-"
+
day
;
return
nextMonth
;
return
nextMonth
;
},
},
formatDate
(
date
)
{
formatDate
(
date
)
{
...
...
packagesList/packageOutput/pages/monthReport/monthReport.scss
View file @
6a79d2e
...
@@ -248,11 +248,52 @@
...
@@ -248,11 +248,52 @@
line-height
:
48rpx
;
line-height
:
48rpx
;
margin-bottom
:
22rpx
;
margin-bottom
:
22rpx
;
display
:
flex
;
display
:
flex
;
justify-content
:
space-between
;
}
.select-up
{
font-weight
:
400
;
font-size
:
24rpx
;
color
:
#666666
;
position
:
relative
;
.unit
{
text-align
:
center
;
margin-left
:
auto
;
font-size
:
22rpx
;
.staff-type
{
color
:
#5A6066
;
width
:
160rpx
;
text
{
display
:
inline-block
;
width
:
120rpx
;
text-align
:
right
;
}
.up-icon
{
width
:
32rpx
;
height
:
32rpx
;
vertical-align
:
middle
;
}
}
.up-box
{
position
:
absolute
;
width
:
128rpx
;
left
:
20rpx
;
background
:
#FFFFFF
;
box-shadow
:
0
0
18rpx
0
#3a596a
1c
;
border-radius
:
8rpx
;
z-index
:
100
;
.up-item
{
flex
:
auto
;
font-weight
:
400
;
font-size
:
22rpx
;
color
:
#666666
;
line-height
:
53rpx
;
&
.checked
{
color
:
#708CFF
;
}
}
}
}
}
}
}
}
...
...
packagesList/packageOutput/pages/monthReport/monthReport.wxml
View file @
6a79d2e
...
@@ -51,14 +51,24 @@
...
@@ -51,14 +51,24 @@
<view class="label">{{item.label}}</view>
<view class="label">{{item.label}}</view>
<glsx-image src="{{item.iconUrl}}" class="icon" />
<glsx-image src="{{item.iconUrl}}" class="icon" />
</view>
</view>
<view class="output-num"><text class="_unit">{{item._unit}}</text> {{outputData[item.name] ||0}}<text class="unit_">{{item.unit_}}</text></view>
<view class="output-num"
style="font-size: {{(outputData[item.name] ||0) > 10000000?27:36}}rpx"
><text class="_unit">{{item._unit}}</text> {{outputData[item.name] ||0}}<text class="unit_">{{item.unit_}}</text></view>
</view>
</view>
</view>
</view>
</view>
</view>
<view class="billboard-box">
<view class="billboard-box">
<view class="billboard-title">
<view class="billboard-title">
<text>当{{timeType=='day'?'日':'月'}}员工龙虎榜</text>
<text>当{{timeType=='day'?'日':'月'}}员工龙虎榜</text>
<text class="unit">累计产值(元)</text>
<view class="select-up" wx:if="{{type == 2 && timeType!='day'}}">
<view catchtap="showUp" class="staff-type">
<text>{{dataType[selectValue-1].label}}</text>
<glsx-image webp custom-class="up-icon" src="/output/down.png"></glsx-image>
</view>
<view class="up-box" hidden="{{typeShow}}">
<view class="up-item {{selectValue == item.value? 'checked':''}}" wx:for="{{dataType}}" wx:key="index" data-label="{{item.label}}" data-value="{{item.value}}" catchtap="selectType">
{{item.label}}
</view>
</view>
</view>
</view>
</view>
<view class="billboard-border">
<view class="billboard-border">
<block wx:if="{{billboard.length}}">
<block wx:if="{{billboard.length}}">
...
@@ -66,7 +76,7 @@
...
@@ -66,7 +76,7 @@
<view class="billboard-item-bar">
<view class="billboard-item-bar">
<view class="bill-border">
<view class="bill-border">
<view class="bill-name">{{item.name}}</view>
<view class="bill-name">{{item.name}}</view>
<view class="bill-num" wx:if="{{item.name}}"><text class="unit"
>¥</text>{{item.value}}
</view>
<view class="bill-num" wx:if="{{item.name}}"><text class="unit"
wx:if="{{item.unit}}">{{item.unit}}</text>{{item.value}}<text class="unit" wx:if="{{item.sign}}">{{item.sign}}</text>
</view>
</view>
</view>
<glsx-image webp custom-class="bill-bg" src="output/bill0{{item.sort}}.png"></glsx-image>
<glsx-image webp custom-class="bill-bg" src="output/bill0{{item.sort}}.png"></glsx-image>
</view>
</view>
...
...
packagesList/packageOutput/pages/summary.js
View file @
6a79d2e
...
@@ -292,7 +292,7 @@ Page({
...
@@ -292,7 +292,7 @@ Page({
// item.orderTotal.price = Number(orderTotal.price).toFixed(2)
// item.orderTotal.price = Number(orderTotal.price).toFixed(2)
// }
// }
item
.
conversionRate
=
(
item
.
conversionRate
*
100
).
toFixed
(
0
)
item
.
conversionRate
=
(
item
.
conversionRate
*
100
).
toFixed
(
0
)
item
.
turnover
=
(
item
.
turnover
/
100
).
toFixed
(
2
)
item
.
turnover
=
(
item
.
turnover
1
/
100
).
toFixed
(
2
)
item
.
fuseCustomerPrice
=
(
item
.
fuseCustomerPrice
/
100
).
toFixed
(
2
)
item
.
fuseCustomerPrice
=
(
item
.
fuseCustomerPrice
/
100
).
toFixed
(
2
)
item
.
equityCustomerPrice
=
(
item
.
equityCustomerPrice
/
100
).
toFixed
(
2
)
item
.
equityCustomerPrice
=
(
item
.
equityCustomerPrice
/
100
).
toFixed
(
2
)
total
=
item
.
turnover
total
=
item
.
turnover
...
...
utils/util.js
View file @
6a79d2e
...
@@ -13,132 +13,132 @@ import $router from "../router/index";
...
@@ -13,132 +13,132 @@ import $router from "../router/index";
* let time = new Date().format('yyyy-MM-dd hh:mm:ss') //log 2020-07-31 10:00:00
* let time = new Date().format('yyyy-MM-dd hh:mm:ss') //log 2020-07-31 10:00:00
*/
*/
Date
.
prototype
.
format
=
function
(
fmt
)
{
Date
.
prototype
.
format
=
function
(
fmt
)
{
let
o
=
{
let
o
=
{
"M+"
:
this
.
getMonth
()
+
1
,
//月份
"M+"
:
this
.
getMonth
()
+
1
,
//月份
"d+"
:
this
.
getDate
(),
//日
"d+"
:
this
.
getDate
(),
//日
"h+"
:
this
.
getHours
(),
//小时
"h+"
:
this
.
getHours
(),
//小时
"m+"
:
this
.
getMinutes
(),
//分
"m+"
:
this
.
getMinutes
(),
//分
"s+"
:
this
.
getSeconds
(),
//秒
"s+"
:
this
.
getSeconds
(),
//秒
//季度
//季度
"q+"
:
Math
.
floor
((
this
.
getMonth
()
+
3
)
/
3
),
"q+"
:
Math
.
floor
((
this
.
getMonth
()
+
3
)
/
3
),
S
:
this
.
getMilliseconds
(),
//毫秒
S
:
this
.
getMilliseconds
(),
//毫秒
};
};
if
(
/
(
y+
)
/
.
test
(
fmt
))
if
(
/
(
y+
)
/
.
test
(
fmt
))
fmt
=
fmt
.
replace
(
fmt
=
fmt
.
replace
(
RegExp
.
$1
,
RegExp
.
$1
,
(
this
.
getFullYear
()
+
""
).
substr
(
4
-
RegExp
.
$1
.
length
)
(
this
.
getFullYear
()
+
""
).
substr
(
4
-
RegExp
.
$1
.
length
)
);
);
for
(
let
k
in
o
)
{
for
(
let
k
in
o
)
{
if
(
new
RegExp
(
"("
+
k
+
")"
).
test
(
fmt
))
if
(
new
RegExp
(
"("
+
k
+
")"
).
test
(
fmt
))
fmt
=
fmt
.
replace
(
fmt
=
fmt
.
replace
(
RegExp
.
$1
,
RegExp
.
$1
,
RegExp
.
$1
.
length
==
1
?
o
[
k
]
:
(
"00"
+
o
[
k
]).
substr
((
""
+
o
[
k
]).
length
)
RegExp
.
$1
.
length
==
1
?
o
[
k
]
:
(
"00"
+
o
[
k
]).
substr
((
""
+
o
[
k
]).
length
)
);
);
}
}
return
fmt
;
return
fmt
;
};
};
/**触底加载 */
/**触底加载 */
const
onReachBottom
=
(
obj
,
callBack
)
=>
{
const
onReachBottom
=
(
obj
,
callBack
)
=>
{
let
_this
=
$router
.
getPageInstance
();
let
_this
=
$router
.
getPageInstance
();
let
{
pageNum
,
total
,
pageSize
,
nothing
}
=
obj
;
let
{
pageNum
,
total
,
pageSize
,
nothing
}
=
obj
;
if
(
!
total
&&
!
pageNum
)
{
if
(
!
total
&&
!
pageNum
)
{
console
.
error
(
"total&&pageNum为必传"
);
console
.
error
(
"total&&pageNum为必传"
);
return
;
return
;
}
}
if
(
!
pageSize
)
pageSize
=
10
;
if
(
!
pageSize
)
pageSize
=
10
;
if
(
!
nothing
)
nothing
=
"nothing"
;
if
(
!
nothing
)
nothing
=
"nothing"
;
if
(
Math
.
ceil
(
total
/
pageSize
)
>
pageNum
)
{
if
(
Math
.
ceil
(
total
/
pageSize
)
>
pageNum
)
{
_this
.
setData
({
_this
.
setData
({
pageNum
:
pageNum
+
1
,
pageNum
:
pageNum
+
1
,
});
});
callBack
();
callBack
();
}
else
{
}
else
{
_this
.
setData
({
_this
.
setData
({
[
nothing
]:
true
,
[
nothing
]:
true
,
});
});
}
}
};
};
/**是否全面屏 */
/**是否全面屏 */
const
isFullSucreen
=
(
isComponents
)
=>
{
const
isFullSucreen
=
(
isComponents
)
=>
{
const
thisPage
=
$router
.
getPageInstance
();
const
thisPage
=
$router
.
getPageInstance
();
const
routerList
=
$router
.
getRouterList
();
const
routerList
=
$router
.
getRouterList
();
const
router
=
routerList
.
find
((
item
)
=>
item
.
url
===
`/
${
thisPage
.
route
}
`
);
const
router
=
routerList
.
find
((
item
)
=>
item
.
url
===
`/
${
thisPage
.
route
}
`
);
let
key
=
`
${
router
.
url
.
replace
(
"/"
,
""
)}
.html`
;
let
key
=
`
${
router
.
url
.
replace
(
"/"
,
""
)}
.html`
;
let
val
=
false
;
let
val
=
false
;
if
(
__wxConfig
&&
__wxConfig
.
page
&&
__wxConfig
.
page
[
key
])
{
if
(
__wxConfig
&&
__wxConfig
.
page
&&
__wxConfig
.
page
[
key
])
{
let
{
navigationStyle
}
=
__wxConfig
.
page
[
key
].
window
;
let
{
navigationStyle
}
=
__wxConfig
.
page
[
key
].
window
;
wx
.
getSystemInfo
({
wx
.
getSystemInfo
({
success
(
res
)
{
success
(
res
)
{
if
(
res
.
platform
!=
"android"
)
{
if
(
res
.
platform
!=
"android"
)
{
let
{
statusBarHeight
,
screenHeight
,
windowHeight
}
=
res
;
let
{
statusBarHeight
,
screenHeight
,
windowHeight
}
=
res
;
if
(
navigationStyle
&&
navigationStyle
==
"custom"
)
{
if
(
navigationStyle
&&
navigationStyle
==
"custom"
)
{
windowHeight
=
windowHeight
-
thisPage
.
data
.
navHeight
||
0
;
windowHeight
=
windowHeight
-
thisPage
.
data
.
navHeight
||
0
;
}
}
//兼容自定义标题
//兼容自定义标题
val
=
router
.
isTab
val
=
router
.
isTab
?
screenHeight
-
windowHeight
-
statusBarHeight
-
32
>
72
?
screenHeight
-
windowHeight
-
statusBarHeight
-
32
>
72
:
screenHeight
-
windowHeight
>
72
;
:
screenHeight
-
windowHeight
>
72
;
if
(
isComponents
)
val
=
screenHeight
-
windowHeight
>
72
;
if
(
isComponents
)
val
=
screenHeight
-
windowHeight
>
72
;
}
}
},
},
fail
(
err
)
{
fail
(
err
)
{
return
false
;
return
false
;
},
},
});
});
}
}
return
val
;
return
val
;
};
};
/**节流 */
/**节流 */
const
throttle
=
(
fn
,
gapTime
)
=>
{
const
throttle
=
(
fn
,
gapTime
)
=>
{
if
(
gapTime
==
null
||
gapTime
==
undefined
)
{
if
(
gapTime
==
null
||
gapTime
==
undefined
)
{
gapTime
=
1500
;
gapTime
=
1500
;
}
let
_lastTime
=
null
;
// 返回新的函数
return
function
()
{
let
_nowTime
=
+
new
Date
();
if
(
_nowTime
-
_lastTime
>
gapTime
||
!
_lastTime
)
{
fn
.
apply
(
this
,
arguments
);
//将this和参数传给原函数
_lastTime
=
_nowTime
;
}
}
};
let
_lastTime
=
null
;
// 返回新的函数
return
function
()
{
let
_nowTime
=
+
new
Date
();
if
(
_nowTime
-
_lastTime
>
gapTime
||
!
_lastTime
)
{
fn
.
apply
(
this
,
arguments
);
//将this和参数传给原函数
_lastTime
=
_nowTime
;
}
};
};
};
/* 防抖函数封装 */
/* 防抖函数封装 */
function
debounce
(
fn
,
interval
)
{
function
debounce
(
fn
,
interval
)
{
let
timer
;
let
timer
;
let
delay
=
interval
||
1000
;
// 间隔的时间,如果interval不传,则默认1秒
let
delay
=
interval
||
1000
;
// 间隔的时间,如果interval不传,则默认1秒
return
function
()
{
return
function
()
{
let
that
=
this
;
let
that
=
this
;
let
args
=
arguments
;
// 保存此处的arguments,因为setTimeout是全局的,arguments不是防抖函数需要的。
let
args
=
arguments
;
// 保存此处的arguments,因为setTimeout是全局的,arguments不是防抖函数需要的。
if
(
timer
)
{
if
(
timer
)
{
clearTimeout
(
timer
);
clearTimeout
(
timer
);
}
}
timer
=
setTimeout
(
function
()
{
timer
=
setTimeout
(
function
()
{
fn
.
apply
(
that
,
args
);
// 用apply指向调用debounce的对象,相当于this.fn(args);
fn
.
apply
(
that
,
args
);
// 用apply指向调用debounce的对象,相当于this.fn(args);
},
delay
);
},
delay
);
};
};
}
}
/**删除对象里的null值 */
/**删除对象里的null值 */
const
clearObjNull
=
(
options
)
=>
{
const
clearObjNull
=
(
options
)
=>
{
let
obj
=
{};
let
obj
=
{};
Object
.
keys
(
options
).
map
((
e
)
=>
{
Object
.
keys
(
options
).
map
((
e
)
=>
{
if
(
options
[
e
]
!=
null
&&
options
[
e
]
!=
undefined
)
{
if
(
options
[
e
]
!=
null
&&
options
[
e
]
!=
undefined
)
{
if
(
typeof
options
[
e
]
==
"object"
)
{
if
(
typeof
options
[
e
]
==
"object"
)
{
Object
.
keys
(
options
[
e
]).
map
((
key
)
=>
{
Object
.
keys
(
options
[
e
]).
map
((
key
)
=>
{
if
(
options
[
e
][
key
]
==
null
||
options
[
e
][
key
]
==
undefined
)
if
(
options
[
e
][
key
]
==
null
||
options
[
e
][
key
]
==
undefined
)
delete
options
[
e
][
key
];
delete
options
[
e
][
key
];
});
});
}
}
obj
[
e
]
=
options
[
e
];
obj
[
e
]
=
options
[
e
];
}
}
});
});
return
obj
;
return
obj
;
};
};
/**
/**
* 判断是否是空对象
* 判断是否是空对象
...
@@ -146,162 +146,162 @@ const clearObjNull = (options) => {
...
@@ -146,162 +146,162 @@ const clearObjNull = (options) => {
* @returns
* @returns
*/
*/
const
isEmptyObj
=
(
obj
)
=>
{
const
isEmptyObj
=
(
obj
)
=>
{
return
JSON
.
stringify
(
obj
)
===
"{}"
;
return
JSON
.
stringify
(
obj
)
===
"{}"
;
};
};
// 解析参数成对象 "actNum=1&activeNavIdx=0&isShare=true"
// 解析参数成对象 "actNum=1&activeNavIdx=0&isShare=true"
const
parseString
=
(
str
)
=>
{
const
parseString
=
(
str
)
=>
{
// console.log('str: ', str);
// console.log('str: ', str);
if
(
!
str
)
return
;
if
(
!
str
)
return
;
let
obj
=
{};
let
obj
=
{};
let
strArr
=
str
.
split
(
"&"
);
let
strArr
=
str
.
split
(
"&"
);
// console.log('strArr: ', strArr);
// console.log('strArr: ', strArr);
strArr
.
forEach
((
item
)
=>
{
strArr
.
forEach
((
item
)
=>
{
// console.log("item: ", item);
// console.log("item: ", item);
let
keyArr
=
item
.
split
(
"="
);
let
keyArr
=
item
.
split
(
"="
);
obj
[
keyArr
[
0
]]
=
keyArr
[
1
];
obj
[
keyArr
[
0
]]
=
keyArr
[
1
];
});
});
return
obj
;
return
obj
;
};
};
/**获取图片版本号 */
/**获取图片版本号 */
const
getImgVersion
=
()
=>
{
const
getImgVersion
=
()
=>
{
return
'1.0.0'
return
'1.0.0'
};
};
//获取当前页面路径
//获取当前页面路径
const
getCurrentPageUrl
=
()
=>
{
const
getCurrentPageUrl
=
()
=>
{
const
pages
=
getCurrentPages
()
const
pages
=
getCurrentPages
()
const
currentPage
=
pages
[
pages
.
length
-
1
]
const
currentPage
=
pages
[
pages
.
length
-
1
]
const
url
=
`/
${
currentPage
.
route
}
`
const
url
=
`/
${
currentPage
.
route
}
`
return
url
return
url
}
}
// 克隆
// 克隆
const
deepClone
=
(
target
)
=>
{
const
deepClone
=
(
target
)
=>
{
const
map
=
new
WeakMap
()
const
map
=
new
WeakMap
()
function
isObject
(
target
)
{
return
(
typeof
target
===
'object'
&&
target
)
||
typeof
target
===
'function'
}
function
clone
(
data
)
{
function
isObject
(
target
)
{
if
(
!
isObject
(
data
))
{
return
(
typeof
target
===
'object'
&&
target
)
||
typeof
target
===
'function'
return
data
}
}
if
([
Date
,
RegExp
].
includes
(
data
.
constructor
))
{
function
clone
(
data
)
{
return
new
data
.
constructor
(
data
)
if
(
!
isObject
(
data
))
{
}
return
data
if
(
typeof
data
===
'function'
)
{
}
return
new
Function
(
'return '
+
data
.
toString
())()
if
([
Date
,
RegExp
].
includes
(
data
.
constructor
))
{
}
return
new
data
.
constructor
(
data
)
const
exist
=
map
.
get
(
data
)
}
if
(
exist
)
{
if
(
typeof
data
===
'function'
)
{
return
exist
return
new
Function
(
'return '
+
data
.
toString
())()
}
}
if
(
data
instanceof
Map
)
{
const
exist
=
map
.
get
(
data
)
const
result
=
new
Map
()
if
(
exist
)
{
map
.
set
(
data
,
result
)
return
exist
data
.
forEach
((
val
,
key
)
=>
{
}
if
(
isObject
(
val
))
{
if
(
data
instanceof
Map
)
{
result
.
set
(
key
,
clone
(
val
))
const
result
=
new
Map
()
}
else
{
map
.
set
(
data
,
result
)
result
.
set
(
key
,
val
)
data
.
forEach
((
val
,
key
)
=>
{
}
if
(
isObject
(
val
))
{
})
result
.
set
(
key
,
clone
(
val
))
return
result
}
else
{
}
result
.
set
(
key
,
val
)
if
(
data
instanceof
Set
)
{
}
const
result
=
new
Set
()
})
map
.
set
(
data
,
result
)
return
result
data
.
forEach
(
val
=>
{
}
if
(
isObject
(
val
))
{
if
(
data
instanceof
Set
)
{
result
.
add
(
clone
(
val
))
const
result
=
new
Set
()
}
else
{
map
.
set
(
data
,
result
)
result
.
add
(
val
)
data
.
forEach
(
val
=>
{
}
if
(
isObject
(
val
))
{
})
result
.
add
(
clone
(
val
))
return
result
}
else
{
}
result
.
add
(
val
)
const
keys
=
Reflect
.
ownKeys
(
data
)
}
const
allDesc
=
Object
.
getOwnPropertyDescriptors
(
data
)
})
const
result
=
Object
.
create
(
Object
.
getPrototypeOf
(
data
),
allDesc
)
return
result
map
.
set
(
data
,
result
)
}
keys
.
forEach
(
key
=>
{
const
keys
=
Reflect
.
ownKeys
(
data
)
const
val
=
data
[
key
]
const
allDesc
=
Object
.
getOwnPropertyDescriptors
(
data
)
if
(
isObject
(
val
))
{
const
result
=
Object
.
create
(
Object
.
getPrototypeOf
(
data
),
allDesc
)
result
[
key
]
=
clone
(
val
)
map
.
set
(
data
,
result
)
}
else
{
keys
.
forEach
(
key
=>
{
result
[
key
]
=
val
const
val
=
data
[
key
]
}
if
(
isObject
(
val
))
{
})
result
[
key
]
=
clone
(
val
)
return
result
}
else
{
}
result
[
key
]
=
val
}
})
return
result
}
return
clone
(
target
)
return
clone
(
target
)
}
}
//设置标题
//设置标题
const
setNavigationBarTitle
=
(
title
)
=>
{
const
setNavigationBarTitle
=
(
title
)
=>
{
wx
.
getSystemInfo
({
wx
.
getSystemInfo
({
success
:
(
res
)
=>
{
success
:
(
res
)
=>
{
// console.log('++++++++++++++', res);
// console.log('++++++++++++++', res);
// console.log('title length',title.length)
// console.log('title length',title.length)
let
width
=
res
.
safeArea
.
width
/
res
.
fontSizeSetting
;
let
width
=
res
.
safeArea
.
width
/
res
.
fontSizeSetting
;
// console.log('width: ', width);
// console.log('width: ', width);
let
space
=
''
;
let
space
=
''
;
// for (let i = 0; i <= width+4; i++) {
// for (let i = 0; i <= width+4; i++) {
// space = space + ' ';
// space = space + ' ';
// }
// }
width
=
width
-
(
title
.
length
)
/
2
width
=
width
-
(
title
.
length
)
/
2
for
(
let
i
=
0
;
i
<
width
;
i
++
)
{
for
(
let
i
=
0
;
i
<
width
;
i
++
)
{
space
=
space
+
' '
;
space
=
space
+
' '
;
}
}
if
(
res
.
system
.
includes
(
'iOS'
)
===
false
)
{
if
(
res
.
system
.
includes
(
'iOS'
)
===
false
)
{
wx
.
setNavigationBarTitle
({
wx
.
setNavigationBarTitle
({
title
:
space
+
title
title
:
space
+
title
});
});
}
else
{
}
else
{
wx
.
setNavigationBarTitle
({
wx
.
setNavigationBarTitle
({
title
:
title
title
:
title
});
});
}
}
}
}
});
});
}
}
/** 钱转化千分 */
/** 钱转化千分 */
const
moneyThreeForTwoThousands
=
num
=>
{
const
moneyThreeForTwoThousands
=
num
=>
{
//num = parseInt(num);
//num = parseInt(num);
// return num
// return num
var
num
=
num
+
''
var
num
=
num
+
''
var
d
=
''
var
d
=
''
if
(
num
.
slice
(
0
,
1
)
==
'-'
)
{
if
(
num
.
slice
(
0
,
1
)
==
'-'
)
{
d
=
num
.
slice
(
0
,
1
)
d
=
num
.
slice
(
0
,
1
)
num
=
num
.
slice
(
1
)
num
=
num
.
slice
(
1
)
}
}
var
len
=
num
.
length
var
len
=
num
.
length
var
index
=
num
.
indexOf
(
'.'
)
var
index
=
num
.
indexOf
(
'.'
)
if
(
index
==
-
1
)
{
if
(
index
==
-
1
)
{
num
=
num
+
'.00'
num
=
num
+
'.00'
}
else
if
(
index
+
2
==
len
)
{
}
else
if
(
index
+
2
==
len
)
{
num
=
num
+
'0'
num
=
num
+
'0'
}
}
var
index
=
num
.
indexOf
(
'.'
)
// 字符出现的位置
var
index
=
num
.
indexOf
(
'.'
)
// 字符出现的位置
var
num2
=
num
.
slice
(
-
3
)
var
num2
=
num
.
slice
(
-
3
)
num
=
num
.
slice
(
0
,
index
)
num
=
num
.
slice
(
0
,
index
)
var
result
=
''
var
result
=
''
while
(
num
.
length
>
3
)
{
while
(
num
.
length
>
3
)
{
result
=
','
+
num
.
slice
(
-
3
)
+
result
result
=
','
+
num
.
slice
(
-
3
)
+
result
num
=
num
.
slice
(
0
,
num
.
length
-
3
)
num
=
num
.
slice
(
0
,
num
.
length
-
3
)
}
}
if
(
num
)
{
if
(
num
)
{
result
=
num
+
result
result
=
num
+
result
}
}
// return result
// return result
return
d
+
(
result
+
num2
)
return
d
+
(
result
+
num2
)
}
}
/**
/**
...
@@ -320,46 +320,52 @@ const moneyThreeForTwoThousands = num => {
...
@@ -320,46 +320,52 @@ const moneyThreeForTwoThousands = num => {
* }
* }
*/
*/
const
checkRule
=
function
(
obj
,
formRule
)
{
const
checkRule
=
function
(
obj
,
formRule
)
{
let
target
=
Object
.
keys
(
formRule
)
let
target
=
Object
.
keys
(
formRule
)
for
(
let
i
=
0
;
i
<
target
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
target
.
length
;
i
++
)
{
let
attr
=
target
[
i
]
let
attr
=
target
[
i
]
let
item
=
formRule
[
attr
]
let
item
=
formRule
[
attr
]
let
requirObj
=
item
.
find
(
k
=>
k
.
required
==
true
)
let
requirObj
=
item
.
find
(
k
=>
k
.
required
==
true
)
let
validFn
=
item
.
find
(
k
=>
k
.
validator
)
let
validFn
=
item
.
find
(
k
=>
k
.
validator
)
if
(
requirObj
&&
!
obj
[
attr
])
{
if
(
requirObj
&&
!
obj
[
attr
])
{
return
{
return
{
...
requirObj
,
...
requirObj
,
attr
attr
}
}
}
}
if
(
validFn
)
{
if
(
validFn
)
{
let
validObj
=
validFn
.
validator
({},
obj
[
attr
],
obj
)
let
validObj
=
validFn
.
validator
({},
obj
[
attr
],
obj
)
if
(
validObj
)
{
if
(
validObj
)
{
return
{
return
{
...
validObj
,
...
validObj
,
attr
attr
}
}
}
}
}
}
}
}
return
false
return
false
}
const
accMul
=
(
arg1
,
arg2
)
=>
{
var
m
=
0
,
s1
=
arg1
.
toString
(),
s2
=
arg2
.
toString
();
try
{
m
+=
s1
.
split
(
"."
)[
1
].
length
}
catch
(
e
)
{
}
try
{
m
+=
s2
.
split
(
"."
)[
1
].
length
}
catch
(
e
)
{
}
return
Number
(
s1
.
replace
(
"."
,
""
))
*
Number
(
s2
.
replace
(
"."
,
""
))
/
Math
.
pow
(
10
,
m
)
}
}
const
Util
=
{
const
Util
=
{
getImgVersion
,
getImgVersion
,
onReachBottom
,
onReachBottom
,
isFullSucreen
,
isFullSucreen
,
clearObjNull
,
clearObjNull
,
throttle
,
throttle
,
debounce
,
debounce
,
isEmptyObj
,
isEmptyObj
,
parseString
,
parseString
,
getCurrentPageUrl
,
getCurrentPageUrl
,
deepClone
,
deepClone
,
setNavigationBarTitle
,
setNavigationBarTitle
,
moneyThreeForTwoThousands
,
moneyThreeForTwoThousands
,
checkRule
checkRule
,
accMul
};
};
export
default
Util
;
export
default
Util
;
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