parent
72385f8ed8
commit
8e2d28d27a
84
App.vue
84
App.vue
|
@ -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';
|
||||
|
|
Loading…
Reference in New Issue