chat.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. const app = getApp();
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. focus: false,
  8. // scrollTop: 100,
  9. menu: false, //菜单显示隐藏
  10. uploadImages: ["/image/smyz2.png","/image/smyz1.png"], //相册放大图集
  11. news:'',//input消息
  12. inputValue: null, //input 的 value
  13. messages:'',//接收消息数据
  14. photo:'', //相片
  15. },
  16. onLoad: function (options) {
  17. var that = this;
  18. },
  19. // 点击scroll-view 关闭底部菜单
  20. resetInputStatus: function() {
  21. var that = this;
  22. that.setData({
  23. menu: false, //关闭底部菜单
  24. })
  25. },
  26. // 底部菜单显示隐藏切换
  27. chatInputExtraClickEvent:function(){
  28. var that = this;
  29. that.setData({
  30. menu: !that.data.menu
  31. })
  32. },
  33. // 相册点击放大
  34. enlarge: function (e) {
  35. var that = this;
  36. // console.log(that.data.uploadImages)
  37. // console.log(e.currentTarget.dataset.src,)
  38. wx.previewImage({
  39. current: e.currentTarget.dataset.src, // 当前显示图片的http链接
  40. urls: that.data.uploadImages, // 需要预览的图片http链接列表
  41. })
  42. },
  43. // 发送消息事件
  44. Sendout: function (e) {
  45. var that = this;
  46. console.log(that.data.news);
  47. that.setData({
  48. menu: false, //隐藏底部菜单
  49. inputValue: '', //清空 input
  50. messages: that.data.news, //显示信息
  51. })
  52. console.log('发送');
  53. },
  54. //输入框
  55. Telephone: function (e) {
  56. var that = this;
  57. // console.log(e.detail.value);
  58. that.setData({
  59. news: e.detail.value, //获取输入文字
  60. })
  61. },
  62. // 上传图片
  63. chooseImageTap: function () {
  64. var that = this;
  65. wx.chooseImage({
  66. count: 1,
  67. sizeType: ['original', 'compressed'],
  68. sourceType: ['album', 'camera'],
  69. success(res) {
  70. console.log(res.tempFilePaths[0]);
  71. // tempFilePath可以作为img标签的src属性显示图片
  72. that.setData({
  73. photo: res.tempFilePaths[0],
  74. });
  75. }
  76. })
  77. },
  78. // 重发消息
  79. retransmission:function(){
  80. wx.showModal({
  81. content: '重发该消息?',
  82. success(res) {
  83. if (res.confirm) {
  84. console.log('用户点击确定')
  85. } else if (res.cancel) {
  86. console.log('用户点击取消')
  87. }
  88. }
  89. })
  90. }
  91. })