Commit dedd9ade8d17f206304bc057a8a8a3aedad542dd

Authored by wuxw
1 parent aaa767a4

开发完成admin 系统小区公众号

src/api/community/communityWechatApi.js 0 → 100644
  1 +import request from '@/utils/request'
  2 +
  3 +// 获取管理员小区列表
  4 +export function listAdminCommunitys(params) {
  5 + return new Promise((resolve, reject) => {
  6 + request({
  7 + url: '/community.listAdminCommunitys',
  8 + method: 'get',
  9 + params
  10 + }).then(response => {
  11 + const res = response.data
  12 + if (res.code == 0) {
  13 + resolve(res)
  14 + } else {
  15 + reject(new Error(res.msg || '获取小区列表失败'))
  16 + }
  17 + }).catch(error => {
  18 + reject(error)
  19 + })
  20 + })
  21 +}
  22 +
  23 +// 获取公众号列表
  24 +export function listAdminSmallWeChats(params) {
  25 + return new Promise((resolve, reject) => {
  26 + request({
  27 + url: '/smallWeChat.listAdminSmallWeChats',
  28 + method: 'get',
  29 + params
  30 + }).then(response => {
  31 + const res = response.data
  32 + if (res.code == 0) {
  33 + resolve(res)
  34 + } else {
  35 + reject(new Error(res.msg || '获取公众号列表失败'))
  36 + }
  37 + }).catch(error => {
  38 + reject(error)
  39 + })
  40 + })
  41 +}
  42 +
  43 +// 添加公众号
  44 +export function saveAdminSmallWeChat(data) {
  45 + return new Promise((resolve, reject) => {
  46 + request({
  47 + url: '/smallWeChat.saveAdminSmallWeChat',
  48 + method: 'post',
  49 + data
  50 + }).then(response => {
  51 + const res = response.data
  52 + if (res.code == 0) {
  53 + resolve(res)
  54 + } else {
  55 + reject(new Error(res.msg || '添加公众号失败'))
  56 + }
  57 + }).catch(error => {
  58 + reject(error)
  59 + })
  60 + })
  61 +}
  62 +
  63 +// 更新公众号
  64 +export function updateAdminSmallWeChat(data) {
  65 + return new Promise((resolve, reject) => {
  66 + request({
  67 + url: '/smallWeChat.updateAdminSmallWeChat',
  68 + method: 'post',
  69 + data
  70 + }).then(response => {
  71 + const res = response.data
  72 + if (res.code == 0) {
  73 + resolve(res)
  74 + } else {
  75 + reject(new Error(res.msg || '更新公众号失败'))
  76 + }
  77 + }).catch(error => {
  78 + reject(error)
  79 + })
  80 + })
  81 +}
0 82 \ No newline at end of file
... ...
src/components/community/addCommunityWechat.vue 0 → 100644
  1 +<template>
  2 + <el-dialog
  3 + :title="$t('addCommunityWechat.title')"
  4 + :visible.sync="visible"
  5 + width="50%"
  6 + @close="handleClose"
  7 + >
  8 + <el-form
  9 + ref="form"
  10 + :model="form"
  11 + :rules="rules"
  12 + label-width="120px"
  13 + label-position="right"
  14 + >
  15 + <el-form-item
  16 + :label="$t('addCommunityWechat.name')"
  17 + prop="name"
  18 + >
  19 + <el-input
  20 + v-model="form.name"
  21 + :placeholder="$t('addCommunityWechat.placeholder.name')"
  22 + />
  23 + </el-form-item>
  24 +
  25 + <el-form-item label="APPID" prop="appId">
  26 + <el-input
  27 + v-model="form.appId"
  28 + :placeholder="$t('addCommunityWechat.placeholder.appId')"
  29 + />
  30 + </el-form-item>
  31 +
  32 + <el-form-item
  33 + :label="$t('addCommunityWechat.appSecret')"
  34 + prop="appSecret"
  35 + >
  36 + <el-input
  37 + v-model="form.appSecret"
  38 + type="password"
  39 + show-password
  40 + :placeholder="$t('addCommunityWechat.placeholder.appSecret')"
  41 + />
  42 + </el-form-item>
  43 +
  44 + <el-form-item
  45 + :label="$t('addCommunityWechat.description')"
  46 + prop="remarks"
  47 + >
  48 + <el-input
  49 + v-model="form.remarks"
  50 + type="textarea"
  51 + :placeholder="$t('addCommunityWechat.placeholder.remarks')"
  52 + :rows="3"
  53 + />
  54 + </el-form-item>
  55 + </el-form>
  56 +
  57 + <div slot="footer" class="dialog-footer">
  58 + <el-button @click="visible = false">
  59 + {{ $t('communityWechat.cancel') }}
  60 + </el-button>
  61 + <el-button type="primary" @click="handleSubmit">
  62 + {{ $t('communityWechat.save') }}
  63 + </el-button>
  64 + </div>
  65 + </el-dialog>
  66 +</template>
  67 +
  68 +<script>
  69 +import { saveAdminSmallWeChat } from '@/api/community/communityWechatApi'
  70 +
  71 +export default {
  72 + name: 'AddCommunityWechat',
  73 + data() {
  74 + return {
  75 + visible: false,
  76 + form: {
  77 + name: '',
  78 + appId: '',
  79 + appSecret: '',
  80 + remarks: '',
  81 + weChatType: '1100',
  82 + objType: '1000',
  83 + objId: '',
  84 + communityId: '',
  85 + payPassword: '1',
  86 + mchId: '1',
  87 + mchName: '1',
  88 + certPath: ''
  89 + },
  90 + rules: {
  91 + name: [
  92 + { required: true, message: this.$t('communityWechat.required'), trigger: 'blur' },
  93 + { max: 100, message: this.$t('communityWechat.maxLength100'), trigger: 'blur' }
  94 + ],
  95 + appId: [
  96 + { required: true, message: this.$t('communityWechat.required'), trigger: 'blur' },
  97 + { max: 100, message: this.$t('communityWechat.maxLength100'), trigger: 'blur' }
  98 + ],
  99 + appSecret: [
  100 + { required: true, message: this.$t('communityWechat.required'), trigger: 'blur' },
  101 + { max: 200, message: this.$t('communityWechat.maxLength200'), trigger: 'blur' }
  102 + ]
  103 + }
  104 + }
  105 + },
  106 + methods: {
  107 + open(data) {
  108 + this.form = {
  109 + ...this.form,
  110 + ...data,
  111 + objId: data.communityId,
  112 + communityId: data.communityId
  113 + }
  114 + this.visible = true
  115 + },
  116 + handleClose() {
  117 + this.$refs.form.resetFields()
  118 + this.form = {
  119 + name: '',
  120 + appId: '',
  121 + appSecret: '',
  122 + remarks: '',
  123 + weChatType: '1100',
  124 + objType: '1000',
  125 + objId: '',
  126 + communityId: '',
  127 + payPassword: '1',
  128 + mchId: '1',
  129 + mchName: '1',
  130 + certPath: ''
  131 + }
  132 + },
  133 + handleSubmit() {
  134 + this.$refs.form.validate(async valid => {
  135 + if (valid) {
  136 + try {
  137 + const res = await saveAdminSmallWeChat(this.form)
  138 + if (res.code === 0) {
  139 + this.$message.success(this.$t('communityWechat.addSuccess'))
  140 + this.visible = false
  141 + this.$emit('success')
  142 + } else {
  143 + this.$message.error(res.msg || this.$t('communityWechat.addFailed'))
  144 + }
  145 + } catch (error) {
  146 + console.error('添加公众号失败:', error)
  147 + this.$message.error(this.$t('communityWechat.addFailed'))
  148 + }
  149 + }
  150 + })
  151 + }
  152 + }
  153 +}
  154 +</script>
0 155 \ No newline at end of file
... ...
src/components/community/editCommunityWechat.vue 0 → 100644
  1 +<template>
  2 + <el-dialog
  3 + :title="$t('editCommunityWechat.title')"
  4 + :visible.sync="visible"
  5 + width="50%"
  6 + @close="handleClose"
  7 + >
  8 + <el-form
  9 + ref="form"
  10 + :model="form"
  11 + :rules="rules"
  12 + label-width="120px"
  13 + label-position="right"
  14 + >
  15 + <el-form-item
  16 + :label="$t('editCommunityWechat.name')"
  17 + prop="name"
  18 + >
  19 + <el-input
  20 + v-model="form.name"
  21 + :placeholder="$t('editCommunityWechat.placeholder.name')"
  22 + />
  23 + </el-form-item>
  24 +
  25 + <el-form-item label="APPID" prop="appId">
  26 + <el-input
  27 + v-model="form.appId"
  28 + :placeholder="$t('editCommunityWechat.placeholder.appId')"
  29 + />
  30 + </el-form-item>
  31 +
  32 + <el-form-item
  33 + :label="$t('editCommunityWechat.appSecret')"
  34 + prop="appSecret"
  35 + >
  36 + <el-input
  37 + v-model="form.appSecret"
  38 + type="password"
  39 + show-password
  40 + :placeholder="$t('editCommunityWechat.placeholder.appSecret')"
  41 + />
  42 + </el-form-item>
  43 +
  44 + <el-form-item
  45 + :label="$t('editCommunityWechat.description')"
  46 + prop="remarks"
  47 + >
  48 + <el-input
  49 + v-model="form.remarks"
  50 + type="textarea"
  51 + :placeholder="$t('editCommunityWechat.placeholder.remarks')"
  52 + :rows="3"
  53 + />
  54 + </el-form-item>
  55 + </el-form>
  56 +
  57 + <div slot="footer" class="dialog-footer">
  58 + <el-button @click="visible = false">
  59 + {{ $t('communityWechat.cancel') }}
  60 + </el-button>
  61 + <el-button type="primary" @click="handleSubmit">
  62 + {{ $t('communityWechat.save') }}
  63 + </el-button>
  64 + </div>
  65 + </el-dialog>
  66 +</template>
  67 +
  68 +<script>
  69 +import { updateAdminSmallWeChat } from '@/api/community/communityWechatApi'
  70 +
  71 +export default {
  72 + name: 'EditCommunityWechat',
  73 + data() {
  74 + return {
  75 + visible: false,
  76 + form: {
  77 + wechatId: '',
  78 + weChatId: '',
  79 + name: '',
  80 + appId: '',
  81 + appSecret: '',
  82 + remarks: '',
  83 + payPassword: '1',
  84 + objType: '1000',
  85 + mchId: '1',
  86 + mchName: '1',
  87 + certPath: ''
  88 + },
  89 + rules: {
  90 + name: [
  91 + { required: true, message: this.$t('communityWechat.required'), trigger: 'blur' },
  92 + { max: 100, message: this.$t('communityWechat.maxLength100'), trigger: 'blur' }
  93 + ],
  94 + appId: [
  95 + { required: true, message: this.$t('communityWechat.required'), trigger: 'blur' },
  96 + { max: 100, message: this.$t('communityWechat.maxLength100'), trigger: 'blur' }
  97 + ],
  98 + appSecret: [
  99 + { required: true, message: this.$t('communityWechat.required'), trigger: 'blur' },
  100 + { max: 200, message: this.$t('communityWechat.maxLength200'), trigger: 'blur' }
  101 + ]
  102 + }
  103 + }
  104 + },
  105 + methods: {
  106 + open(data) {
  107 + this.form = {
  108 + ...this.form,
  109 + ...data,
  110 + wechatId: data.wechatId || data.weChatId,
  111 + weChatId: data.wechatId || data.weChatId
  112 + }
  113 + this.visible = true
  114 + },
  115 + handleClose() {
  116 + this.$refs.form.resetFields()
  117 + this.form = {
  118 + wechatId: '',
  119 + weChatId: '',
  120 + name: '',
  121 + appId: '',
  122 + appSecret: '',
  123 + remarks: '',
  124 + payPassword: '1',
  125 + objType: '1000',
  126 + mchId: '1',
  127 + mchName: '1',
  128 + certPath: ''
  129 + }
  130 + },
  131 + handleSubmit() {
  132 + this.$refs.form.validate(async valid => {
  133 + if (valid) {
  134 + try {
  135 + const res = await updateAdminSmallWeChat(this.form)
  136 + if (res.code === 0) {
  137 + this.$message.success(this.$t('communityWechat.editSuccess'))
  138 + this.visible = false
  139 + this.$emit('success')
  140 + } else {
  141 + this.$message.error(res.msg || this.$t('communityWechat.editFailed'))
  142 + }
  143 + } catch (error) {
  144 + console.error('更新公众号失败:', error)
  145 + this.$message.error(this.$t('communityWechat.editFailed'))
  146 + }
  147 + }
  148 + })
  149 + }
  150 + }
  151 +}
  152 +</script>
0 153 \ No newline at end of file
... ...
src/components/staff/deleteAStaffCommunity.vue
... ... @@ -47,27 +47,3 @@ export default {
47 47 }
48 48 </script>
49 49  
50   -<i18n>
51   -{
52   - "en": {
53   - "deleteAStaffCommunity": {
54   - "confirmOperation": "Confirm Your Operation",
55   - "confirmDelete": "Are you sure you want to delete this community?",
56   - "cancel": "Cancel",
57   - "confirm": "Confirm Delete",
58   - "deleteSuccess": "Community deleted successfully",
59   - "deleteError": "Failed to delete community"
60   - }
61   - },
62   - "zh": {
63   - "deleteAStaffCommunity": {
64   - "confirmOperation": "请确认您的操作",
65   - "confirmDelete": "确定删除隶属小区?",
66   - "cancel": "点错了",
67   - "confirm": "确认删除",
68   - "deleteSuccess": "小区删除成功",
69   - "deleteError": "小区删除失败"
70   - }
71   - }
72   -}
73   -</i18n>
74 50 \ No newline at end of file
... ...
src/i18n/index.js
... ... @@ -115,6 +115,7 @@ import { messages as supplierCouponBuyMessages } from &#39;../views/scm/supplierCoup
115 115 import { messages as aStaffMessages } from '../views/staff/aStaffLang'
116 116 import { messages as aStaffDetailMessages } from '../views/staff/aStaffDetailLang'
117 117 import { messages as aStaffCommunityMessages } from '../views/staff/aStaffCommunityLang'
  118 +import { messages as communityWechatMessages } from '../views/community/communityWechatLang'
118 119  
119 120 Vue.use(VueI18n)
120 121  
... ... @@ -234,6 +235,7 @@ const messages = {
234 235 ...aStaffMessages.en,
235 236 ...aStaffDetailMessages.en,
236 237 ...aStaffCommunityMessages.en,
  238 + ...communityWechatMessages.en,
237 239 },
238 240 zh: {
239 241 ...loginMessages.zh,
... ... @@ -349,6 +351,7 @@ const messages = {
349 351 ...aStaffMessages.zh,
350 352 ...aStaffDetailMessages.zh,
351 353 ...aStaffCommunityMessages.zh,
  354 + ...communityWechatMessages.zh,
352 355 }
353 356 }
354 357  
... ...
src/router/index.js
... ... @@ -561,6 +561,11 @@ const routes = [
561 561 name:'/pages/staff/aStaffCommunity',
562 562 component: () => import('@/views/staff/aStaffCommunityList.vue')
563 563 },
  564 + {
  565 + path:'/pages/community/communityWechat',
  566 + name:'/pages/community/communityWechat',
  567 + component: () => import('@/views/community/communityWechatList.vue')
  568 + },
564 569 // 其他子路由可以在这里添加
565 570 ]
566 571 },
... ...
src/views/community/communityWechatLang.js 0 → 100644
  1 +export const messages = {
  2 + en: {
  3 + communityWechat: {
  4 + title: 'Community WeChat',
  5 + name: 'Name',
  6 + communityName: 'Community Name',
  7 + appId: 'APPID',
  8 + appSecret: 'App Secret',
  9 + description: 'Description',
  10 + operation: 'Operation',
  11 + add: 'Add',
  12 + edit: 'Edit',
  13 + cancel: 'Cancel',
  14 + save: 'Save',
  15 + required: 'Required',
  16 + maxLength100: 'Cannot exceed 100 characters',
  17 + maxLength200: 'Cannot exceed 200 characters',
  18 + addSuccess: 'Add successful',
  19 + editSuccess: 'Update successful'
  20 + },
  21 + addCommunityWechat: {
  22 + title: 'Add WeChat',
  23 + name: 'Name',
  24 + appId: 'APPID',
  25 + appSecret: 'App Secret',
  26 + description: 'Description',
  27 + remarks: 'Remarks',
  28 + placeholder: {
  29 + name: 'Required, please enter name',
  30 + appId: 'Required, please enter APPID',
  31 + appSecret: 'Required, please enter app secret',
  32 + remarks: 'Optional, please enter description'
  33 + }
  34 + },
  35 + editCommunityWechat: {
  36 + title: 'Edit WeChat',
  37 + name: 'Name',
  38 + appId: 'APPID',
  39 + appSecret: 'App Secret',
  40 + description: 'Description',
  41 + remarks: 'Remarks',
  42 + placeholder: {
  43 + name: 'Required, please enter name',
  44 + appId: 'Required, please enter APPID',
  45 + appSecret: 'Required, please enter app secret',
  46 + remarks: 'Optional, please enter description'
  47 + }
  48 + },
  49 + },
  50 + zh: {
  51 + communityWechat: {
  52 + title: '小区公众号',
  53 + name: '名称',
  54 + communityName: '小区名称',
  55 + appId: 'APPID',
  56 + appSecret: '应用密钥',
  57 + description: '描述',
  58 + operation: '操作',
  59 + add: '添加',
  60 + edit: '修改',
  61 + cancel: '取消',
  62 + save: '保存',
  63 + required: '不能为空',
  64 + maxLength100: '不能超过100个字符',
  65 + maxLength200: '不能超过200个字符',
  66 + addSuccess: '添加成功',
  67 + editSuccess: '修改成功'
  68 + },
  69 + addCommunityWechat: {
  70 + title: '添加公众号',
  71 + name: '名称',
  72 + appId: 'APPID',
  73 + appSecret: '应用密钥',
  74 + description: '描述',
  75 + remarks: '备注',
  76 + placeholder: {
  77 + name: '必填,请填写名称',
  78 + appId: '必填,请填写APPID',
  79 + appSecret: '必填,请填写应用密钥',
  80 + remarks: '选填,请填写描述信息'
  81 + }
  82 + },
  83 + editCommunityWechat: {
  84 + title: '修改公众号',
  85 + name: '名称',
  86 + appId: 'APPID',
  87 + appSecret: '应用密钥',
  88 + description: '描述',
  89 + remarks: '备注',
  90 + placeholder: {
  91 + name: '必填,请填写名称',
  92 + appId: '必填,请填写APPID',
  93 + appSecret: '必填,请填写应用密钥',
  94 + remarks: '选填,请填写描述信息'
  95 + }
  96 + },
  97 + }
  98 +}
0 99 \ No newline at end of file
... ...
src/views/community/communityWechatList.vue 0 → 100644
  1 +<template>
  2 + <div class="community-wechat-container">
  3 + <el-row :gutter="20">
  4 + <el-col :span="4">
  5 + <select-admin-community :community-id="communityId" @changeCommunity="handleCommunityChange" />
  6 + </el-col>
  7 +
  8 + <el-col :span="20">
  9 + <el-card>
  10 + <div slot="header" class="clearfix">
  11 + <span>{{ $t('communityWechat.title') }}</span>
  12 + <el-button v-if="communityId && tableData.length === 0" type="primary" size="small" class="float-right"
  13 + @click="openAddDialog">
  14 + <i class="el-icon-plus"></i>
  15 + {{ $t('communityWechat.add') }}
  16 + </el-button>
  17 + </div>
  18 +
  19 + <el-table :data="tableData" border style="width: 100%" v-loading="loading">
  20 + <el-table-column :label="$t('communityWechat.name')" prop="name" align="center" />
  21 +
  22 + <el-table-column :label="$t('communityWechat.communityName')" prop="communityName" align="center" />
  23 +
  24 + <el-table-column label="APPID" prop="appId" align="center" />
  25 +
  26 + <el-table-column :label="$t('communityWechat.appSecret')" align="center">
  27 + <template >
  28 + ********
  29 + </template>
  30 + </el-table-column>
  31 +
  32 + <el-table-column :label="$t('communityWechat.description')" prop="remarks" align="center" />
  33 +
  34 + <el-table-column :label="$t('communityWechat.operation')" align="center" width="150">
  35 + <template slot-scope="scope">
  36 + <el-button type="text" size="small" @click="openEditDialog(scope.row)">
  37 + {{ $t('communityWechat.edit') }}
  38 + </el-button>
  39 + </template>
  40 + </el-table-column>
  41 + </el-table>
  42 + </el-card>
  43 + </el-col>
  44 + </el-row>
  45 +
  46 + <add-community-wechat ref="addDialog" @success="loadData" />
  47 +
  48 + <edit-community-wechat ref="editDialog" @success="loadData" />
  49 + </div>
  50 +</template>
  51 +
  52 +<script>
  53 +import { listAdminSmallWeChats } from '@/api/community/communityWechatApi'
  54 +import SelectAdminCommunity from '@/components/community/selectAdminCommunity'
  55 +import AddCommunityWechat from '@/components/community/addCommunityWechat'
  56 +import EditCommunityWechat from '@/components/community/editCommunityWechat'
  57 +
  58 +export default {
  59 + name: 'CommunityWechatList',
  60 + components: {
  61 + SelectAdminCommunity,
  62 + AddCommunityWechat,
  63 + EditCommunityWechat
  64 + },
  65 + data() {
  66 + return {
  67 + loading: false,
  68 + communityId: '',
  69 + tableData: [],
  70 + page: {
  71 + current: 1,
  72 + size: 100,
  73 + total: 0
  74 + }
  75 + }
  76 + },
  77 + watch: {
  78 + communityId() {
  79 + this.loadData()
  80 + }
  81 + },
  82 + methods: {
  83 + handleCommunityChange(community) {
  84 + this.communityId = community.communityId
  85 + },
  86 + async loadData() {
  87 + if (!this.communityId) {
  88 + this.tableData = []
  89 + return
  90 + }
  91 +
  92 + try {
  93 + this.loading = true
  94 + const params = {
  95 + page: this.page.current,
  96 + row: this.page.size,
  97 + weChatType: '1100',
  98 + communityId: this.communityId
  99 + }
  100 +
  101 + const res = await listAdminSmallWeChats(params)
  102 + if (res.code === 0) {
  103 + this.tableData = res.data || []
  104 + this.page.total = res.total || 0
  105 + } else {
  106 + this.$message.error(res.msg || this.$t('communityWechat.loadFailed'))
  107 + }
  108 + } catch (error) {
  109 + console.error('获取公众号列表失败:', error)
  110 + this.$message.error(this.$t('communityWechat.loadFailed'))
  111 + } finally {
  112 + this.loading = false
  113 + }
  114 + },
  115 + openAddDialog() {
  116 + this.$refs.addDialog.open({
  117 + communityId: this.communityId,
  118 + objId: this.communityId,
  119 + weChatType: '1100'
  120 + })
  121 + },
  122 + openEditDialog(row) {
  123 + this.$refs.editDialog.open(row)
  124 + }
  125 + }
  126 +}
  127 +</script>
  128 +
  129 +<style scoped>
  130 +.community-wechat-container {
  131 + padding: 20px;
  132 +}
  133 +
  134 +.float-right {
  135 + float: right;
  136 +}
  137 +
  138 +.clearfix:after {
  139 + content: "";
  140 + display: table;
  141 + clear: both;
  142 +}
  143 +</style>
0 144 \ No newline at end of file
... ...