const shareEntry = { data() { return { // 分享链接携带的数据 shareData: { type: '', inviteUserId: '', // 邀请者用户ID activityId: '', // 分享者活动ID dealerUserId: '', // 协销用户ID keyWord: '', // 搜索关键词 productId: '', // 产品ID jumpState: '' // 跳转类型 普通用户 协销 } } }, methods: { // 处理分享参数 shareHandle(state_str) { if (!state_str) return state_str = decodeURIComponent(state_str) try { const decrypt = this.$crypto.decrypt(state_str) // 解密参数 this.shareData = { ...this.shareData, ...JSON.parse(decrypt) } // 保存分享者的用户id if (this.shareData.inviteUserId) { this.$store.commit('SET_INVITE_USER_ID', this.shareData.inviteUserId) } this.shareData.type = parseInt(this.shareData.type) this.jumpTopSharePage() } catch (e) { return } }, // 跳转到对应的分享页面 jumpTopSharePage() { const { type = 0, collageId, jumpState, productId, dealerUserId, keyWord } = this.shareData const path = { 0: 'home', //首页 1: `goods/goods-detail?jumpState=${jumpState}&productId=${productId}`, //商品详情 2: `goods/goods-search?keyWord=${keyWord}`, // 搜索页面 3: `activity/activity-detail?dealerUserId=${dealerUserId}`, //活动商品列表 4: `share-buy/share-buy-entry?collageId=${collageId}` // 拼团分享 } if (type === 0) { this.$router.switchTab(path[type]) } else { this.$router.redirectTo(path[type]) } } } } export default shareEntry