Skip to content

Commit

Permalink
fix:教材查询添加搜索条件
Browse files Browse the repository at this point in the history
  • Loading branch information
hey-a-pple committed Jul 23, 2024
1 parent d1b66f2 commit 5ca7161
Show file tree
Hide file tree
Showing 2 changed files with 133 additions and 13 deletions.
139 changes: 127 additions & 12 deletions miniprogram/pages/sydw/tgjsjccx/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ Page({
actid: "", //zg99id
backgroundColor: "",

yearList: [],
yearValue: '',

dsList: [],
dsValue: '',

dwList: [],
dwValue: '',

Expand All @@ -37,6 +43,97 @@ Page({
m_select_touch(e) {
var _this = this
switch (e.detail.type) {
case "year": //年份
_this.setData({
yearValue: e.detail.text,
dsList: [],

})

// zg99二级联动
wx.request({
url: "https://zg99.offcn.com/index/chaxun/getlevel?actid=" + _this.data.actid, //路径
data: {
level: '2',
grfiled: 'item01',
grtext: e.detail.text,
sstime: new Date().valueOf()
}, //二级联动,上级联动字段名,上级联动参数值
success(res) {
let response = JSON.parse(res.data.substring(1, res.data.length - 1)); //去头尾(),转为json对象
// 现将之前内容清空
const List = []


// 将数据添加到已清空的列表中
for (var i = 0; i < response.lists.length; i++) {

List.push(response.lists[i].item02)
}
_this.setData({
dsList:List
})


},
fail: err => { //获取失败后提示
wx.hideLoading() // 隐藏 loading
getApp().methods.handleError({
err: err,
title: "出错啦",
content: '查询失败',
reLaunch: true
})
}
})
break

case "ds": //地市
_this.setData({
dsValue: e.detail.text,
dwList: [],

})

// zg99二级联动
wx.request({
url: "https://zg99.offcn.com/index/chaxun/getlevel?actid=" + _this.data.actid, //路径
data: {
level: '3',
grfiled: 'item02',
grtext: e.detail.text,
sstime: new Date().valueOf()
}, //二级联动,上级联动字段名,上级联动参数值
success(res) {
let response = JSON.parse(res.data.substring(1, res.data.length - 1)); //去头尾(),转为json对象
// 现将之前内容清空
const List = []


// 将数据添加到已清空的列表中
for (var i = 0; i < response.lists.length; i++) {

List.push(response.lists[i].item03)
}
_this.setData({
dwList:List
})


},
fail: err => { //获取失败后提示
wx.hideLoading() // 隐藏 loading
getApp().methods.handleError({
err: err,
title: "出错啦",
content: '查询失败',
reLaunch: true
})
}
})
break


case "dw": //单位
_this.setData({
dwValue: e.detail.text,
Expand All @@ -48,24 +145,24 @@ Page({
wx.request({
url: "https://zg99.offcn.com/index/chaxun/getlevel?actid=" + _this.data.actid, //路径
data: {
level: '2',
grfiled: 'item01',
level: '4',
grfiled: 'item03',
grtext: e.detail.text,
sstime: new Date().valueOf()
}, //二级联动,上级联动字段名,上级联动参数值
success(res) {
let response = JSON.parse(res.data.substring(1, res.data.length - 1)); //去头尾(),转为json对象
// 现将之前内容清空
const gwList = []
const List = []


// 将数据添加到已清空的列表中
for (var i = 0; i < response.lists.length; i++) {

gwList.push(response.lists[i].item02)
List.push(response.lists[i].item04)
}
_this.setData({
gwList
gwList:List
})


Expand Down Expand Up @@ -118,9 +215,24 @@ Page({
//查询
search() {
let _this = this //作用域
if (!_this.data.yearValue) {
wx.showToast({
title: '请输入年份',
icon: 'error'
})
return
}

if (!_this.data.dsValue) {
wx.showToast({
title: '请输入地市',
icon: 'error'
})
return
}
if (!_this.data.dwValue) {
wx.showToast({
title: '请输入单位名称',
title: '请输入单位',
icon: 'error'
})
return
Expand All @@ -133,8 +245,11 @@ Page({
wx.request({
url: "https://zg99.offcn.com/index/chaxun/getfzinfo?actid=" + _this.data.actid,
data: {
item01: this.data.dwValue,
item02: this.data.gwValue,
item01: this.data.yearValue,
item02: this.data.dsValue,
item03: this.data.dwValue,
item04: this.data.gwValue,

tabnum: 2,
limits: 200,
page: this.data.page,
Expand Down Expand Up @@ -308,13 +423,13 @@ Page({
return
}
// 录入问题,不用提前清空,因为只进行一次获取
const dwList = [];
const yearList = [];
for (var i = 0; i < list.lists.length; i++) {
dwList.push(list.lists[i].item01)
yearList.push(list.lists[i].item01)

}
_this.setData({
dwList
yearList
})
// 判断是否是单页模式
if (wx.getLaunchOptionsSync().scene !== 1154) {
Expand Down Expand Up @@ -429,7 +544,7 @@ Page({
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
if (this.data.dwValue !== "" && this.data.gwValue !== "" && this.data.result.length < this.data.count) {
if (this.data.yearValue!== "" && this.data.dsValue!== "" && this.data.dsValue !== "" && this.data.gwValue !== "" && this.data.result.length < this.data.count) {
this.search();
}
},
Expand Down
7 changes: 6 additions & 1 deletion miniprogram/pages/sydw/tgjsjccx/index.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
<image mode="widthFix" src="{{imageUrl}}" class="banner_bk w100"></image>
<view class="container">
<view class="select_wrap">

<view class='offcn_item' wx:if="{{yearList.length > 0}}">
<select-search options='{{yearList}}' icon="icon-icon1" text="年份" type="year" bind:m_selectSearch_touch="m_select_touch"></select-search>
</view>
<view class='offcn_item' wx:if="{{dsList.length > 0}}">
<select-search options='{{dsList}}' icon="icon-icon1" text="地市" type="ds" bind:m_selectSearch_touch="m_select_touch"></select-search>
</view>
<view class='offcn_item' wx:if="{{dwList.length > 0}}">
<select-search options='{{dwList}}' icon="icon-icon1" text="学段" type="dw" bind:m_selectSearch_touch="m_select_touch"></select-search>
</view>
Expand Down

0 comments on commit 5ca7161

Please sign in to comment.