Commit 316052faf27393916f1a65b8f608a87eb5dd1900
1 parent
20ca5dc6
加入用户关注功能
Showing
6 changed files
with
308 additions
and
0 deletions
src/api/community/wechatSubscribeApi.js
0 → 100644
| 1 | +import request from '@/utils/request' | ||
| 2 | +import { getCommunityId } from '@/api/community/communityApi' | ||
| 3 | + | ||
| 4 | +// 获取微信关注用户列表 | ||
| 5 | +export function listWechatSubscribe(params) { | ||
| 6 | + return new Promise((resolve, reject) => { | ||
| 7 | + request({ | ||
| 8 | + url: '/wechat.listWechatSubscribe', | ||
| 9 | + method: 'get', | ||
| 10 | + params: { | ||
| 11 | + ...params, | ||
| 12 | + communityId: getCommunityId() | ||
| 13 | + } | ||
| 14 | + }).then(response => { | ||
| 15 | + const res = response.data | ||
| 16 | + resolve(res) | ||
| 17 | + }).catch(error => { | ||
| 18 | + reject(error) | ||
| 19 | + }) | ||
| 20 | + }) | ||
| 21 | +} | ||
| 22 | + | ||
| 23 | +// 同步微信关注用户 | ||
| 24 | +export function synchronizeWechatSubscribe(data) { | ||
| 25 | + return new Promise((resolve, reject) => { | ||
| 26 | + request({ | ||
| 27 | + url: '/wechat.synchronizeWechatSubscribe', | ||
| 28 | + method: 'post', | ||
| 29 | + data: { | ||
| 30 | + ...data, | ||
| 31 | + communityId: getCommunityId() | ||
| 32 | + } | ||
| 33 | + }).then(response => { | ||
| 34 | + const res = response.data | ||
| 35 | + resolve(res) | ||
| 36 | + }).catch(error => { | ||
| 37 | + reject(error) | ||
| 38 | + }) | ||
| 39 | + }) | ||
| 40 | +} | ||
| 0 | \ No newline at end of file | 41 | \ No newline at end of file |
src/components/community/syncSubscribeWechat.vue
0 → 100644
| 1 | +<template> | ||
| 2 | + <el-dialog | ||
| 3 | + :title="$t('wechatSubscribe.confirmTitle')" | ||
| 4 | + :visible.sync="visible" | ||
| 5 | + width="500px" | ||
| 6 | + @close="handleClose"> | ||
| 7 | + <div class="dialog-content"> | ||
| 8 | + <p>{{ $t('wechatSubscribe.syncConfirmText') }}</p> | ||
| 9 | + </div> | ||
| 10 | + <div slot="footer" class="dialog-footer"> | ||
| 11 | + <el-button @click="handleClose">{{ $t('common.cancel') }}</el-button> | ||
| 12 | + <el-button type="primary" @click="syncSubscribeWechat">{{ $t('common.submit') }}</el-button> | ||
| 13 | + </div> | ||
| 14 | + </el-dialog> | ||
| 15 | +</template> | ||
| 16 | + | ||
| 17 | +<script> | ||
| 18 | +import { synchronizeWechatSubscribe } from '@/api/community/wechatSubscribeApi' | ||
| 19 | +import { getCommunityId } from '@/api/community/communityApi' | ||
| 20 | + | ||
| 21 | +export default { | ||
| 22 | + name: 'SyncSubscribeWechat', | ||
| 23 | + data() { | ||
| 24 | + return { | ||
| 25 | + visible: false | ||
| 26 | + } | ||
| 27 | + }, | ||
| 28 | + methods: { | ||
| 29 | + open() { | ||
| 30 | + this.visible = true | ||
| 31 | + }, | ||
| 32 | + handleClose() { | ||
| 33 | + this.visible = false | ||
| 34 | + }, | ||
| 35 | + async syncSubscribeWechat() { | ||
| 36 | + try { | ||
| 37 | + const params = { | ||
| 38 | + communityId: getCommunityId() | ||
| 39 | + } | ||
| 40 | + await synchronizeWechatSubscribe(params) | ||
| 41 | + this.$message.success(this.$t('wechatSubscribe.syncSuccess')) | ||
| 42 | + this.$emit('success') | ||
| 43 | + this.handleClose() | ||
| 44 | + } catch (error) { | ||
| 45 | + this.$message.error(this.$t('wechatSubscribe.syncError')) | ||
| 46 | + } | ||
| 47 | + } | ||
| 48 | + } | ||
| 49 | +} | ||
| 50 | +</script> | ||
| 51 | + | ||
| 52 | +<style lang="scss" scoped> | ||
| 53 | +.dialog-content { | ||
| 54 | + padding: 20px; | ||
| 55 | + text-align: center; | ||
| 56 | + | ||
| 57 | + p { | ||
| 58 | + margin: 0; | ||
| 59 | + line-height: 1.5; | ||
| 60 | + } | ||
| 61 | +} | ||
| 62 | + | ||
| 63 | +.dialog-footer { | ||
| 64 | + text-align: right; | ||
| 65 | +} | ||
| 66 | +</style> | ||
| 0 | \ No newline at end of file | 67 | \ No newline at end of file |
src/i18n/communityI18n.js
| @@ -13,6 +13,7 @@ import { messages as adminCarDetailMessages } from '../views/aCommunity/adminCar | @@ -13,6 +13,7 @@ import { messages as adminCarDetailMessages } from '../views/aCommunity/adminCar | ||
| 13 | import { messages as adminFeeDetailMessages } from '../views/aCommunity/adminFeeDetailLang.js' | 13 | import { messages as adminFeeDetailMessages } from '../views/aCommunity/adminFeeDetailLang.js' |
| 14 | import { messages as listRoomDecorationRecordMessages } from '../views/community/listRoomDecorationRecordLang' | 14 | import { messages as listRoomDecorationRecordMessages } from '../views/community/listRoomDecorationRecordLang' |
| 15 | import { messages as listRoomRenovationRecordDetailsMessages } from '../views/community/listRoomRenovationRecordDetailsLang' | 15 | import { messages as listRoomRenovationRecordDetailsMessages } from '../views/community/listRoomRenovationRecordDetailsLang' |
| 16 | +import { messages as wechatSubscribeMessages } from '../views/community/wechatSubscribeLang' | ||
| 16 | export const messages = { | 17 | export const messages = { |
| 17 | en: { | 18 | en: { |
| 18 | ...roomStructureMessages.en, | 19 | ...roomStructureMessages.en, |
| @@ -30,6 +31,7 @@ export const messages = { | @@ -30,6 +31,7 @@ export const messages = { | ||
| 30 | ...adminFeeDetailMessages.en, | 31 | ...adminFeeDetailMessages.en, |
| 31 | ...listRoomDecorationRecordMessages.en, | 32 | ...listRoomDecorationRecordMessages.en, |
| 32 | ...listRoomRenovationRecordDetailsMessages.en, | 33 | ...listRoomRenovationRecordDetailsMessages.en, |
| 34 | + ...wechatSubscribeMessages.en, | ||
| 33 | }, | 35 | }, |
| 34 | zh: { | 36 | zh: { |
| 35 | ...roomStructureMessages.zh, | 37 | ...roomStructureMessages.zh, |
| @@ -47,5 +49,6 @@ export const messages = { | @@ -47,5 +49,6 @@ export const messages = { | ||
| 47 | ...adminFeeDetailMessages.zh, | 49 | ...adminFeeDetailMessages.zh, |
| 48 | ...listRoomDecorationRecordMessages.zh, | 50 | ...listRoomDecorationRecordMessages.zh, |
| 49 | ...listRoomRenovationRecordDetailsMessages.zh, | 51 | ...listRoomRenovationRecordDetailsMessages.zh, |
| 52 | + ...wechatSubscribeMessages.zh, | ||
| 50 | } | 53 | } |
| 51 | } | 54 | } |
| 52 | \ No newline at end of file | 55 | \ No newline at end of file |
src/router/communityRouter.js
| @@ -74,4 +74,9 @@ export default [ | @@ -74,4 +74,9 @@ export default [ | ||
| 74 | name: '/views/community/listRoomRenovationRecordDetails', | 74 | name: '/views/community/listRoomRenovationRecordDetails', |
| 75 | component: () => import('@/views/community/listRoomRenovationRecordDetailsList.vue') | 75 | component: () => import('@/views/community/listRoomRenovationRecordDetailsList.vue') |
| 76 | }, | 76 | }, |
| 77 | + { | ||
| 78 | + path: '/pages/community/wechatSubscribe', | ||
| 79 | + name: '/pages/community/wechatSubscribe', | ||
| 80 | + component: () => import('@/views/community/wechatSubscribeList.vue') | ||
| 81 | + }, | ||
| 77 | ] | 82 | ] |
| 78 | \ No newline at end of file | 83 | \ No newline at end of file |
src/views/community/wechatSubscribeLang.js
0 → 100644
| 1 | +export const messages = { | ||
| 2 | + en: { | ||
| 3 | + wechatSubscribe: { | ||
| 4 | + title: 'Subscribed Users', | ||
| 5 | + type: 'Type', | ||
| 6 | + openId: 'Open ID', | ||
| 7 | + unionId: 'Union ID', | ||
| 8 | + syncTime: 'Sync Time', | ||
| 9 | + wechat: 'WeChat', | ||
| 10 | + other: 'Other', | ||
| 11 | + syncUser: 'Sync Users', | ||
| 12 | + confirmTitle: 'Please confirm your operation!', | ||
| 13 | + syncConfirmText: 'Confirm to sync subscribed users data from WeChat official account. Please do not use frequently to avoid being banned by WeChat. Please refresh to view sync records after submission.', | ||
| 14 | + syncSuccess: 'Sync successfully', | ||
| 15 | + syncError: 'Sync failed', | ||
| 16 | + fetchError: 'Failed to fetch subscribed users' | ||
| 17 | + } | ||
| 18 | + }, | ||
| 19 | + zh: { | ||
| 20 | + wechatSubscribe: { | ||
| 21 | + title: '关注用户', | ||
| 22 | + type: '类型', | ||
| 23 | + openId: 'Open ID', | ||
| 24 | + unionId: 'Union ID', | ||
| 25 | + syncTime: '同步时间', | ||
| 26 | + wechat: '微信', | ||
| 27 | + other: '其他', | ||
| 28 | + syncUser: '同步用户', | ||
| 29 | + confirmTitle: '请确认您的操作!', | ||
| 30 | + syncConfirmText: '确定从公众号同步关注用户数据,请不要频繁使用,以免微信公众号封禁,提交后请刷新查看同步记录', | ||
| 31 | + syncSuccess: '同步成功', | ||
| 32 | + syncError: '同步失败', | ||
| 33 | + fetchError: '获取关注用户失败' | ||
| 34 | + } | ||
| 35 | + } | ||
| 36 | +} | ||
| 0 | \ No newline at end of file | 37 | \ No newline at end of file |
src/views/community/wechatSubscribeList.vue
0 → 100644
| 1 | +<template> | ||
| 2 | + <div class="wechat-subscribe-container"> | ||
| 3 | + <el-card class="box-card"> | ||
| 4 | + <div slot="header" class="flex justify-between items-center"> | ||
| 5 | + <span>{{ $t('wechatSubscribe.title') }}</span> | ||
| 6 | + <div class="card-header-actions"> | ||
| 7 | + <el-button size="small" @click="_queryWechatSubscribeMethod()"> | ||
| 8 | + {{ $t('common.refresh') }} | ||
| 9 | + </el-button> | ||
| 10 | + <el-button | ||
| 11 | + type="primary" | ||
| 12 | + size="small" | ||
| 13 | + @click="_openOpenSyncDataModel()"> | ||
| 14 | + {{ $t('wechatSubscribe.syncUser') }} | ||
| 15 | + </el-button> | ||
| 16 | + </div> | ||
| 17 | + </div> | ||
| 18 | + | ||
| 19 | + <el-table | ||
| 20 | + v-loading="loading" | ||
| 21 | + :data="wechatSubscribeInfo.users" | ||
| 22 | + border | ||
| 23 | + style="width: 100%"> | ||
| 24 | + <el-table-column | ||
| 25 | + prop="openType" | ||
| 26 | + :label="$t('wechatSubscribe.type')" | ||
| 27 | + align="center"> | ||
| 28 | + <template slot-scope="scope"> | ||
| 29 | + {{ scope.row.openType === 'WECHAT' ? $t('wechatSubscribe.wechat') : $t('wechatSubscribe.other') }} | ||
| 30 | + </template> | ||
| 31 | + </el-table-column> | ||
| 32 | + <el-table-column | ||
| 33 | + prop="openId" | ||
| 34 | + :label="$t('wechatSubscribe.openId')" | ||
| 35 | + align="center"> | ||
| 36 | + </el-table-column> | ||
| 37 | + <el-table-column | ||
| 38 | + prop="unionId" | ||
| 39 | + :label="$t('wechatSubscribe.unionId')" | ||
| 40 | + align="center"> | ||
| 41 | + </el-table-column> | ||
| 42 | + <el-table-column | ||
| 43 | + prop="appId" | ||
| 44 | + label="app_id" | ||
| 45 | + align="center"> | ||
| 46 | + </el-table-column> | ||
| 47 | + <el-table-column | ||
| 48 | + prop="createTime" | ||
| 49 | + :label="$t('wechatSubscribe.syncTime')" | ||
| 50 | + align="center"> | ||
| 51 | + </el-table-column> | ||
| 52 | + </el-table> | ||
| 53 | + | ||
| 54 | + <el-pagination | ||
| 55 | + class="pagination-wrapper" | ||
| 56 | + :current-page.sync="page.current" | ||
| 57 | + :page-sizes="[10, 20, 30, 50]" | ||
| 58 | + :page-size="page.size" | ||
| 59 | + :total="page.total" | ||
| 60 | + layout="total, sizes, prev, pager, next, jumper" | ||
| 61 | + @size-change="handleSizeChange" | ||
| 62 | + @current-change="handleCurrentChange"> | ||
| 63 | + </el-pagination> | ||
| 64 | + </el-card> | ||
| 65 | + | ||
| 66 | + <sync-subscribe-wechat ref="syncSubscribeWechat" @success="handleSyncSuccess"></sync-subscribe-wechat> | ||
| 67 | + </div> | ||
| 68 | +</template> | ||
| 69 | + | ||
| 70 | +<script> | ||
| 71 | +import { listWechatSubscribe } from '@/api/community/wechatSubscribeApi' | ||
| 72 | +import { getCommunityId } from '@/api/community/communityApi' | ||
| 73 | +import SyncSubscribeWechat from '@/components/community/syncSubscribeWechat' | ||
| 74 | + | ||
| 75 | +export default { | ||
| 76 | + name: 'WechatSubscribeList', | ||
| 77 | + components: { | ||
| 78 | + SyncSubscribeWechat | ||
| 79 | + }, | ||
| 80 | + data() { | ||
| 81 | + return { | ||
| 82 | + loading: false, | ||
| 83 | + wechatSubscribeInfo: { | ||
| 84 | + users: [], | ||
| 85 | + conditions: { | ||
| 86 | + name: '', | ||
| 87 | + appId: '', | ||
| 88 | + weChatType: '1000' | ||
| 89 | + } | ||
| 90 | + }, | ||
| 91 | + page: { | ||
| 92 | + current: 1, | ||
| 93 | + size: 10, | ||
| 94 | + total: 0 | ||
| 95 | + } | ||
| 96 | + } | ||
| 97 | + }, | ||
| 98 | + created() { | ||
| 99 | + this._listWechatSubscribes(this.page.current, this.page.size) | ||
| 100 | + }, | ||
| 101 | + methods: { | ||
| 102 | + async _listWechatSubscribes(page, size) { | ||
| 103 | + try { | ||
| 104 | + this.loading = true | ||
| 105 | + const params = { | ||
| 106 | + page, | ||
| 107 | + row: size, | ||
| 108 | + communityId: getCommunityId(), | ||
| 109 | + ...this.wechatSubscribeInfo.conditions | ||
| 110 | + } | ||
| 111 | + const { data, total } = await listWechatSubscribe(params) | ||
| 112 | + this.wechatSubscribeInfo.users = data | ||
| 113 | + this.page.total = total | ||
| 114 | + } catch (error) { | ||
| 115 | + this.$message.error(this.$t('wechatSubscribe.fetchError')) | ||
| 116 | + } finally { | ||
| 117 | + this.loading = false | ||
| 118 | + } | ||
| 119 | + }, | ||
| 120 | + _openOpenSyncDataModel() { | ||
| 121 | + this.$refs.syncSubscribeWechat.open() | ||
| 122 | + }, | ||
| 123 | + _queryWechatSubscribeMethod() { | ||
| 124 | + this.page.current = 1 | ||
| 125 | + this._listWechatSubscribes(this.page.current, this.page.size) | ||
| 126 | + }, | ||
| 127 | + handleSyncSuccess() { | ||
| 128 | + this._listWechatSubscribes(this.page.current, this.page.size) | ||
| 129 | + }, | ||
| 130 | + handleSizeChange(val) { | ||
| 131 | + this.page.size = val | ||
| 132 | + this._listWechatSubscribes(this.page.current, val) | ||
| 133 | + }, | ||
| 134 | + handleCurrentChange(val) { | ||
| 135 | + this._listWechatSubscribes(val, this.page.size) | ||
| 136 | + } | ||
| 137 | + } | ||
| 138 | +} | ||
| 139 | +</script> | ||
| 140 | + | ||
| 141 | +<style lang="scss" scoped> | ||
| 142 | +.wechat-subscribe-container { | ||
| 143 | + padding: 20px; | ||
| 144 | + | ||
| 145 | + .box-card { | ||
| 146 | + margin-bottom: 20px; | ||
| 147 | + } | ||
| 148 | + | ||
| 149 | + .card-header-actions { | ||
| 150 | + float: right; | ||
| 151 | + } | ||
| 152 | + | ||
| 153 | + .pagination-wrapper { | ||
| 154 | + margin-top: 20px; | ||
| 155 | + text-align: right; | ||
| 156 | + } | ||
| 157 | +} | ||
| 158 | +</style> | ||
| 0 | \ No newline at end of file | 159 | \ No newline at end of file |