privacy.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const api_user = require("../../api/user.js");
  4. const _sfc_main = {
  5. data() {
  6. return {
  7. agreementContent: "",
  8. loading: true,
  9. error: false,
  10. errorMsg: "加载失败,请重试"
  11. };
  12. },
  13. onLoad() {
  14. this.fetchAgreement();
  15. },
  16. methods: {
  17. goBack() {
  18. common_vendor.index.navigateBack();
  19. },
  20. fetchAgreement() {
  21. this.loading = true;
  22. this.error = false;
  23. api_user.getUserAgreement().then((res) => {
  24. console.log(res);
  25. this.loading = false;
  26. this.agreementContent = res.content || "";
  27. console.log(this.agreementContent);
  28. }).catch((err) => {
  29. console.error("获取用户协议失败:", err);
  30. this.error = true;
  31. this.errorMsg = "网络异常,请稍后重试";
  32. }).finally(() => {
  33. this.loading = false;
  34. });
  35. }
  36. }
  37. };
  38. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  39. return common_vendor.e({
  40. a: $data.loading
  41. }, $data.loading ? {} : $data.error ? {
  42. c: common_vendor.t($data.errorMsg),
  43. d: common_vendor.o((...args) => $options.fetchAgreement && $options.fetchAgreement(...args))
  44. } : {
  45. e: $data.agreementContent
  46. }, {
  47. b: $data.error
  48. });
  49. }
  50. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
  51. wx.createPage(MiniProgramPage);