Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
dev
/
marubi-wish-list-mp
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
00b209ae
authored
2019-08-28 16:42:03 +0800
by
simon
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
1.摇一摇防抖 2.coop码重置
1 parent
1252787a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
110 additions
and
39 deletions
src/app.js
src/pages/coop/coop.js
src/pages/coop/coop.wxml
src/pages/create-wish/create-wish.js
src/app.js
View file @
00b209a
...
...
@@ -30,8 +30,23 @@ App({
coopOptions
:
null
,
// 协作页 onload入参
},
onLaunch
:
function
(
options
)
{
console
.
log
(
"app q:"
,
decodeURIComponent
(
options
.
query
.
q
));
// console.log("app q:", decodeURIComponent(options.query.q));
console
.
log
(
"onLaunch options:"
,
options
)
this
.
globalData
.
coopOptions
=
null
;
this
.
share
();
this
.
shake
();
},
shake
()
{
wx
.
onAccelerometerChange
(
function
(
res
)
{
let
pages
=
getCurrentPages
();
let
view
=
pages
[
pages
.
length
-
1
];
if
(
view
)
{
let
data
=
view
.
data
;
if
(
data
.
isShake
)
{
view
.
onShakeHandler
(
res
);
}
}
});
},
//重写分享方法
share
:
function
()
{
...
...
@@ -53,11 +68,12 @@ App({
title
:
'弹弹弹 看你有多弹'
,
path
:
'pages/index/index'
,
// imageUrl: './image/share.png',
//
imageUrl: 'https://kd.cdn.xyiyang.com/weapp/marubi/wish-list/share.png'
imageUrl
:
'https://kdcdn.oss-cn-shenzhen.aliyuncs.com/weapp/marubi/wish-list/share.png'
imageUrl
:
'https://kd.cdn.xyiyang.com/weapp/marubi/wish-list/share.png'
//
imageUrl: 'https://kdcdn.oss-cn-shenzhen.aliyuncs.com/weapp/marubi/wish-list/share.png'
};
};
}
}
})
},
...
...
src/pages/coop/coop.js
View file @
00b209a
import
{
getBindtapData
,
getObjByListKeyValue
getObjByListKeyValue
,
debounce
,
}
from
'../../utils/util'
;
import
{
...
...
@@ -27,7 +28,10 @@ Page({
animationShake
:
{},
// 摇一摇动画
aniTimeoutIndex
:
0
,
initComplete
:
false
,
initShakeComplete
:
false
,
isShake
:
true
,
},
onShareAppMessage
()
{},
showAuth
()
{
this
.
setData
({
...
...
@@ -38,13 +42,18 @@ Page({
this
.
setData
({
options
})
console
.
log
(
"coop options:"
,
options
);
// 注册回调的入参
if
(
app
.
globalData
.
coopOptions
)
{
this
.
setData
({
options
:
app
.
globalData
.
coopOptions
})
if
(
!
options
.
code
)
{
if
(
app
.
globalData
.
coopOptions
)
{
this
.
setData
({
options
:
app
.
globalData
.
coopOptions
})
console
.
log
(
"app.globalData.coopOptions:"
,
app
.
globalData
.
coopOptions
);
app
.
globalData
.
coopOptions
=
null
;
}
}
// this.initData();
console
.
log
(
"onLoad"
);
},
onHide
()
{},
...
...
@@ -77,24 +86,60 @@ Page({
tipsGuideRegisterVisible
:
true
})
}
this
.
initShake
();
})
this
.
initShake
();
})
},
// 添加摇一摇
// initShake() {
// console.log("initShake start");
// if (this.data.initShakeComplete) {
// return;
// }
// console.log("initShake completed");
// this.data.initShakeComplete = true;
// let _this = this;
// wx.onAccelerometerChange(function (res) {
// if (!_this.data.canShake || _this.data.tipsCommonVisible) {
// return
// }
// let shakeValue = 2;
// if (res.x > shakeValue || res.y > shakeValue || res.z > shakeValue) { //偏移量为2时触发,有的使用1
// // 触发摇一摇
// console.log("摇一摇");
// // 加防抖函数 100毫秒
// debounce(_this.queryWishbillAssist.bind(_this), 1000)()
// }
// });
// },
// 添加摇一摇
initShake
()
{
return
;
console
.
log
(
"initShake start"
);
if
(
this
.
data
.
initShakeComplete
)
{
return
;
}
console
.
log
(
"initShake completed"
);
this
.
data
.
initShakeComplete
=
true
;
let
_this
=
this
;
wx
.
onAccelerometerChange
(
function
(
res
)
{
if
(
!
_this
.
data
.
canShake
||
_this
.
data
.
tipsCommonVisible
)
{
return
}
let
shakeValue
=
2
;
if
(
res
.
x
>
shakeValue
||
res
.
y
>
shakeValue
||
res
.
z
>
shakeValue
)
{
//偏移量为2时触发,有的使用1
// 触发摇一摇
_this
.
queryWishbillAssist
();
}
});
wx
.
onAccelerometerChange
(
_this
.
onShakeHandler
.
bind
(
_this
));
},
onShakeHandler
(
res
)
{
let
_this
=
this
;
if
(
!
_this
.
data
.
canShake
||
_this
.
data
.
tipsCommonVisible
)
{
return
}
let
shakeValue
=
2
;
if
(
res
.
x
>
shakeValue
||
res
.
y
>
shakeValue
||
res
.
z
>
shakeValue
)
{
//偏移量为2时触发,有的使用1
// 触发摇一摇
console
.
log
(
"摇一摇"
);
// 加防抖函数 100毫秒
debounce
(
_this
.
queryWishbillAssist
.
bind
(
this
),
1000
)()
}
},
// 我也要玩
onPlayTooHandler
()
{
app
.
router
.
push
({
...
...
@@ -136,21 +181,22 @@ Page({
if
(
wishInfo
.
isSelfWishBill
==
1
)
{
return
;
}
// 已经助力
// if (wishInfo.isAssist
== 1) {
//
return;
//
}
// 已经助力
过这张表单
if
(
wishInfo
.
isAssistThisBill
==
1
)
{
return
;
}
this
.
setData
({
canShake
:
false
})
this
.
playShakeSound
();
this
.
data
.
canShake
=
false
;
console
.
log
(
"app.api.wishbillAssist"
);
app
.
post
({
toast
:
false
,
url
:
app
.
api
.
wishbillAssist
,
data
:
{
billCode
:
this
.
data
.
options
.
code
}
}).
then
((
result
)
=>
{
this
.
playShakeSound
();
let
status
=
result
.
status
;
if
(
status
!=
1
)
{
this
.
setData
({
...
...
@@ -212,9 +258,7 @@ Page({
tipsCommonVisible
:
true
,
tipsInnerText
:
"助力失败"
})
this
.
setData
({
canShake
:
false
})
this
.
data
.
canShake
=
false
;
}
})
},
...
...
@@ -256,13 +300,7 @@ Page({
},
// 触发摇一摇测试入口
queryWishbillAssistTest
()
{
let
isTest
=
app
.
globalData
.
isTest
;
if
(
!
isTest
)
{
return
;
}
this
.
queryWishbillAssist
();
},
queryWishbillAssistTest
()
{},
hideMask
()
{
this
.
setData
({
...
...
src/pages/coop/coop.wxml
View file @
00b209a
...
...
@@ -14,7 +14,7 @@
<!-- 摇一摇 -->
<!-- bindtap="queryWishbillAssist" -->
<!-- 点自己链接未助力 -->
<view bindtap="queryWishbillAssistTest" wx:if="{{wishInfo.isSelfWishBill == 1 ||
wishInfo.isAssistThisBill == 0}}" class="shake">
<view bindtap="queryWishbillAssistTest" wx:if="{{wishInfo.isSelfWishBill == 1 || wishInfo.isAssistThisBill == 0}}" class="shake">
<image class="ebg" mode="widthFix" src="../../image/oss/coop/coop-c2.png" />
<image class="coop-shake animated infinite {{animationPassVisible || !initComplete ?'':'tada'}}" mode="widthFix" src="../../image/oss/coop/coop-shake.png" />
<view class="space1"></view>
...
...
src/pages/create-wish/create-wish.js
View file @
00b209a
...
...
@@ -32,6 +32,7 @@ Page({
userInfo
:
{},
// canShake:false,
guideIndex
:
0
,
isShake
:
true
,
},
onShareAppMessage
()
{},
showAuth
()
{
...
...
@@ -78,6 +79,7 @@ Page({
},
// 添加摇一摇
initShake
()
{
return
;
let
_this
=
this
;
wx
.
onAccelerometerChange
(
function
(
res
)
{
if
(
!
_this
.
data
.
tipsShakeVisible
)
{
...
...
@@ -94,6 +96,21 @@ Page({
});
},
onShakeHandler
(
res
)
{
let
_this
=
this
;
if
(
!
_this
.
data
.
tipsShakeVisible
)
{
return
}
let
shakeValue
=
2
;
if
(
res
.
x
>
shakeValue
||
res
.
y
>
shakeValue
||
res
.
z
>
shakeValue
)
{
//偏移量为2时触发,有的使用1
_this
.
setData
({
tipsShakeVisible
:
false
,
tipsCreateCompleteVisible
:
true
})
_this
.
playShakeSound
();
}
},
/**
* 播放摇动声音
*/
...
...
Please
register
or
sign in
to post a comment