| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- interface Gallery {
- label?: string;
- src: string;
- }
- type Result = {
- thumbnail: Gallery[];
- source: (Gallery & { target: string; })[];
- }
- // module/chats/components/message-analysis/message-analysis.ts
- const defaultGallery = {
- 'tongueImgUrl': '',
- 'tongueBackImgUrl': '',
- 'faceImgUrl': '',
- }
- Component({
- properties: {
- payload: { type: Object, value: { title: '', description: '' } },
- active: { type: Boolean, value: false },
- },
- data: {
- examples: [
- { label: '舌面举例', src: '../../assets/tongue-1.png' },
- { label: '舌下举例', src: '../../assets/tongue-2.png' },
- { label: '面部举例', src: '../../assets/face-1.png' },
- ] as Gallery[],
- source: [] as Gallery[],
- },
- /**
- * 组件的方法列表
- */
- methods: {
- onConfirm() {
- if (this.data.source.length) return;
- wx.navigateTo({
- url: '/module/chats/pages/analysis/analysis',
- events: { update: (data: Result) => this._update(data) }
- });
- },
- onCancel() {
- this.triggerEvent('next', defaultGallery);
- },
- _update({source, thumbnail}:Result) {
- this.setData({ source: thumbnail });
- const data = {} as AnyObject;
- for (const item of source) { data[item.target] = item.src; }
- this.triggerEvent('next', {
- ...defaultGallery,
- ...data,
- });
- }
- }
- })
|