index.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <template>
  2. <view class="u-rules">
  3. <parse :content="html"></parse>
  4. </view>
  5. </template>
  6. <script>
  7. import parse from "../../components/basic-component/app-rich/parse.vue";
  8. export default {
  9. name: "index",
  10. data() {
  11. return {
  12. html: ''
  13. }
  14. },
  15. components: {
  16. parse
  17. },
  18. onLoad(options) { this.$commonLoad.onload(options);
  19. options.keys ? options.keys = JSON.parse(options.keys) : null;
  20. options.data ? options.data = JSON.parse(options.data) : null;
  21. this.request(decodeURIComponent(options.url), options.key, options.keys, options.data, options.title);
  22. },
  23. methods: {
  24. async request(url,key, keys, data, title) {
  25. const res = await this.$request({
  26. url: url,
  27. method: 'get',
  28. data: data ? data : null
  29. });
  30. if (res.code === 0) {
  31. if (keys && this.$validation.array(keys)) {
  32. if (keys.length === 2) {
  33. this.html = res.data[keys[0]][keys[1]];
  34. }
  35. } else {
  36. this.html = res.data[key];
  37. }
  38. if(title) {
  39. uni.setNavigationBarTitle({
  40. title: title
  41. });
  42. }
  43. } else {
  44. uni.showModal({
  45. title: '提示',
  46. content: res.msg
  47. });
  48. }
  49. }
  50. }
  51. }
  52. </script>
  53. <style scoped lang="scss">
  54. .u-rules {
  55. min-height: 100vh;
  56. background-color: #ffffff;
  57. padding: 24upx;
  58. }
  59. </style>