| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216 |
- <script>
- import Vue from 'vue'
- import Wechat from '@/util/wechat/wechat.js'
- import mpWx from '@/common/mpWX.js'
- import store from '@/store'
- import { updateCheck } from "@/util/index.js"
- export default {
- computed:{
-
- },
- methods: {
- // 获取系统栏高度
-
- async setAppInfo() {
- let that = this;
- let platform = '';
- return new Promise((resolve, reject) => {
- uni.getSystemInfo({
- success: function(e) {
- Vue.prototype.StatusBar = e.statusBarHeight;
- // #ifdef H5
- Vue.prototype.CustomBar = e.statusBarHeight + 45;
- Vue.prototype.SystemInfo = e;
-
- if (that.$wxsdk.isWechat()) {
- platform = 'wxOfficialAccount';
- } else {
- platform = 'H5';
- }
- // #endif
-
- // #ifdef APP-PLUS
- platform = 'App';
- if (e.platform == 'android') {
- uni.setStorageSync('isAndroid', true);
- Vue.prototype.CustomBar = e.statusBarHeight + 50;
- } else {
- Vue.prototype.CustomBar = e.statusBarHeight + 45;
- uni.setStorageSync('isAndroid', false);
- }
- // #endif
-
- // #ifdef MP-WEIXIN
- platform = 'wxMiniProgram';
- // new Wechat().getWxMiniProgramSessionKey();
- let custom = wx.getMenuButtonBoundingClientRect();
- Vue.prototype.Custom = custom;
- Vue.prototype.CustomBar = custom.bottom + custom.top - e.statusBarHeight;
- // #endif
- uni.setStorageSync('platform', platform);
- resolve(platform);
- }
- });
- });
-
- },
- // 自动登录
- async autoLogin(options) {
- // let initData = data;
- var wechat = new Wechat();
- if (!uni.getStorageSync('token')) {
- // #ifdef H5
- // await wechat.login();
- // #endif
- }else {
- // 已经登录
- this.jumpPage()
- }
- },
- jumpPage(){
- // if(window.location.hash.indexOf('page') < 0){
- // // uni.switchTab({
- // // url: '/pages/index/index'
- // // });
- // }else{
- // uni.switchTab({
- // url: window.location.hash.split('#')[1]
- // });
- // }
- },
- wechatLogin() {
-
- // mpWx.checkSession().then(res => {
- // console.log(res, 222)
- // })
-
- // mpWx.getUserInfo().then(res => {
- // console.log(res)
- // })
-
- // 微信登录
- mpWx.login().then(code => {
- // 获取openId
- store.dispatch("getOpenId", {code: code}).then(res => {
- setTimeout(() => {
- uni.reLaunch({
- url: '/pages/signs/main/main',
- })
- })
- })
- })
-
- // uni.switchTab({
- // url: "/pages/signs/me/me"
- // })
-
- }
- },
- onLaunch: async function(options) {
- console.log(options)
- // 初始化
- await this.setAppInfo();
-
- // 检查更新
- // #ifdef MP-WEIXIN
- updateCheck.call(this)
- // #endif
-
- // #ifdef MP-WEIXIN
- this.wechatLogin()
- // #endif
-
-
- // #ifdef H5
- try {
- // await this.autoLogin(options.query);
- } catch (e) {
-
- }
- // #endif
- },
- onPageNotFound(){
- uni.reLaunch({
- url: '/pages/signs/main/main',
- })
- },
- onUnhandledRejection(e) {
- // console.log(e)
- // console.log(this)
- uni.showModal({
- title: '提示',
- content: "加载失败,请尝试刷新"
- });
- }
- }
- </script>
- <style lang="scss">
- /*每个页面公共css */
- @import "@/uni_modules/colorui/main.css";
- @import "@/uni_modules/uview-ui/index.scss";
- @import "@/uni_modules/uview-ui/theme.scss";
- @import "common/demo.scss";
- @import "common/fontFamily/fontCss.css";
-
- uni-radio:not([disabled]) .uni-radio-input:hover,
- uni-checkbox:not([disabled]) .uni-checkbox-input:hover {
- border-color: #ccc !important;
- }
-
- page {
- -webkit-overflow-scrolling: touch; //ios滑动不流畅
- height: 100%;
- background: #f6f6f6;
- width: 100%;
- font-size: 30upx;
- font-family: NotoSansHans-Bold;
- word-break: break-all; //英文文本不换行
- color: #333;
- }
- ::-webkit-scrollbar {
- width: 0;
- height: 0;
- color: transparent;
- display: none;
- }
-
-
- page{
- height: 100%;
- }
- .app-full{
- background-color: $app-bg-color;
- height: 100%;
- }
- .app-page{
- background-color: $app-bg-color;
- height: 100%;
- padding-bottom: 100rpx;
-
- /* #ifndef H5*/
- min-height: 100%
- /* #endif */
-
- /* #ifdef H5 */
- padding-bottom: 100rpx;
- /* #endif */
- }
-
- .box-head{
- display: flex;
- align-items: center;
- background: linear-gradient(90deg, rgba(121,169,206,0.4) 0%, rgba(121,169,206,0) 100%);
- border-radius: 2rpx;
- width: 259rpx;
- height: 50rpx;
- padding-left: 28rpx;
- border-left: 8rpx solid #79A9CE;
- .name{
- font-size: 28rpx;
- font-family: PingFang SC;
- font-weight: bold;
- color: #333333;
- }
- }
- </style>
|