index.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. discussionGroupList: [], //讨论组列表
  14. },
  15. /**
  16. * 生命周期函数--监听页面加载
  17. */
  18. onLoad: function (options) {
  19. //是否为带有底部安全距离机型
  20. let iosX = (getApp().globalData.safeAreaBottom == 0) ? false : true;
  21. this.setData({
  22. iosX
  23. })
  24. },
  25. /* 创建对话 */
  26. createDialogue() {
  27. wx.navigateTo({
  28. url: './create',
  29. })
  30. },
  31. /* 进入对话 */
  32. enterTheDialogue(e) {
  33. const {
  34. item
  35. } = e.currentTarget.dataset;
  36. wx.navigateTo({
  37. url: "./dialogbox?id=" + item.timdialogid
  38. })
  39. },
  40. /* 获取聊天列表 */
  41. queryImdialogList(condition = "") {
  42. _Http.basic({
  43. "accesstoken": wx.getStorageSync('userData').token,
  44. "classname": "system.im.imdialog.imdialog",
  45. "method": "query_imdialogList",
  46. "content": {
  47. "getdatafromdbanyway": true,
  48. "where": {
  49. "condition": condition,
  50. "fimdialogtype2": "供需"
  51. }
  52. }
  53. }).then(res => {
  54. console.log("对话列表", res)
  55. if (res.msg != '成功') return wx.showToast({
  56. title: res.data,
  57. icon: "none"
  58. });
  59. for (let i = 0; i < res.data.length; i++) {
  60. let time = res.data[i].fjoindate.split(" "),
  61. date = new Date(),
  62. getMonth = (date.getMonth() + 1),
  63. Month = (getMonth < 10) ? '0' + getMonth : getMonth,
  64. now = date.getFullYear() + '-' + Month + '-' + date.getDate();
  65. if (now == time[0]) {
  66. let a1 = time[1].split(".");
  67. res.data[i].fjoindate = a1[0];
  68. } else {
  69. res.data[i].fjoindate = time[0];
  70. }
  71. }
  72. let relationList = [],
  73. discussionGroupList = [];
  74. for (let i = 0; i < res.data.length; i++) {
  75. if (res.data[i].fimdialogtype == '话题') {
  76. discussionGroupList.push(res.data[i])
  77. } else {
  78. relationList.push(res.data[i])
  79. }
  80. }
  81. this.setData({
  82. relationList,
  83. discussionGroupList
  84. })
  85. })
  86. },
  87. /* 底部选中 */
  88. footerOption(e) {
  89. const {
  90. index
  91. } = e.currentTarget.dataset;
  92. this.setData({
  93. optionItem: index
  94. })
  95. },
  96. /**
  97. * 生命周期函数--监听页面初次渲染完成
  98. */
  99. onReady: function () {
  100. },
  101. /**
  102. * 生命周期函数--监听页面显示
  103. */
  104. onShow: function () {
  105. this.queryImdialogList()
  106. },
  107. /**
  108. * 生命周期函数--监听页面隐藏
  109. */
  110. onHide: function () {
  111. },
  112. /**
  113. * 生命周期函数--监听页面卸载
  114. */
  115. onUnload: function () {
  116. },
  117. /**
  118. * 页面相关事件处理函数--监听用户下拉动作
  119. */
  120. onPullDownRefresh: function () {
  121. },
  122. /**
  123. * 页面上拉触底事件的处理函数
  124. */
  125. onReachBottom: function () {
  126. },
  127. /**
  128. * 用户点击右上角分享
  129. */
  130. onShareAppMessage: function () {
  131. }
  132. })