瀏覽代碼

feat: 优化小程序

xiansin 2 年之前
父節點
當前提交
58b214600c
共有 1 個文件被更改,包括 23 次插入2 次删除
  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()
   }
 }