chat.js 3.0 KB

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