user-agreement.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <template>
  2. <view class="user-agreement">
  3. <view class="agreement-title">{{ agreementData.title }}</view>
  4. <view class="agreement-content">
  5. <rich-text :nodes="agreementData.content"></rich-text>
  6. </view>
  7. </view>
  8. </template>
  9. <script>
  10. import { ARTICLE_CODE, ARTICLE_TITLE } from '@/utils/policy-config.js'
  11. export default {
  12. data() {
  13. return {
  14. articleCode: ARTICLE_CODE.orderAgreement,
  15. agreementData: {
  16. title: "",
  17. content: "",
  18. },
  19. };
  20. },
  21. onLoad(options) {
  22. const code = options.code || ARTICLE_CODE.orderAgreement
  23. let title = ARTICLE_TITLE.orderAgreement
  24. if (options.title) {
  25. title = decodeURIComponent(options.title)
  26. } else {
  27. Object.keys(ARTICLE_CODE).forEach((key) => {
  28. if (ARTICLE_CODE[key] === code && ARTICLE_TITLE[key]) {
  29. title = ARTICLE_TITLE[key]
  30. }
  31. })
  32. }
  33. this.articleCode = code
  34. uni.setNavigationBarTitle({ title })
  35. this.fetchAgreement()
  36. },
  37. methods: {
  38. fetchAgreement() {
  39. uni.showLoading({
  40. title: "加载中...",
  41. });
  42. uni.$u.http
  43. .get(`/token/getArticleOne?code=${this.articleCode}`)
  44. .then((res) => {
  45. if (res.code === 200) {
  46. this.agreementData = res.data;
  47. } else {
  48. this.$u.toast(res.msg || "获取协议内容失败");
  49. }
  50. })
  51. .finally(() => {
  52. uni.hideLoading();
  53. });
  54. },
  55. },
  56. };
  57. </script>
  58. <style lang="scss" scoped>
  59. .user-agreement {
  60. min-height: 100vh;
  61. background-color: $app-theme-bg-color;
  62. padding: 30rpx;
  63. padding-bottom: 50px;
  64. .agreement-title {
  65. font-size: 36rpx;
  66. font-weight: bold;
  67. color: $app-theme-text-color;
  68. text-align: center;
  69. margin-bottom: 40rpx;
  70. }
  71. .agreement-content {
  72. font-size: 28rpx;
  73. color: $app-theme-text-color;
  74. line-height: 1.8;
  75. :deep(rich-text) {
  76. width: 100%;
  77. }
  78. }
  79. }
  80. </style>