index.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import {
  2. getMsgDet,
  3. sendMsg
  4. } from "~/api/message"
  5. const app = getApp()
  6. Page({
  7. data: {
  8. targetUid: '',
  9. value: '',
  10. isIos: app.globalData.isIOS
  11. },
  12. onLoad(options) {
  13. console.log(options);
  14. wx.setNavigationBarTitle({
  15. title: options.title,
  16. })
  17. this.setData({
  18. targetUid: options.uid
  19. })
  20. },
  21. async getMsgDet() {
  22. await getMsgDet()
  23. },
  24. async sendReply() {
  25. if (!this.data.value) {
  26. return
  27. }
  28. await sendMsg({
  29. content: "1",
  30. receiverUid: ""
  31. })
  32. },
  33. bindKeyInput(e) {
  34. this.setData({
  35. value: e.detail.value
  36. })
  37. },
  38. jumpUserInfo({
  39. currentTarget
  40. }) {
  41. wx.navigateTo({
  42. url: `/pages/personal/index?uid=${currentTarget.dataset.uid}&type=user`,
  43. })
  44. },
  45. chooseImage() {
  46. wx.chooseImage({
  47. count: 1, // 可选择的图片数量
  48. sizeType: ['compressed'], // 压缩图片
  49. sourceType: ['album', 'camera'], // 来源:相册或相机
  50. success: (res) => {
  51. // 将选择的图片上传到服务器
  52. this.uploadImage(res.tempFilePaths[0]);
  53. }
  54. })
  55. },
  56. uploadImage(imagePath) {
  57. wx.uploadFile({
  58. url: 'https://reader-api.ai160.com/file/upload',
  59. filePath: imagePath,
  60. header: {
  61. uid: wx.getStorageSync('uid')
  62. },
  63. success: (res) => {
  64. console.log(res.data);
  65. }
  66. })
  67. }
  68. })