douyin/js/Share2Friend-D_dS-S4n.js
2024-04-23 09:37:32 +00:00

2 lines
11 KiB
JavaScript

import{c as B,aj as x,e as p,C as f,am as S,an as C,_ as F}from"./common-DzJQztrr.js";import{u as T,D as K,E as D}from"./other-s7HPCK19.js";import"./vendor-B0vIwkRg.js";const I=""+new URL("../assets/water-Cq3Nzf11.png",import.meta.url).href,i=v=>(Vue.pushScopeId("data-v-d1f9ee52"),v=v(),Vue.popScopeId(),v),w={class:"Share2Friend"},O=i(()=>Vue.createElementVNode("span",{class:"f16"},"私信给",-1)),b={class:"search"},U={key:0,class:"search-select-friends"},L={class:"wrapper"},R=["src","onClick"],Y={key:1,class:"search-icon",src:S,alt:""},$={key:0,class:"list"},q=["onClick"],z=["src"],H={class:"desc"},M={class:"name"},j={key:0},A={style:{color:"#ffd800"}},G={key:1},J={key:0,class:"account"},P={key:0},Q={style:{color:"#ffd800"}},W={key:1},X={key:1,class:"no-result"},Z=i(()=>Vue.createElementVNode("img",{src:D,alt:""},null,-1)),ee=i(()=>Vue.createElementVNode("span",{class:"n1"},"搜索结果为空",-1)),te=i(()=>Vue.createElementVNode("span",{class:"n2"},"没有搜索到相关的联系人",-1)),le=[Z,ee,te],ne={class:"list"},oe=i(()=>Vue.createElementVNode("span",null,"已加入的群聊",-1)),se=i(()=>Vue.createElementVNode("div",{class:"title"},"最近聊天",-1)),ae=["onClick"],ce=["src"],re=i(()=>Vue.createElementVNode("div",{class:"title"},"互关好友",-1)),de=["onClick"],ie=["src"],ue=i(()=>Vue.createElementVNode("div",{class:"title"},"全部",-1)),Ve=["onClick"],me=["src"],pe={key:0,class:"share2friend"},fe=i(()=>Vue.createElementVNode("div",{class:"comment"},[Vue.createElementVNode("textarea",{placeholder:"有什么想和好友说的..."}),Vue.createElementVNode("img",{class:"poster",src:C,alt:""})],-1)),ve={class:"wrapper"},he={key:0,class:"create-chat"},_e=i(()=>Vue.createElementVNode("span",null,"创建群聊",-1)),ke=Vue.createStaticVNode('<div class="indicator-ctn" data-v-d1f9ee52><div class="indicator" data-v-d1f9ee52><div class="item" data-index="top" data-v-d1f9ee52>#</div><div class="item" data-v-d1f9ee52>A</div><div class="item" data-v-d1f9ee52>B</div><div class="item" data-v-d1f9ee52>C</div><div class="item" data-v-d1f9ee52>D</div><div class="item" data-v-d1f9ee52>E</div><div class="item" data-v-d1f9ee52>F</div><div class="item" data-v-d1f9ee52>G</div><div class="item" data-v-d1f9ee52>H</div><div class="item" data-v-d1f9ee52>I</div><div class="item" data-v-d1f9ee52>J</div><div class="item" data-v-d1f9ee52>K</div><div class="item" data-v-d1f9ee52>L</div><div class="item" data-v-d1f9ee52>M</div><div class="item" data-v-d1f9ee52>N</div><div class="item" data-v-d1f9ee52>O</div><div class="item" data-v-d1f9ee52>P</div><div class="item" data-v-d1f9ee52>Q</div><div class="item" data-v-d1f9ee52>R</div><div class="item" data-v-d1f9ee52>S</div><div class="item" data-v-d1f9ee52>T</div><div class="item" data-v-d1f9ee52>U</div><div class="item" data-v-d1f9ee52>V</div><div class="item" data-v-d1f9ee52>W</div><div class="item" data-v-d1f9ee52>X</div><div class="item" data-v-d1f9ee52>Y</div><div class="item" data-v-d1f9ee52>Z</div></div></div>',1),ye=i(()=>Vue.createElementVNode("img",{src:I,alt:""},null,-1)),ge=Vue.defineComponent({name:"Share2Friend"}),Ee=Vue.defineComponent({...ge,setup(v){const _=T(),e=Vue.reactive({isCreateChat:!1,searchKey:"",indexOffsetTop:{},currentFixedIndicator:"",currentFixedIndicatorTop:"0px",friends:{all:{},recent:[],eachOther:[]},selectFriends:[],friendsSort:{},searchResult:[]});Vue.onMounted(()=>{g(),document.querySelectorAll(".index").forEach(r=>{e.indexOffsetTop[r.children[0].innerText]=r.offsetTop});let l=document.querySelectorAll(".item"),d=document.querySelector(".item:nth-child(2)").clientHeight,s=document.querySelector(".indicator"),t=s.offsetTop,a="rgb(143, 143, 158)";s.addEventListener("touchstart",r=>{let u=(r.touches[0].pageY-t)/d;u=Math.floor(u),o(u),e.currentFixedIndicatorTop=r.touches[0].pageY-28+"px"}),s.addEventListener("touchmove",r=>{let V=r.touches[0].pageY-t;e.currentFixedIndicatorTop=r.touches[0].pageY-28+"px";let u=V/d;u=Math.floor(u),u>=0&&u<27&&o(u)}),s.addEventListener("touchend",()=>e.currentFixedIndicator="");let o=r=>{l.forEach(V=>{V.style.color=a}),l[r].style.color="#fff",e.currentFixedIndicator=l[r].innerText,E(l[r])}}),Vue.watch(()=>e.searchKey,n=>{let l=B(e.friends.all);l.map(c=>{e.selectFriends.find(d=>d.id===c.id)&&(c.select=!0)}),e.searchResult=l.filter(c=>c.name.includes(n)||c.account.includes(n))});function k(n){m(n),e.searchKey=""}function y(){console.log("clear"),e.searchKey=""}function m(n){for(let s=0;s<e.friends.recent.length;s++){let t=e.friends.recent[s];if(t.name===n.name){t.select=!t.select;break}}for(let s=0;s<e.friends.eachOther.length;s++){let t=e.friends.eachOther[s];if(t.name===n.name){t.select=!t.select;break}}let l=!1,c=Object.keys(e.friendsSort);for(let s=0;s<c.length;s++){let t=c[s];for(let a=0;a<e.friendsSort[t].length;a++){let o=e.friendsSort[t][a];if(o.name===n.name){o.select=!o.select,l=!0;break}}if(l)break}let d=e.selectFriends.findIndex(s=>s.name===n.name);d!==-1?(n.select=!1,e.selectFriends.splice(d,1)):(n.select=!0,e.selectFriends.push(n))}async function g(){let n=await x();console.log("getFriends",n),n.success&&(e.friends=n.data,e.friends.all=e.friends.all.sort((l,c)=>l.pinyin<c.pinyin?-1:l.pinyin>c.pinyin?1:0),e.friends.all.map(l=>{e.friendsSort[l.pinyin]?e.friendsSort[l.pinyin].push(l):e.friendsSort[l.pinyin]=[l]}))}const h=Vue.ref();function E(n){let l;n.dataset.index?l="top":l=n.innerText,document.querySelector(`.${l}`)&&(h.value.scrollTop=document.querySelector(`.${l}`).offsetTop-100)}function N(n){let l=n.target.scrollTop+110,c=null;for(const d in e.indexOffsetTop)e.indexOffsetTop[d]<l&&(c=d);e.currentFixedIndicator=c}return(n,l)=>{const c=Vue.resolveComponent("BaseHeader"),d=Vue.resolveComponent("dy-back"),s=Vue.resolveComponent("dy-button");return Vue.openBlock(),Vue.createElementBlock("div",w,[Vue.createVNode(c,{backImg:"close",style:{"z-index":"7"}},{center:Vue.withCtx(()=>[O]),bottom:Vue.withCtx(()=>[Vue.createElementVNode("div",b,[e.selectFriends.length?(Vue.openBlock(),Vue.createElementBlock("div",U,[Vue.createElementVNode("div",L,[(Vue.openBlock(!0),Vue.createElementBlock(Vue.Fragment,null,Vue.renderList(e.selectFriends,(t,a)=>(Vue.openBlock(),Vue.createElementBlock("img",{src:Vue.unref(p)(t.avatar),key:a,onClick:o=>m(t)},null,8,R))),128))])])):(Vue.openBlock(),Vue.createElementBlock("img",Y)),Vue.withDirectives(Vue.createElementVNode("input",{type:"text",placeholder:"搜索","onUpdate:modelValue":l[0]||(l[0]=t=>e.searchKey=t)},null,512),[[Vue.vModelText,e.searchKey]]),e.searchKey?(Vue.openBlock(),Vue.createElementBlock("img",{key:2,onClick:y,class:"clear",src:K})):Vue.createCommentVNode("",!0)])]),_:1}),Vue.withDirectives(Vue.createElementVNode("div",{class:"is-search",style:Vue.normalizeStyle({height:e.selectFriends.length&&e.searchResult.length?"calc(100% - 272rem)":"calc(100% - 112rem)"})},[e.searchResult.length?(Vue.openBlock(),Vue.createElementBlock("div",$,[(Vue.openBlock(!0),Vue.createElementBlock(Vue.Fragment,null,Vue.renderList(e.searchResult,(t,a)=>(Vue.openBlock(),Vue.createElementBlock("div",{class:"local-row",key:a,onClick:o=>k(t)},[Vue.createVNode(f,{mode:"red",modelValue:t.select,"onUpdate:modelValue":o=>t.select=o},null,8,["modelValue","onUpdate:modelValue"]),Vue.createElementVNode("img",{src:Vue.unref(p)(t.avatar),alt:""},null,8,z),Vue.createElementVNode("div",H,[Vue.createElementVNode("span",M,[t.name.indexOf(e.searchKey)>-1?(Vue.openBlock(),Vue.createElementBlock("span",j,[Vue.createTextVNode(Vue.toDisplayString(t.name.substr(0,t.name.indexOf(e.searchKey))),1),Vue.createElementVNode("span",A,Vue.toDisplayString(e.searchKey),1),Vue.createTextVNode(Vue.toDisplayString(t.name.substr(t.name.indexOf(e.searchKey)+e.searchKey.length)),1)])):(Vue.openBlock(),Vue.createElementBlock("span",G,Vue.toDisplayString(t.name),1))]),t.account?(Vue.openBlock(),Vue.createElementBlock("span",J,[Vue.createTextVNode(" 抖音号: "),t.account.indexOf(e.searchKey)>-1?(Vue.openBlock(),Vue.createElementBlock("span",P,[Vue.createTextVNode(Vue.toDisplayString(t.account.substr(0,t.account.indexOf(e.searchKey))),1),Vue.createElementVNode("span",Q,Vue.toDisplayString(e.searchKey),1),Vue.createTextVNode(Vue.toDisplayString(t.account.substr(t.account.indexOf(e.searchKey)+e.searchKey.length)),1)])):(Vue.openBlock(),Vue.createElementBlock("span",W,Vue.toDisplayString(t.account),1))])):Vue.createCommentVNode("",!0)])],8,q))),128))])):(Vue.openBlock(),Vue.createElementBlock("div",X,le))],4),[[Vue.vShow,e.searchKey]]),Vue.createElementVNode("div",{ref_key:"list",ref:h,style:Vue.normalizeStyle({paddingBottom:e.selectFriends.length?"160rem":0}),class:"content",onScroll:N},[Vue.createElementVNode("div",ne,[Vue.createElementVNode("div",{class:"row",onClick:l[1]||(l[1]=t=>Vue.unref(_)("/message/joined-group-chat"))},[oe,Vue.createVNode(d,{scale:.7,direction:"right"})]),se,(Vue.openBlock(!0),Vue.createElementBlock(Vue.Fragment,null,Vue.renderList(e.friends.recent,(t,a)=>(Vue.openBlock(),Vue.createElementBlock("div",{class:"local-row",key:a,onClick:o=>m(t)},[Vue.createVNode(f,{mode:"red",modelValue:t.select,"onUpdate:modelValue":o=>t.select=o},null,8,["modelValue","onUpdate:modelValue"]),Vue.createElementVNode("img",{src:Vue.unref(p)(t.avatar),alt:""},null,8,ce),Vue.createElementVNode("span",null,Vue.toDisplayString(t.name),1)],8,ae))),128)),re,(Vue.openBlock(!0),Vue.createElementBlock(Vue.Fragment,null,Vue.renderList(e.friends.eachOther,(t,a)=>(Vue.openBlock(),Vue.createElementBlock("div",{class:"local-row",key:a,onClick:o=>m(t)},[Vue.createVNode(f,{mode:"red",modelValue:t.select,"onUpdate:modelValue":o=>t.select=o},null,8,["modelValue","onUpdate:modelValue"]),Vue.createElementVNode("img",{src:Vue.unref(p)(t.avatar),alt:""},null,8,ie),Vue.createElementVNode("span",null,Vue.toDisplayString(t.name),1)],8,de))),128)),ue,(Vue.openBlock(!0),Vue.createElementBlock(Vue.Fragment,null,Vue.renderList(e.friendsSort,(t,a)=>(Vue.openBlock(),Vue.createElementBlock("div",{key:a},[Vue.createElementVNode("div",{class:Vue.normalizeClass([a==="#"?"top":a,"title"])},[Vue.createElementVNode("span",null,Vue.toDisplayString(a),1)],2),(Vue.openBlock(!0),Vue.createElementBlock(Vue.Fragment,null,Vue.renderList(t,(o,r)=>(Vue.openBlock(),Vue.createElementBlock("div",{class:"local-row",key:r,onClick:V=>m(o)},[Vue.createVNode(f,{mode:"red",modelValue:o.select,"onUpdate:modelValue":V=>o.select=V},null,8,["modelValue","onUpdate:modelValue"]),Vue.createElementVNode("img",{src:Vue.unref(p)(o.avatar),alt:""},null,8,me),Vue.createElementVNode("span",null,Vue.toDisplayString(o.name),1)],8,Ve))),128))]))),128))]),e.selectFriends.length&&e.searchResult.length?(Vue.openBlock(),Vue.createElementBlock("div",pe,[fe,Vue.createElementVNode("div",ve,[e.selectFriends.length>1?(Vue.openBlock(),Vue.createElementBlock("div",he,[Vue.createVNode(f,{mode:"red",modelValue:e.isCreateChat,"onUpdate:modelValue":l[2]||(l[2]=t=>e.isCreateChat=t)},null,8,["modelValue"]),_e])):Vue.createCommentVNode("",!0),Vue.createVNode(s,{type:"primary"},{default:Vue.withCtx(()=>[Vue.createTextVNode(Vue.toDisplayString(e.selectFriends.length>1?"分别发送":"发送"),1)]),_:1})])])):Vue.createCommentVNode("",!0)],36),ke,e.currentFixedIndicator?(Vue.openBlock(),Vue.createElementBlock("div",{key:0,class:"hover",style:Vue.normalizeStyle({top:e.currentFixedIndicatorTop}),ref:"hover"},[ye,Vue.createElementVNode("span",null,Vue.toDisplayString(e.currentFixedIndicator),1)],4)):Vue.createCommentVNode("",!0)])}}}),Se=F(Ee,[["__scopeId","data-v-d1f9ee52"]]);export{Se as default};