1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- // 分享
- import { mapMutations } from 'vuex'
- const shareEntry = {
- data() {
- return {
- shareData: {
- type: '',
- inviteUserId: '',
- activityId: '',
- productId: '',
- userId: '',
- keyWord: '',
- jumpState: ''
- }
- }
- },
- methods: {
- ...mapMutations('user', ['setInviteUserId']),
- // 处理分享参数
- shareHandle(option) {
- const state_str = decodeURIComponent(option.state_str)
- if (!state_str) return
- // 解密参数
- this.shareData = {
- ...this.shareData,
- ...JSON.parse(this.$crypto.decrypt(state_str))
- }
- // 保存分享者的用户id
- this.setInviteUserId(this.shareData.inviteUserId)
- this.jumpTopSharePage()
- },
- // 跳转到对应的分享页面
- 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}` //活动商品列表
- }
- // 200 ms后跳转
- setTimeout(() => {
- this.$api.navigateTo(path[this.shareData.type])
- }, 200)
- }
- }
- }
- export default shareEntry
|