?? ?????? ?? ?? ??? ???? ??? ?????? ?? ??? ?? ?????? ?? ??? ???? ??? ???? ?????. ??? ?? ????.
??? ?? ????? ???? ???? ????? ?? ??? ???? ???, ?? ????? ???? ?? ??? ??? ???? ???? ??? ??? ?????!
?? ??
- WeChat ???
- ?? ???? ???????
?? ??
???? ?? ?????
?? ??
??? ?? ???? ?????? ??? ???? ??? ?? ???
??
???? ??? ? ?? ? ???? ?????
??? ???? ? ?? ???? ?????
?? ??? ???? ??? ??
hotsearch? ?? ???? ?? ??????
?? ??? ? ???? ?? ????? ???????. ???? ?? ???? ???? ?????. ?? ??? ??? ???? ????.
index.wxml ?????
<view class="search_1" bindtap="gotoSearch"> <van-search placeholder="搜索單品" disabled /> </view> <view class="search_2"> <view class="pic" bindtap="list" > <image src=""></image> </view> </view> </view>
???? search.wxml ?????
<view class="dewu-search"> <view class="return" > <view class="return_pic" bindtap="gotoindex"> <image ></image> </view> <view class="txt">搜索</view> </view> </view> <van-search value="{{value}}" show-action placeholder="輸入商品名稱(chēng)、貨號(hào)" bind:clear="onClear" bind:search="onSearch" bind:cancel="oncancel" bind:change="onchange" bindtap="input" value="{{value}}" /> <block wx:if="results.length > 0"> <van-cell wx:for="{{results}}" wx:key="_id" title="{{item.title}}" size="large" /> </block> <view class="page1" hidden="{{issuggest==true?'hidden':''}}" > <view class="bd"> <view class="content">熱門(mén)搜索</view> <view class="box"> <view class="items"> <view class="item" wx:for="{{goods}}" wx:key="index" bindtap="hotsearch" data-id="{{item.id}}" > {{item.hot}} </view> </view> </view> </view> <view class="last"> <view class="content">搜索歷史</view> <view class="box"> <view class="items"> <view class="item" wx:for="{{historyList}}" wx:key="index" data-id="{{item.id}}" bindtap="gotohistoryList" wx:key="index"> {{item.hot}} </view> </view> </view> </view> </view> <view class="page2" hidden="{{issuggest==false?'hidden':''}}"> <view class="content1"> <view class="title" wx:for="{{goods1}}" data-id="{{item.id}}" wx:key="index" bindtap="hotsearch" > {{item.hot}} </view> </view> </view> </view>
js ??, ???? ??????? ?? ??????. ???? ???
const db = wx.cloud.database(); const dewuCollection = db.collection('dewu');
?? ??? ??? ? ?? ??? ????? ??? ?? ??? ?? ??? ?? ? ?? ?? ???? ????? ???? ?? ? ???? ?????. ???? ???.
indexOf
? ???? e.detail
(?? ?? ??)? ???? ??????? ????? ????, ???? ?? ? ???? ??? ???? ??? ??? ??? ?????. ?? ?? wx.setStorageSync();
? ???? ?? ??? ???? ???? ??? ?? wx.getStorageSync()
? ???? ???? ?????. hidden="{{issuggest==false?'hidden':''}}"
indexOf
判斷e.detail
(輸入框內(nèi)容)是否是在云數(shù)據(jù)庫(kù)里存在的,如果是存在的,那么將這條數(shù)據(jù)存入一個(gè)數(shù)組里面,并且連接之前搜索后的數(shù)組,再使用 wx.setStorageSync();
將輸入框的數(shù)據(jù)存入到storage里面,然后再wx.getStorageSync()
提取數(shù)據(jù)。
這是當(dāng)輸入框有數(shù)據(jù)的時(shí)候就會(huì)彈出詳情頁(yè)面,點(diǎn)擊可以跳轉(zhuǎn)到商品的詳情頁(yè)
這是搜索框的邏輯
if(e.detail.length!=0){ this.setData({ issuggest:true, }) var arr = []; console.log(this.data.goods.length); for (var i = 0; i < this.data.goods.length; i++) { if (this.data.goods[i].hot.indexOf(e.detail)>=0) { arr.push(this.data.goods[i]); } this.setData({ goods1:arr, }) } } else { console.log('succes'); this.setData({ issuggest:false }) } }, async onSearch(e){ var arr1=new Array(); var historyList=new Array(); var storage=new Array(); for (let i = 0; i < this.data.goods.length; i++){ if(e.detail==this.data.goods[i].hot){ arr1.push(this.data.goods[i]); console.log(arr1); break } else{ arr1.push(e.detail); console.log(arr1); } } if(arr1.length>1){ this.setData({ storage:arr1.slice(arr1.length-1,arr1.length) }) } else{ console.log(arr1,'要存進(jìn)去的數(shù)據(jù)'); this.setData({ storage:arr1 }) } if(this.data.historyList !=[]){ this.data.historyList = this.data.historyList.concat(this.data.storage);//連接 } else{ this.data.historyList=this.data.storage } wx.setStorageSync('historyList', this.data.historyList); this.setData({ historyList:this.data.historyList }) },
wx.navigateTo
可以用來(lái)跳轉(zhuǎn)到詳細(xì)的頁(yè)面,加上字符串模板,判斷id的值,用數(shù)據(jù)來(lái)驅(qū)動(dòng)頁(yè)面,跳轉(zhuǎn)到相同的頁(yè)面不同的數(shù)據(jù)。
wx.navigateTo({ url: `../hotsearch/hotsearch?id=`+id })
最后還要更新數(shù)據(jù)
wx.showLoading({ title: '數(shù)據(jù)加載中...', }) setTimeout(()=>{ wx.hideLoading() this.setData({ goodsNav: nav, goodsList:List, recommend:List, goods2:this.data.historyList }) },1000) // console.log(goodsList,'==========='); },
注意不要忘記要在全局json或者局部頁(yè)面json里引入需要使用的組件的地址
"usingComponents": { "van-search":"./miniprogram_npm/@vant/weapp/search/index" },
擴(kuò)展
這個(gè)自動(dòng)跳轉(zhuǎn)到導(dǎo)航欄中間的功能也是挺常用的
這是wxml代碼 最主要的是 scroll-x="true"
讓導(dǎo)航欄在水平方向可以滑動(dòng)scroll-with-animation="true"
是讓滑動(dòng)產(chǎn)生動(dòng)畫(huà),scroll-into-view="{{scrollTop}}"
<scroll-view scroll-x="true" scroll-with-animation="true" style="width:100%;" class="scroll-view_H " scroll-into-view="{{scrollTop}}"> <view wx:for="{{goodsNav}}" wx:key="index" id="{{item.id}}" data-index="{{index}}" data-type="{{item.type}}" bindtap="changegoods" class="scroll-view-item_H {{activeNavIndex == index?'active': ''}} " > <text>{{item.text}}</text> </view> </scroll-view> </view>
這是綁定在導(dǎo)航欄上面的事件 let {index, type} = e.currentTarget.dataset;
提取到 index 和 type ,然后設(shè)置一個(gè)count作為前幾個(gè)不動(dòng),然后拼接給id
,把id
的值傳給scrollTop
,讓導(dǎo)航欄跳到scrollTop
???? ???? ?? ? ???? ????????. ????? ?? ?????? ?????
??? ???? ?????
console.log(e); let {index, type} = e.currentTarget.dataset; console.log("index=" +index, "type="+type); this.setData({ activeNavIndex:index }) if (type == 'recommend') { this.setData({ goodsList: this.data.recommend }) } else { let goods = this.data.recommend.filter((good) => good.camptype == type ) this.setData({ goodsList: goods }) //console.log(this.data.goods) } var index1 = e.currentTarget.dataset.index; var count = 2; var id = "item"+(index1-count);//拼接id if(count == 2 && index1 < 3 || count == 3 && index1 < 2 || count == 4 && index1 < 3){ id = "item0"; } console.log("下標(biāo)",index1,"---分類(lèi)id名稱(chēng)",id) this.setData({ scrollTop: id }) },
wx.navigateTo
? ???? ??? ? ????. ?? ???? ??? ???? ????, ID ?? ????, ???? ???? ???? ????, ?? ???? ?? ??? ???? ?????.rrreee
??????? ???? ?????? ???????rrreee????? json ?? ?? ??? json?? ???? ?? ????? ??? ???? ?? ?? ??? ???????rrreeeextend????this ????? ? ???? ?? ???? ??? ?? ???????
????wxml ?????. ?? ??? ??
scroll-x="true"
??? ?? ??? ?? ???? ????? ? ????.scroll-with-animation ="true"
? ????? ?????? ???? ????.scroll-into-view="{{scrollTop}}"
??rrreee????? ?? ??? ???? ??????let {index, type} = e.currentTarget.dataset;
???? ??? ??? ?? ??? ?? ? ?? ??? ?? ?????.id
? ??id ?
?scrollTop
? ???? ?? ???scrollTop
??? ????? ???. code>. ? ?? ????rrreee???? ??? wxss? ???? ??? ?? ? ????. ??? ??? ?? ??? ???, ? ??? ??? 6? ?? ??? ???? ???? ???? ???? ??? 3? ??? ???? ?? ??? ??? ???? ???. . ?? ? ??? ???? ?????. ?? ??? ??? ? ????? ?????? ????????? ????? ?? ?? ??? ????. ??? ???? ?? ?? ??? ???? ? ??????????https://gitee.com/xinccc/ fullstack_huoshan/tree/master/wxapp/dewu??
??
???? ?? ??? ?? ????? ???? ?????. ???? ?? ???? ?? ?? ???? ?? ?????. ?? ???? ???? ??? ??? ???? ? ??? ????. ??? ??? ?? ?? ?? ?? ?? ??? ?? ??????. ?? ?? ???? ?? ? ?? ??? ? ????? ? ?????? ??????. ???? ????? ??? ? ?? ? ????. ??? ???? ????? ?? ???? ?? ? ??? ????.
? ?? ????? ?? ??? ??? ????? ??? ?????! !
? ??? ?? ?????? ?? ??? ???? ??? ?? ?? ??? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)

??? ??? ??? ????? ???? ?? WeChat? ???? ?? ???? ?? ??????? ?????. WeChat ?? ????? ???? ???? ??????? ?????? ???? ??? ?? ????? ?? ???? ? ?? ??? ?? ??? ??? ? ????. ? ????? Python? ???? WeChat ???? ???? ??? ?????. 1. ?? Python? ???? WeChat ???? ???? ?? ?? Python ?????? ???? ???. ???? wxpy? itchat ? ?????? ???? ?? ????. wxpy? ?? ?????

WeChat ?? ?????? ?? ??? ?? ?? WeChat ?? ?????? ?? ??? ??? ???? ?? ??? ??? ????? ?? ??? ??? ???? ? ?? ???? ????? ?????. ??? WeChat ????? ?? ??? ??? ???? ??? ??? ???? ?? ?? ??? ?????. ??, ?? ????? ??? ???? ??? ? ?? ?? ??? ???? ???. ??? ?? ??? ???? ?? ??? ?? ??? ?? ??? ???? ?? ????. <--index.wxml- ->&l

10? 31? ? ???? ??? ??? ?? 5? 27? Ant Group? '?? ?? ????'? ????? ????? ?? ??? ??? ?????. Alipay? '?? ?? - ??? ?? ??' ?? ????? ??????. ?? ???? ?? ??? ?????? ???? ?? ???? ?? ??? ?? ??? ???? Alipay? ?? ??? ?? ??? ???? ? ??? ???. ?? ???? "????", "????" ?? ???? ???? "????" ???? ??? ? ????. ?? ?????? ???? ????? ?? ? ???? ?? ?? ??? ??? ??? ? ??? ?? ? Alipay ????? ?? ?????? ?? ??? ?????. ? ??????? ?? ??????? ?? ?? ?? ?? ??? ??? ? ??? ?????. ? ?? ??? ??? ???? ?? ??? ?? ???????. ??? ??

???? ?? ????? H5 ??? ??? ????? ???? ?? ??? ?????. ?? ??? ???? ??? ????? ???? ?? ?? ????? H5? ?? ?????? ??? ?????. ??? ??? ?? ?????? uniapp? ?? ??? ???? ?? ????? H5 ?? ??? ???? ???? ?? ???? ?? ???? ? ????. ? ????? uniapp? ?? ????? H5 ?? ??? ??? ???? ??? ???? ???? ?? ??? ?????. 1. ??? ??? ??

PHP ? ?? ????? ??? ?? ?? ? ?? ?? ??? ?? ?? ? ?? ??? ?? ???? ??? ?? ? ??? ?????. ??? ??? ??? ?? ?? ?? ? ?? ??? ?? ???? ??? ???? ????. ?? ???? PHP? ???? ? ?? ???? ?? ?????. ? ????? PHP ? ?? ?????? ??? ?? ?? ? ?? ?? ?? ??? ???? ?? ?? ??? ?????. 1. PHP? ???? PHP??? ?? ????? ??? ? ????.

1. WeChat ?? ????? ?? ?? ?? ???? ???? ?????. 2. ?? ???? ????? ?? ?? ??? ????. ????? ?? ??? ?? ????? ? ?? ?? ??? ????. 3. ??? ??? ???? ??? ?? ???? ?????. 4. ?????? ????? ?????, ?? ? ?? ??? ???? ?, ????? ????. 5. ?? ????? ?? ?? ???? ??? ?, ???? ?? ?? ????? ??? ? ? ????. 6. ???? ??? ?? ???, ??, ???? ??? ? ? ?? ???? ?? ? ????.

HTML, CSS ? jQuery: ?? ??? ???? ??? ??? ??? ?? ? ???? ??? ???? ?? ???? ?????. ???? ???? ?? ?? ????? ???? ??? ???? ?? ??? ???? ?? ?? ??? ?????. ? ????? HTML, CSS ? jQuery? ???? ?? ??? ?? ??? ???? ??? ??? ???? ???? ?? ??? ?????. 1. HTML ?? ??, ??? ???? ??? ?? HTML ??? ???? ???.

?? ????? ??? ?? ??: 1. ?? ???? API? ???? ??? ???? wx.getStorageInfoSync() ???? ???? ?? ????? ?? ?? ??? ?? ? ????. ??? ???? ??? ?? ? ????. ???? ?? ???? "???"? ??? ?? "?? ?? ?? ??"? ???? ?? ????? ?? ??? ?? ? ????. ?? ???? ?? ?? ?? ????? ?? ????? ?? ?? ????? ??? ????.
