Prechádzať zdrojové kódy

完成 AdminCategory.vue 页面的"更新站点通知"接口

reghao 3 mesiacov pred
rodič
commit
5334b05245
2 zmenil súbory, kde vykonal 23 pridanie a 30 odobranie
  1. 4 0
      src/api/admin.js
  2. 19 30
      src/views/admin/site/AdminCategory.vue

+ 4 - 0
src/api/admin.js

@@ -81,3 +81,7 @@ export function getVipPlan() {
 export function getSiteNotice() {
   return get(adminApi.getSiteNoticeApi)
 }
+
+export function updateSiteNotice(payload) {
+  return post(adminApi.getSiteNoticeApi, payload)
+}

+ 19 - 30
src/views/admin/site/AdminCategory.vue

@@ -26,7 +26,7 @@
         <el-card class="box-card">
           <div slot="header" class="clearfix">
             <span>站点公告</span>
-            <el-button style="float: right; padding: 3px 0" type="text" @click="onUpdate">更新</el-button>
+            <el-button style="float: right; padding: 3px 0" type="text" @click="handleUpdateNotice">更新</el-button>
           </div>
           <div class="text item">
             {{ siteNotice }}
@@ -89,7 +89,7 @@
           <el-form-item>
             <el-button
               type="primary"
-              @click.native="updateNotice"
+              @click.native="onUpdateNotice"
             >更新</el-button>
             <el-button
               type="primary"
@@ -137,7 +137,7 @@
 
 <script>
 import { userMixin } from 'assets/js/mixin'
-import { getSiteNotice, getVipPlan } from '@/api/admin'
+import {getSiteNotice, getVipPlan, updateSiteNotice} from '@/api/admin'
 import { videoCategories } from '@/api/video'
 
 export default {
@@ -168,65 +168,54 @@ export default {
     document.title = '站点分区'
     this.getData()
   },
-  mounted() {
-  },
   methods: {
     getData() {
       getVipPlan().then(resp => {
         if (resp.code === 0) {
           this.vipPlanList = resp.data
         } else {
-          this.$message.error(resp.msg)
+          this.$message.warning(resp.msg)
         }
       }).catch(error => {
-        this.$notify({
-          title: '提示',
-          message: error.message,
-          type: 'warning',
-          duration: 3000
-        })
+        this.$message.error(error.message)
       })
 
       videoCategories().then(resp => {
         if (resp.code === 0) {
           this.treeNode = resp.data
         } else {
-          this.$message.error(resp.msg)
+          this.$message.warning(resp.msg)
         }
       }).catch(error => {
-        this.$notify({
-          title: '提示',
-          message: error.message,
-          type: 'warning',
-          duration: 3000
-        })
+        this.$message.error(error.message)
       })
 
       getSiteNotice().then(resp => {
         if (resp.code === 0) {
           this.siteNotice = resp.data
         } else {
-          this.$message.error(resp.msg)
+          this.$message.warning(resp.msg)
         }
       }).catch(error => {
-        this.$notify({
-          title: '提示',
-          message: error.message,
-          type: 'warning',
-          duration: 3000
-        })
+        this.$message.error(error.message)
       })
     },
     // ****************************************************************************************************************
     handleNodeClick() {
       this.$message.info('handleNodeClick')
     },
-    onUpdate() {
+    handleUpdateNotice() {
       this.updateDialog = true
     },
-    updateNotice() {
-      this.updateDialog = false
-      this.$message.info(this.updateForm.content)
+    onUpdateNotice() {
+      updateSiteNotice(this.updateForm).then(resp => {
+        if (resp.code === 0) {
+          this.$message.warning(resp.msg)
+          this.updateDialog = false
+        }
+      }).catch(error => {
+        this.$message.error(error.message)
+      })
     },
     onAddCategory() {
       this.addCategoryDialog = true