/** * 预览页底部悬浮操作条:左为次级操作(分享,toy-button type=secondary),右为主操作(保存等,primary)。 */ Component({ options: { styleIsolation: 'apply-shared', addGlobalClass: true, }, properties: { primaryText: { type: String, value: '保存到相册', }, primaryIcon: { type: String, value: 'download', }, secondaryText: { type: String, value: '分享', }, /** 须对应 iconfont 中 toy-icon-{name};历史上常用 wechat 已映射为 wechat-o */ secondaryIcon: { type: String, value: 'line-share', }, disabled: { type: Boolean, value: false, }, loading: { type: Boolean, value: false, }, shareOpenType: { type: String, value: 'share', }, }, data: { /** 经归一化后的图标名,供 wxml 绑定(避免父级传 wechat 等 iconfont 中不存在的 name) */ resolvedSecondaryIcon: 'line-share', }, observers: { secondaryIcon() { this.syncSecondaryIconGlyph(); }, }, lifetimes: { attached() { this.syncSecondaryIconGlyph(); }, }, methods: { syncSecondaryIconGlyph() { const raw = (this.data.secondaryIcon ?? '').trim(); const aliases: Record = { wechat: 'wechat-o', }; const name = aliases[raw] || raw; this.setData({ resolvedSecondaryIcon: name || 'line-share', }); }, onPrimaryTap() { if (this.data.disabled || this.data.loading) return; this.triggerEvent('primary'); }, onSecondaryTap() { this.triggerEvent('secondary'); }, }, });