chat.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. //分享组件弹窗调用里边方法,在底下会获取
  81. this.share.showPopup(postId);
  82. },
  83. //跳转详情页
  84. particulars: function (e) {
  85. const postId = e.currentTarget.dataset.postsid;
  86. const type = e.currentTarget.dataset.type;
  87. //取消小点
  88. login.getOpenidSessionKey(function(res) {
  89. APIClient.cancelDian({
  90. uid: res.data.data.uid
  91. }, {
  92. "postsId":postId
  93. }).success((res) => {
  94. console.log(res);
  95. })
  96. }, function() {
  97. wx.showModal({
  98. title: '提示',
  99. content: '需要获取您的公开信息(昵称、头像等),请从小程序列表删除小学王者班后再次扫码进入,允许授权后可正常使用',
  100. showCancel: false,
  101. success: function (res) {
  102. if (res.confirm) {
  103. console.log('用户点击确定')
  104. } else if (res.cancel) {
  105. console.log('用户点击取消')
  106. }
  107. }
  108. })
  109. });
  110. wx.navigateTo({
  111. url: '../../pages/particulars/particulars?postId=' + postId + '&type=' + type
  112. })
  113. },
  114. //查看更多
  115. examine: function () {
  116. //组件间方法的调用
  117. var myEventDetail = {} // detail对象,提供给事件监听函数
  118. var myEventOption = {} // 触发事件的选项
  119. this.triggerEvent('myevent', myEventDetail, myEventOption)
  120. }
  121. },
  122. ready: function(){
  123. //获取分享弹窗组件
  124. this.share = this.selectComponent("#share");
  125. }
  126. })