2 lines
2.3 KiB
JavaScript
2 lines
2.3 KiB
JavaScript
"use strict";const e=require("../../../../common/vendor.js"),r=require("../store/index.js"),a=require("./index.js"),t=require("../router/index.js"),o=require("../url/index.js"),i=require("../api/trade/brokerage.js"),s=["H5","WechatOfficialAccount","WechatMiniProgram","App"],d=["forward","poster","link"],n=e=>{const t=r.$store("user");let o="0";void 0===e.shareId&&t.isLogin&&(o=t.userInfo.id);let i="1";void 0!==e.page&&(i=e.page);let d="0";void 0!==e.query&&(d=e.query);const n=s.indexOf(a._platform.name)+1;let l="1";return void 0!==e.from&&(l=s.indexOf(e.from)+1),`spm=${o}.${i}.${d}.${n}.${l}`},l=e=>"pages/index/index",u=(e,r="")=>`${r}?${e}`,p=(r=void 0)=>{return a=exports,t=null,o=function*(){try{const a=r||e.index.getStorageSync("shareId");if(!a)return;yield i.BrokerageApi.bindBrokerageUser({bindUserId:a}),e.index.removeStorageSync("shareId")}catch(a){}},new Promise(((e,r)=>{var i=e=>{try{d(o.next(e))}catch(a){r(a)}},s=e=>{try{d(o.throw(e))}catch(a){r(a)}},d=r=>r.done?e(r.value):Promise.resolve(r.value).then(i,s);d((o=o.apply(a,t)).next())}));var a,t,o},c={getShareInfo:(e={title:"",desc:"",image:"",params:{}},a={type:"user"})=>{const t={title:"",desc:"",image:"",path:"",link:"",query:"",poster:a},i=r.$store("app").platform.share,s=n(e.params);return t.query=s,t.link=u(s,i.linkAddress),t.path=l(),i.methods.includes("forward")&&(""===i.forwardInfo.title||i.forwardInfo.image,t.title=e.title||i.forwardInfo.title,t.image=o.$url.cdn(e.image||i.forwardInfo.image),t.desc=e.desc||i.forwardInfo.subtitle,t.path=l(e.path)),t},updateShareInfo:e=>{},decryptSpm:a=>{const o=r.$store("user"),i=a.split("."),n={spm:a,shareId:0,page:"",query:{},platform:"",from:""};let l;switch(n.shareId=i[0],i[1]){case"1":n.page="/modules/mall/index/index";break;case"2":n.page="/modules/mall/goods/index",n.query={id:i[2]};break;case"3":n.page="/modules/mall/goods/groupon",l=i[2].split(","),n.query={id:l[0],activity_id:l[1]};break;case"4":n.page="/modules/mall/goods/seckill",l=i[2].split(","),n.query={id:l[1]};break;case"5":n.page="/modules/mall/activity/groupon/detail",n.query={id:i[2]}}return n.platform=s[i[3]-1],n.from=d[i[4]-1],0!==n.shareId&&(o.isLogin?p(n.shareId):e.index.setStorageSync("shareId",n.shareId)),"/modules/mall/index/index"!==n.page&&t.$router.go(n.page,n.query),n},bindBrokerageUser:p};exports.$share=c;
|