123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343 |
- <script>
- import {
- HTTP_REQUEST_URL
- } from './config/app';
- import {
- loginConfigApi
- } from '@/api/public';
- import Auth from './libs/wechat.js';
- import Routine from './libs/routine.js';
- import {
- getTheme
- } from './api/api.js';
- import Cache from './utils/cache.js';
- import store from './store'
- import {
- silenceBindingSpread
- } from "./utils";
- var statusBarHeight = uni.getSystemInfoSync().statusBarHeight;
- export default {
- globalData: {
- spread: 0,
- isLogin: false,
- windowHeight: 0,
- navHeight: 0,
- navH: 0,
- id: 0,
- isIframe: false,
- theme: 'theme1',
- statusBarHeight: statusBarHeight,
- mainWidth: 0,
- marketingType: '',
- publicLoginType: Cache.get('publicLoginType') ? Cache.get('publicLoginType') : '',
- routinePhoneVerification: '1,2',
- companyName: uni.getStorageSync('companyName') ? uni.getStorageSync('companyName') : '欢迎你',
- tokenIsExist: false,
- mobileLoginLogo: uni.getStorageSync('mobileLoginLogo') || '/static/images/logo2.png',
- paidMemberPriceDisplay: 'all',
- userIsPaidMember: false,
- changeColorConfig: '',
- copyrightCompanyImage: '',
- frontDomain: '',
- imageDomain: '',
- authorizeAddress: '',
- authorizeFilingNum: '',
- authorizeInfo: '',
- authorizePhone: '',
- merId: 0
- },
- onLaunch: function(option) {
- let that = this;
-
- store.dispatch('GetLoginConfig');
-
- store.dispatch('GetGlobalConfig');
-
- store.dispatch("GetTokenIsExist");
-
- getTheme().then(res => {
- that.globalData.theme = `theme${Number(res.data.value)}`
- Cache.set('theme', `theme${Number(res.data.value)}`);
- store.commit('Change_GLOBAL_theme', `theme${Number(res.data.value)}`)
-
- window.document.documentElement.setAttribute('data-theme', that.globalData.theme);
-
- })
-
- uni.getSystemInfo({
- success: function(res) {
-
-
- let height = res.windowHeight - res.statusBarHeight - 44;
-
- that.globalData.windowHeight = res.windowHeight + 'px';
-
-
- that.globalData.navHeight = res.statusBarHeight * (750 / res.windowWidth) + 91;
-
- that.globalData.mainWidth = res.windowWidth
- store.commit('SYSTEM_PLATFORM', res.platform.toLowerCase());
- }
- });
-
- if (option.query.sd) {
- that.globalData.spread = option.query.sd;
- store.commit('GLOBAL_DATA', JSON.parse(JSON.stringify(that.globalData)));
- }
- if (option.sd) {
- that.globalData.spread = option.sd;
- store.commit('GLOBAL_DATA', JSON.parse(JSON.stringify(that.globalData)));
- }
-
-
- if (option.query.hasOwnProperty('scene')) {
- switch (option.scene) {
- case 1001:
- case 1047:
- case 1048:
- case 1049:
- case 1001:
- let value = this.$util.getUrlParams(decodeURIComponent(option.query.scene));
- that.globalData.spread = value.sd ? value.sd : '';
- that.globalData.id = value.id ? value.id : '';
- that.globalData.marketingType = value.mt ? value.mt : '0';
- that.globalData.merId = value.merId ? value.merId : '0';
- break;
- }
- }
- let menuButtonInfo = uni.getMenuButtonBoundingClientRect();
- that.globalData.navH = menuButtonInfo.top * 2 + menuButtonInfo.height / 2;
- const updateManager = uni.getUpdateManager();
- if (!updateManager) return;
- updateManager.onCheckForUpdate(function(res) {
-
- if (res.hasUpdate) {
- updateManager.onUpdateReady(function(res2) {
- uni.showModal({
- title: '更新提示',
- content: '发现新版本,是否重启应用?',
- cancelColor: '#eeeeee',
- confirmColor: '#FF0000',
- success(res2) {
- if (res2.confirm) {
-
- updateManager.applyUpdate();
- }
- }
- });
- });
- }
- });
- updateManager.onUpdateFailed(function(res) {
-
- uni.showModal({
- title: '提示',
- content: '检查到有新版本,但下载失败,请检查网络设置',
- success(res) {
- if (res.confirm) {
-
- updateManager.applyUpdate();
- }
- }
- });
- });
- if (HTTP_REQUEST_URL == '') {
- console.error(
- "请配置根目录下的config.js文件中的 'HTTP_REQUEST_URL'\n\n请修改开发者工具中【详情】->【AppID】改为自己的Appid\n\n请前往后台【小程序】->【小程序配置】填写自己的 appId and AppSecret"
- );
- return false;
- }
-
-
- if (option.query.hasOwnProperty('type') && option.query.type == "iframeVisualizing") {
- this.globalData.isIframe = true;
- } else {
- this.globalData.isIframe = false;
- }
-
- let snsapiBase = 'snsapi_base';
- let urlData = location.pathname + location.search;
-
- if (!store.getters.isLogin && Auth.isWeixin() && this.globalData.publicLoginType == 1 && !that.globalData
- .tokenIsExist) {
- const {
- code,
- state,
- scope
- } = option.query;
- if (code && code != uni.getStorageSync('snsapiCode') && location.pathname.indexOf(
- '/pages/users/wechat_login/index') === -1) {
-
- uni.setStorageSync('snsapiCode', code);
- let spread = that.globalData.spread ? that.globalData.spread : 0;
- Auth.auth(code, Cache.get('spread'))
- .then(res => {
- uni.setStorageSync('snRouter', decodeURIComponent(decodeURIComponent(option.query
- .back_url)));
- if (res.type === 'register') {
- Cache.set('snsapiKey', res.key);
- }
- if (res.type === 'login') {
- store.commit('LOGIN', {
- token: res.token
- });
- store.commit("SETUID", res.id);
- location.replace(decodeURIComponent(decodeURIComponent(option.query.back_url)));
- }
- })
- .catch(error => {
- if (!Cache.has('snsapiKey')) {
- if (location.pathname.indexOf('/pages/users/wechat_login/index') === -1) {
- Auth.oAuth(snsapiBase, option.query.back_url);
- }
- }
- });
- } else {
- if (!Cache.has('snsapiKey')) {
- if (location.pathname.indexOf('/pages/users/wechat_login/index') === -1) {
- Auth.oAuth(snsapiBase, urlData);
- }
- }
- }
- } else {
- if (option.query.back_url) {
- location.replace(uni.getStorageSync('snRouter'));
- }
- }
-
-
-
- if (Cache.get('UID') && !Cache.get('wechatQRcode')) {
- Routine.getQrcode()
- }
-
- if (!store.getters.isLogin) {
- Routine.getCode().then(code => {
- let userInfo = {
- code: code,
- spreadPid: this.globalData.spread,
- type: 'routine'
- };
- Routine.authUserInfo(userInfo)
- })
- .catch(res => {
- uni.hideLoading();
- });
- }
-
-
- silenceBindingSpread(store.getters.isLogin, this.globalData.spread)
-
- store.commit('GLOBAL_DATA', JSON.parse(JSON.stringify(that.globalData)));
- },
- async mounted() {
-
- },
- methods: {
- handleResize(e) {
-
- if (e.size.windowWidth > 430 && !/iOS|Android/i.test(e.system)) {
-
-
- window.location.pathname = '/static/html/pc.html';
- }
- }
- },
- onShow: function() {
-
- uni.onWindowResize(this.handleResize);
-
- },
- onUnload() {
-
- uni.offWindowResize(this.handleResize);
- },
- }
- </script>
- <style>
- .uno-start {
- --un: 0;
- }
-
- .uno-end {
- --un: 0;
- }
- </style>
- <style lang="scss">
- /* #ifndef APP-PLUS-NVUE || APP-NVUE */
- @import "@/plugin/animate/animate.min.css";
- @import 'static/css/unocss.css';
- @import 'static/css/base.css';
- @import 'static/css/style.scss';
- @import 'static/iconfont/iconfont.css';
- @import 'static/fonts/font.css';
- view {
- box-sizing: border-box;
- }
- body::-webkit-scrollbar,
- html::-webkit-scrollbar {
- display: none;
- }
- .bg-color-red {
- background-color: #E93323;
- }
- .syspadding {
- padding-top: var(--status-bar-height);
- }
- /deep/.uni-scroll-view::-webkit-scrollbar {
- /* 隐藏滚动条,但依旧具备可以滚动的功能 */
- display: none
- }
- ::-moz-scrollbar {
- width: 0;
- height: 0;
- color: transparent;
- }
- ::-webkit-scrollbar {
- display: none;
- width: 0 !important;
- height: 0 !important;
- -webkit-appearance: none;
- background: transparent;
- }
- checkbox.mycheck .wx-checkbox-input,
- checkbox.mycheck .uni-checkbox-input {
- width: 30rpx !important;
- height: 30rpx !important;
- background-color: #fff !important;
- border-radius: 4rpx !important;
- border: 2rpx solid #D6D7DC !important;
- }
- // 选中后的 对勾样式
- checkbox.mycheck .uni-checkbox-input-checked::before,
- checkbox.mycheck .wx-checkbox-input-checked::before {
- // width: 25rpx !important; // 选中后对勾大小,不要超过背景的尺寸
- // height: 25rpx !important; // 选中后对勾大小,不要超过背景的尺寸
- font-size: 36rpx !important; // 对勾大小 30rpx
- color: #fff !important;
- background-color: $bg-color-primary;
- }
- /*#endif*/
- </style>
|