123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- // 分享
- import { mapMutations } from 'vuex'
- const shareEntry = {
- data() {
- return {
- // 分享链接携带的数据
- shareData: {
- type: '',
- inviteUserId: '',
- activityId: '',
- productId: '',
- userId: '',
- keyWord: '',
- jumpState: ''
- }
- }
- },
- methods: {
- ...mapMutations('user', ['setInviteUserId']),
- // 处理分享参数
- shareHandle(option) {
- let state_str = option.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
- this.setInviteUserId(this.shareData.inviteUserId)
- this.jumpTopSharePage()
- } catch (e) {
- console.log(e)
- return
- }
- },
- // 跳转到对应的分享页面
- jumpTopSharePage() {
- if (!this.shareData.type || this.shareData.type === 0) return
- const path = {
- 0: '/pages/tabBar/index/index', //首页
- 1: `/pages/goods/product-detail?productId=${this.shareData.productId}&jumpState=${this.shareData.jumpState}`, //商品详情
- 2: `/pages/goods/search?type=share&keyWord=${this.shareData.keyWord}`, // 搜索页面
- 3: `/pages/user/activity/activity?type=share&activityId=${this.shareData.activityId}&userId=${this.shareData.userId}`, //活动商品列表
- 4: `/pages/fight-order/fight-share-entry?type=share&collageId=${this.shareData.collageId}&initiatorId=${this.shareData.initiatorId}` // 拼团分享
- }
- // 1000 ms后跳转
- setTimeout(() => {
- this.$api.navigateTo(path[this.shareData.type])
- }, 1000)
- }
- }
- }
- export default shareEntry
|