123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- <script>
- import Vue from 'vue';
- export default {
- onLaunch: function() {
- // #ifdef MP-WEIXIN
- // 小程序更新
- const updateManager = uni.getUpdateManager();
- // 请求完新版本信息
- updateManager.onCheckForUpdate((res) => {
- // console.log(res.hasUpdate);
- });
- // 新的版本已经下载好
- updateManager.onUpdateReady((res) => {
- uni.showModal({
- title: '更新提示',
- content: '新版本已经准备好,是否重启应用?',
- success(res) {
- if (res.confirm) {
- // 调用 applyUpdate 应用新版本并重启
- updateManager.applyUpdate();
- }
- },
- });
- });
- // 新的版本下载失败
- updateManager.onUpdateFailed((res) => {});
- uni.$on('updateUserInfo', () => {
- this.updateUserInfo();
- });
- this.updateUserInfo();
- // #endif
- uni.getSystemInfo({
- success: function(e) {
- console.log(e);
- Vue.prototype.StatusBar = e.statusBarHeight;
- // #ifdef MP-WEIXIN
- let custom = wx.getMenuButtonBoundingClientRect();
- Vue.prototype.Custom = custom;
- Vue.prototype.CustomBar = custom.bottom + custom.top - e.statusBarHeight + 4;
- // #endif
- // #ifndef MP-WEIXIN
- Vue.prototype.CustomBar = 48
- // #endif
- //用来判断是否iphoneX类型的全面屏设备
- if (e.model.indexOf('iPhone X') == 0) {
- Vue.prototype.isIphoneX = 68;
- } else {
- Vue.prototype.isIphoneX = 0;
- }
- },
- });
- },
- onShow: function() {
- },
- onHide: function() {
- },
- methods: {
- // #ifdef MP-WEIXIN
- async updateUserInfo() {
- // if (this.$store.state.isLogin) {
- // const data = await this.$getUserInfo();
- // if (!data) {
- // this.$store.commit('changeLoginStatus', false);
- // this.$store.commit('changeToken', '');
- // uni.removeStorageSync('isLogin');
- // uni.removeStorageSync('token');
- // }
- // }
- // this.$isResolve();
- // uni.login({
- // provider: 'weixin',
- // success: (loginRes) => {
- // console.log(loginRes.code)
- // this.$axios({
- // url: '/v1app/user/auth',
- // params: {
- // code: loginRes.code,
- // },
- // }).then((res) => {
- // try {
- // console.log('====token====', res.data.token);
- // if (this.$store.state.isLogin) {
- // this.$store.commit('changeToken', res.data.token);
- // uni.setStorageSync('token', res.data.token);
- // this.$getUserInfo();
- // }
- // this.$isResolve();
- // } catch (e) {
- // console.error(e);
- // }
- // }).catch(res => {
- // this.$store.commit('changeLoginStatus', false);
- // this.$store.commit('changeToken', '');
- // uni.removeStorageSync('isLogin');
- // uni.removeStorageSync('token');
- // this.$isResolve();
- // })
- // },
- // });
- },
- // #endif
- },
- }
- </script>
- <style lang="scss">
- /*每个页面公共css */
- @import "uview-ui/index.scss";
- @import "styles/iconfont.css";
- </style>
|