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