Explorar o código

:sparkles: 添加新特性。 新增微信公众号菜单管理

冷冷 %!s(int64=6) %!d(string=hai) anos
pai
achega
c684e6ce87
Modificáronse 5 ficheiros con 627 adicións e 690 borrados
  1. 7 22
      src/api/mp/wxmenu.js
  2. 525 395
      src/components/wechat/index.vue
  3. 51 61
      src/router/page/index.js
  4. 44 148
      src/views/mp/wxmenu/index.vue
  5. 0 64
      src/views/test.vue

+ 7 - 22
src/api/mp/wxmenu.js

@@ -17,22 +17,6 @@
 
 import request from '@/router/axios'
 
-export function fetchList(query) {
-  return request({
-    url: '/mp/wxmenu/page',
-    method: 'get',
-    params: query
-  })
-}
-
-export function addObj(obj) {
-  return request({
-    url: '/mp/wxmenu',
-    method: 'post',
-    data: obj
-  })
-}
-
 export function getObj(id) {
   return request({
     url: '/mp/wxmenu/' + id,
@@ -40,17 +24,18 @@ export function getObj(id) {
   })
 }
 
-export function delObj(id) {
+export function putObj(appId) {
   return request({
-    url: '/mp/wxmenu/' + id,
-    method: 'delete'
+    url: '/mp/wxmenu/' + appId,
+    method: 'put'
   })
 }
 
-export function putObj(obj) {
+
+export function addObj(appId, obj) {
   return request({
-    url: '/mp/wxmenu',
-    method: 'put',
+    url: '/mp/wxmenu/' + appId,
+    method: 'post',
     data: obj
   })
 }

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 525 - 395
src/components/wechat/index.vue


+ 51 - 61
src/router/page/index.js

@@ -1,101 +1,91 @@
 import Layout from '@/page/index/'
+
 export default [{
-    path: '/login',
-    name: '登录页',
-    component: () =>
-        import( /* webpackChunkName: "page" */ '@/page/login/index'),
-    meta: {
-        keepAlive: true,
-        isTab: false,
-        isAuth: false
-    }
+  path: '/login',
+  name: '登录页',
+  component: () =>
+    import( /* webpackChunkName: "page" */ '@/page/login/index'),
+  meta: {
+    keepAlive: true,
+    isTab: false,
+    isAuth: false
+  }
 },
-{
+  {
     path: '/lock',
     name: '锁屏页',
     component: () =>
-        import( /* webpackChunkName: "page" */ '@/page/lock/index'),
-    meta: {
-        keepAlive: true,
-        isTab: false,
-        isAuth: false
-    }
-},
-{
-    path: '/wechat',
-    name: '微信',
-    component: () =>
-        import( /* webpackChunkName: "page" */ '@/views/test'),
+      import( /* webpackChunkName: "page" */ '@/page/lock/index'),
     meta: {
-        keepAlive: false,
-        isTab: false,
-        isAuth: false
+      keepAlive: true,
+      isTab: false,
+      isAuth: false
     }
-},
-{
+  },
+  {
     path: '/404',
     component: () =>
-        import( /* webpackChunkName: "page" */ '@/components/error-page/404'),
+      import( /* webpackChunkName: "page" */ '@/components/error-page/404'),
     name: '404',
     meta: {
-        keepAlive: true,
-        isTab: false,
-        isAuth: false
+      keepAlive: true,
+      isTab: false,
+      isAuth: false
     }
 
-},
-{
+  },
+  {
     path: '/403',
     component: () =>
-        import( /* webpackChunkName: "page" */ '@/components/error-page/403'),
+      import( /* webpackChunkName: "page" */ '@/components/error-page/403'),
     name: '403',
     meta: {
-        keepAlive: true,
-        isTab: false,
-        isAuth: false
+      keepAlive: true,
+      isTab: false,
+      isAuth: false
     }
-},
-{
+  },
+  {
     path: '/500',
     component: () =>
-        import( /* webpackChunkName: "page" */ '@/components/error-page/500'),
+      import( /* webpackChunkName: "page" */ '@/components/error-page/500'),
     name: '500',
     meta: {
-        keepAlive: true,
-        isTab: false,
-        isAuth: false
+      keepAlive: true,
+      isTab: false,
+      isAuth: false
     }
-},
-{
+  },
+  {
     path: '/',
     name: '主页',
     redirect: '/wel'
-},
-{
+  },
+  {
     path: '/myiframe',
     component: Layout,
     redirect: '/myiframe',
     children: [{
-        path: ":routerPath",
-        name: 'iframe',
-        component: () =>
-            import( /* webpackChunkName: "page" */ '@/components/iframe/main'),
-        props: true
+      path: ":routerPath",
+      name: 'iframe',
+      component: () =>
+        import( /* webpackChunkName: "page" */ '@/components/iframe/main'),
+      props: true
     }]
-},
-{
+  },
+  {
     path: '*',
     redirect: '/404',
-},
-{
+  },
+  {
     path: '/authredirect',
     name: '授权页',
     component: () =>
-        import( /* webpackChunkName: "page" */ '@/page/login/authredirect'),
+      import( /* webpackChunkName: "page" */ '@/page/login/authredirect'),
     meta: {
-        keepAlive: true,
-        isTab: false,
-        isAuth: false
+      keepAlive: true,
+      isTab: false,
+      isAuth: false
     }
-},
+  },
 ]

+ 44 - 148
src/views/mp/wxmenu/index.vue

@@ -1,158 +1,54 @@
-<!--
-  -    Copyright (c) 2018-2025, lengleng All rights reserved.
-  -
-  - Redistribution and use in source and binary forms, with or without
-  - modification, are permitted provided that the following conditions are met:
-  -
-  - Redistributions of source code must retain the above copyright notice,
-  - this list of conditions and the following disclaimer.
-  - Redistributions in binary form must reproduce the above copyright
-  - notice, this list of conditions and the following disclaimer in the
-  - documentation and/or other materials provided with the distribution.
-  - Neither the name of the pig4cloud.com developer nor the names of its
-  - contributors may be used to endorse or promote products derived from
-  - this software without specific prior written permission.
-  - Author: lengleng (wangiegie@gmail.com)
-  -->
 <template>
-    <div class="execution">
-        <basic-container>
-            <avue-crud ref="crud"
-                       :page="page"
-                       :data="tableData"
-                       :permission="permissionList"
-                       :table-loading="tableLoading"
-                       :option="tableOption"
-                       @on-load="getList"
-                       @refresh-change="refreshChange"
-                       @row-update="handleUpdate"
-                       @row-save="handleSave"
-                       @row-del="rowDel">
-            </avue-crud>
-        </basic-container>
-    </div>
+  <div>
+    <wechat :data="data"
+            @submit="submit"></wechat>
+  </div>
 </template>
 
 <script>
-    import {
-        fetchList,
-        getObj,
-        addObj,
-        putObj,
-        delObj
-    } from '@/api/mp/wxmenu'
-    import {
-        tableOption
-    } from '@/const/crud/mp/wxmenu'
-    import {
-        mapGetters
-    } from 'vuex'
+  import wechat from "@/components/wechat/"
+  import {addObj, getObj, putObj} from '@/api/mp/wxmenu'
+  import {mapGetters} from 'vuex'
 
-    export default {
-        name: 'wxmenu',
-        data() {
-            return {
-                tableData: [],
-                page: {
-                    total: 0, // 总页数
-                    currentPage: 1, // 当前页数
-                    pageSize: 20 // 每页显示多少条
-                },
-                tableLoading: false,
-                tableOption: tableOption
-            }
-        },
-        created() {
-        },
-        mounted: function () {
-        },
-        computed: {
-            ...mapGetters(['permissions']),
-            permissionList() {
-                return {
-                    addBtn: this.vaildData(this.permissions.mp_wxmenu_add, false),
-                    delBtn: this.vaildData(this.permissions.mp_wxmenu_del, false),
-                    editBtn: this.vaildData(this.permissions.mp_wxmenu_edit, false)
-                };
-            }
-        },
-        methods: {
-            getList(page, params) {
-                this.tableLoading = true
-                fetchList(Object.assign({
-                    current: page.currentPage,
-                    size: page.pageSize
-                }, params)).then(response => {
-                    this.tableData = response.data.data.records
-                    this.page.total = response.data.data.total
-                    this.tableLoading = false
-                })
-            },
-            rowDel: function (row, index) {
-                var _this = this
-                this.$confirm('是否确认删除ID为' + row.id, '提示', {
-                    confirmButtonText: '确定',
-                    cancelButtonText: '取消',
-                    type: 'warning'
-                }).then(function () {
-                    return delObj(row.id)
-                }).then(data => {
-                    _this.tableData.splice(index, 1)
-                    _this.$message({
-                        showClose: true,
-                        message: '删除成功',
-                        type: 'success'
-                    })
-                    this.getList(this.page)
-                }).catch(function (err) {
-                })
-            },
-            /**
-             * @title 数据更新
-             * @param row 为当前的数据
-             * @param index 为当前更新数据的行数
-             * @param done 为表单关闭函数
-             *
-             **/
-            handleUpdate: function (row, index, done) {
-                putObj(row).then(data => {
-                    this.tableData.splice(index, 1, Object.assign({}, row))
-                    this.$message({
-                        showClose: true,
-                        message: '修改成功',
-                        type: 'success'
-                    })
-                    done()
-                    this.getList(this.page)
-                })
-            },
-            /**
-             * @title 数据添加
-             * @param row 为当前的数据
-             * @param done 为表单关闭函数
-             *
-             **/
-            handleSave: function (row, done) {
-                addObj(row).then(data => {
-                    this.tableData.push(Object.assign({}, row))
-                    this.$message({
-                        showClose: true,
-                        message: '添加成功',
-                        type: 'success'
-                    })
-                    done()
-                    this.getList(this.page)
-                })
-            },
-            /**
-             * 刷新回调
-             */
-            refreshChange() {
-                this.getList(this.page)
-            }
+  export default {
+    components: {
+      wechat
+    },
+    data() {
+      return {
+        data: {
+          button: []
         }
+      };
+    },
+    created() {
+      this.getAccountMenu()
+    },
+    computed: {
+      ...mapGetters(['permissions'])
+    },
+    methods: {
+      submit(form) {
+        if (this.permissions.mp_wxmenu_add) {
+          addObj('wxeb4543e2d692ec5a', form).then(data => {
+            this.$message.success("保存成功")
+          })
+        } else {
+          this.$message.error("权限不足,不能保存");
+        }
+      },
+      getAccountMenu() {
+        getObj('wxeb4543e2d692ec5a').then(response => {
+          if (response.data.data) {
+            this.data = JSON.parse(response.data.data)
+          } else {
+            this.data.button = []
+          }
+        })
+      }
     }
+  };
 </script>
 
-<style lang="scss" scoped>
+<style>
 </style>

+ 0 - 64
src/views/test.vue

@@ -1,64 +0,0 @@
-<template>
-  <div>
-    <wechat :data="data"
-            @submit="submit"></wechat>
-  </div>
-</template>
-
-<script>
-import wechat from "@/components/wechat/";
-export default {
-  components: {
-    wechat
-  },
-  data() {
-    return {
-      data: {
-        button: [
-          {
-            type: "click",
-            name: "歌手简介",
-            key: "V1001_TODAY_SINGER",
-            url: "",
-            sub_button: []
-          },
-          {
-            name: "菜单",
-            sub_button: [
-              {
-                type: "view",
-                name: "搜索",
-                key: "",
-                url: "http://www.soso.com/",
-                sub_button: []
-              },
-              {
-                type: "view",
-                name: "视频",
-                key: "",
-                url: "http://v.qq.com/",
-                sub_button: []
-              },
-              {
-                type: "click",
-                name: "赞一下我们",
-                key: "V1001_GOOD",
-                url: "",
-                sub_button: []
-              }
-            ]
-          }
-        ]
-      }
-    };
-  },
-  methods: {
-    submit(form) {
-      this.$message(JSON.stringify(form));
-    }
-  }
-};
-</script>
-
-<style>
-</style>