You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 lines
3.2 KiB
1 lines
3.2 KiB
import{d as e,r as t,q as a,y as s,an as o,o as l,c as r,w as n,b as c,f as i,B as u,z as x,n as d,Q as h,a3 as p,R as f,bz as y,l as g,a as m,aq as v,b3 as _,E as S,ag as C,j as k,A as b}from"./index-ed377420.js";import{_ as H}from"./_plugin-vue_export-helper.1b428a4d.js";const V=H(e({__name:"search",setup(e){const H=t(""),V=t([]),j=t(!1);a((e=>{!uni.getStorageSync("goodsSearchHistory")&&uni.setStorageSync("goodsSearchHistory",[])})),s((()=>{z(),o((()=>{I()}))}));const z=()=>{V.value=uni.getStorageSync("goodsSearchHistory").reverse()},R=()=>{y({title:"提示",content:"确认删除全部历史记录?",confirmColor:g().themeColor["--primary-color"],success:e=>{e.confirm&&(uni.setStorageSync("goodsSearchHistory",[]),z())}})},q=()=>{let e=uni.getStorageSync("goodsSearchHistory"),t=[];e.length?(t=e.filter((e=>e!=H.value.trim())),t.push(H.value.trim())):t.push(H.value.trim()),uni.setStorageSync("goodsSearchHistory",t),m({url:"/addon/shop/pages/goods/list",param:{goods_name:encodeURIComponent(H.value)},mode:"navigateTo"})},I=()=>{v().in(this).select("#history-list").boundingClientRect((e=>{e&&e.height>2*_(70)+2*_(35)&&(j.value=!0)})).exec()};return(e,t)=>{const a=S,s=C,o=k;return l(),r(o,{style:d(e.themeColor())},{default:n((()=>[c(o,{class:"flex items-center px-[20rpx] h-[120rpx]"},{default:n((()=>[c(o,{class:"h-[68rpx] bg-[var(--temp-bg)] px-[30rpx] flex items-center rounded-[100rpx] flex-1"},{default:n((()=>[c(a,{class:"nc-iconfont nc-icon-sousuo-duanV6xx1 text-[var(--text-color-light9)] text-[26rpx] mr-[18rpx]"}),c(s,{class:"text-[28rpx] flex-1",maxlength:"50",type:"text",modelValue:H.value,"onUpdate:modelValue":t[0]||(t[0]=e=>H.value=e),placeholder:"请搜索您想要的商品","confirm-type":"search",placeholderClass:"text-[var(--text-color-light9)] text-[28rpx]",onConfirm:q},null,8,["modelValue"]),H.value?(l(),r(a,{key:0,class:"nc-iconfont nc-icon-cuohaoV6xx1 text-[24rpx] text-[var(--text-color-light9)]",onClick:t[1]||(t[1]=e=>H.value="")})):i("v-if",!0)])),_:1}),c(a,{onClick:t[2]||(t[2]=u((e=>q()),["stop"])),class:"text-[26rpx] ml-[32rpx] -mb-[2rpx]"},{default:n((()=>[x("搜索")])),_:1})])),_:1}),c(o,{class:"search-content"},{default:n((()=>[i(" 历史搜索 "),V.value.length?(l(),r(o,{key:0,class:"history"},{default:n((()=>[c(o,{class:"history-box"},{default:n((()=>[c(o,{class:"history-top"},{default:n((()=>[c(o,{class:"title font-500"},{default:n((()=>[x("历史搜索")])),_:1}),c(o,{class:"icon nc-iconfont nc-icon-shanchu-yuangaizhiV6xx !text-[24rpx] text-[var(--text-color-light6)]",onClick:R})])),_:1}),c(o,{class:"history-bottom",id:"history-list",style:d({maxHeight:j.value?"148rpx":"100%"})},{default:n((()=>[(l(!0),h(f,null,p(V.value,((e,t)=>(l(),h(f,{key:t},[e?(l(),r(o,{key:0,class:"history-li",onClick:t=>{return a=e,H.value=a,void q();var a}},{default:n((()=>[c(o,null,{default:n((()=>[x(b(e),1)])),_:2},1024)])),_:2},1032,["onClick"])):i("v-if",!0)],64)))),128)),j.value?(l(),r(o,{key:0,class:"history-li history_more",onClick:t[3]||(t[3]=e=>j.value=!1)},{default:n((()=>[c(o,{class:"content-box"},{default:n((()=>[c(a,{class:"text-[30rpx] nc-iconfont nc-icon-xiaV6xx"})])),_:1})])),_:1})):i("v-if",!0)])),_:1},8,["style"])])),_:1})])),_:1})):i("v-if",!0)])),_:1})])),_:1},8,["style"])}}}),[["__scopeId","data-v-df946775"]]);export{V as default};
|
|
|