This commit is contained in:
YunaiV 2023-11-04 10:50:04 +08:00
commit ac7f1e29fb
12 changed files with 865 additions and 24 deletions

View File

@ -0,0 +1,37 @@
import request from '@/config/axios'
export interface SocialClientVO {
id: number
name: string
socialType: number
userType: number
clientId: string
clientSecret: string
agentId: string
status: number
}
// 查询社交客户端列表
export const getSocialClientPage = async (params) => {
return await request.get({ url: `/system/social-client/page`, params })
}
// 查询社交客户端详情
export const getSocialClient = async (id: number) => {
return await request.get({ url: `/system/social-client/get?id=` + id })
}
// 新增社交客户端
export const createSocialClient = async (data: SocialClientVO) => {
return await request.post({ url: `/system/social-client/create`, data })
}
// 修改社交客户端
export const updateSocialClient = async (data: SocialClientVO) => {
return await request.put({ url: `/system/social-client/update`, data })
}
// 删除社交客户端
export const deleteSocialClient = async (id: number) => {
return await request.delete({ url: `/system/social-client/delete?id=` + id })
}

View File

@ -0,0 +1,34 @@
import request from '@/config/axios'
export interface SocialUserVO {
id: number
type: number
openid: string
token: string
rawTokenInfo: string
nickname: string
avatar: string
rawUserInfo: string
code: string
state: string
}
// 查询社交用户列表
export const getSocialUserPage = async (params) => {
return await request.get({ url: `/system/social-user/page`, params })
}
// 查询社交用户详情
export const getSocialUser = async (id: number) => {
return await request.get({ url: `/system/social-user/get?id=` + id })
}
// 修改社交用户
export const updateSocialUser = async (data: SocialUserVO) => {
return await request.put({ url: `/system/social-user/update`, data })
}
// 删除社交用户
export const deleteSocialUser = async (id: number) => {
return await request.delete({ url: `/system/social-user/delete?id=` + id })
}

View File

@ -116,6 +116,7 @@ export enum DICT_TYPE {
SYSTEM_OAUTH2_GRANT_TYPE = 'system_oauth2_grant_type',
SYSTEM_MAIL_SEND_STATUS = 'system_mail_send_status',
SYSTEM_NOTIFY_TEMPLATE_TYPE = 'system_notify_template_type',
SYSTEM_SOCIAL_CLIENT_TYPE = 'system_social_client_type',
// ========== INFRA 模块 ==========
INFRA_BOOLEAN_STRING = 'infra_boolean_string',

View File

@ -15,7 +15,7 @@
</div>
</template>
<div>
<el-tabs v-model="activeName" tab-position="top" style="height: 400px" class="profile-tabs">
<el-tabs v-model="activeName" class="profile-tabs" style="height: 400px" tab-position="top">
<el-tab-pane :label="t('profile.info.basicInfo')" name="basicInfo">
<BasicInfo />
</el-tab-pane>
@ -23,17 +23,18 @@
<ResetPwd />
</el-tab-pane>
<el-tab-pane :label="t('profile.info.userSocial')" name="userSocial">
<UserSocial />
<UserSocial v-model:activeName="activeName" />
</el-tab-pane>
</el-tabs>
</div>
</el-card>
</div>
</template>
<script setup lang="ts" name="Profile">
import { BasicInfo, ProfileUser, ResetPwd, UserSocial } from './components/'
const { t } = useI18n()
<script lang="ts" setup>
import { BasicInfo, ProfileUser, ResetPwd, UserSocial } from './components'
const { t } = useI18n()
defineOptions({ name: 'Profile' })
const activeName = ref('basicInfo')
</script>
<style scoped>

View File

@ -27,12 +27,15 @@ import { getUserProfile, ProfileVO } from '@/api/system/user/profile'
import { socialAuthRedirect, socialBind, socialUnbind } from '@/api/system/user/socialUser'
defineOptions({ name: 'UserSocial' })
defineProps<{
activeName: string
}>()
const message = useMessage()
const socialUsers = ref<any[]>([])
const userInfo = ref<ProfileVO>()
const initSocial = async () => {
socialUsers.value = [] //
const res = await getUserProfile()
userInfo.value = res
for (const i in SystemUserSocialTypeEnum) {
@ -49,9 +52,12 @@ const initSocial = async () => {
}
}
const route = useRoute()
const emit = defineEmits<{
(e: 'update:activeName', v: string): void
}>()
const bindSocial = () => {
//
const type = route.query.type
const type = getUrlValue('type')
const code = route.query.code
const state = route.query.state
if (!code) {
@ -59,11 +65,20 @@ const bindSocial = () => {
}
socialBind(type, code, state).then(() => {
message.success('绑定成功')
emit('update:activeName', 'userSocial')
initSocial()
})
}
// encode decode
function getUrlValue(key: string): string {
const url = new URL(decodeURIComponent(location.href))
return url.searchParams.get(key) ?? ''
}
const bind = (row) => {
const redirectUri = location.origin + '/user/profile?type=' + row.type
// encode type
const redirectUri = location.origin + '/user/profile?' + encodeURIComponent(`type=${row.type}`)
//
socialAuthRedirect(row.type, encodeURIComponent(redirectUri)).then((res) => {
window.location.href = res
@ -83,9 +98,8 @@ onMounted(async () => {
watch(
() => route,
(newRoute) => {
() => {
bindSocial()
console.log(newRoute)
},
{
immediate: true

View File

@ -16,7 +16,7 @@
<el-descriptions-item label="付款方式: ">
<dict-tag :type="DICT_TYPE.PAY_CHANNEL_CODE" :value="formData.payChannelCode!" />
</el-descriptions-item>
<el-descriptions-item label="推广用户: " v-if="formData.brokerageUser">
<el-descriptions-item v-if="formData.brokerageUser" label="推广用户: ">
{{ formData.brokerageUser?.nickname }}
</el-descriptions-item>
</el-descriptions>
@ -26,7 +26,7 @@
<el-descriptions-item label="订单状态: ">
<dict-tag :type="DICT_TYPE.TRADE_ORDER_STATUS" :value="formData.status!" />
</el-descriptions-item>
<el-descriptions-item label-class-name="no-colon">
<el-descriptions-item v-hasPermi="['trade:order:update']" label-class-name="no-colon">
<el-button
v-if="formData.status! === TradeOrderStatusEnum.UNPAID.status"
type="primary"
@ -150,7 +150,7 @@
<el-descriptions-item label="联系电话: ">{{ formData.receiverMobile }}</el-descriptions-item>
<!-- 快递配送 -->
<div v-if="formData.deliveryType === DeliveryTypeEnum.EXPRESS.type">
<el-descriptions-item label="收货地址: " v-if="formData.receiverDetailAddress">
<el-descriptions-item v-if="formData.receiverDetailAddress" label="收货地址: ">
{{ formData.receiverAreaName }} {{ formData.receiverDetailAddress }}
<el-link
v-clipboard:copy="formData.receiverAreaName + ' ' + formData.receiverDetailAddress"
@ -159,17 +159,17 @@
type="primary"
/>
</el-descriptions-item>
<el-descriptions-item label="物流公司: " v-if="formData.logisticsId">
<el-descriptions-item v-if="formData.logisticsId" label="物流公司: ">
{{ deliveryExpressList.find((item) => item.id === formData.logisticsId)?.name }}
</el-descriptions-item>
<el-descriptions-item label="运单号: " v-if="formData.logisticsId">
<el-descriptions-item v-if="formData.logisticsId" label="运单号: ">
{{ formData.logisticsNo }}
</el-descriptions-item>
<el-descriptions-item label="发货时间: " v-if="formatDate.deliveryTime">
<el-descriptions-item v-if="formatDate.deliveryTime" label="发货时间: ">
{{ formatDate(formData.deliveryTime) }}
</el-descriptions-item>
<el-descriptions-item v-for="item in 2" :key="item" label-class-name="no-colon" />
<el-descriptions-item label="物流详情: " v-if="expressTrackList.length > 0">
<el-descriptions-item v-if="expressTrackList.length > 0" label="物流详情: ">
<el-timeline>
<el-timeline-item
v-for="(express, index) in expressTrackList"
@ -183,7 +183,7 @@
</div>
<!-- 自提门店 -->
<div v-if="formData.deliveryType === DeliveryTypeEnum.PICK_UP.type">
<el-descriptions-item label="自提门店: " v-if="formData.pickUpStoreId">
<el-descriptions-item v-if="formData.pickUpStoreId" label="自提门店: ">
{{ pickUpStore?.name }}
</el-descriptions-item>
</div>

View File

@ -125,10 +125,10 @@
<el-input
v-show="true"
v-model="queryParams[queryType.queryParam]"
:type="queryType.queryParam === 'userId' ? 'number' : 'text'"
class="!w-280px"
clearable
placeholder="请输入"
:type="queryType.queryParam === 'userId' ? 'number' : 'text'"
>
<template #prepend>
<el-select
@ -163,16 +163,24 @@
<!-- 列表 -->
<ContentWrap>
<el-table v-loading="loading" :data="list">
<!-- 添加 row-key="id" 解决列数据中的 table#header 数据不刷新的问题 -->
<el-table v-loading="loading" :data="list" row-key="id">
<OrderTableColumn :list="list" :pick-up-store-list="pickUpStoreList">
<template #default="{ row }">
<!-- TODO 权限后续补齐 -->
<div class="flex items-center justify-center">
<el-button link type="primary" @click="openDetail(row.id)">
<el-button
v-hasPermi="['trade:order:query']"
link
type="primary"
@click="openDetail(row.id)"
>
<Icon icon="ep:notification" />
详情
</el-button>
<el-dropdown @command="(command) => handleCommand(command, row)">
<el-dropdown
v-hasPermi="['trade:order:update']"
@command="(command) => handleCommand(command, row)"
>
<el-button link type="primary">
<Icon icon="ep:d-arrow-right" />
更多

View File

@ -162,7 +162,8 @@
<!-- 列表 -->
<ContentWrap>
<el-table v-loading="loading" :data="list">
<!-- 添加 row-key="id" 解决列数据中的 table#header 数据不刷新的问题 -->
<el-table v-loading="loading" :data="list" row-key="id">
<OrderTableColumn :list="list" :pick-up-store-list="pickUpStoreList">
<template #default="{ row }">
<el-button link type="primary" @click="openDetail(row.id)">

View File

@ -0,0 +1,154 @@
<template>
<Dialog v-model="dialogVisible" :title="dialogTitle">
<el-form
ref="formRef"
v-loading="formLoading"
:model="formData"
:rules="formRules"
label-width="120px"
>
<el-form-item label="应用名" prop="name">
<el-input v-model="formData.name" placeholder="请输入应用名" />
</el-form-item>
<el-form-item label="社交平台" prop="socialType">
<el-radio-group v-model="formData.socialType">
<el-radio
v-for="dict in getIntDictOptions(DICT_TYPE.SYSTEM_SOCIAL_CLIENT_TYPE)"
:key="dict.value"
:label="dict.value"
>
{{ dict.label }}
</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="用户类型" prop="userType">
<el-radio-group v-model="formData.userType">
<el-radio
v-for="dict in getIntDictOptions(DICT_TYPE.USER_TYPE)"
:key="dict.value"
:label="dict.value"
>
{{ dict.label }}
</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="客户端编号" prop="clientId">
<el-input v-model="formData.clientId" placeholder="请输入客户端编号,对应各平台的appKey" />
</el-form-item>
<el-form-item label="客户端密钥" prop="clientSecret">
<el-input
v-model="formData.clientSecret"
placeholder="请输入客户端密钥,对应各平台的appSecret"
/>
</el-form-item>
<el-form-item label="agentId" prop="agentId">
<el-input v-model="formData.agentId" placeholder="授权方的网页应用ID,有则填" />
</el-form-item>
<el-form-item label="状态" prop="status">
<el-radio-group v-model="formData.status">
<el-radio
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
:key="dict.value"
:label="dict.value"
>
{{ dict.label }}
</el-radio>
</el-radio-group>
</el-form-item>
</el-form>
<template #footer>
<el-button :disabled="formLoading" type="primary" @click="submitForm"> </el-button>
<el-button @click="dialogVisible = false"> </el-button>
</template>
</Dialog>
</template>
<script lang="ts" setup>
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import * as SocialClientApi from '@/api/system/social/client'
const { t } = useI18n() //
const message = useMessage() //
const dialogVisible = ref(false) //
const dialogTitle = ref('') //
const formLoading = ref(false) // 12
const formType = ref('') // create - update -
const formData = ref({
id: undefined,
name: undefined,
socialType: undefined,
userType: undefined,
clientId: undefined,
clientSecret: undefined,
agentId: undefined,
status: 0
})
const formRules = reactive({
name: [{ required: true, message: '应用名不能为空', trigger: 'blur' }],
socialType: [{ required: true, message: '社交平台不能为空', trigger: 'blur' }],
userType: [{ required: true, message: '用户类型不能为空', trigger: 'blur' }],
clientId: [{ required: true, message: '客户端编号不能为空', trigger: 'blur' }],
clientSecret: [{ required: true, message: '客户端密钥不能为空', trigger: 'blur' }],
status: [{ required: true, message: '状态不能为空', trigger: 'blur' }]
})
const formRef = ref() // Ref
/** 打开弹窗 */
const open = async (type: string, id?: number) => {
dialogVisible.value = true
dialogTitle.value = t('action.' + type)
formType.value = type
resetForm()
//
if (id) {
formLoading.value = true
try {
formData.value = await SocialClientApi.getSocialClient(id)
} finally {
formLoading.value = false
}
}
}
defineExpose({ open }) // open
/** 提交表单 */
const emit = defineEmits(['success']) // success
const submitForm = async () => {
//
if (!formRef) return
const valid = await formRef.value.validate()
if (!valid) return
//
formLoading.value = true
try {
const data = formData.value as unknown as SocialClientApi.SocialClientVO
if (formType.value === 'create') {
await SocialClientApi.createSocialClient(data)
message.success(t('common.createSuccess'))
} else {
await SocialClientApi.updateSocialClient(data)
message.success(t('common.updateSuccess'))
}
dialogVisible.value = false
//
emit('success')
} finally {
formLoading.value = false
}
}
/** 重置表单 */
const resetForm = () => {
formData.value = {
id: undefined,
name: undefined,
socialType: undefined,
userType: undefined,
clientId: undefined,
clientSecret: undefined,
agentId: undefined,
status: 0
}
formRef.value?.resetFields()
}
</script>

View File

@ -0,0 +1,248 @@
<template>
<ContentWrap>
<!-- 搜索工作栏 -->
<el-form
ref="queryFormRef"
:inline="true"
:model="queryParams"
class="-mb-15px"
label-width="130px"
>
<el-form-item label="应用名" prop="name">
<el-input
v-model="queryParams.name"
class="!w-240px"
clearable
placeholder="请输入应用名"
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item label="社交平台" prop="socialType">
<el-select
v-model="queryParams.socialType"
class="!w-240px"
clearable
placeholder="请选择社交平台"
>
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.SYSTEM_SOCIAL_CLIENT_TYPE)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="用户类型" prop="userType">
<el-select
v-model="queryParams.userType"
class="!w-240px"
clearable
placeholder="请选择用户类型"
>
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.USER_TYPE)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="客户端编号" prop="clientId">
<el-input
v-model="queryParams.clientId"
class="!w-240px"
clearable
placeholder="请输入客户端编号"
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item label="客户端密钥" prop="clientSecret">
<el-input
v-model="queryParams.clientSecret"
class="!w-240px"
clearable
placeholder="请输入客户端密钥"
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item label="状态" prop="status">
<el-select v-model="queryParams.status" class="!w-240px" clearable placeholder="请选择状态">
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="创建时间" prop="createTime">
<el-date-picker
v-model="queryParams.createTime"
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
class="!w-240px"
end-placeholder="结束日期"
start-placeholder="开始日期"
type="daterange"
value-format="YYYY-MM-DD HH:mm:ss"
/>
</el-form-item>
<el-form-item>
<el-button @click="handleQuery">
<Icon class="mr-5px" icon="ep:search" />
搜索
</el-button>
<el-button @click="resetQuery">
<Icon class="mr-5px" icon="ep:refresh" />
重置
</el-button>
<el-button
v-hasPermi="['system:social-client:create']"
plain
type="primary"
@click="openForm('create')"
>
<Icon class="mr-5px" icon="ep:plus" />
新增
</el-button>
</el-form-item>
</el-form>
</ContentWrap>
<!-- 列表 -->
<ContentWrap>
<el-table v-loading="loading" :data="list" :show-overflow-tooltip="true" :stripe="true">
<el-table-column align="center" label="编号" prop="id" />
<el-table-column align="center" label="应用名" prop="name" />
<el-table-column align="center" label="社交平台" prop="socialType">
<template #default="scope">
<dict-tag :type="DICT_TYPE.SYSTEM_SOCIAL_CLIENT_TYPE" :value="scope.row.socialType" />
</template>
</el-table-column>
<el-table-column align="center" label="用户类型" prop="userType">
<template #default="scope">
<dict-tag :type="DICT_TYPE.USER_TYPE" :value="scope.row.userType" />
</template>
</el-table-column>
<el-table-column align="center" label="客户端编号" prop="clientId" />
<el-table-column align="center" label="客户端密钥" prop="clientSecret" />
<el-table-column align="center" label="状态" prop="status">
<template #default="scope">
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
</template>
</el-table-column>
<el-table-column
:formatter="dateFormatter"
align="center"
label="创建时间"
prop="createTime"
width="180px"
/>
<el-table-column align="center" label="操作">
<template #default="scope">
<el-button
v-hasPermi="['system:social-client:update']"
link
type="primary"
@click="openForm('update', scope.row.id)"
>
编辑
</el-button>
<el-button
v-hasPermi="['system:social-client:delete']"
link
type="danger"
@click="handleDelete(scope.row.id)"
>
删除
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<Pagination
v-model:limit="queryParams.pageSize"
v-model:page="queryParams.pageNo"
:total="total"
@pagination="getList"
/>
</ContentWrap>
<!-- 表单弹窗添加/修改 -->
<SocialClientForm ref="formRef" @success="getList" />
</template>
<script lang="ts" setup>
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import { dateFormatter } from '@/utils/formatTime'
import * as SocialClientApi from '@/api/system/social/client'
import SocialClientForm from './SocialClientForm.vue'
defineOptions({ name: 'SocialClient' })
const message = useMessage() //
const { t } = useI18n() //
const loading = ref(true) //
const total = ref(0) //
const list = ref([]) //
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
name: null,
socialType: null,
userType: null,
clientId: null,
clientSecret: null,
status: null,
createTime: []
})
const queryFormRef = ref() //
/** 查询列表 */
const getList = async () => {
loading.value = true
try {
const data = await SocialClientApi.getSocialClientPage(queryParams)
list.value = data.list
total.value = data.total
} finally {
loading.value = false
}
}
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.pageNo = 1
getList()
}
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value.resetFields()
handleQuery()
}
/** 添加/修改操作 */
const formRef = ref()
const openForm = (type: string, id?: number) => {
formRef.value.open(type, id)
}
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
try {
//
await message.delConfirm()
//
await SocialClientApi.deleteSocialClient(id)
message.success(t('common.delSuccess'))
//
await getList()
} catch {}
}
/** 初始化 **/
onMounted(() => {
getList()
})
</script>

View File

@ -0,0 +1,139 @@
<template>
<Dialog v-model="dialogVisible" :title="dialogTitle">
<el-form
ref="formRef"
v-loading="formLoading"
:model="formData"
:rules="formRules"
label-width="150px"
>
<el-form-item label="社交平台" prop="type">
<el-radio-group v-model="formData.type">
<el-radio
v-for="dict in getIntDictOptions(DICT_TYPE.SYSTEM_SOCIAL_CLIENT_TYPE)"
:key="dict.value"
:label="dict.value"
>
{{ dict.label }}
</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="社交 openid" prop="openid">
<el-input v-model="formData.openid" placeholder="请输入社交 openid" />
</el-form-item>
<el-form-item label="社交 token" prop="token">
<el-input v-model="formData.token" placeholder="请输入社交 token" />
</el-form-item>
<el-form-item label="原始 Token 数据" prop="rawTokenInfo">
<el-input v-model="formData.rawTokenInfo" placeholder="请输入原始 Token 数据" />
</el-form-item>
<el-form-item label="用户昵称" prop="nickname">
<el-input v-model="formData.nickname" placeholder="请输入用户昵称" />
</el-form-item>
<el-form-item label="用户头像" prop="avatar">
<el-input v-model="formData.avatar" placeholder="请输入用户头像" />
</el-form-item>
<el-form-item label="原始用户数据" prop="rawUserInfo">
<el-input v-model="formData.rawUserInfo" placeholder="请输入原始用户数据" />
</el-form-item>
<el-form-item label="最后一次的认证 code" prop="code">
<el-input v-model="formData.code" placeholder="请输入最后一次的认证 code" />
</el-form-item>
<el-form-item label="最后一次的认证 state" prop="state">
<el-input v-model="formData.state" placeholder="请输入最后一次的认证 state" />
</el-form-item>
</el-form>
<template #footer>
<el-button :disabled="formLoading" type="primary" @click="submitForm"> </el-button>
<el-button @click="dialogVisible = false"> </el-button>
</template>
</Dialog>
</template>
<script lang="ts" setup>
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import * as SocialUserApi from '@/api/system/social/user'
const { t } = useI18n() //
const message = useMessage() //
const dialogVisible = ref(false) //
const dialogTitle = ref('') //
const formLoading = ref(false) // 12
const formType = ref('') // create - update -
const formData = ref({
id: undefined,
type: undefined,
openid: undefined,
token: undefined,
rawTokenInfo: undefined,
nickname: undefined,
avatar: undefined,
rawUserInfo: undefined,
code: undefined,
state: 0
})
const formRules = reactive({
type: [{ required: true, message: '社交平台不能为空', trigger: 'blur' }],
openid: [{ required: true, message: '社交 openid 不能为空', trigger: 'blur' }],
nickname: [{ required: true, message: '用户昵称不能为空', trigger: 'blur' }]
})
const formRef = ref() // Ref
/** 打开弹窗 */
const open = async (type: string, id?: number) => {
dialogVisible.value = true
dialogTitle.value = t('action.' + type)
formType.value = type
resetForm()
//
if (id) {
formLoading.value = true
try {
formData.value = await SocialUserApi.getSocialUser(id)
} finally {
formLoading.value = false
}
}
}
defineExpose({ open }) // open
/** 提交表单 */
const emit = defineEmits(['success']) // success
const submitForm = async () => {
//
if (!formRef) return
const valid = await formRef.value.validate()
if (!valid) return
//
formLoading.value = true
try {
const data = formData.value as unknown as SocialUserApi.SocialUserVO
if (formType.value === 'update') {
await SocialUserApi.updateSocialUser(data)
message.success(t('common.updateSuccess'))
}
dialogVisible.value = false
//
emit('success')
} finally {
formLoading.value = false
}
}
/** 重置表单 */
const resetForm = () => {
formData.value = {
id: undefined,
type: undefined,
openid: undefined,
token: undefined,
rawTokenInfo: undefined,
nickname: undefined,
avatar: undefined,
rawUserInfo: undefined,
code: undefined,
state: 0
}
formRef.value?.resetFields()
}
</script>

View File

@ -0,0 +1,204 @@
<template>
<ContentWrap>
<!-- 搜索工作栏 -->
<el-form
ref="queryFormRef"
:inline="true"
:model="queryParams"
class="-mb-15px"
label-width="68px"
>
<el-form-item label="社交平台" prop="type">
<el-select
v-model="queryParams.type"
class="!w-240px"
clearable
placeholder="请选择社交平台"
>
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.SYSTEM_SOCIAL_CLIENT_TYPE)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="用户昵称" prop="nickname">
<el-input
v-model="queryParams.nickname"
class="!w-240px"
clearable
placeholder="请输入用户昵称"
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item label="创建时间" prop="createTime">
<el-date-picker
v-model="queryParams.createTime"
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
class="!w-240px"
end-placeholder="结束日期"
start-placeholder="开始日期"
type="daterange"
value-format="YYYY-MM-DD HH:mm:ss"
/>
</el-form-item>
<el-form-item>
<el-button @click="handleQuery">
<Icon class="mr-5px" icon="ep:search" />
搜索
</el-button>
<el-button @click="resetQuery">
<Icon class="mr-5px" icon="ep:refresh" />
重置
</el-button>
</el-form-item>
</el-form>
</ContentWrap>
<!-- 列表 -->
<ContentWrap>
<el-table v-loading="loading" :data="list" :show-overflow-tooltip="true" :stripe="true">
<el-table-column align="center" label="社交平台" prop="type">
<template #default="scope">
<dict-tag :type="DICT_TYPE.SYSTEM_SOCIAL_CLIENT_TYPE" :value="scope.row.type" />
</template>
</el-table-column>
<el-table-column align="center" label="社交 openid" prop="openid" />
<el-table-column align="center" label="社交 token" prop="token" />
<el-table-column align="center" label="原始 Token 数据" prop="rawTokenInfo" />
<el-table-column align="center" label="用户昵称" prop="nickname" />
<el-table-column align="center" label="用户头像" prop="avatar">
<template #default="{ row }">
<el-image :src="row.avatar" class="h-30px w-30px" @click="imagePreview(row.avatar)" />
</template>
</el-table-column>
<el-table-column align="center" label="原始用户数据" prop="rawUserInfo" />
<el-table-column align="center" label="最后一次的认证 code" prop="code" />
<el-table-column align="center" label="最后一次的认证 state" prop="state" />
<el-table-column
:formatter="dateFormatter"
align="center"
label="创建时间"
prop="createTime"
width="180px"
/>
<el-table-column align="center" fixed="right" label="操作">
<template #default="scope">
<el-button
v-hasPermi="['system:social-user:update']"
link
type="primary"
@click="openForm('update', scope.row.id)"
>
编辑
</el-button>
<el-button
v-hasPermi="['system:social-user:delete']"
link
type="danger"
@click="handleDelete(scope.row.id)"
>
删除
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<Pagination
v-model:limit="queryParams.pageSize"
v-model:page="queryParams.pageNo"
:total="total"
@pagination="getList"
/>
</ContentWrap>
<!-- 表单弹窗添加/修改 -->
<SocialUserForm ref="formRef" @success="getList" />
</template>
<script lang="ts" setup>
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import { dateFormatter } from '@/utils/formatTime'
import * as SocialUserApi from '@/api/system/social/user'
import SocialUserForm from './SocialUserForm.vue'
import { createImageViewer } from '@/components/ImageViewer'
defineOptions({ name: 'SocialUser' })
const message = useMessage() //
const { t } = useI18n() //
const loading = ref(true) //
const total = ref(0) //
const list = ref([]) //
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
type: undefined,
openid: undefined,
token: undefined,
rawTokenInfo: undefined,
nickname: undefined,
avatar: undefined,
rawUserInfo: undefined,
code: undefined,
state: undefined,
createTime: []
})
const queryFormRef = ref() //
/** 查询列表 */
const getList = async () => {
loading.value = true
try {
const data = await SocialUserApi.getSocialUserPage(queryParams)
list.value = data.list
total.value = data.total
} finally {
loading.value = false
}
}
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.pageNo = 1
getList()
}
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value.resetFields()
handleQuery()
}
const imagePreview = (imgUrl: string) => {
createImageViewer({
urlList: [imgUrl]
})
}
/** 修改操作 */
const formRef = ref()
const openForm = (type: string, id?: number) => {
formRef.value.open(type, id)
}
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
try {
//
await message.delConfirm()
//
await SocialUserApi.deleteSocialUser(id)
message.success(t('common.delSuccess'))
//
await getList()
} catch {}
}
/** 初始化 **/
onMounted(() => {
getList()
})
</script>