"use strict"; const common_vendor = require("../../common/vendor.js"); require("../../utils/request.js"); const common_config = require("../../common/config.js"); const _sfc_main = { data() { return { agreementContent: "", loading: true, error: false, errorMsg: "加载失败,请重试" }; }, computed: { parsedContent() { if (!this.agreementContent) return ""; return this.parseMarkdown(this.agreementContent); } }, onLoad() { this.fetchAgreement(); }, methods: { // 简单的 markdown 解析函数 parseMarkdown(markdown) { if (!markdown) return ""; let html = markdown.replace(/^### (.*$)/gim, "

$1

").replace(/^## (.*$)/gim, "

$1

").replace(/^# (.*$)/gim, "

$1

").replace(/\*\*(.*)\*\*/gim, "$1").replace(/\*(.*)\*/gim, "$1").replace(/\[([^\]]*)\]\(([^\)]*)\)/gim, '$1').replace(/```(.*?)```/gims, "
$1
").replace(/`([^`]*)`/gim, "$1").replace(/^\* (.*$)/gim, "
  • $1
  • ").replace(/^\d+\. (.*$)/gim, "
  • $1
  • ").replace(/\n\n/gim, "

    ").replace(/\n/gim, "
    "); html = html.replace(/(

  • .*<\/li>)/gim, ""); if (html && !html.startsWith(""; } return html; }, goBack() { common_vendor.index.navigateBack(); }, async fetchAgreement() { this.loading = true; this.error = false; const res = await common_vendor.index.request({ url: `${common_config.apiBaseUrl}/api/public/agreements/terms_of_service/`, method: "GET" }); console.log(res); if (res.statusCode == 200) { this.loading = false; this.agreementContent = res.data.content || ""; } } } }; function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { return common_vendor.e({ a: $data.loading }, $data.loading ? {} : $data.error ? { c: common_vendor.t($data.errorMsg), d: common_vendor.o((...args) => $options.fetchAgreement && $options.fetchAgreement(...args)) } : { e: $options.parsedContent }, { b: $data.error }); } const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]); wx.createPage(MiniProgramPage);