import { ApiModel } from "../../utils/api"; const _Http = new ApiModel(); Page({ /** * 页面的初始数据 */ data: { iosX: false, //判断是否具有安全距离 optionItem: 0, //底部选中 reltionList: [], //沟通列表 discussionGroupList: [], //讨论组列表 }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { //是否为带有底部安全距离机型 let iosX = (getApp().globalData.safeAreaBottom == 0) ? false : true; this.setData({ iosX }) }, /* 创建对话 */ createDialogue() { wx.navigateTo({ url: './create', }) }, /* 进入对话 */ enterTheDialogue(e) { const { item } = e.currentTarget.dataset; wx.navigateTo({ url: "./dialogbox?id=" + item.timdialogid }) }, /* 获取聊天列表 */ queryImdialogList(condition = "") { _Http.basic({ "accesstoken": wx.getStorageSync('userData').token, "classname": "system.im.imdialog.imdialog", "method": "query_imdialogList", "content": { "getdatafromdbanyway": true, "where": { "condition": condition, "fimdialogtype2": "供需" } } }).then(res => { console.log("对话列表", res) if (res.msg != '成功') return wx.showToast({ title: res.data, icon: "none" }); for (let i = 0; i < res.data.length; i++) { let time = res.data[i].fjoindate.split(" "), date = new Date(), getMonth = (date.getMonth() + 1), Month = (getMonth < 10) ? '0' + getMonth : getMonth, now = date.getFullYear() + '-' + Month + '-' + date.getDate(); if (now == time[0]) { let a1 = time[1].split("."); res.data[i].fjoindate = a1[0]; } else { res.data[i].fjoindate = time[0]; } } let relationList = [], discussionGroupList = []; for (let i = 0; i < res.data.length; i++) { if (res.data[i].fimdialogtype == '话题') { discussionGroupList.push(res.data[i]) } else { relationList.push(res.data[i]) } } this.setData({ relationList, discussionGroupList }) }) }, /* 底部选中 */ footerOption(e) { const { index } = e.currentTarget.dataset; this.setData({ optionItem: index }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { this.queryImdialogList() }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })