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