index.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. import {
  2. ApiModel
  3. } from "../../utils/api";
  4. const _Http = new ApiModel();
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. iosX: false, //判断是否具有安全距离
  11. optionItem: 0, //底部选中
  12. reltionList: [], //沟通列表
  13. },
  14. /**
  15. * 生命周期函数--监听页面加载
  16. */
  17. onLoad: function (options) {
  18. //是否为带有底部安全距离机型
  19. let iosX = (getApp().globalData.safeAreaBottom == 0) ? false : true;
  20. this.setData({
  21. iosX
  22. })
  23. },
  24. /* 进入对话 */
  25. enterTheDialogue(e) {
  26. const {
  27. item
  28. } = e.currentTarget.dataset;
  29. wx.navigateTo({
  30. url: "./dialogbox?id=" + item.timdialogid
  31. })
  32. },
  33. /* 获取聊天列表 */
  34. queryImdialogList(condition = "") {
  35. _Http.basic({
  36. "accesstoken": wx.getStorageSync('userData').token,
  37. "classname": "system.im.imdialog.imdialog",
  38. "method": "query_imdialogList",
  39. "content": {
  40. "getdatafromdbanyway": true,
  41. "where": {
  42. "condition": condition
  43. }
  44. }
  45. }).then(res => {
  46. console.log("获取聊天记录", res)
  47. if (res.msg != '成功') return wx.showToast({
  48. title: res.data,
  49. icon: "none"
  50. });
  51. this.setData({
  52. relationList: res.data
  53. })
  54. })
  55. },
  56. /* 底部选中 */
  57. footerOption(e) {
  58. const {
  59. index
  60. } = e.currentTarget.dataset;
  61. console.log(index)
  62. this.setData({
  63. optionItem: index
  64. })
  65. },
  66. /**
  67. * 生命周期函数--监听页面初次渲染完成
  68. */
  69. onReady: function () {
  70. },
  71. /**
  72. * 生命周期函数--监听页面显示
  73. */
  74. onShow: function () {
  75. this.queryImdialogList()
  76. },
  77. /**
  78. * 生命周期函数--监听页面隐藏
  79. */
  80. onHide: function () {
  81. },
  82. /**
  83. * 生命周期函数--监听页面卸载
  84. */
  85. onUnload: function () {
  86. },
  87. /**
  88. * 页面相关事件处理函数--监听用户下拉动作
  89. */
  90. onPullDownRefresh: function () {
  91. },
  92. /**
  93. * 页面上拉触底事件的处理函数
  94. */
  95. onReachBottom: function () {
  96. },
  97. /**
  98. * 用户点击右上角分享
  99. */
  100. onShareAppMessage: function () {
  101. }
  102. })