notice_deatil.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. id: "",
  18. },
  19. };
  20. },
  21. components: {
  22. ArticalDeatil,
  23. },
  24. onLoad(op) {
  25. this.model.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.model.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. let time = this.$options.filters["globalTime"](data.publish_time);
  62. let timeSecond = this.$options.filters["globalTimeSecond"](
  63. data.publish_time
  64. );
  65. this.model.time = time + " " + timeSecond;
  66. this.getRich();
  67. }
  68. },
  69. fail: () => {
  70. console.log("连接失败");
  71. },
  72. });
  73. },
  74. getRich() {
  75. uni.request({
  76. url:
  77. getApp().globalData.shareUrl +
  78. `content/notice/${Math.floor(this.model.id / 1000)}/${this.model.id}.html`,
  79. method: "GET",
  80. header: {
  81. "content-type": "application/x-www-form-urlencoded",
  82. },
  83. success: (res) => {
  84. if (res.statusCode === 200) {
  85. this.model.artical = res.data;
  86. }
  87. },
  88. fail: () => {
  89. console.log("连接失败");
  90. },
  91. });
  92. },
  93. },
  94. };
  95. </script>
  96. <style lang="scss" scoped>
  97. </style>