examtest_mp/pages/main/threshold/threshold.js

84 lines
1.9 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// pages/lianxi/index.js
const api = require("../../../utils/request.js");
Page({
data: {
results: [],
count:1,
query: {
page: 1,
limit: 10,
search:'',
compound_cate:''
},
arrayIndex:null,
array: ['醇类', '醛类', '酸类', '酯类', '酮类', '醚类', '酚类', '苯系物', '卤代物', '烷烃类', '烯烃类', '硫化物', '胺类', '其他'],
listData:[],
},
onLoad: function () {
this.getList();
},
onShow: function () {
},
searchChange(e){
var that = this;
that.setData({
listData:[],
['query.page']:1,
['query.search']:e.detail.value
})
that.getList();
},
searchClear(){
this.setData({
['query.search']:'',
['query.page']:1,
['query.compound_cate']:'',
listData:[],
arrayIndex:null,
})
this.getList();
},
getList () {
var that = this;
console.log(that.data.query)
api.request('/cms/threshold/', 'GET',that.data.query).then(res => {
let list = res.data.results;
let dataList = that.data.listData;
for(let i = 0;i<list.length;i++){
dataList.push(list[i])
}
that.setData({
listData:dataList,
count:res.data.count
})
})
},
bindPickerChange(e) {
console.log('picker发送选择改变携带值为', e.detail.value)
let cate = this.data.array[e.detail.value];
this.setData({
arrayIndex: e.detail.value,
['query.compound_cate']:cate,
['query.page']:1,
listData:[]
})
this.getList();
},
onHide: function () {
},
onReachBottom() {
var that = this;
if (that.data.count > that.data.listData.length) {
that.setData({
['query.page']:that.data.query.page + 1,
})
that.getList()
} else {
wx.showToast({
title: '没有更多了',
icon: 'none'
})
}
},
})