|
@@ -1,5 +1,5 @@
|
|
<script>
|
|
<script>
|
|
-
|
|
|
|
|
|
+import Cache from './utils/cache'
|
|
export default {
|
|
export default {
|
|
globalData: {
|
|
globalData: {
|
|
isLogin: false
|
|
isLogin: false
|
|
@@ -9,9 +9,26 @@ export default {
|
|
console.log('App Launch')
|
|
console.log('App Launch')
|
|
const path = options.path ? '/' + options.path : '/pages/index/index'
|
|
const path = options.path ? '/' + options.path : '/pages/index/index'
|
|
const query = options.query
|
|
const query = options.query
|
|
|
|
+ // 直接传递user_id
|
|
|
|
+ if (typeof query.user_id !== 'undefined' && query.user_id) {
|
|
|
|
+ Cache.set('parent_id', query.user_id)
|
|
|
|
+ }
|
|
|
|
+ // 微信小程序 对应的二维码是 scene_code
|
|
|
|
+ if (typeof query.scene_code !== 'undefined' && query.scene_code) {
|
|
|
|
+ Cache.set('parent_id', query.scene_code)
|
|
|
|
+ }
|
|
if (this.$api.user.isLogin()) {
|
|
if (this.$api.user.isLogin()) {
|
|
await this.$api.user.info().then(res => {
|
|
await this.$api.user.info().then(res => {
|
|
this.$store.dispatch('user/info', res.data)
|
|
this.$store.dispatch('user/info', res.data)
|
|
|
|
+ // 绑定上级
|
|
|
|
+ const parentId = Cache.get('parent_id')
|
|
|
|
+ if (parentId && !res.data.info.parent_id) {
|
|
|
|
+ this.$api.user.bind(parentId).then(res => {
|
|
|
|
+ console.log('-->bind parent success')
|
|
|
|
+ this.$store.dispatch('user/info', res.data)
|
|
|
|
+ Cache.remove('parent_id')
|
|
|
|
+ })
|
|
|
|
+ }
|
|
})
|
|
})
|
|
} else {
|
|
} else {
|
|
uni.reLaunch({
|
|
uni.reLaunch({
|