Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
junlebao-milk-20240619
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
SparkProjects
junlebao-milk-20240619
Commits
30d16745
Commit
30d16745
authored
Jun 25, 2024
by
haiyoucuv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
1b5560fd
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
3 deletions
+49
-3
index.ts
miniprogram/pages/index/index.ts
+12
-1
index.wxml
miniprogram/pages/index/index.wxml
+1
-1
util.ts
miniprogram/utils/util.ts
+35
-0
tsconfig.json
tsconfig.json
+1
-1
No files found.
miniprogram/pages/index/index.ts
View file @
30d16745
...
@@ -2,7 +2,9 @@
...
@@ -2,7 +2,9 @@
// 获取应用实例
// 获取应用实例
import
{
ComponentWithStore
}
from
"mobx-miniprogram-bindings"
;
import
{
ComponentWithStore
}
from
"mobx-miniprogram-bindings"
;
import
{
store
}
from
"../../store/store"
;
import
{
store
}
from
"../../store/store"
;
import
{
dbLogin
}
from
"../../utils/request"
;
import
{
dbLogin
,
request
}
from
"../../utils/request"
;
import
{
API_PATH
}
from
"../../utils/config"
;
import
{
_asyncThrottle
}
from
"../../utils/util"
;
const
app
=
getApp
<
IAppOption
>
()
const
app
=
getApp
<
IAppOption
>
()
const
defaultAvatarUrl
=
'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0'
const
defaultAvatarUrl
=
'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0'
...
@@ -59,6 +61,15 @@ ComponentWithStore({
...
@@ -59,6 +61,15 @@ ComponentWithStore({
showPhoneBtn
:
!
store
.
homeInfo
.
mobile
,
showPhoneBtn
:
!
store
.
homeInfo
.
mobile
,
});
});
},
},
clickSubscribe
:
_asyncThrottle
(
async
function
()
{
console
.
log
(
'clickSubscribe'
,
this
)
await
request
({
url
:
API_PATH
.
subscribe
,
});
await
this
.
updateHomeInfo
();
}),
closeGetPanel
()
{
closeGetPanel
()
{
this
.
setData
({
this
.
setData
({
showGetPanel
:
false
,
showGetPanel
:
false
,
...
...
miniprogram/pages/index/index.wxml
View file @
30d16745
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
</view>
</view>
<view class="content_info">
<view class="content_info">
<view class="content_info_bg"></view>
<view class="content_info_bg"></view>
<view class="content_sub">订阅消息</view>
<view class="content_sub"
wx:if="{{!homeInfo.subscribe}}" bindtap="clickSubscribe"
>订阅消息</view>
<view class="content_act_list">
<view class="content_act_list">
<view class="content_act_list_title">热门活动</view>
<view class="content_act_list_title">热门活动</view>
<view class="content_act_list_more">查看更多 ></view>
<view class="content_act_list_more">查看更多 ></view>
...
...
miniprogram/utils/util.ts
View file @
30d16745
...
@@ -17,3 +17,38 @@ const formatNumber = (n: number) => {
...
@@ -17,3 +17,38 @@ const formatNumber = (n: number) => {
const
s
=
n
.
toString
()
const
s
=
n
.
toString
()
return
s
[
1
]
?
s
:
'0'
+
s
return
s
[
1
]
?
s
:
'0'
+
s
}
}
/**
* @description: 支持异步函数的节流,防止接口时间太长击穿防连点
* @return {Function}
* @param fun
* @param delay
*/
export
const
_asyncThrottle
=
(
fun
,
delay
=
2000
)
=>
{
let
last
,
deferTimer
;
let
canClick
=
true
;
return
function
()
{
const
now
=
Date
.
now
();
if
(
!
canClick
)
return
;
if
(
last
&&
now
<
last
+
delay
)
{
// clearTimeout(deferTimer);
// deferTimer = setTimeout(() => {
// last = now;
// }, delay);
}
else
{
last
=
now
;
// @ts-ignore
const
ps
=
fun
.
apply
(
this
,
arguments
);
if
(
ps
instanceof
Promise
)
{
canClick
=
false
;
ps
.
then
(()
=>
{
canClick
=
true
;
});
}
}
};
};
tsconfig.json
View file @
30d16745
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
"allowSyntheticDefaultImports"
:
true
,
"allowSyntheticDefaultImports"
:
true
,
"esModuleInterop"
:
true
,
"esModuleInterop"
:
true
,
"experimentalDecorators"
:
true
,
"experimentalDecorators"
:
true
,
"noImplicitThis"
:
tru
e
,
"noImplicitThis"
:
fals
e
,
"noImplicitReturns"
:
true
,
"noImplicitReturns"
:
true
,
"alwaysStrict"
:
true
,
"alwaysStrict"
:
true
,
"noFallthroughCasesInSwitch"
:
true
,
"noFallthroughCasesInSwitch"
:
true
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment