vue实现记录分享是否有上级

前言:

项目需要做活动分享功能(增加网站、app等访问量),但是,,,无功不受禄,也就需要分享时带上级ID,好友中奖,本人也受同样优惠

需求开发:

开发一个活动后,本人参加之后,分享给好友,增加自身中奖概率;

分享功能有两种:组队、好友

组队的话是不会记录给分享人的(就像最近淘宝双十一,扔骰子,分享给组队人是不会助力成功的,也就没有骰子)

但是分享给好友,好友点击助力是可以帮你拿骰子的

功能开发也类似,好友中奖你也中奖,分享给组队的人,组队的再分享给好友,好友的上级就是组队好友

所以就要区分分享的是组队还是好友,就需要有个变量了,这边就用“type”来区分吧

代码实现:

this.g_user=this.$store.state.query.user_at?this.$store.state.query.user_at:''//记录当前登录的用户
let parentUser = sessionStorage.getItem('parentUser') || ''//本地储存,看是否有上级
if(!parentUser){
  sessionStorage.setItem('parentUser',this.$route.query.user_at)
}
this.type= this.$route.query.type?this.$route.query.type:'';//看当前用户是好友还是组队if(this.type == 1){
  this.share_data.link = window.location.origin+'/indexActive?user_at='+this.g_user+'&type=2'
}else{
 this.share_data.link = window.location.origin+'/indexActive?user_at='+parentUser+'&type=2'//当前用户分享的链接
}

 

posted @ 2021-11-03 16:45  eternityAsr  阅读(80)  评论(0)    收藏  举报