Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mini-program-wepy
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ui
mini-program-wepy
Commits
b27f8720
Commit
b27f8720
authored
Jul 09, 2020
by
郭志伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 修复签到多次点击问题
parent
6e4d57c7
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
61 additions
and
4 deletions
+61
-4
.eslintcache
.eslintcache
+1
-1
utils.js
src/common/utils.js
+46
-0
wxRequest.js
src/common/wxRequest.js
+1
-1
index.wpy
src/pages/index.wpy
+13
-2
No files found.
.eslintcache
View file @
b27f8720
This diff is collapsed.
Click to expand it.
src/common/utils.js
0 → 100644
View file @
b27f8720
/*
* @Description:
* @Date: 2020-07-09 11:14:06
* @LastEditors: gzw
* @LastEditTime: 2020-07-09 11:14:26
*/
/**
* 延时函数
* @param {Function} func 方法
* @param {Number} wait 等待时间
* @param {Boolean} immediate 是否立即执行
* @return: {Function} result 方法执行
*/
export
function
debounce
(
func
,
wait
,
immediate
)
{
let
timeout
,
args
,
context
,
timestamp
,
result
;
const
later
=
function
()
{
// 据上一次触发时间间隔
const
last
=
+
new
Date
()
-
timestamp
;
// 上次被包装函数被调用时间间隔last小于设定时间间隔wait
if
(
last
<
wait
&&
last
>
0
)
{
timeout
=
setTimeout
(
later
,
wait
-
last
);
}
else
{
timeout
=
null
;
// 如果设定为immediate===true,因为开始边界已经调用过了此处无需调用
if
(
!
immediate
)
{
result
=
func
.
apply
(
context
,
args
);
if
(
!
timeout
)
context
=
args
=
null
;
}
}
};
return
function
(...
args
)
{
context
=
this
;
timestamp
=
+
new
Date
();
const
callNow
=
immediate
&&
!
timeout
;
// 如果延时不存在,重新设定延时
if
(
!
timeout
)
timeout
=
setTimeout
(
later
,
wait
);
if
(
callNow
)
{
result
=
func
.
apply
(
context
,
args
);
context
=
args
=
null
;
}
return
result
;
};
}
src/common/wxRequest.js
View file @
b27f8720
import
wepy
from
'
@wepy/core
'
;
import
wepy
from
'
@wepy/core
'
;
import
Notify
from
'
../components/vant/notify/notify
'
;
import
Notify
from
'
../components/vant/notify/notify
'
;
const
env
=
'
prod
'
;
// 每次上线手动切换成 prod/test
const
env
=
'
test
'
;
// 每次上线手动切换成 prod/test
let
baseUrl
=
'
https://api-luckii.q-gp.com
'
;
let
baseUrl
=
'
https://api-luckii.q-gp.com
'
;
if
(
env
===
'
test
'
)
{
if
(
env
===
'
test
'
)
{
baseUrl
=
'
https://luckii-qa.liangkebang.net
'
;
baseUrl
=
'
https://luckii-qa.liangkebang.net
'
;
...
...
src/pages/index.wpy
View file @
b27f8720
...
@@ -233,6 +233,7 @@
...
@@ -233,6 +233,7 @@
import store from '../store';
import store from '../store';
import { mapState, mapActions } from '@wepy/x';
import { mapState, mapActions } from '@wepy/x';
import wepy from '@wepy/core';
import wepy from '@wepy/core';
import { debounce } from "../common/utils";
import Notify from '../components/vant/notify/notify';
import Notify from '../components/vant/notify/notify';
import Dialog from '../components/vant/dialog/dialog';
import Dialog from '../components/vant/dialog/dialog';
import { login, register, getMainInfo, addGold, getPrizeList, signIn, getActivityFeed, checkCornCode } from '../common/api.js';
import { login, register, getMainInfo, addGold, getPrizeList, signIn, getActivityFeed, checkCornCode } from '../common/api.js';
...
@@ -311,6 +312,10 @@
...
@@ -311,6 +312,10 @@
return;
return;
}
}
}
}
wepy.wx.showLoading({
title: "请稍候...",
mask: true
});
wx.requestSubscribeMessage({
wx.requestSubscribeMessage({
tmplIds,
tmplIds,
success (res) {
success (res) {
...
@@ -320,7 +325,7 @@
...
@@ -320,7 +325,7 @@
const rs = tmplIds.every(v => res[v] === undefined || res[v] === 'accept');
const rs = tmplIds.every(v => res[v] === undefined || res[v] === 'accept');
if (rs) {
if (rs) {
that.sign = true;
that.sign = true;
setTimeout
(async () => {
debounce
(async () => {
const innerAudioContext = wx.createInnerAudioContext();
const innerAudioContext = wx.createInnerAudioContext();
innerAudioContext.autoplay = true;
innerAudioContext.autoplay = true;
innerAudioContext.src = '/static/audio/supermarie.mp3';
innerAudioContext.src = '/static/audio/supermarie.mp3';
...
@@ -330,14 +335,20 @@
...
@@ -330,14 +335,20 @@
console.log(res.errCode);
console.log(res.errCode);
});
});
const { coins } = await signIn();
const { coins } = await signIn();
wepy.wx.hideLoading();
if (coins === 0) return;
if (coins === 0) return;
that.mainInfo.account.quantity = coins;
that.mainInfo.account.quantity = coins;
}, 1500);
}, 700)();
} else {
wepy.wx.hideLoading();
}
}
} else {
wepy.wx.hideLoading();
}
}
},
},
fail (res) {
fail (res) {
console.log('requestSubscribeMessage fail', res);
console.log('requestSubscribeMessage fail', res);
wepy.wx.hideLoading();
}
}
});
});
},
},
...
...
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