message-analysis.ts 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. interface Gallery {
  2. label?: string;
  3. src: string;
  4. }
  5. type Result = {
  6. thumbnail: Gallery[];
  7. source: (Gallery & { target: string; })[];
  8. }
  9. // module/chats/components/message-analysis/message-analysis.ts
  10. const defaultGallery = {
  11. 'tongueImgUrl': '',
  12. 'tongueBackImgUrl': '',
  13. 'faceImgUrl': '',
  14. }
  15. Component({
  16. properties: {
  17. payload: { type: Object, value: { title: '', description: '' } },
  18. active: { type: Boolean, value: false },
  19. },
  20. data: {
  21. examples: [
  22. { label: '舌面举例', src: '../../assets/tongue-1.png' },
  23. { label: '舌下举例', src: '../../assets/tongue-2.png' },
  24. { label: '面部举例', src: '../../assets/face-1.png' },
  25. ] as Gallery[],
  26. source: [] as Gallery[],
  27. },
  28. /**
  29. * 组件的方法列表
  30. */
  31. methods: {
  32. onConfirm() {
  33. if (this.data.source.length) return;
  34. wx.navigateTo({
  35. url: '/module/chats/pages/analysis/analysis',
  36. events: { update: (data: Result) => this._update(data) }
  37. });
  38. },
  39. onCancel() {
  40. this.triggerEvent('next', defaultGallery);
  41. },
  42. _update({source, thumbnail}:Result) {
  43. this.setData({ source: thumbnail });
  44. const data = {} as AnyObject;
  45. for (const item of source) { data[item.target] = item.src; }
  46. this.triggerEvent('next', {
  47. ...defaultGallery,
  48. ...data,
  49. });
  50. }
  51. }
  52. })