123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- import {
- TestVerify
- } from "../../utils/verify";
- import {
- ApiModel
- } from "../../utils/api"
- const _Http = new ApiModel();
- const _Verify = new TestVerify();
- const processingData = require("../../utils/processingData.js");
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- tabsList: ['通告', '供需', '直播'],
- ftype: 3, //1:直播,2:供需,3:通告
- annunciateList: [], //通告列表
- liveList: [], //直播列表
- supplyanddemandList: [], //供需列表
- showPlaceholder: true, //是否显示占位图
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- },
- //切换搜索类型
- tabsSelectedIitem({
- detail
- }) {
- let ftype = this.data.ftype;
- switch (detail) {
- case "通告":
- ftype = 3;
- break;
- case "供需":
- ftype = 2;
- break;
- case "直播":
- ftype = 1;
- break;
- }
- if (ftype == this.data.ftype) return;
- this.setData({
- ftype
- });
- this.isPlaceholder()
- },
- /* 搜索关键字 */
- searchContent(e) {
- let {
- value
- } = e.detail;
- value = _Verify.Eliminate(value.trim());
- if (value) {
- _Http.basic({
- "classname": "publicmethod.homepage.homepage",
- "method": "searchPortalInfo",
- "content": {
- "getdatafromdbanyway": true,
- "keyStr": value,
- "ftype": ""
- }
- }).then(res => {
- if (res.msg != '成功') return wx.showToast({
- title: res.data,
- icon: 'none'
- })
- let annunciateList = res.data.TNOTICE,
- supplyanddemandList = res.data.tsupplyanddemand;
- if (annunciateList.length != 0) annunciateList = processingData.annunciateCheckdate(annunciateList);
- if (supplyanddemandList.length != 0) supplyanddemandList = processingData.annunciateCheckdate(supplyanddemandList);
- this.setData({
- annunciateList,
- liveList: res.data.tlive,
- supplyanddemandList
- })
- this.isPlaceholder()
- })
- } else {
- this.setData({
- annunciateList: [],
- liveList: [],
- supplyanddemandList: []
- })
- this.isPlaceholder()
- }
- },
- /* 是否显示占位图 */
- isPlaceholder() {
- let showPlaceholder = false;
- switch (this.data.ftype) {
- case 3:
- showPlaceholder = (this.data.annunciateList.length == 0) ? true : false;
- break;
- case 2:
- showPlaceholder = (this.data.supplyanddemandList.length == 0) ? true : false;
- break;
- case 1:
- showPlaceholder = (this.data.liveList.length == 0) ? true : false;
- break;
- }
- this.setData({
- showPlaceholder
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|