index.course.html 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <html lang="zh">
  2. <head>
  3. <title>百日题库-题目合集</title>
  4. <meta charset="utf-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  6. <script src="/static/vue.js"></script>
  7. <script src="/static/jquery.min.js"></script>
  8. <style>
  9. .click {
  10. font-size: 22px;
  11. /*text-decoration: underline;*/
  12. user-select: none;
  13. cursor: pointer;
  14. }
  15. </style>
  16. </head>
  17. <body>
  18. <div id="app">
  19. <p v-show="courseName!=''">{{courseName}}</p>
  20. <p v-show="msg!=''">{{msg}}</p>
  21. <p v-show="msg==''" class="click" @click="goAll()">所有</p>
  22. <p class="click" v-for="q, i in questions" @click="goQuestion(q.id, q.title, i+1)">{{((i+1
  23. <10)?( "0"+(i+1)):( ""+(i+1))) + '-' +q.title}}</p>
  24. </div>
  25. <script>
  26. var URL_PREFIX = "";
  27. var app = new Vue({
  28. el: '#app',
  29. data: {
  30. msg: "loading...",
  31. course: -1,
  32. questions: [],
  33. courseName: ""
  34. },
  35. methods: {
  36. getQuestionList() {
  37. var self = this;
  38. $.ajax({
  39. url: URL_PREFIX + "/get/question/list/" + this.course,
  40. success: function(data) {
  41. console.log(data);
  42. if (data["success"]) {
  43. self.msg = "";
  44. self.questions = data["data"]["results"];
  45. }
  46. else {
  47. self.msg = "获取失败";
  48. }
  49. }
  50. });
  51. },
  52. goQuestion(id, paperName, index) {
  53. location.href = URL_PREFIX + "/show_new/" + id + '?course_name=' + encodeURI(this.courseName) + '&paper_name=' + encodeURI(paperName) + "&index=" + ((index < 10) ? ("0" + index) : ("" + index));
  54. },
  55. goAll() {
  56. location.href = URL_PREFIX + "/show/all/" + this.course + "?course_name=" + encodeURI(this.courseName);
  57. }
  58. },
  59. mounted() {
  60. var search = location.search.substr(1).split('&');
  61. for (var i = 0, j = search.length; i < j; i++) {
  62. var s = search[i].split('=');
  63. if (s[0] === "course_name") {
  64. this.courseName = decodeURI(s[1]);
  65. }
  66. }
  67. if (this.courseName !== '') {
  68. document.title = "百日题库-" + this.courseName;
  69. }
  70. var url = location.href.split('?')[0].split('/');
  71. this.course = url[url.length - 1];
  72. this.getQuestionList();
  73. }
  74. });
  75. </script>
  76. </body>
  77. </html>