index.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. this.getMsgDet()
  21. },
  22. async getMsgDet() {
  23. let list = await getMsgDet({
  24. senderUid: this.data.targetUid,
  25. pageNo: 1,
  26. pageSize: 20
  27. })
  28. console.log(list);
  29. },
  30. async sendReply() {
  31. if (!this.data.value) {
  32. return
  33. }
  34. await sendMsg({
  35. content: "1",
  36. receiverUid: ""
  37. })
  38. },
  39. bindKeyInput(e) {
  40. this.setData({
  41. value: e.detail.value
  42. })
  43. },
  44. jumpUserInfo({
  45. currentTarget
  46. }) {
  47. wx.navigateTo({
  48. url: `/pages/personal/index?uid=${currentTarget.dataset.uid}&type=user`,
  49. })
  50. },
  51. chooseImage() {
  52. wx.chooseImage({
  53. count: 1, // 可选择的图片数量
  54. sizeType: ['compressed'], // 压缩图片
  55. sourceType: ['album', 'camera'], // 来源:相册或相机
  56. success: (res) => {
  57. // 将选择的图片上传到服务器
  58. this.uploadImage(res.tempFilePaths[0]);
  59. }
  60. })
  61. },
  62. uploadImage(imagePath) {
  63. wx.uploadFile({
  64. url: 'https://reader-api.ai160.com/file/upload',
  65. filePath: imagePath,
  66. header: {
  67. uid: wx.getStorageSync('uid')
  68. },
  69. success: (res) => {
  70. console.log(res.data);
  71. }
  72. })
  73. }
  74. })