index.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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) {
  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);
  22. },
  23. methods: {
  24. async request(url,key, keys, data) {
  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. } else {
  39. uni.showModal({
  40. title: '提示',
  41. content: res.msg
  42. });
  43. }
  44. }
  45. }
  46. }
  47. </script>
  48. <style scoped lang="scss">
  49. .u-rules {
  50. min-height: 100vh;
  51. background-color: #ffffff;
  52. padding: 24upx;
  53. }
  54. </style>