collection_details.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <template>
  2. <view style="width: 100%;height: 100%;padding: 32rpx 28rpx;background-color: #FFFFFF;">
  3. <!-- 头部 -->
  4. <view class="title">
  5. <!-- 标题左边 -->
  6. <view style="width: 80%;height: auto;">
  7. <view class="l">{{title}}</view>
  8. <view style="color: #999999;font-size: 22rpx;">发布时间:{{info.created_at}}</view>
  9. </view>
  10. <!-- 标题右边 -->
  11. <view class="r">
  12. <view class="shoucang" @click="sc">
  13. <image :src="imgsrc" style="width: 24rpx; height: 24rpx;margin-right: 15rpx;"></image>
  14. <text style="font-size: 26rpx;color: #666666;">收藏</text>
  15. </view>
  16. </view>
  17. </view>
  18. <!-- 文章内容 -->
  19. <view class="content">
  20. {{info.content}}
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. export default {
  26. data() {
  27. return {
  28. title: '',
  29. id: "",
  30. info: {},
  31. imgsrc: "../../../static/img/start_gray.png"
  32. }
  33. },
  34. mounted() {
  35. this.getdetailes()
  36. },
  37. methods: {
  38. //收藏点击事件
  39. sc: async function() {
  40. let res = await this.$request.post("/api/v1/collection/submitCollect", {
  41. type: 2,
  42. relation_id: this.info.id
  43. })
  44. console.log(res)
  45. if (res.status == 0) {
  46. if (res.data.is_collect == 0) {
  47. this.imgsrc = "../../../static/img/start_gray.png"
  48. uni.showToast({
  49. title: "取消成功",
  50. icon: "none"
  51. })
  52. } else {
  53. this.imgsrc = "../../../static/img/start.png"
  54. uni.showToast({
  55. title: "收藏成功",
  56. icon: "none"
  57. })
  58. }
  59. }
  60. },
  61. getdetailes: async function() {
  62. let res = await this.$request.post("/api/v1/article/articleDetail", {
  63. article_id: this.id
  64. })
  65. if (res.status == 0) {
  66. this.info = res.data
  67. }
  68. if (this.info.is_collect == 0) {
  69. this.imgsrc = "../../../static/img/start_gray.png"
  70. } else {
  71. this.imgsrc = "../../../static/img/start.png"
  72. }
  73. }
  74. },
  75. onLoad: function(option) { //option为object类型,会序列化上个页面传递的参数
  76. this.title = option.title
  77. uni.setNavigationBarTitle({
  78. title: this.title
  79. })
  80. this.id = option.id
  81. }
  82. }
  83. </script>
  84. <style lang="scss">
  85. .title {
  86. display: flex;
  87. padding-bottom: 40rpx;
  88. //左
  89. .l {
  90. font-size: 45rpx;
  91. font-weight: bold;
  92. margin-bottom: 10rpx;
  93. }
  94. //右
  95. .r {
  96. width: 20%;
  97. height: 100rpx;
  98. display: flex;
  99. justify-content: center;
  100. align-items: center;
  101. //收藏
  102. .shoucang {
  103. height: 48rpx;
  104. width: 136rpx;
  105. border-radius: 27rpx;
  106. display: flex;
  107. justify-content: center;
  108. align-items: center;
  109. border: 1px solid #C0C0C0;
  110. }
  111. }
  112. }
  113. .content {
  114. color: #999999;
  115. font-size: 32rpx;
  116. background: #F6F6F6;
  117. line-height: 32px;
  118. }
  119. </style>