1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- <template>
- <view class="login" />
- </template>
- <script>
- export default {
- data() {
- return {
- path: '/pages/index/index',
- query: {}
- }
- },
- computed: {},
- methods: {
- login() {
- this.$loading('登陆中...')
- this.$api.user.login().then(async res => {
- this.$hideLoading()
- const { token, user_info } = res.data
- await this.$store.dispatch('user/token', token)
- await this.$store.dispatch('user/info', user_info)
- uni.reLaunch({
- url: this.path,
- success() {
- console.log('-->success')
- },
- fail(err) {
- uni.reLaunch({
- url: '/pages/index/index'
- })
- console.log('-->error', err)
- }
- })
- })
- }
- },
- onLoad(options) {
- console.log('-->data', options)
- this.path = options.path ? options.path : this.path
- this.path = this.path.replace('//', '/')
- this.path = this.path.indexOf('/') !== 0 ? '/' + this.path : this.path
- const query = options.query ? JSON.parse(decodeURI(options.query)) : {}
- const queryArr = []
- for (const queryKey in query) {
- queryArr.push(`${queryKey}=${query[queryKey]}`)
- }
- this.path = this.path + '?' + queryArr.join('&')
- this.login()
- }
- }
- </script>
- <style lang="scss" scoped>
- .login{
- }
- </style>
|