| xqd
@@ -53,6 +53,7 @@ import NavBar from '../../components/NavBar/index'
|
|
|
import Recent from './components/Recent'
|
|
|
import CheckLogin from '../../components/CheckLogin/index'
|
|
|
import { mapState } from 'vuex'
|
|
|
+import Cache from '../../utils/cache'
|
|
|
export default {
|
|
|
components: { CheckLogin, Recent, NavBar, TabBar, EpisodeBox, SwiperBox },
|
|
|
data() {
|
| xqd
@@ -78,8 +79,13 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
onLoad(options) {
|
|
|
+ // 微信小程序 对应的二维码是 scene_code
|
|
|
+ if (typeof options.scene !== 'undefined' && options.scene) {
|
|
|
+ Cache.set('parent_id', options.scene)
|
|
|
+ }
|
|
|
console.log('-->index data', options)
|
|
|
this.isLogin && this.getHomeColumn()
|
|
|
+ this.isLogin && this.bindParent()
|
|
|
},
|
|
|
methods: {
|
|
|
handleSearch() {
|
| xqd
@@ -103,10 +109,14 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
bindParent() {
|
|
|
- this.$api.user.bind(this.parent_id ? this.parent_id : this.scene_code).then(res => {
|
|
|
- console.log('-->bind success')
|
|
|
- this.$store.dispatch('user/info', res.data)
|
|
|
- })
|
|
|
+ const parentId = Cache.get('parent_id')
|
|
|
+ if (parentId && !this.userInfo.parent_id) {
|
|
|
+ this.$api.user.bind(parentId).then(res => {
|
|
|
+ console.log('-->bind success')
|
|
|
+ this.$store.dispatch('user/info', res.data)
|
|
|
+ Cache.remove('parent_id')
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
onShareAppMessage() {
|