【App 页面】

1. 整理代码
pull/1/MERGE
YunaiV 2023-06-27 00:06:02 +08:00
parent 72385f8ed8
commit 8e2d28d27a
1 changed files with 33 additions and 51 deletions

84
App.vue
View File

@ -1,17 +1,7 @@
<script>
import {
checkLogin
} from "./libs/login";
import {
HTTP_REQUEST_URL
} from './config/app';
import { HTTP_REQUEST_URL } from './config/app';
import Auth from './libs/wechat.js';
import Routine from './libs/routine.js';
import Apps from './libs/apps.js';
import {
mapActions
} from 'vuex'
export default {
globalData: {
spid: 0,
@ -24,6 +14,7 @@
},
onLaunch: function(option) {
let that = this;
// window
// #ifdef H5
uni.getSystemInfo({
success: function(res) {
@ -33,24 +24,35 @@
// #ifdef H5
that.globalData.windowHeight = res.windowHeight + 'px'
// #endif
}
});
// #endif
// #endif
//
uni.getSystemInfo({
success: function(res) {
that.globalData.navHeight = res.statusBarHeight * (750 / res.windowWidth) + 91;
}
});
// #ifdef MP
let menuButtonInfo = uni.getMenuButtonBoundingClientRect();
that.globalData.navH = menuButtonInfo.top * 2 + menuButtonInfo.height / 2;
// #endif
// #ifdef MP
if (HTTP_REQUEST_URL == '') {
if (HTTP_REQUEST_URL === '') {
console.error(
"请配置根目录下的config.js文件中的 'HTTP_REQUEST_URL'\n\n请修改开发者工具中【详情】->【AppID】改为自己的Appid\n\n请前往后台【小程序】->【小程序配置】填写自己的 appId and AppSecret"
);
return false;
}
// TODO :
if (option.query.hasOwnProperty('scene')) {
switch(option.scene){
case 1047: //
case 1048: //
case 1049: //
case 1001: //
case 1047: //
case 1048: //
case 1049: //
case 1001: //
let value = this.$util.getUrlParams(decodeURIComponent(option.query.scene));
let values = value.split(',');
if(values.length === 2){
@ -73,28 +75,15 @@
}
}
// #endif
//
uni.getSystemInfo({
success: function(res) {
that.globalData.navHeight = res.statusBarHeight * (750 / res.windowWidth) + 91;
}
});
// #ifdef MP
let menuButtonInfo = uni.getMenuButtonBoundingClientRect();
that.globalData.navH = menuButtonInfo.top * 2 + menuButtonInfo.height / 2;
// #endif
// #ifdef H5
// #ifdef H5
// TODO
let snsapiBase = 'snsapi_base';
let urlData = location.pathname + location.search;
if (!that.$store.getters.isLogin && Auth.isWeixin()) {
const {
code,
state,
scope
} = option.query;
if (code && code != uni.getStorageSync('snsapiCode') && location.pathname.indexOf(
'/pages/users/wechat_login/index') === -1) {
const { code, state, scope } = option.query;
if (code && code != uni.getStorageSync('snsapiCode')
&& location.pathname.indexOf('/pages/users/wechat_login/index') === -1) {
// code
uni.setStorageSync('snsapiCode', code);
let spread = that.globalData.spid ? that.globalData.spid : 0;
@ -112,11 +101,7 @@
this.$store.commit("SETUID", res.uid);
location.replace(decodeURIComponent(decodeURIComponent(option.query.back_url)));
}
})
.catch(error => {
// this.$util.Tips({
// title: error
// });
}).catch(error => {
if (!this.$Cache.has('snsapiKey')) {
if (location.pathname.indexOf('/pages/users/wechat_login/index') === -1) {
Auth.oAuth(snsapiBase, option.query.back_url);
@ -138,7 +123,7 @@
// #endif
// #ifdef MP
//
// TODO
if (!this.$store.getters.isLogin) {
let spread = that.globalData.spid ? that.globalData.spid : 0;
Routine.getCode()
@ -148,22 +133,23 @@
}).then(res => {
// that.$store.commit('AuthorizeType', res.data.type);
})
})
.catch(res => {
}).catch(res => {
uni.hideLoading();
});
}
// #endif
},
async mounted() {
if(this.$store.getters.isLogin && !this.$Cache.get('USER_INFO'))await this.$store.dispatch('USERINFO');
},
methods: {
//
if (this.$store.getters.isLogin && !this.$Cache.get('USER_INFO')) {
await this.$store.dispatch('USERINFO');
}
},
onShow: function() {
// #ifdef H5
uni.getSystemInfo({
success(e) {
// TODO
/* 窗口宽度大于420px且不在PC页面且不在移动设备时跳转至 PC.html 页面 */
if (e.windowWidth > 420 && !window.top.isPC && !/iOS|Android/i.test(e.system)) {
// window.location.pathname = 'https://java.crmeb.net/';
@ -173,13 +159,9 @@
}
})
// #endif
},
onHide: function() {
//console.log('App Hide')
}
}
</script>
<style>
@import url("@/plugin/animate/animate.min.css");
@import 'static/css/base.css';