notice_deatil.vue 2.6 KB

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