diff --git a/assets/image/add-tips.png b/assets/image/add-tips.png new file mode 100644 index 0000000..3c0d446 Binary files /dev/null and b/assets/image/add-tips.png differ diff --git a/components/add-tips/index.js b/components/add-tips/index.js new file mode 100644 index 0000000..7412238 --- /dev/null +++ b/components/add-tips/index.js @@ -0,0 +1,66 @@ +const STORAGE_KEY = 'PLUG-ADD-MYAPP-KEY' + +Component({ + properties: { + name: { + type: String, + value: '测试' + }, + duration: { + type: Number, + value: 5 + }, + delay: { + type: Number, + value: 2 + }, + logo: { + type: String, + value: '/assets/image/add-tips.png' + }, + custom: { + type: Boolean, + value: false + } + }, + lifetimes: { + attached: function() { + if (wx.getStorageSync(STORAGE_KEY)) return; + let rect = wx.getMenuButtonBoundingClientRect ? wx.getMenuButtonBoundingClientRect() : null + let {screenWidth} = wx.getSystemInfoSync() + this.setData({ + navbarHeight: rect.bottom, + arrowR: screenWidth - rect.right + rect.width * 3 / 4 - 5, + bodyR: screenWidth - rect.right + }) + this.startTimer = setTimeout(() => { + this.setData({ SHOW_TOP: true }) + }, 500) + this.duraTimer = setTimeout(() => { + this.hidden(); + }, (this.data.duration + this.data.delay) * 1000) + }, + detached: function() { + if (this.startTimer) clearTimeout(this.startTimer) + if (this.duraTimer) clearTimeout(this.duraTimer) + }, + }, + data: { + SHOW_TOP: false + }, + methods: { + hidden: function() { + // wx.setStorageSync(STORAGE_KEY, true) + this.setData({ SHOW_TOP: false }) + // this.shrink() + }, + shrink:function() { + this.animate('#add-tips', [ + {scale: [1, 1]}, + {scale: [0, 0], ease:'ease', transformOrigin: `calc(600rpx - ${this.data.arrowR}px) 1%`} + ], 500, function () { + this.setData({ SHOW_TOP: false }) + }.bind(this)) + } + } +}) \ No newline at end of file diff --git a/components/add-tips/index.json b/components/add-tips/index.json new file mode 100644 index 0000000..32640e0 --- /dev/null +++ b/components/add-tips/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} \ No newline at end of file diff --git a/components/add-tips/index.wxml b/components/add-tips/index.wxml new file mode 100644 index 0000000..f78a720 --- /dev/null +++ b/components/add-tips/index.wxml @@ -0,0 +1,7 @@ + + + + + 将“{{name}}”添加到手机桌面,下次访问更便捷 + + \ No newline at end of file diff --git a/components/add-tips/index.wxss b/components/add-tips/index.wxss new file mode 100644 index 0000000..e18050e --- /dev/null +++ b/components/add-tips/index.wxss @@ -0,0 +1 @@ +.box{position:fixed;right:0;z-index:999;display:flex;justify-content:flex-end;align-items:flex-end;flex-direction:column;width:600rpx;}.arrow{width:0;height:0;border-width:5px;border-style:solid;border-color:transparent transparent rgba(0,0,0,0.75) transparent;}.body{background-color:rgba(0,0,0,0.75);border-radius:2px;display:flex;align-items:center;justify-content:center;padding:10px;}.tips{flex:1;color:#fff;font-size:14px;font-weight:700;}.logo{height:42px;width:42px;border-radius:8px;margin-right:10px;} \ No newline at end of file diff --git a/pages/index/index.json b/pages/index/index.json index 9060de5..8467e7c 100644 --- a/pages/index/index.json +++ b/pages/index/index.json @@ -10,6 +10,7 @@ "van-popup": "/components/popup/index", "van-cell": "/components/cell/index", "van-tree-select": "/components/tree-select/index", + "add-tips": "/components/add-tips/index", "notification": "/pages/message/notification/index" } } \ No newline at end of file diff --git a/pages/index/index.wxml b/pages/index/index.wxml index 2f3a52e..dd45a7d 100644 --- a/pages/index/index.wxml +++ b/pages/index/index.wxml @@ -5,7 +5,7 @@ - +