| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- import PageContainerBehavior from "../../../../core/behavior/page-container.behavior";
- import tickleBehavior, {
- getTickleContext,
- } from "../../../../core/behavior/tickle.behavior";
- import { getScienceMethod } from "../../request";
- // module/diet/pages/science-info/science-info.ts
- Component({
- behaviors: [PageContainerBehavior, tickleBehavior],
- lifetimes: {
- attached() {
- const channel = this.getOpenerEventChannel();
- channel.on?.("load", (data: AnyObject) => {
- // 支持直接传入外链 URL,直接使用 web-view 打开 新加的
- if (data?.url) {
- this.setData({
- dataset: { content: data.url },
- title: data?.title ?? "",
- });
- return;
- }
- // ===end===
- this.setData({ title: data?.title ?? "" });
- });
- this.load();
- },
- },
- properties: {
- id: { type: String, value: "" },
- },
- data: {
- title: "",
- },
- methods: {
- async load() {
- wx.showLoading({ title: "加载中" });
- try {
- const dataset = await getScienceMethod(this.data.id);
- this.setData({ dataset, title: dataset.name });
- } catch (error) {
- getTickleContext.call(this).showWarnMessage(error.errMsg);
- }
- wx.hideLoading();
- },
- },
- });
|