Browse Source

tips

feature/v2.1
xpz2018 4 years ago
parent
commit
5577220c7b
7 changed files with 79 additions and 1 deletions
  1. BIN
      assets/image/add-tips.png
  2. 66
      components/add-tips/index.js
  3. 3
      components/add-tips/index.json
  4. 7
      components/add-tips/index.wxml
  5. 1
      components/add-tips/index.wxss
  6. 1
      pages/index/index.json
  7. 2
      pages/index/index.wxml

BIN
assets/image/add-tips.png

Before After
Width: 232  |  Height: 232  |  Size: 3.6 KiB

66
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))
}
}
})

3
components/add-tips/index.json

@ -0,0 +1,3 @@
{
"component": true
}

7
components/add-tips/index.wxml

@ -0,0 +1,7 @@
<view class="box" wx:if="{{SHOW_TOP}}" style="top:{{custom?navbarHeight:0}}px;" id="add-tips">
<view class='arrow' style="margin-right:{{arrowR}}px;"></view>
<view class='body' bindtap='hidden' style="margin-right:{{bodyR}}px;">
<image src="{{logo}}" class="logo"></image>
<view class="tips">将“{{name}}”添加到手机桌面,下次访问更便捷</view>
</view>
</view>

1
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;}

1
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"
}
}

2
pages/index/index.wxml

@ -5,7 +5,7 @@
<van-icon name="{{visible ? 'arrow-up' : 'arrow-down'}}" size="36rpx" color="white" wx:if="{{arrow}}"/>
</view>
</cu-custom>
<add-tips name="纸通宝工厂版" custom/>
<swiper current="{{tabIndex}}" duration="0" style="height:{{fragment}}rpx">
<swiper-item catchtouchmove="stopTouchMove">
<process id="{{tabList[0].value}}" bind:zIndex="onPopupChange" />

Loading…
Cancel
Save