parent
72385f8ed8
commit
8e2d28d27a
80
App.vue
80
App.vue
|
@ -1,17 +1,7 @@
|
||||||
<script>
|
<script>
|
||||||
import {
|
import { HTTP_REQUEST_URL } from './config/app';
|
||||||
checkLogin
|
|
||||||
} from "./libs/login";
|
|
||||||
import {
|
|
||||||
HTTP_REQUEST_URL
|
|
||||||
} from './config/app';
|
|
||||||
import Auth from './libs/wechat.js';
|
import Auth from './libs/wechat.js';
|
||||||
import Routine from './libs/routine.js';
|
import Routine from './libs/routine.js';
|
||||||
import Apps from './libs/apps.js';
|
|
||||||
import {
|
|
||||||
mapActions
|
|
||||||
} from 'vuex'
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
globalData: {
|
globalData: {
|
||||||
spid: 0,
|
spid: 0,
|
||||||
|
@ -24,6 +14,7 @@
|
||||||
},
|
},
|
||||||
onLaunch: function(option) {
|
onLaunch: function(option) {
|
||||||
let that = this;
|
let that = this;
|
||||||
|
// 获得全局的 window 高度
|
||||||
// #ifdef H5
|
// #ifdef H5
|
||||||
uni.getSystemInfo({
|
uni.getSystemInfo({
|
||||||
success: function(res) {
|
success: function(res) {
|
||||||
|
@ -33,24 +24,35 @@
|
||||||
// #ifdef H5
|
// #ifdef H5
|
||||||
that.globalData.windowHeight = res.windowHeight + 'px'
|
that.globalData.windowHeight = res.windowHeight + 'px'
|
||||||
// #endif
|
// #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
|
// #ifdef MP
|
||||||
if (HTTP_REQUEST_URL == '') {
|
if (HTTP_REQUEST_URL === '') {
|
||||||
console.error(
|
console.error(
|
||||||
"请配置根目录下的config.js文件中的 'HTTP_REQUEST_URL'\n\n请修改开发者工具中【详情】->【AppID】改为自己的Appid\n\n请前往后台【小程序】->【小程序配置】填写自己的 appId and AppSecret"
|
"请配置根目录下的config.js文件中的 'HTTP_REQUEST_URL'\n\n请修改开发者工具中【详情】->【AppID】改为自己的Appid\n\n请前往后台【小程序】->【小程序配置】填写自己的 appId and AppSecret"
|
||||||
);
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
// TODO 芋艿: 分销
|
||||||
if (option.query.hasOwnProperty('scene')) {
|
if (option.query.hasOwnProperty('scene')) {
|
||||||
switch(option.scene){
|
switch(option.scene){
|
||||||
case 1047: //扫描小程序码
|
case 1047: // 扫描小程序码
|
||||||
case 1048: //长按图片识别小程序码
|
case 1048: // 长按图片识别小程序码
|
||||||
case 1049: //手机相册选取小程序码
|
case 1049: // 手机相册选取小程序码
|
||||||
case 1001: //直接进入小程序
|
case 1001: // 直接进入小程序
|
||||||
let value = this.$util.getUrlParams(decodeURIComponent(option.query.scene));
|
let value = this.$util.getUrlParams(decodeURIComponent(option.query.scene));
|
||||||
let values = value.split(',');
|
let values = value.split(',');
|
||||||
if(values.length === 2){
|
if(values.length === 2){
|
||||||
|
@ -73,28 +75,15 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// #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 H5
|
// #ifdef H5
|
||||||
|
// TODO 芋艿:公众号的静默授权
|
||||||
let snsapiBase = 'snsapi_base';
|
let snsapiBase = 'snsapi_base';
|
||||||
let urlData = location.pathname + location.search;
|
let urlData = location.pathname + location.search;
|
||||||
if (!that.$store.getters.isLogin && Auth.isWeixin()) {
|
if (!that.$store.getters.isLogin && Auth.isWeixin()) {
|
||||||
const {
|
const { code, state, scope } = option.query;
|
||||||
code,
|
if (code && code != uni.getStorageSync('snsapiCode')
|
||||||
state,
|
&& location.pathname.indexOf('/pages/users/wechat_login/index') === -1) {
|
||||||
scope
|
|
||||||
} = option.query;
|
|
||||||
if (code && code != uni.getStorageSync('snsapiCode') && location.pathname.indexOf(
|
|
||||||
'/pages/users/wechat_login/index') === -1) {
|
|
||||||
// 存储静默授权code
|
// 存储静默授权code
|
||||||
uni.setStorageSync('snsapiCode', code);
|
uni.setStorageSync('snsapiCode', code);
|
||||||
let spread = that.globalData.spid ? that.globalData.spid : 0;
|
let spread = that.globalData.spid ? that.globalData.spid : 0;
|
||||||
|
@ -112,11 +101,7 @@
|
||||||
this.$store.commit("SETUID", res.uid);
|
this.$store.commit("SETUID", res.uid);
|
||||||
location.replace(decodeURIComponent(decodeURIComponent(option.query.back_url)));
|
location.replace(decodeURIComponent(decodeURIComponent(option.query.back_url)));
|
||||||
}
|
}
|
||||||
})
|
}).catch(error => {
|
||||||
.catch(error => {
|
|
||||||
// this.$util.Tips({
|
|
||||||
// title: error
|
|
||||||
// });
|
|
||||||
if (!this.$Cache.has('snsapiKey')) {
|
if (!this.$Cache.has('snsapiKey')) {
|
||||||
if (location.pathname.indexOf('/pages/users/wechat_login/index') === -1) {
|
if (location.pathname.indexOf('/pages/users/wechat_login/index') === -1) {
|
||||||
Auth.oAuth(snsapiBase, option.query.back_url);
|
Auth.oAuth(snsapiBase, option.query.back_url);
|
||||||
|
@ -138,7 +123,7 @@
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
// #ifdef MP
|
// #ifdef MP
|
||||||
// 小程序静默授权
|
// 小程序静默授权 TODO 芋艿:
|
||||||
if (!this.$store.getters.isLogin) {
|
if (!this.$store.getters.isLogin) {
|
||||||
let spread = that.globalData.spid ? that.globalData.spid : 0;
|
let spread = that.globalData.spid ? that.globalData.spid : 0;
|
||||||
Routine.getCode()
|
Routine.getCode()
|
||||||
|
@ -148,22 +133,23 @@
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
// that.$store.commit('AuthorizeType', res.data.type);
|
// that.$store.commit('AuthorizeType', res.data.type);
|
||||||
})
|
})
|
||||||
})
|
}).catch(res => {
|
||||||
.catch(res => {
|
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// #endif
|
// #endif
|
||||||
},
|
},
|
||||||
async mounted() {
|
async mounted() {
|
||||||
if(this.$store.getters.isLogin && !this.$Cache.get('USER_INFO'))await this.$store.dispatch('USERINFO');
|
// 读取用户的基本信息
|
||||||
},
|
if (this.$store.getters.isLogin && !this.$Cache.get('USER_INFO')) {
|
||||||
methods: {
|
await this.$store.dispatch('USERINFO');
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onShow: function() {
|
onShow: function() {
|
||||||
// #ifdef H5
|
// #ifdef H5
|
||||||
uni.getSystemInfo({
|
uni.getSystemInfo({
|
||||||
success(e) {
|
success(e) {
|
||||||
|
// TODO 芋艿:这样是否合理???
|
||||||
/* 窗口宽度大于420px且不在PC页面且不在移动设备时跳转至 PC.html 页面 */
|
/* 窗口宽度大于420px且不在PC页面且不在移动设备时跳转至 PC.html 页面 */
|
||||||
if (e.windowWidth > 420 && !window.top.isPC && !/iOS|Android/i.test(e.system)) {
|
if (e.windowWidth > 420 && !window.top.isPC && !/iOS|Android/i.test(e.system)) {
|
||||||
// window.location.pathname = 'https://java.crmeb.net/';
|
// window.location.pathname = 'https://java.crmeb.net/';
|
||||||
|
@ -173,13 +159,9 @@
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
// #endif
|
// #endif
|
||||||
},
|
|
||||||
onHide: function() {
|
|
||||||
//console.log('App Hide')
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
@import url("@/plugin/animate/animate.min.css");
|
@import url("@/plugin/animate/animate.min.css");
|
||||||
@import 'static/css/base.css';
|
@import 'static/css/base.css';
|
||||||
|
|
Loading…
Reference in New Issue