"use strict";const e=require("../../common/vendor.js"),r=require("../store/index.js"),a=require("./index.js"),o=require("../router/index.js"),s=require("../url/index.js"),i=["H5","WechatOfficialAccount","WechatMiniProgram","App"],t=["forward","poster","link"],d=e=>{const o=r.$store("user");let s="0";void 0===e.shareId&&o.isLogin&&(s=o.userInfo.id);let t="1";void 0!==e.page&&(t=e.page);let d="0";void 0!==e.query&&(d=e.query);let n=i.indexOf(a._platform.name)+1,p="1";return void 0!==e.from&&(p=i.indexOf(e.from)+1),`spm=${s}.${t}.${d}.${n}.${p}`},n=e=>`/pages/index/index?${e}`,p=(e,r="")=>`${r}?${e}`,g={getShareInfo:(e={title:"",desc:"",image:"",params:{}},a={type:"user"})=>{let o={title:"",desc:"",image:"",path:"",link:"",query:"",poster:a};const i=r.$store("app").platform.share,t=d(e.params);return o.query=t,o.link=p(t,i.linkAddress),i.methods.includes("forward")&&(""!==i.forwardInfo.title&&""!==i.forwardInfo.image||console.log("请在平台设置中配置转发信息"),o.title=e.title||i.forwardInfo.title,o.image=s.$url.cdn(e.image||i.forwardInfo.image),o.desc=e.desc||i.forwardInfo.subtitle,o.path=n(t)),o},updateShareInfo:e=>{},decryptSpm:a=>{const s=r.$store("user");let d,n=a.split("."),p={spm:a,shareId:0,page:"",query:{},platform:"",from:""};switch(p.shareId=n[0],n[1]){case"1":p.page="/pages/index/index";break;case"2":p.page="/pages/goods/index",p.query={linkId:n[2]},console.log(p.query);break;case"3":p.page="/pages/goods/groupon",d=n[2].split(","),p.query={id:d[0],activity_id:d[1]};break;case"4":p.page="/pages/goods/seckill",d=n[2].split(","),p.query={id:d[1]};break;case"5":p.page="/pages/activity/groupon/detail",p.query={id:n[2]}}return p.platform=i[n[3]-1],p.from=t[n[4]-1],0!=p.shareId&&(s.isLogin?s.addShareLog(p):e.index.setStorageSync("shareLog",p)),"/pages/index/index"!==p.page&&o.$router.go(p.page,p.query),p}};exports.$share=g;
