| | |
| | | <script> |
| | | import Vue from 'vue' |
| | | import { |
| | | getUserInfor, |
| | | getDic |
| | | } from '@/utils/login.js' // 配置文件 |
| | | import store from '@/store/index.js' |
| | | import { |
| | | httpPost, |
| | | httpGet |
| | | } from '@/utils/http.js' |
| | | export default { |
| | | onLaunch: function() { |
| | | onLaunch() { |
| | | // 自动登录检测 |
| | | this.getUserInfo() |
| | | }, |
| | | methods: { |
| | | /** |
| | | * 自动登录 |
| | | * 判断本地是否有账号信息,如果有,就自动重新登录 |
| | | * |
| | | */ |
| | | getUserInfo() { |
| | | let token = uni.getStorageSync('token') |
| | | console.log('apptoken', token) |
| | | if (!token) { |
| | | uni.login({ |
| | | provider: 'weixin', |
| | | success(res) { |
| | | if (res.code) { |
| | | // 调用接口。将登录code传给后端进行判断 |
| | | httpGet('/AppUser/wx/login', { |
| | | 'code': res.code |
| | | }).then(result => { |
| | | success: loginRes => { |
| | | console.log('loginRes', loginRes) |
| | | httpGet('/AppUser/wx/login', { |
| | | 'code': loginRes.code |
| | | }).then(result => { |
| | | try { |
| | | if (result.data.code === 0) { |
| | | // 存在用户 |
| | | uni.clearStorageSync() |
| | | uni.setStorageSync('token', result.data.token) |
| | | // setTimeout(() => { |
| | | // uni.reLaunch({ |
| | | // url: '/pages/actionChange/agencyPage/index', |
| | | // }) |
| | | // }, 3000) |
| | | getUserInfor(result.data.token) |
| | | uni.setStorageSync('userInfor', JSON.stringify(result.data)) |
| | | uni.setStorageSync('tonken', result.data.token) |
| | | getDic() |
| | | this.$isResolve() |
| | | } else { |
| | | // 不存在用户 |
| | | uni.clearStorageSync() |
| | | uni.setStorageSync('openId', result.data.openId) |
| | | uni.showModal({ |
| | | title: '未登录', |
| | |
| | | } |
| | | }, |
| | | }) |
| | | this.$isResolve() |
| | | } |
| | | } catch (e) { |
| | | console.error(e) |
| | | } |
| | | }).catch(errors => { |
| | | console.log('appdddd', errors) |
| | | uni.showToast({ |
| | | title: errors, |
| | | icon: 'none', |
| | | }) |
| | | } else { |
| | | console.log(res.errMsg) |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | } else { |
| | | this.$isResolve() |
| | | } |
| | | }, |
| | | methods: { |
| | | /** |
| | | * 自动登录 |
| | | * 判断本地是否有账号信息,如果有,就自动重新登录 |
| | | * |
| | | */ |
| | | getWXCode() { |
| | | let that = this |
| | | uni.login({ |
| | | provider: 'weixin', |
| | | success(res) { |
| | | that.getLogin(res.code) |
| | | } |
| | | }) |
| | | }, |
| | | getLogin(data) { |
| | | // 调用接口。将登录code传给后端进行判断 |
| | | httpGet('/AppUser/wx/login', { |
| | | 'code': data |
| | | }).then(result => { |
| | | if (result.data.code === 0) { |
| | | // 存在用户 |
| | | uni.clearStorage() |
| | | store.commit('setUserInfor', result.data) |
| | | store.commit('setTonken', result.data.token) |
| | | getDic() |
| | | try { |
| | | this.$isResolve() |
| | | } catch (e) { |
| | | console.error(e) |
| | | } |
| | | // getUserInfor(result.data.token) |
| | | } else { |
| | | // 不存在用户 |
| | | // console.log('openId', result.data.openId) |
| | | } |
| | | }) |
| | | } |
| | | }, |
| | | } |
| | | </script> |
| | |
| | | |
| | | .formItemContent { |
| | | ::v-deep.u-form-item { |
| | | padding: 8px 0; |
| | | padding: 5px 0; |
| | | border-bottom: 1px dashed #bbb; |
| | | } |
| | | |
| | | ::v-deep.u-form-item__body__left__content__label { |
| | | font-size: 16px !important; |
| | | } |
| | | |
| | | ::v-deep.u-form-item__body, |
| | | /deep/.u-textarea { |
| | | padding: 0 !important; |
| | | } |
| | | } |
| | | |
| | | ::v-deep.u-form-item__body__left__content__label, |
| | | /deep/.u-radio__text { |
| | | font-size: 13px !important; |
| | | .tabarStyle { |
| | | /deep/.u-tabbar-item__text { |
| | | font-size: 18px !important; |
| | | } |
| | | |
| | | /deep/.u-tabbar__content__item-wrapper { |
| | | height: 60px !important; |
| | | } |
| | | |
| | | /deep/.u-icon__icon { |
| | | font-size: 25px !important; |
| | | } |
| | | } |
| | | |
| | | .dataRangeSerch { |
| | | |
| | | /deep/.range-separator, |
| | | /deep/.uni-date__x-input { |
| | | height: 30px !important; |
| | | line-height: 30px !important; |
| | | } |
| | | } |
| | | </style> |