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

This commit is contained in:
wuxw 2025-06-04 11:56:27 +08:00
parent aaa767a4a4
commit dedd9ade8d
8 changed files with 636 additions and 24 deletions

View File

@ -0,0 +1,81 @@
import request from '@/utils/request'
// 获取管理员小区列表
export function listAdminCommunitys(params) {
return new Promise((resolve, reject) => {
request({
url: '/community.listAdminCommunitys',
method: 'get',
params
}).then(response => {
const res = response.data
if (res.code == 0) {
resolve(res)
} else {
reject(new Error(res.msg || '获取小区列表失败'))
}
}).catch(error => {
reject(error)
})
})
}
// 获取公众号列表
export function listAdminSmallWeChats(params) {
return new Promise((resolve, reject) => {
request({
url: '/smallWeChat.listAdminSmallWeChats',
method: 'get',
params
}).then(response => {
const res = response.data
if (res.code == 0) {
resolve(res)
} else {
reject(new Error(res.msg || '获取公众号列表失败'))
}
}).catch(error => {
reject(error)
})
})
}
// 添加公众号
export function saveAdminSmallWeChat(data) {
return new Promise((resolve, reject) => {
request({
url: '/smallWeChat.saveAdminSmallWeChat',
method: 'post',
data
}).then(response => {
const res = response.data
if (res.code == 0) {
resolve(res)
} else {
reject(new Error(res.msg || '添加公众号失败'))
}
}).catch(error => {
reject(error)
})
})
}
// 更新公众号
export function updateAdminSmallWeChat(data) {
return new Promise((resolve, reject) => {
request({
url: '/smallWeChat.updateAdminSmallWeChat',
method: 'post',
data
}).then(response => {
const res = response.data
if (res.code == 0) {
resolve(res)
} else {
reject(new Error(res.msg || '更新公众号失败'))
}
}).catch(error => {
reject(error)
})
})
}

View File

@ -0,0 +1,154 @@
<template>
<el-dialog
:title="$t('addCommunityWechat.title')"
:visible.sync="visible"
width="50%"
@close="handleClose"
>
<el-form
ref="form"
:model="form"
:rules="rules"
label-width="120px"
label-position="right"
>
<el-form-item
:label="$t('addCommunityWechat.name')"
prop="name"
>
<el-input
v-model="form.name"
:placeholder="$t('addCommunityWechat.placeholder.name')"
/>
</el-form-item>
<el-form-item label="APPID" prop="appId">
<el-input
v-model="form.appId"
:placeholder="$t('addCommunityWechat.placeholder.appId')"
/>
</el-form-item>
<el-form-item
:label="$t('addCommunityWechat.appSecret')"
prop="appSecret"
>
<el-input
v-model="form.appSecret"
type="password"
show-password
:placeholder="$t('addCommunityWechat.placeholder.appSecret')"
/>
</el-form-item>
<el-form-item
:label="$t('addCommunityWechat.description')"
prop="remarks"
>
<el-input
v-model="form.remarks"
type="textarea"
:placeholder="$t('addCommunityWechat.placeholder.remarks')"
:rows="3"
/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="visible = false">
{{ $t('communityWechat.cancel') }}
</el-button>
<el-button type="primary" @click="handleSubmit">
{{ $t('communityWechat.save') }}
</el-button>
</div>
</el-dialog>
</template>
<script>
import { saveAdminSmallWeChat } from '@/api/community/communityWechatApi'
export default {
name: 'AddCommunityWechat',
data() {
return {
visible: false,
form: {
name: '',
appId: '',
appSecret: '',
remarks: '',
weChatType: '1100',
objType: '1000',
objId: '',
communityId: '',
payPassword: '1',
mchId: '1',
mchName: '1',
certPath: ''
},
rules: {
name: [
{ required: true, message: this.$t('communityWechat.required'), trigger: 'blur' },
{ max: 100, message: this.$t('communityWechat.maxLength100'), trigger: 'blur' }
],
appId: [
{ required: true, message: this.$t('communityWechat.required'), trigger: 'blur' },
{ max: 100, message: this.$t('communityWechat.maxLength100'), trigger: 'blur' }
],
appSecret: [
{ required: true, message: this.$t('communityWechat.required'), trigger: 'blur' },
{ max: 200, message: this.$t('communityWechat.maxLength200'), trigger: 'blur' }
]
}
}
},
methods: {
open(data) {
this.form = {
...this.form,
...data,
objId: data.communityId,
communityId: data.communityId
}
this.visible = true
},
handleClose() {
this.$refs.form.resetFields()
this.form = {
name: '',
appId: '',
appSecret: '',
remarks: '',
weChatType: '1100',
objType: '1000',
objId: '',
communityId: '',
payPassword: '1',
mchId: '1',
mchName: '1',
certPath: ''
}
},
handleSubmit() {
this.$refs.form.validate(async valid => {
if (valid) {
try {
const res = await saveAdminSmallWeChat(this.form)
if (res.code === 0) {
this.$message.success(this.$t('communityWechat.addSuccess'))
this.visible = false
this.$emit('success')
} else {
this.$message.error(res.msg || this.$t('communityWechat.addFailed'))
}
} catch (error) {
console.error('添加公众号失败:', error)
this.$message.error(this.$t('communityWechat.addFailed'))
}
}
})
}
}
}
</script>

View File

@ -0,0 +1,152 @@
<template>
<el-dialog
:title="$t('editCommunityWechat.title')"
:visible.sync="visible"
width="50%"
@close="handleClose"
>
<el-form
ref="form"
:model="form"
:rules="rules"
label-width="120px"
label-position="right"
>
<el-form-item
:label="$t('editCommunityWechat.name')"
prop="name"
>
<el-input
v-model="form.name"
:placeholder="$t('editCommunityWechat.placeholder.name')"
/>
</el-form-item>
<el-form-item label="APPID" prop="appId">
<el-input
v-model="form.appId"
:placeholder="$t('editCommunityWechat.placeholder.appId')"
/>
</el-form-item>
<el-form-item
:label="$t('editCommunityWechat.appSecret')"
prop="appSecret"
>
<el-input
v-model="form.appSecret"
type="password"
show-password
:placeholder="$t('editCommunityWechat.placeholder.appSecret')"
/>
</el-form-item>
<el-form-item
:label="$t('editCommunityWechat.description')"
prop="remarks"
>
<el-input
v-model="form.remarks"
type="textarea"
:placeholder="$t('editCommunityWechat.placeholder.remarks')"
:rows="3"
/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="visible = false">
{{ $t('communityWechat.cancel') }}
</el-button>
<el-button type="primary" @click="handleSubmit">
{{ $t('communityWechat.save') }}
</el-button>
</div>
</el-dialog>
</template>
<script>
import { updateAdminSmallWeChat } from '@/api/community/communityWechatApi'
export default {
name: 'EditCommunityWechat',
data() {
return {
visible: false,
form: {
wechatId: '',
weChatId: '',
name: '',
appId: '',
appSecret: '',
remarks: '',
payPassword: '1',
objType: '1000',
mchId: '1',
mchName: '1',
certPath: ''
},
rules: {
name: [
{ required: true, message: this.$t('communityWechat.required'), trigger: 'blur' },
{ max: 100, message: this.$t('communityWechat.maxLength100'), trigger: 'blur' }
],
appId: [
{ required: true, message: this.$t('communityWechat.required'), trigger: 'blur' },
{ max: 100, message: this.$t('communityWechat.maxLength100'), trigger: 'blur' }
],
appSecret: [
{ required: true, message: this.$t('communityWechat.required'), trigger: 'blur' },
{ max: 200, message: this.$t('communityWechat.maxLength200'), trigger: 'blur' }
]
}
}
},
methods: {
open(data) {
this.form = {
...this.form,
...data,
wechatId: data.wechatId || data.weChatId,
weChatId: data.wechatId || data.weChatId
}
this.visible = true
},
handleClose() {
this.$refs.form.resetFields()
this.form = {
wechatId: '',
weChatId: '',
name: '',
appId: '',
appSecret: '',
remarks: '',
payPassword: '1',
objType: '1000',
mchId: '1',
mchName: '1',
certPath: ''
}
},
handleSubmit() {
this.$refs.form.validate(async valid => {
if (valid) {
try {
const res = await updateAdminSmallWeChat(this.form)
if (res.code === 0) {
this.$message.success(this.$t('communityWechat.editSuccess'))
this.visible = false
this.$emit('success')
} else {
this.$message.error(res.msg || this.$t('communityWechat.editFailed'))
}
} catch (error) {
console.error('更新公众号失败:', error)
this.$message.error(this.$t('communityWechat.editFailed'))
}
}
})
}
}
}
</script>

View File

@ -47,27 +47,3 @@ export default {
}
</script>
<i18n>
{
"en": {
"deleteAStaffCommunity": {
"confirmOperation": "Confirm Your Operation",
"confirmDelete": "Are you sure you want to delete this community?",
"cancel": "Cancel",
"confirm": "Confirm Delete",
"deleteSuccess": "Community deleted successfully",
"deleteError": "Failed to delete community"
}
},
"zh": {
"deleteAStaffCommunity": {
"confirmOperation": "请确认您的操作",
"confirmDelete": "确定删除隶属小区?",
"cancel": "点错了",
"confirm": "确认删除",
"deleteSuccess": "小区删除成功",
"deleteError": "小区删除失败"
}
}
}
</i18n>

View File

@ -115,6 +115,7 @@ import { messages as supplierCouponBuyMessages } from '../views/scm/supplierCoup
import { messages as aStaffMessages } from '../views/staff/aStaffLang'
import { messages as aStaffDetailMessages } from '../views/staff/aStaffDetailLang'
import { messages as aStaffCommunityMessages } from '../views/staff/aStaffCommunityLang'
import { messages as communityWechatMessages } from '../views/community/communityWechatLang'
Vue.use(VueI18n)
@ -234,6 +235,7 @@ const messages = {
...aStaffMessages.en,
...aStaffDetailMessages.en,
...aStaffCommunityMessages.en,
...communityWechatMessages.en,
},
zh: {
...loginMessages.zh,
@ -349,6 +351,7 @@ const messages = {
...aStaffMessages.zh,
...aStaffDetailMessages.zh,
...aStaffCommunityMessages.zh,
...communityWechatMessages.zh,
}
}

View File

@ -561,6 +561,11 @@ const routes = [
name:'/pages/staff/aStaffCommunity',
component: () => import('@/views/staff/aStaffCommunityList.vue')
},
{
path:'/pages/community/communityWechat',
name:'/pages/community/communityWechat',
component: () => import('@/views/community/communityWechatList.vue')
},
// 其他子路由可以在这里添加
]
},

View File

@ -0,0 +1,98 @@
export const messages = {
en: {
communityWechat: {
title: 'Community WeChat',
name: 'Name',
communityName: 'Community Name',
appId: 'APPID',
appSecret: 'App Secret',
description: 'Description',
operation: 'Operation',
add: 'Add',
edit: 'Edit',
cancel: 'Cancel',
save: 'Save',
required: 'Required',
maxLength100: 'Cannot exceed 100 characters',
maxLength200: 'Cannot exceed 200 characters',
addSuccess: 'Add successful',
editSuccess: 'Update successful'
},
addCommunityWechat: {
title: 'Add WeChat',
name: 'Name',
appId: 'APPID',
appSecret: 'App Secret',
description: 'Description',
remarks: 'Remarks',
placeholder: {
name: 'Required, please enter name',
appId: 'Required, please enter APPID',
appSecret: 'Required, please enter app secret',
remarks: 'Optional, please enter description'
}
},
editCommunityWechat: {
title: 'Edit WeChat',
name: 'Name',
appId: 'APPID',
appSecret: 'App Secret',
description: 'Description',
remarks: 'Remarks',
placeholder: {
name: 'Required, please enter name',
appId: 'Required, please enter APPID',
appSecret: 'Required, please enter app secret',
remarks: 'Optional, please enter description'
}
},
},
zh: {
communityWechat: {
title: '小区公众号',
name: '名称',
communityName: '小区名称',
appId: 'APPID',
appSecret: '应用密钥',
description: '描述',
operation: '操作',
add: '添加',
edit: '修改',
cancel: '取消',
save: '保存',
required: '不能为空',
maxLength100: '不能超过100个字符',
maxLength200: '不能超过200个字符',
addSuccess: '添加成功',
editSuccess: '修改成功'
},
addCommunityWechat: {
title: '添加公众号',
name: '名称',
appId: 'APPID',
appSecret: '应用密钥',
description: '描述',
remarks: '备注',
placeholder: {
name: '必填,请填写名称',
appId: '必填请填写APPID',
appSecret: '必填,请填写应用密钥',
remarks: '选填,请填写描述信息'
}
},
editCommunityWechat: {
title: '修改公众号',
name: '名称',
appId: 'APPID',
appSecret: '应用密钥',
description: '描述',
remarks: '备注',
placeholder: {
name: '必填,请填写名称',
appId: '必填请填写APPID',
appSecret: '必填,请填写应用密钥',
remarks: '选填,请填写描述信息'
}
},
}
}

View File

@ -0,0 +1,143 @@
<template>
<div class="community-wechat-container">
<el-row :gutter="20">
<el-col :span="4">
<select-admin-community :community-id="communityId" @changeCommunity="handleCommunityChange" />
</el-col>
<el-col :span="20">
<el-card>
<div slot="header" class="clearfix">
<span>{{ $t('communityWechat.title') }}</span>
<el-button v-if="communityId && tableData.length === 0" type="primary" size="small" class="float-right"
@click="openAddDialog">
<i class="el-icon-plus"></i>
{{ $t('communityWechat.add') }}
</el-button>
</div>
<el-table :data="tableData" border style="width: 100%" v-loading="loading">
<el-table-column :label="$t('communityWechat.name')" prop="name" align="center" />
<el-table-column :label="$t('communityWechat.communityName')" prop="communityName" align="center" />
<el-table-column label="APPID" prop="appId" align="center" />
<el-table-column :label="$t('communityWechat.appSecret')" align="center">
<template >
********
</template>
</el-table-column>
<el-table-column :label="$t('communityWechat.description')" prop="remarks" align="center" />
<el-table-column :label="$t('communityWechat.operation')" align="center" width="150">
<template slot-scope="scope">
<el-button type="text" size="small" @click="openEditDialog(scope.row)">
{{ $t('communityWechat.edit') }}
</el-button>
</template>
</el-table-column>
</el-table>
</el-card>
</el-col>
</el-row>
<add-community-wechat ref="addDialog" @success="loadData" />
<edit-community-wechat ref="editDialog" @success="loadData" />
</div>
</template>
<script>
import { listAdminSmallWeChats } from '@/api/community/communityWechatApi'
import SelectAdminCommunity from '@/components/community/selectAdminCommunity'
import AddCommunityWechat from '@/components/community/addCommunityWechat'
import EditCommunityWechat from '@/components/community/editCommunityWechat'
export default {
name: 'CommunityWechatList',
components: {
SelectAdminCommunity,
AddCommunityWechat,
EditCommunityWechat
},
data() {
return {
loading: false,
communityId: '',
tableData: [],
page: {
current: 1,
size: 100,
total: 0
}
}
},
watch: {
communityId() {
this.loadData()
}
},
methods: {
handleCommunityChange(community) {
this.communityId = community.communityId
},
async loadData() {
if (!this.communityId) {
this.tableData = []
return
}
try {
this.loading = true
const params = {
page: this.page.current,
row: this.page.size,
weChatType: '1100',
communityId: this.communityId
}
const res = await listAdminSmallWeChats(params)
if (res.code === 0) {
this.tableData = res.data || []
this.page.total = res.total || 0
} else {
this.$message.error(res.msg || this.$t('communityWechat.loadFailed'))
}
} catch (error) {
console.error('获取公众号列表失败:', error)
this.$message.error(this.$t('communityWechat.loadFailed'))
} finally {
this.loading = false
}
},
openAddDialog() {
this.$refs.addDialog.open({
communityId: this.communityId,
objId: this.communityId,
weChatType: '1100'
})
},
openEditDialog(row) {
this.$refs.editDialog.open(row)
}
}
}
</script>
<style scoped>
.community-wechat-container {
padding: 20px;
}
.float-right {
float: right;
}
.clearfix:after {
content: "";
display: table;
clear: both;
}
</style>