chat.js 3.5 KB

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