chat.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. // compontents/chat/chat.js
  2. const util = require('../../utils/util.js');
  3. const APIClient = require('../../utils/APIClient.js');
  4. const login = require('../../utils/loginSchedule.js');
  5. Component({
  6. /**
  7. * 组件的属性列表
  8. */
  9. properties: {
  10. productionData: {
  11. type: Object,
  12. value: {}
  13. },
  14. title: {
  15. type: String,
  16. value: ''
  17. },
  18. query: {
  19. type: String,
  20. value: ''
  21. },
  22. type: {
  23. type: String,
  24. value: ''
  25. },
  26. columnType: {
  27. type: String,
  28. value: ''
  29. },
  30. more: {
  31. type: String,
  32. value: ''
  33. }
  34. },
  35. /**
  36. * 组件的初始数据
  37. */
  38. data: {
  39. text: '',
  40. chatDatas: [],
  41. animationData: {},
  42. },
  43. /**
  44. * 组件的方法列表
  45. */
  46. methods: {
  47. uploadImage (e) {
  48. const type = this.properties.type;
  49. const columnType = this.properties.columnType;
  50. wx.navigateTo({
  51. url: '../input_content/input_content?type=' + type + '&columnType=' + columnType
  52. })
  53. },
  54. listenerButtonPreviewImage: function(e) {
  55. let imgUrl = [];
  56. imgUrl.push(e.target.dataset.img);
  57. wx.previewImage({
  58. current: '', // 当前显示图片的http链接
  59. urls: imgUrl, // 需要预览的图片http链接列表
  60. //这根本就不走
  61. success: function(res) {
  62. //console.log(res);
  63. },
  64. //也根本不走
  65. fail: function() {
  66. //console.log('fail')
  67. }
  68. })
  69. },
  70. //分享
  71. shareImage: function(e){
  72. console.log(e);
  73. //分享查询单条的时候会用到这两个值
  74. const postId = e.currentTarget.dataset.postsid;
  75. this.share.showPopup(postId);
  76. },
  77. //跳转详情页
  78. particulars: function (e) {
  79. const postId = e.currentTarget.dataset.postsid;
  80. const type = e.currentTarget.dataset.type;
  81. //取消小点
  82. login.getOpenidSessionKey(function(res) {
  83. APIClient.cancelDian({
  84. uid: res.data.data.uid
  85. }, {
  86. "postsId":postId
  87. }).success((res) => {
  88. console.log(res);
  89. })
  90. }, function() {
  91. wx.showModal({
  92. title: '提示',
  93. content: '需要获取您的公开信息(昵称、头像等),请从小程序列表删除小学王者班后再次扫码进入,允许授权后可正常使用',
  94. showCancel: false,
  95. success: function (res) {
  96. if (res.confirm) {
  97. console.log('用户点击确定')
  98. } else if (res.cancel) {
  99. console.log('用户点击取消')
  100. }
  101. }
  102. })
  103. });
  104. wx.navigateTo({
  105. url: '../../pages/particulars/particulars?postId=' + postId + '&type=' + type
  106. })
  107. },
  108. //查看更多
  109. examine: function () {
  110. //console.log(1)
  111. var myEventDetail = {} // detail对象,提供给事件监听函数
  112. var myEventOption = {} // 触发事件的选项
  113. this.triggerEvent('myevent', myEventDetail, myEventOption)
  114. }
  115. },
  116. ready: function(){
  117. this.share = this.selectComponent("#share");
  118. }
  119. })