search.js
1.9 KB
"use strict";const e=require("../../common/vendor.js"),a=require("../../api/index.js");require("../../utils/request.js");Array||e.resolveComponent("u-navbar")();const m=()=>"../../uni_modules/uview-plus/components/u-navbar/u-navbar.js";Math||(m+y+x)();const y=()=>"../../componets/searchBox.js",x=()=>"../../componets/shops.js",R={__name:"search",setup(g){let c=e.ref(""),l=e.ref([]),t=e.ref([]),s=e.ref(!1);e.ref(""),e.ref(1),e.ref(1),e.onLoad(()=>{n()});const f=o=>{c.value=o,i(o)},d=()=>{e.index.showModal({title:"提示",content:"是否清空历史记录",success:function(o){o.confirm?(v(),e.index.showToast({title:"清空成功"}),e.index.removeStorage({key:"searchRecords"})):o.cancel&&console.log("用户点击取消")}})},p=o=>{o.trim()!=""&&i(o)},_=o=>{s.value=!1,t.value=[]},i=async o=>{try{const r=await a.getSearch(o);t.value=r.goods.concat(r.tjgoods),s.value=t.value.length==0,n(),console.log("getSearch",r)}catch(r){console.log("getSearch",r)}},n=async()=>{try{const o=await a.getRecord();l.value=o,console.log("getRecord",o)}catch(o){e.index.showToast({title:o,icon:"none"}),console.log("getRecord",o)}},v=async()=>{try{const o=await a.getDelRecord();n(),console.log("getDelRecord",o)}catch(o){e.index.showToast({title:o,icon:"none"}),console.log("getDelRecord",o)}};return e.onReachBottom(()=>{this.page!=this.lastPage?(this.page=this.page+1,this.getSearch(1)):e.index.showToast({title:"暂无更多商品~",icon:"none"})}),(o,r)=>e.e({a:e.p({bgColor:"#F6F8FA",title:"搜索",placeholder:!0,autoBack:!0}),b:e.o(p),c:e.o(_),d:e.p({keyWord:e.unref(c),disabled:!1}),e:!e.unref(t).length&&!e.unref(s)},!e.unref(t).length&&!e.unref(s)?{f:e.o(d),g:e.f(e.unref(l),(u,h,w)=>({a:e.t(u),b:h,c:e.o(S=>f(u),h)}))}:{},{h:o.index,i:e.p({list:e.unref(t),shopWidth:344,shopHeight:344}),j:e.unref(s)},e.unref(s)?{}:{})}},b=e._export_sfc(R,[["__file","D:/vue/大健康商城/healthMall/pages/index/search.vue"]]);wx.createPage(b);