| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- <script>
- import { mapMutations, mapActions, mapGetters } from 'vuex'
- import { setTimeout } from 'timers'
- import { getCheckLogin, getUser } from '@/utils/auth'
- export default {
- // 全端,数据共享,还可以解决页面初始化模板访问不到值得问题
- // 有坑 分包里的页面访问不到
- globalData: {
- },
- onLaunch() {
- // this.getAllOptions()
- // #ifdef MP-WEIXIN
- // wxLoginFn()
- // #endif
- // 开发
- uni.setStorageSync('token', 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImp0aSI6IjFfMTI1MzY2MzAifQ.eyJpc3MiOiJodHRwOlwvXC9tLmhoYi5jb20iLCJhdWQiOiJodHRwOlwvXC9tLmhoYi5jb20iLCJqdGkiOiIxXzEyNTM2NjMwIiwiaWF0IjoxNTc0NDIzMDc4LCJuYmYiOjE1NzQ0MjMwNzgsImV4cCI6MTU3NDQyNjY3OCwidXNlcklkIjoxMjUzNjYzMH0.v_T9NuFRpzuI7GtwuuuNlVg6EylImaCUwqo2A6NRTE4')
- uni.setStorageSync('account', '12358')
- // 登录
- if (this.$constant.source == 'business') {
- getCheckLogin().then(res => {
- if (res) {
- getUser()
- }
- })
- }
- },
- onShow() {
- // this.isLogin()
- },
- onHide() {
- },
- onError(err) {
- console.error(err, '错误捕获')
- },
- methods: {
- isLogin() {
- let token = uni.getStorageSync('token')
- if (!token) {
- uni.reLaunch({
- url: '/pages/page/login/index'
- })
- }
- }
- // ...mapMutations(['setLoginInfo'])
- // #ifdef MP-WEIXIN
- // wxLogin() {
- // uni.login({
- // provider: 'weixin',
- // success: res => {
- // uni.setStorageSync('code', res.code)
- // console.log(res.code, 'res.code')
- // postWxCode({ code: res.code }).then(subRes => {
- // const { openid, session_key, unionid } = subRes.data
- // this.setLoginInfo({
- // openid,
- // session_key,
- // unionid
- // })
- // })
- // }
- // })
- // }
- // #endif
- }
- }
- </script>
- <style lang="scss">
- //没有scss变量方法的,主要引入 这样打包的时候就不会所以的组件都打包进去
- @import './static/iconfont/iconfont.css';
- @import './static/css/uni2.css';
- @import './static/css/base.scss';
- @import './static/css/common.scss';
- @import './static/css/reset.scss';
- page {
- height: 100%;
- }
- </style>
|