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.

111 lines
2.5 KiB

// miniprogram/pages/find/find.js
const db = wx.cloud.database();
Page({
data: {
inputcon:'',
swiperImg:
[],//轮播图图片列表
showindex1:0,
bannerImg1:[
'cloud://iii-apple-5g4fz3cz1a2cc511.6969-iii-apple-5g4fz3cz1a2cc511-1304058842/互联网.png',
'cloud://iii-apple-5g4fz3cz1a2cc511.6969-iii-apple-5g4fz3cz1a2cc511-1304058842/数学建模.png',
'cloud://iii-apple-5g4fz3cz1a2cc511.6969-iii-apple-5g4fz3cz1a2cc511-1304058842/数学能力挑战赛.png'],
showindex2:0,
},
/**
* 生命周期函数--监听页面加载
*/
sliderto:function(e){
console.log(e)
var url=e.currentTarget.dataset.url
wx.navigateTo({
url: '/pages/webview/webview?url=' + url,
})
},
onLoad: function (options) {
const that=this
/*轮播图 */
db.collection('slider').orderBy('index','asc').get({
success:function(res){
that.setData({
swiperImg:res.data
})
}
})
/*推荐栏*/
db.collection('recommend').limit(6).orderBy('index','asc').get({
success:function(res){
console.log(res)
that.setData({
bannerImg1:res.data
})
}
})
},
search: function(){
var that = this;
if(this.data.inputcon==''){
wx.showToast({
title: '请输入搜索内容',
icon:'none'
})
}else{
var key = this.data.inputcon;
db.collection('recommend').where({
title: db.RegExp({
regexp: key,
options: 'i'
})
})
.get({
success: function(res) {
console.log(res.data)
that.setData({
inputcon: ''
})
if(res.data.length==0){
wx.showToast({
title: '搜索内容暂无!',
icon:'none'
})
}else{
var model = JSON.stringify(res.data);
wx.navigateTo({
url: '../more/more?model='+model,
})
}
}
})
}
},
bindchange1(e) {
this.setData({
showindex1: e.detail.current,
})
},
bindchange2(e) {
this.setData({
showindex2: e.detail.current
})
},
gotomore1:function(){
wx.navigateTo({
url: '../more/more?isfirst=true',
})
},
gotomore2:function(){
wx.navigateTo({
url: '../more/more?isfirst=false',
})
},
gotocompete:function(){
},
inputchange:function(e){
this.setData({
inputcon: e.detail.value
})
},
})