66 lines
1.3 KiB
JavaScript
66 lines
1.3 KiB
JavaScript
// pages/lianxi/search.js
|
|
const api = require("../../utils/request.js");
|
|
Page({
|
|
data: {
|
|
listData: [],
|
|
isLoad: true,
|
|
query:{
|
|
page:1,
|
|
limit:20,
|
|
search:''
|
|
}
|
|
},
|
|
onLoad: function () {
|
|
if (getApp().globalData.userinfo.workscope) {
|
|
} else {
|
|
wx.switchTab({
|
|
url: '/pages/main/main',
|
|
})
|
|
}
|
|
},
|
|
onShow: function () {
|
|
this.setData({
|
|
listData:[],
|
|
['query.search']:''
|
|
})
|
|
},
|
|
cancelSearch:function(){
|
|
this.setData({
|
|
listData:[],
|
|
['query.search']:''
|
|
|
|
})
|
|
},
|
|
search: function (e) {
|
|
// debugger;
|
|
console.log(e.detail.value)
|
|
this.setData({
|
|
['query.search']:e.detail.value
|
|
})
|
|
api.request('/question/question/', 'GET', this.data.query).then(res => {
|
|
if(res.data && res.data.results){
|
|
this.setData({
|
|
listData:res.data.results
|
|
})
|
|
console.log(res.data.results)
|
|
}else{
|
|
}
|
|
})
|
|
},
|
|
goDetail: function (e) {
|
|
console.log(e.currentTarget.dataset.id)
|
|
wx.navigateTo({
|
|
url: `/pages/question/detail?id=${e.currentTarget.dataset.id}`,
|
|
})
|
|
},
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {
|
|
},
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
},
|
|
}) |