notice_deatil.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <template>
  2. <view>
  3. <artical-deatil :model="model"></artical-deatil>
  4. </view>
  5. </template>
  6. <script>
  7. import md5 from "@/common/md5.js";
  8. import ArticalDeatil from "../../components/artical-deatil/index";
  9. export default {
  10. data() {
  11. return {
  12. model: {
  13. title: "",
  14. way: "",
  15. time: "",
  16. artical: "",
  17. },
  18. id: "",
  19. };
  20. },
  21. components: {
  22. ArticalDeatil,
  23. },
  24. onLoad(op) {
  25. this.id = op.id;
  26. this.getNotice();
  27. },
  28. methods: {
  29. getNotice() {
  30. let md5Sign = md5(
  31. "method=" +
  32. "common" +
  33. "&timestamp=" +
  34. getApp().globalData.globalTimestamp +
  35. "&secret=" +
  36. getApp().globalData.secret
  37. );
  38. let url =
  39. getApp().globalData.shareUrl +
  40. "api/api.php" +
  41. "?method=common&source=notice&action=info_by_id&timestamp=" +
  42. getApp().globalData.globalTimestamp +
  43. "&sign=" +
  44. md5Sign;
  45. let postData = {
  46. id: this.id,
  47. };
  48. //获取文章
  49. uni.request({
  50. url: url,
  51. method: "POST",
  52. header: {
  53. "content-type": "application/x-www-form-urlencoded",
  54. },
  55. data: postData,
  56. success: (res) => {
  57. if (res.data.code === 200) {
  58. let data = res.data.data;
  59. this.model.title = data.title;
  60. this.model.way = data.sponsor;
  61. this.model.sponsor = data.sponsor
  62. let time = this.$options.filters["globalTime"](data.publish_time);
  63. let timeSecond = this.$options.filters["globalTimeSecond"](
  64. data.publish_time
  65. );
  66. this.model.time = time + " " + timeSecond;
  67. this.getRich();
  68. }
  69. },
  70. fail: () => {
  71. console.log("连接失败");
  72. },
  73. });
  74. },
  75. getRich() {
  76. uni.request({
  77. url: `https://kiq.xazhima.com/content/notice/${Math.floor(
  78. this.id / 1000
  79. )}/${this.id}.html`,
  80. method: "GET",
  81. header: {
  82. "content-type": "application/x-www-form-urlencoded",
  83. },
  84. success: (res) => {
  85. if (res.statusCode === 200) {
  86. this.model.artical = res.data
  87. }
  88. },
  89. fail: () => {
  90. console.log("连接失败");
  91. },
  92. });
  93. },
  94. },
  95. };
  96. </script>
  97. <style lang="scss" scoped>
  98. </style>