2020/9/27 0:00:00
泉源:不详
作者:未知
这部分也是列表样式,,,每一项由前面的时钟图标,,,中心的文字以及最后体现删除的“X”组成,,,最下方为清空整个列表的选项。。。。。。
-
<view class="search-hi" wx:if="{{showSearchPanel == 2}}">
-
<block wx:if="{{historySearchs.length > 0}}">
-
<view class="search-hi-item" wx:for="{{historySearchs}}" wx:key="unique">
-
<view class="hi-icon"></view>
-
<text class="hi-text" data-key="{{item}}" bindtap="historysearchTap">{{item}}</text>
-
<view class="hi-close" data-index="{{index}}" bindtap="delHistoryItem"></view>
-
</view>
-
<view class="clear-serach" bindtap="clearHistorySearchs">扫除搜索纪录</view>
-
</block>
-
</view>
复制代码

这一部分只有当showSearchPanel=2才显示。。。。。。
详细的内容,,,我们首先要判断是否有历史数据。。。。。。使用historySearchs存储以是历史纪录,,,只有当其长度大于0时,,,才渲染这一部分。。。。。。
block里的内容就如我们所要的一致,,,然后我们为文字,,,最后的“X”标记,,,和最后的“扫除搜索纪录”添加点击事务。。。。。。
名堂文件为:
-
.search-hi-item {
-
height:88rpx;
-
line-height:88rpx;
-
border-bottom:2rpx solid #ededed;
-
}
-
.hi-icon {
-
position:absolute;
-
left:20rpx;
-
display:inline-block;
-
width:88rpx;
-
height:88rpx;
-
background:url(/miniprogramdev/&) no-repeat center center;
-
background-size:40rpx;
-
}
-
.hi-text {
-
position:absolute;
-
left:108rpx;
-
right:108rpx;
-
display:block;
-
white-space:nowrap;
-
text-overflow:ellipsis;
-
overflow:hidden;
-
font-size:32rpx;
-
}
-
.hi-close {
-
width:88rpx;
-
height:88rpx;
-
position:absolute;
-
right:20rpx;
-
background:url(/miniprogramdev/&) no-repeat center center;
-
}
-
.clear-serach {
-
font-size:24rpx;
-
text-align:center;
-
color:#47c88a;
-
line-height:88rpx;
-
}
复制代码
background里加载了划分加载了两个外地图片并为其设置了不平铺与居中的属性。。。。。。
很显然,,,在我们每次点击确定按钮后,,,输入框内的值除了发送到服务器请求搜索效果,,,还要添加到historySearchs里。。。。。。
以是我们先写搜索效果列表,,,然后一起处理确定按钮的点击事务。。。。。。
首先是网络请求的函数:
-
function getSearchMusic(word,callback){ //word为传入的要害字,,,callback为回调函数
-
var data = {
-
g_tk: 5381,
-
uin: 0,
-
format: 'json',
-
inCharset: 'utf-8',
-
outCharset: 'utf-8',
-
notice: 0,
-
platform: 'h5',
-
needNewCode: 1,
-
w: word,
-
zhidaqu: 1,
-
catZhida: 1,
-
t: 0,
-
flag: 1,
-
ie: 'utf-8',
-
sem: 1,
-
aggr: 0,
-
perpage: 20,
-
n: 20,
-
p: 1,
-
remoteplace: 'txt.mqq.all',
-
_: Date.now()
-
};
-
wx.request({
-
url: 'http://c.y.qq.com/soso/fcgi-bin/search_for_qq_cp',
-
data: data,
-
header: {
-
'Content-Type': 'application/json'
-
},
-
success: function (res) {
-
if (res.statusCode == 200) {
-
callback(res.data);
-
} else {
-
-
}
-
-
}
-
});
-
}
-
...
-
module.exports = {
-
...
-
getSearchMusic:getSearchMusic
-
}
复制代码
返回的JSON数据为:
-
{
-
"code": 0,
-
"data": {
-
"keyword": "那片星空那片海 ",
-
"priority": 0,
-
"qc": [],
-
"semantic": {
-
"curnum": 0,
-
"curpage": 1,
-
"list": [],
-
"totalnum": 0
-
},
-
"song": {
-
"curnum": 6,
-
"curpage": 1,
-
"list": [
-
{
-
"albumid": 1829165,
-
"albummid": "000cvc411fKPIC",
-
"albumname": "那片星空那片海 电视原声带",
-
"albumname_hilight": "<span class=\"c_tx_highlight\">那片星空那片海</span> 电视原声带",
-
"alertid": 100007,
-
"chinesesinger": 0,
-
"docid": "8313377529987609872",
-
"format": "qqhq;common;mp3common;wmacommon",
-
"grp": [],
-
"interval": 227,
-
"isonly": 1,
-
"lyric": "《那片星空那片海》电视剧片头曲",
-
&nnbsp; "lyric_hilight": "《<span class=\"c_tx_highlight\">那片星空那片海</span>》电视剧<span class=\"c_tx_highlight\">片</span>头曲",
-
"msgid": 13,
-
"nt": 3247935513,
-
"pay": {
-
"payalbum": 1,
-
"payalbumprice": 500,
-
"paydownload": 1,
-
"payinfo": 1,
-
"payplay": 1,
-
"paytrackmouth": 0,
-
"paytrackprice": 0
-
},
-
"preview": {
-
"trybegin": 0,
-
"tryend": 0,
-
"trysize": 0
-
},
-
"pubtime": 1486483200,
-
"pure": 0,
-
"singer": [
-
{
-
"id": 12111,
-
"mid": "004YXxql1sSr2o",
-
"name": "金志文",
-
"name_hilight": "金志文"
-
}
-
],
-
"size128": 3649005,
-
"size320": 9122181,
-
"sizeape": 23599481,
-
"sizeflac": 23676261,
-
"sizeogg": 4916985,
-
"songid": 200552006,
-
"songmid": "001lggCh2Nw7us",
-
"songname": "那片星空那片海",
-
"songname_hilight": "<span class=\"c_tx_highlight\">那片星空那片海</span>",
-
"songurl": "http://y.qq.com/#type=song&id=200552006",
-
"stream": 5,
-
"switch": 594177,
-
"t": 0,
-
"tag": 10,
-
"type": 0,
-
"ver": 0,
-
"vid": ""
-
},
-
...
-
],
-
"totalnum": 6
-
},
-
"totaltime": 0,
-
"zhida": {
-
"albumid": 1829165,
-
"albummid": "000cvc411fKPIC",
-
"albumname": "那片星空那片海 电视原声带",
-
"singername": "华语群星",
-
"type": 3
-
}
-
},
-
"message": "",
-
"notice": "",
-
"subcode": 0,
-
"time": 1487063618,
-
"tips": ""
-
}
复制代码
有了数据之后,,,我们需要在列内外显示的内容为歌曲名称(songname)与歌手名称(singer.name)。。。。。。
上一节:微信小程序小白项目开发案例之音乐播放器—检索页(上)
下一节:微信小程序小白项目开发案例之音乐播放器—检索页(下)
【本站声明】
1、本站文章中所选用的图片及文字泉源于网络以及用户投稿,,,由于未联系到知识产权人或未发明有关知识产权的挂号,,,若有知识产权人并不肯意我们使用,,,若是有侵权请连忙联系。。。。。。
2、本网站差池文章中所涉及的内容真实性、准确性、可靠性认真,,,仅系客观性形貌,,,如您需要相识该类商品/服务详细的资讯,,,请您直接与该类商品/服务的提供者联系。。。。。。
KESION pp电子软件
KESION pp电子软件是海内领先的在线教育软件及私域社交电商软件服务提供商,,,恒久专注于为企业提供在线教育软件及社交电商SaaS平台解决方案。。。。。。
公司焦点产品云开店SaaS社交电商服务平台、在线教育SaaS服务平台、教育企业数字化SaaS云平台、企微营销助手、私有化自力安排品牌网校和在线教育咨询等。。。。。。KESION 一直通过手艺立异,,,提供产品和服务,,,助力企业向数字化转型,,,通过科技驱动商业刷新,,,让商业变得更智慧!