index.js 1.0 KB

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