const b_loadingStatus = require("../../../base/behaviors/b_loadingStatus")
|
const consultservice = require("../../../service/consultservice")
|
const util = require("../../../utils/util")
|
const app = getApp()
|
|
/**
|
* 通过分类获取问题
|
*/
|
module.exports = Behavior({
|
behaviors: [b_loadingStatus],
|
data: {
|
//搜索结果
|
questions: [],
|
},
|
methods: {
|
loadmore(cPage) {
|
this.getQuestionsByType(++cPage, this.selectedValues)
|
},
|
/**
|
* 根据要素类型获取对应的问题
|
* @see "./b_element-types.js"
|
* @param page 分页
|
* @param selectedValues [i, j],选中的分类编号i和子类编号j,i、j为null表示全部
|
*/
|
getQuestionsByType(page = 1, selectedValues, perPage = this.data.perPage) {
|
this.selectedValues = selectedValues
|
this.setData({loading: true})
|
// const t = setTimeout(() => {
|
// this.setData({loading: false})
|
// }, 10000);
|
var that = this
|
consultservice.getQuestionsByType(app.globalData.accessToken.userId, selectedValues[0], selectedValues[1], page, perPage, {
|
onPage(head) {
|
that.setData({
|
cPage: head.page,
|
tPage: head.totalPage,
|
perPage: perPage,
|
totalCount: head.totalCount
|
})
|
},
|
success(res) {
|
res.forEach(r => {
|
r.time = util.formatTime(r.time)
|
r.des = r.des.replaceAll('\\n', '<br/>')
|
});
|
let questions = that.data.questions
|
if (page == 1) {
|
questions = []
|
}
|
questions = questions.concat(res)
|
that.setData({questions})
|
},
|
complete(e) {
|
that.setData({loading: false})
|
clearTimeout(t)
|
}
|
})
|
},
|
}
|
})
|