宜呗小程序--微信小程序
Lzk
2025-08-05 b7bcaf556aa2424e808b6e6426ab22df9cfe11c1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<script lang="uts">
import { initEid } from './pages/mp_ecard_sdk/main';
let firstBackTime = 0
export default {
  onLaunch: function () {
  // #ifdef MP-WX-PLUGIN
initEid();
// #endif
 
      uni.getSystemInfo({
    success: (res) => {
      uni.setStorageSync('statusBarHeight', res.statusBarHeight+44);
    },
  });
    console.log('App Launch----------')
  },
  onShow: function () {
    console.log('App Show')
  },
  onHide: function () {
    console.log('App Hide')
  },
  // #ifdef APP-ANDROID
  onLastPageBackPress: function () {
    console.log('App LastPageBackPress')
    if (firstBackTime == 0) {
      uni.showToast({
        title: '再按一次退出应用',
        position: 'bottom',
      })
      firstBackTime = Date.now()
      setTimeout(() => {
        firstBackTime = 0
      }, 2000)
    } else if (Date.now() - firstBackTime < 2000) {
      firstBackTime = Date.now()
      uni.exit()
    }
  },
  // #endif
  onExit: function () {
    console.log('App Exit')
  },
}
</script>
 
<style lang="scss">
.paddingNav{
  padding-top: calc(var(--status-bar-height) + 44px);
}
.paddingNavNot{
  padding-top: calc(var(--status-bar-height));
}
.paddingNavNot_15{
  padding-top: calc(var(--status-bar-height) + 15px);
}
.paddingNavNot_35{
  padding-top: calc(var(--status-bar-height) + 35px);
}
</style>