1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <script>
- export default {
- onLaunch: function() {
- console.log('App Launch')
- },
- onShow: function() {
- console.log('App Show')
- this.autoUpdate();
- // if(uni.getStorageSync('userInfo')) uni.reLaunch({ url:'/pages/home/index' })
- // else uni.reLaunch({ url:'/pages/login/index' })
- },
- onHide: function() {
- console.log('App Hide')
- },
- methods: {
- autoUpdate() {
- if (wx.canIUse('getUpdateManager')) {
- const updateManager = wx.getUpdateManager();
- updateManager.onCheckForUpdate(res => {
- if (res.hasUpdate) {
- updateManager.onUpdateReady(() => {
- wx.showModal({
- title: '更新提示',
- content: '发现新版本,是否更新?',
- success: function(res) {
- if (res.confirm) {
- updateManager.applyUpdate();
- }
- }
- })
- });
- updateManager.onUpdateFailed(function() {
- wx.showModal({
- title: '最新版提示',
- content: '新版本已上线,请您删除当前小程序,重新搜索打开',
- showCancel: false
- })
- });
- }
- })
- } else {
- wx.showModal({
- title: '提示',
- content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。',
- showCancel: false
- })
- }
- }
- }
- }
- </script>
- <style lang="scss">
- /* 注意要写在第一行,同时给style标签加入lang="scss"属性 */
- @import "@/uni_modules/uview-ui/index.scss";
- * {
- padding: 0;
- margin: 0;
- box-sizing: border-box;
- font-family: PingFangSC-Regular, PingFang SC;
- }
- html,
- body {
- font-family: PingFangSC-Regular, PingFang SC;
- font-size: 24rpx;
- width: 100%;
- height: 100%;
- }
- </style>
|