|
@@ -1,35 +1,30 @@
|
|
|
|
|
|
+
|
|
|
+const app = getApp<IAppOption>()
|
|
|
Component({
|
|
|
|
|
|
- * 组件的属性列表
|
|
|
- */
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
* 组件的初始数据
|
|
|
*/
|
|
|
data: {
|
|
|
popShow: false,
|
|
|
+ btnShow: true,
|
|
|
top: 0,
|
|
|
- startX: 0,
|
|
|
startY: 0,
|
|
|
windowWidth: 0,
|
|
|
windowHeight: 0,
|
|
|
elementHeight: 60
|
|
|
},
|
|
|
- attached() {
|
|
|
-
|
|
|
- const systemInfo = wx.getWindowInfo();
|
|
|
- this.setData({
|
|
|
- windowWidth: systemInfo.windowWidth,
|
|
|
- windowHeight: systemInfo.windowHeight,
|
|
|
- top: systemInfo.windowHeight - 180
|
|
|
- });
|
|
|
+ lifetimes: {
|
|
|
+ attached() {
|
|
|
+
|
|
|
+ const systemInfo = wx.getWindowInfo();
|
|
|
+ const globalTop = app.globalData.top
|
|
|
+ this.setData({
|
|
|
+ windowWidth: systemInfo.windowWidth,
|
|
|
+ windowHeight: systemInfo.windowHeight,
|
|
|
+ top: globalTop
|
|
|
+ });
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
* 组件的方法列表
|
|
@@ -61,6 +56,7 @@ Component({
|
|
|
const deltaY = e.touches[0].clientY - this.data.startY;
|
|
|
|
|
|
|
|
|
+ app.globalData.top = this.data.top + deltaY
|
|
|
this.setData({
|
|
|
top: this.data.top + deltaY,
|
|
|
startY: e.touches[0].clientY
|
|
@@ -75,11 +71,17 @@ Component({
|
|
|
const moveHeight = top + elementHeight
|
|
|
|
|
|
if (distanceTop < 0) {
|
|
|
- this.setData({ top: 0 });
|
|
|
+ this.setData({ top: 0 }, () => {
|
|
|
+ app.globalData.top = 0
|
|
|
+ });
|
|
|
} else if(moveHeight >= windowHeight) {
|
|
|
- this.setData({ top: windowHeight - elementHeight })
|
|
|
+ this.setData({ top: windowHeight - elementHeight }, () => {
|
|
|
+ app.globalData.top = windowHeight - elementHeight
|
|
|
+ })
|
|
|
} else {
|
|
|
- this.setData({ top })
|
|
|
+ this.setData({ top }, () => {
|
|
|
+ app.globalData.top = top
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
}
|