import { wikiDrugs } from '../../utils/drug-data';
import type { WikiDrug } from '../../utils/drug-data';
import { getDrugImage } from '../../utils/drug-images';

Page({
  data: {
    drug: {} as WikiDrug,
    drugImage: '',
  },
  onLoad(options: Record<string, string>) {
    const id = Number(options.id);
    const drug = wikiDrugs[id];
    if (drug) {
      this.setData({
        drug,
        drugImage: getDrugImage(drug.category),
      });
      wx.setNavigationBarTitle({ title: drug.name });
    } else {
      wx.showToast({ title: '未找到药品信息', icon: 'none' });
    }
  },
});
