86 lines
2.2 KiB
JavaScript
86 lines
2.2 KiB
JavaScript
// pages/policy/policy.js
|
|
import PolicyService from '../../utils/api/policyApi';
|
|
const app = getApp();
|
|
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
isLoading: false,
|
|
hasMore: true,
|
|
triggered: false,
|
|
policyList: [], //政策
|
|
pageShowLoading: true, //显示页面加载
|
|
currentId: '8e20af26-fed2-4829-a87c-9eddd6311d7c',
|
|
keywords: '',
|
|
showContentLoading: true
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad(options) {
|
|
this.getPolicyList(this.data.keywords)
|
|
},
|
|
inputValue(e) {
|
|
var _self = this
|
|
_self.setData({
|
|
keywords: e.detail.value
|
|
})
|
|
},
|
|
doSearch() {
|
|
var _self = this
|
|
_self.getPolicyList(_self.data.keywords)
|
|
_self.setData({
|
|
keywords: ''
|
|
})
|
|
},
|
|
getPolicyList(k) {
|
|
var _self = this
|
|
_self.setData({
|
|
showContentLoading: true
|
|
})
|
|
PolicyService.doGetPolicyList({
|
|
newsDirectoriesId: _self.data.currentId,
|
|
keywords: k
|
|
})
|
|
.then(res => {
|
|
_self.setData({
|
|
showContentLoading: false
|
|
})
|
|
if (res) {
|
|
if (res.rows && res.rows.length <= 0) {
|
|
wx.showToast({
|
|
icon: 'none',
|
|
title: '暂无数据',
|
|
})
|
|
} else {
|
|
_self.setData({
|
|
policyList: res.rows
|
|
})
|
|
}
|
|
}
|
|
}, err => {
|
|
_self.setData({
|
|
showContentLoading: false
|
|
})
|
|
wx.showToast({
|
|
title: '网络错误(policy)',
|
|
})
|
|
})
|
|
},
|
|
//详情
|
|
goDetail(e) {
|
|
wx.navigateTo({
|
|
url: '/pages/policy-detail/policy-detail?id=' + e.currentTarget.dataset.id,
|
|
})
|
|
},
|
|
changeTab(e) {
|
|
this.setData({
|
|
currentId: e.currentTarget.dataset.id
|
|
})
|
|
this.getPolicyList(this.data.keywords)
|
|
}
|
|
}) |