Browse Source

公众号菜单列表

chao 3 years ago
parent
commit
5a54834976

+ 7 - 7
src/api/qiniu.js

@@ -1,8 +1,8 @@
-import request from '@/utils/request'
+// import request from '@/utils/request'
 
-export function getToken() {
-  return request({
-    url: '/qiniu/upload/token', // 假地址 自行替换
-    method: 'get'
-  })
-}
+// export function getToken() {
+//   return request({
+//     url: '/qiniu/upload/token', // 假地址 自行替换
+//     method: 'get'
+//   })
+// }

+ 66 - 0
src/api/wechat/menu.js

@@ -0,0 +1,66 @@
+import request from '@/utils/request'
+
+/**
+ * 获取微信公众号菜单列表
+ * @param {*} query type 类型: 1采美,2呵呵商城
+ */
+export function fetchList(query) {
+  return request({
+    url: '/wechat/menu/list',
+    method: 'get',
+    params: query
+  })
+}
+
+/**
+ * 根据ID获取微信公众号菜单
+ */
+export function getMenu(id) {
+  return request({
+    url: '/wechat/menu/' + id,
+    method: 'get'
+  })
+}
+
+/**
+ * 根据ID更新微信公众号菜单
+ */
+export function updateMenu(id, data) {
+  return request({
+    url: '/wechat/menu/update/' + id,
+    method: 'post',
+    data: data
+  })
+}
+
+/**
+ * 添加微信公众号菜单
+ */
+export function createMenu(data) {
+  return request({
+    url: '/wechat/menu/create',
+    method: 'post',
+    data: data
+  })
+}
+
+/**
+ * 根据ID删除微信公众号菜单
+ */
+export function deleteMenu(id) {
+  return request({
+    url: '/wechat/menu/delete/' + id,
+    method: 'post'
+  })
+}
+
+/**
+ * 微信公众号菜单发布
+ * @param {*} type 类型: 1采美,2呵呵商城
+ */
+export function pushWechatMenu(type) {
+  return request({
+    url: '/wechat/menu/push/' + type,
+    method: 'post'
+  })
+}

+ 5 - 0
src/router/modules/wechat.js

@@ -12,6 +12,7 @@ const wechatRouter = {
   children: [
     {
       path: 'caimei',
+      component: () => import('@/views/wechat/caimei/index'),
       redirect: '/wechat/caimei/menus',
       name: 'WeChatCaimei',
       meta: { title: '采美网公众号', icon: 'component' },
@@ -19,6 +20,7 @@ const wechatRouter = {
         {
           path: 'menus',
           component: () => import('@/views/wechat/caimei/menus/index'),
+          redirect: '/wechat/caimei/menus/list',
           name: 'WeChatCmMenus',
           meta: { title: '菜单管理' },
           children: [
@@ -48,6 +50,7 @@ const wechatRouter = {
         {
           path: 'reply',
           component: () => import('@/views/wechat/caimei/reply/index'),
+          redirect: '/wechat/caimei/reply/list',
           name: 'WeChatCmReply',
           meta: { title: '回复配置' },
           children: [
@@ -77,6 +80,7 @@ const wechatRouter = {
         {
           path: 'text',
           component: () => import('@/views/wechat/caimei/text/index'),
+          redirect: '/wechat/caimei/text/list',
           name: 'WeChatCmText',
           meta: { title: '文本素材管理' },
           children: [
@@ -106,6 +110,7 @@ const wechatRouter = {
         {
           path: 'image',
           component: () => import('@/views/wechat/caimei/image/index'),
+          redirect: '/wechat/caimei/image/list',
           name: 'WeChatCmImage',
           meta: { title: '图文素材管理' },
           children: [

+ 1 - 1
src/views/sys/menus/index.vue

@@ -1,3 +1,3 @@
 <template>
   <router-view />
-</template>
+</template>

+ 5 - 5
src/views/sys/menus/list.vue

@@ -90,7 +90,7 @@ export default {
   data() {
     return {
       tableKey: 0,
-      list: null,
+      list: [],
       total: 5,
       listLoading: true,
       parentTitle: '',
@@ -151,16 +151,16 @@ export default {
       this.$router.push({ path: '/sys/menus/list' })
     },
     handleCreate() {
-      this.$router.push({ path: '/sys/menus/add', query: { parentId: this.listQuery.parentId, title: this.parentTitle } })
+      this.$router.push({ path: '/sys/menus/add', query: { parentId: this.listQuery.parentId, title: this.parentTitle }})
     },
     handleUpdate(row) {
-      this.$router.push({ path: '/sys/menus/edit', query: { id: row.id, parentId: this.listQuery.parentId, title: this.parentTitle } })
+      this.$router.push({ path: '/sys/menus/edit', query: { id: row.id, parentId: this.listQuery.parentId, title: this.parentTitle }})
     },
     handleShowNextLevel(row) {
-      this.$router.push({ path: '/sys/menus/list', query: { parentId: row.id, title: row.title } })
+      this.$router.push({ path: '/sys/menus/list', query: { parentId: row.id, title: row.title }})
     },
     handleCreateNextLevel(row) {
-      this.$router.push({ path: '/sys/menus/add', query: { parentId: row.id, title: row.title } })
+      this.$router.push({ path: '/sys/menus/add', query: { parentId: row.id, title: row.title }})
     },
     handleDelete(row) {
       this.$confirm('是否要删除该菜单', '提示', {

+ 1 - 1
src/views/sys/roles/list.vue

@@ -81,7 +81,7 @@ export default {
       this.$router.push({ path: '/sys/roles/add' })
     },
     handleUpdate(row) {
-      this.$router.push({ path: '/sys/roles/edit', query: { id: row.id } })
+      this.$router.push({ path: '/sys/roles/edit', query: { id: row.id }})
     },
     handleDelete(row) {
       this.$confirm('是否要删除该角色', '提示', {

+ 1 - 1
src/views/sys/users/list.vue

@@ -94,7 +94,7 @@ export default {
       this.$router.push({ path: '/sys/users/add' })
     },
     handleUpdate(row) {
-      this.$router.push({ path: '/sys/users/edit', query: { id: row.id } })
+      this.$router.push({ path: '/sys/users/edit', query: { id: row.id }})
     },
     handleDelete(row) {
       this.$confirm('是否要删除该用户', '提示', {

+ 3 - 0
src/views/wechat/caimei/index.vue

@@ -0,0 +1,3 @@
+<template>
+  <router-view />
+</template>

+ 145 - 0
src/views/wechat/caimei/menus/list.vue

@@ -0,0 +1,145 @@
+<template>
+  <div class="app-container">
+    <div class="filter-container">
+      <el-button class="filter-item" type="primary" icon="el-icon-edit" @click="handleCreate">
+        添加一级菜单
+      </el-button>
+      <el-button class="filter-item" type="primary" icon="el-icon-upload2" @click="handlePush">
+        发布公众号菜单
+      </el-button>
+    </div>
+    <el-table v-loading="listLoading" row-key="id" :data="list" default-expand-all :row-class-name="rowClassName" border fit highlight-current-row style="width:100%">
+      <el-table-column label="菜单名称" prop="name" align="center" />
+      <el-table-column label="按钮类型" prop="type" align="center" />
+      <el-table-column label="排序" prop="name" width="80" align="center">
+        <template slot-scope="{row}">
+          <el-input v-model="row.sort" maxlength="4" minlength="1" @blur="handleOnInputBlur(row)" />
+        </template>
+      </el-table-column>
+      <el-table-column label="设置" width="250" align="center">
+        <template slot-scope="{row}">
+          <el-button plain size="mini" :disabled="row.parentId | disableAddSub" @click="handleCreateNextLevel(row)">添加子菜单
+          </el-button>
+        </template>
+      </el-table-column>
+      <el-table-column label="操作" width="150" align="center">
+        <template slot-scope="{row}">
+          <el-button size="mini" type="primary" @click="handleUpdate(row)">编辑
+          </el-button>
+          <el-button size="mini" type="danger" @click="handleDelete(row)">删除
+          </el-button>
+        </template>
+      </el-table-column>
+    </el-table>
+  </div>
+</template>
+
+<script>
+import { fetchList, deleteMenu, updateMenu, pushWechatMenu } from '@/api/wechat/menu'
+
+export default {
+  name: 'WeChatMenuList',
+  filters: {
+    disableAddSub(value) {
+      if (value !== 1 && value !== 2) {
+        return true
+      } else {
+        return false
+      }
+    }
+  },
+  data() {
+    return {
+      list: [],
+      listQuery: {
+        // type 类型: 1采美,2呵呵商城
+        type: '1'
+      }
+    }
+  },
+  watch: {
+    $route(route) {
+      this.getList()
+    }
+  },
+  created() {
+    this.getList()
+  },
+  methods: {
+    rowClassName: function(scope) {
+      if (scope.row.parentId === 1 || scope.row.parentId === 2) {
+        return 'parent-row'
+      }
+    },
+    getList() {
+      this.listLoading = true
+      fetchList(this.listQuery).then(response => {
+        this.listLoading = false
+        this.list = response.data
+        // Just to simulate the time of the request
+        setTimeout(() => {
+          this.listLoading = false
+        }, 1.5 * 1000)
+      })
+    },
+    handleCreate() {
+      this.$router.push({ path: '/wechat/caimei/menus/add', query: { parentId: this.listQuery.type, title: '采美公众号' }})
+    },
+    handleUpdate(row) {
+      this.$router.push({ path: '/wechat/caimei/menus/edit', query: { id: row.id, parentId: row.parentId, title: row.parentName }})
+    },
+    handleCreateNextLevel(row) {
+      this.$router.push({ path: '/wechat/caimei/menus/add', query: { parentId: row.id, title: row.name }})
+    },
+    handleDelete(row) {
+      this.$confirm('是否要删除该菜单', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        deleteMenu(row.id).then(response => {
+          this.$message({
+            message: '删除成功',
+            type: 'success',
+            duration: 1000
+          })
+          this.getList()
+        })
+      })
+    },
+    handlePush() {
+      this.$confirm('是否要发布菜单', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        pushWechatMenu(this.listQuery.type).then(response => {
+          this.$message({
+            message: '删除成功',
+            type: 'success',
+            duration: 1000
+          })
+          this.getList()
+        })
+      })
+    },
+    handleOnInputBlur(row) {
+      // 更新排序
+      updateMenu(row.id, { sort: row.sort }).then(response => {
+        this.$message({
+          message: '操作成功',
+          type: 'success',
+          duration: 1000
+        })
+        this.getList()
+      })
+    }
+  }
+}
+</script>
+
+<style>
+.el-table .parent-row {
+  background-color: #fdf6ec;
+}
+</style>

+ 3 - 0
src/views/wechat/hehe/index.vue

@@ -0,0 +1,3 @@
+<template>
+  <router-view />
+</template>