manageArticle.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <template>
  2. <view class="page">
  3. <!-- <view class="nav-bar">
  4. <view class="left">
  5. <view class="uni-btn-icon" @click="goBack">&#xe601;</view>
  6. </view>
  7. <view class="center">管理</view>
  8. <view class="right">
  9. <view class="btn" @click="onManage">管理</view>
  10. <view class="btn" @click="onSubmit">发布</view>
  11. </view>
  12. </view> -->
  13. <view class="list">
  14. <view class="article-item" v-for="(item, index) in articleList" :key="index">
  15. <view class="article-content">
  16. <image class="article-image" :src="item.image" mode="aspectFill"></image>
  17. <view class="article-info">
  18. <view class="article-title">{{item.title}}</view>
  19. <view class="article-desc">{{item.content}}</view>
  20. <view class="article-meta">
  21. <text class="time">{{item.create_time}}</text>
  22. <text class="status" :class="item.status === 1 ? 'published' : 'draft'">
  23. {{item.status === 1 ? '已发布' : '待审核'}}
  24. </text>
  25. </view>
  26. </view>
  27. </view>
  28. <view class="article-actions">
  29. <view class="action-btn edit" @click="onEdit(item)">编辑</view>
  30. <view class="action-btn delete" @click="onDelete(item)">删除</view>
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. </template>
  36. <script>
  37. export default {
  38. components: {},
  39. data() {
  40. return {
  41. skey: '',
  42. uinfo: {},
  43. articleList: [], // 文章列表数据
  44. }
  45. },
  46. onLoad(params) {
  47. if (getApp().globalData.skey != "") {
  48. this.skey = getApp().globalData.skey;
  49. } else {
  50. this.skey = params.skey || ''; //1234567xef
  51. }
  52. this.id = params.id || '';
  53. let that = this;
  54. // this.getCate();
  55. // that.getInfo();
  56. },
  57. onShow() {
  58. let that = this;
  59. this.getArticleList();
  60. },
  61. methods: {
  62. goBack() {
  63. uni.navigateBack();
  64. },
  65. onPublish() {
  66. this.onSubmit();
  67. },
  68. getInfo() {
  69. },
  70. onEdit(item) {
  71. uni.navigateTo({
  72. url: `/pages/make/fabuArticle?id=${item.id}`
  73. });
  74. },
  75. onDelete(item) {
  76. uni.showModal({
  77. title: '提示',
  78. content: '确定要删除这篇文章吗?',
  79. success: (res) => {
  80. if (res.confirm) {
  81. uni.request({
  82. url: this.$apiHost + '/Article/doAct',
  83. data: {
  84. uuid: getApp().globalData.uuid,
  85. act: 'del',
  86. id: item.id
  87. },
  88. header: {
  89. 'content-type': 'application/json',
  90. 'sign': getApp().globalData.headerSign
  91. },
  92. success: (res) => {
  93. if (res.data.success === 'yes') {
  94. uni.showToast({
  95. title: '删除成功',
  96. icon: 'success'
  97. });
  98. // 重新获取列表
  99. this.getArticleList();
  100. } else {
  101. uni.showToast({
  102. title: res.data.str || '删除失败',
  103. icon: 'none'
  104. });
  105. }
  106. }
  107. });
  108. }
  109. }
  110. });
  111. },
  112. getArticleList() {
  113. var that = this;
  114. uni.request({
  115. url: this.$apiHost + '/Article/getlist', //仅为示例,并非真实接口地址。
  116. data: {
  117. uuid: getApp().globalData.uuid,
  118. type: "my"
  119. },
  120. header: {
  121. 'content-type': 'application/json',
  122. 'sign': getApp().globalData.headerSign
  123. },
  124. success: (res) => {
  125. console.log("====", res.data);
  126. that.articleList = res.data.list;
  127. }
  128. });
  129. },
  130. }
  131. }
  132. </script>
  133. <style scoped lang="scss">
  134. @import 'manageArticle.scss';
  135. </style>