Browse Source

feat: 优化小程序

xiansin 2 years ago
parent
commit
58b214600c
1 changed files with 23 additions and 2 deletions
  1. 23 2
      mini/pages/login.vue

+ 23 - 2
mini/pages/login.vue

xqd xqd
@@ -6,7 +6,8 @@
 export default {
   data() {
     return {
-      path: '/pages/index/index'
+      path: '/pages/index/index',
+      query: {}
     }
   },
   computed: {},
@@ -19,13 +20,33 @@ export default {
         await this.$store.dispatch('user/token', token)
         await this.$store.dispatch('user/info', user_info)
         uni.reLaunch({
-          url: this.path.replace('//', '/')
+          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()
   }
 }