123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- <script>
- import {
- getToken
- } from '@/utils/auth';
- import {
- ParseAccessToken
- } from '@/api/api';
- import {
- loginControlIsEffectiveUser
- } from '@/api/user.js';
- export default {
- onLaunch: function(options) {
- // console.log(window.location);
- },
- onShow: function() {
- // console.log('App Show')
- },
- onHide: function() {
- // console.log('App Hide')
- },
- /* 配置页面未找到 */
- onPageNotFound: function(options) {
- const openShare = 'open/share/exercise';
- const _path = window.location.hash;
- if (_path.includes(openShare)) {
- const share_record_id = options.query.share_record_id;
- uni.getStorage({
- key: 'AccessToken',
- success: function(res) {
- ParseAccessToken({
- access_token: res.data
- }).then(({
- is_effective
- }) => {
- if (is_effective == 'true' && share_record_id) {
- uni.navigateTo({
- url: '/pages/answer_question/answer/index?share_record_id=' + share_record_id +
- '&isScanCode=true'
- })
- } else {
- uni.navigateTo({
- url: '/pages/login/index?share_record_id=' + share_record_id
- })
- }
- });
- },
- fail: function(error) {
- uni.navigateTo({
- url: '/pages/login/index?share_record_id=' + share_record_id
- })
- }
- })
- } else {
- uni.getStorage({
- key: 'AccessToken',
- success: function(res) {
- ParseAccessToken({
- access_token: res.data
- }).then(({
- is_effective
- }) => {
- if (is_effective == 'true') {
- uni.navigateTo({
- url: options.path,
- fail(error) {
- uni.redirectTo({
- url: "pages/404", // 404 页面的路径
- });
- }
- })
- } else {
- uni.navigateTo({
- url: '/pages/login/index'
- })
- }
- });
- },
- fail: function(error) {
- uni.navigateTo({
- url: '/pages/login/index'
- })
- }
- })
- }
- },
- }
- </script>
- <style>
- /*每个页面公共css */
- body {
- background-color: #f4f2f4;
- }
- /*去掉浏览器输入框自带小眼睛图标*/
- .uni-easyinput__content-input ::-ms-reveal {
- display: none;
- }
- .uni-easyinput__content-input ::-ms-clear {
- display: none;
- }
- .uni-easyinput__content-input ::-o-clear {
- display: none;
- }
- /*图片等比缩放*/
- /deep/ img {
- width: auto;
- height: auto;
- max-width: 100%;
- max-height: 100%;
- }
- </style>
|