Skip to content

Commit df64617

Browse files
YunaiVgitee-org
authored andcommitted
!296 新增社交客户端 CRUD,新增社交用户 RUD
Merge pull request !296 from puhui999/dev_tmp
2 parents e5d6a9d + a624db0 commit df64617

File tree

12 files changed

+865
-24
lines changed

12 files changed

+865
-24
lines changed

src/api/system/social/client/index.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import request from '@/config/axios'
2+
3+
export interface SocialClientVO {
4+
id: number
5+
name: string
6+
socialType: number
7+
userType: number
8+
clientId: string
9+
clientSecret: string
10+
agentId: string
11+
status: number
12+
}
13+
14+
// 查询社交客户端列表
15+
export const getSocialClientPage = async (params) => {
16+
return await request.get({ url: `/system/social-client/page`, params })
17+
}
18+
19+
// 查询社交客户端详情
20+
export const getSocialClient = async (id: number) => {
21+
return await request.get({ url: `/system/social-client/get?id=` + id })
22+
}
23+
24+
// 新增社交客户端
25+
export const createSocialClient = async (data: SocialClientVO) => {
26+
return await request.post({ url: `/system/social-client/create`, data })
27+
}
28+
29+
// 修改社交客户端
30+
export const updateSocialClient = async (data: SocialClientVO) => {
31+
return await request.put({ url: `/system/social-client/update`, data })
32+
}
33+
34+
// 删除社交客户端
35+
export const deleteSocialClient = async (id: number) => {
36+
return await request.delete({ url: `/system/social-client/delete?id=` + id })
37+
}

src/api/system/social/user/index.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import request from '@/config/axios'
2+
3+
export interface SocialUserVO {
4+
id: number
5+
type: number
6+
openid: string
7+
token: string
8+
rawTokenInfo: string
9+
nickname: string
10+
avatar: string
11+
rawUserInfo: string
12+
code: string
13+
state: string
14+
}
15+
16+
// 查询社交用户列表
17+
export const getSocialUserPage = async (params) => {
18+
return await request.get({ url: `/system/social-user/page`, params })
19+
}
20+
21+
// 查询社交用户详情
22+
export const getSocialUser = async (id: number) => {
23+
return await request.get({ url: `/system/social-user/get?id=` + id })
24+
}
25+
26+
// 修改社交用户
27+
export const updateSocialUser = async (data: SocialUserVO) => {
28+
return await request.put({ url: `/system/social-user/update`, data })
29+
}
30+
31+
// 删除社交用户
32+
export const deleteSocialUser = async (id: number) => {
33+
return await request.delete({ url: `/system/social-user/delete?id=` + id })
34+
}

src/utils/dict.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ export enum DICT_TYPE {
116116
SYSTEM_OAUTH2_GRANT_TYPE = 'system_oauth2_grant_type',
117117
SYSTEM_MAIL_SEND_STATUS = 'system_mail_send_status',
118118
SYSTEM_NOTIFY_TEMPLATE_TYPE = 'system_notify_template_type',
119+
SYSTEM_SOCIAL_CLIENT_TYPE = 'system_social_client_type',
119120

120121
// ========== INFRA 模块 ==========
121122
INFRA_BOOLEAN_STRING = 'infra_boolean_string',

src/views/Profile/Index.vue

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,26 @@
1515
</div>
1616
</template>
1717
<div>
18-
<el-tabs v-model="activeName" tab-position="top" style="height: 400px" class="profile-tabs">
18+
<el-tabs v-model="activeName" class="profile-tabs" style="height: 400px" tab-position="top">
1919
<el-tab-pane :label="t('profile.info.basicInfo')" name="basicInfo">
2020
<BasicInfo />
2121
</el-tab-pane>
2222
<el-tab-pane :label="t('profile.info.resetPwd')" name="resetPwd">
2323
<ResetPwd />
2424
</el-tab-pane>
2525
<el-tab-pane :label="t('profile.info.userSocial')" name="userSocial">
26-
<UserSocial />
26+
<UserSocial v-model:activeName="activeName" />
2727
</el-tab-pane>
2828
</el-tabs>
2929
</div>
3030
</el-card>
3131
</div>
3232
</template>
33-
<script setup lang="ts" name="Profile">
34-
import { BasicInfo, ProfileUser, ResetPwd, UserSocial } from './components/'
35-
const { t } = useI18n()
33+
<script lang="ts" setup>
34+
import { BasicInfo, ProfileUser, ResetPwd, UserSocial } from './components'
3635
36+
const { t } = useI18n()
37+
defineOptions({ name: 'Profile' })
3738
const activeName = ref('basicInfo')
3839
</script>
3940
<style scoped>

src/views/Profile/components/UserSocial.vue

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,15 @@ import { getUserProfile, ProfileVO } from '@/api/system/user/profile'
2727
import { socialAuthRedirect, socialBind, socialUnbind } from '@/api/system/user/socialUser'
2828
2929
defineOptions({ name: 'UserSocial' })
30-
30+
defineProps<{
31+
activeName: string
32+
}>()
3133
const message = useMessage()
3234
const socialUsers = ref<any[]>([])
3335
const userInfo = ref<ProfileVO>()
3436
3537
const initSocial = async () => {
38+
socialUsers.value = [] // 重置避免无限增长
3639
const res = await getUserProfile()
3740
userInfo.value = res
3841
for (const i in SystemUserSocialTypeEnum) {
@@ -49,21 +52,33 @@ const initSocial = async () => {
4952
}
5053
}
5154
const route = useRoute()
55+
const emit = defineEmits<{
56+
(e: 'update:activeName', v: string): void
57+
}>()
5258
const bindSocial = () => {
5359
// 社交绑定
54-
const type = route.query.type
60+
const type = getUrlValue('type')
5561
const code = route.query.code
5662
const state = route.query.state
5763
if (!code) {
5864
return
5965
}
6066
socialBind(type, code, state).then(() => {
6167
message.success('绑定成功')
68+
emit('update:activeName', 'userSocial')
6269
initSocial()
6370
})
6471
}
72+
73+
// 双层 encode 需要在回调后进行 decode
74+
function getUrlValue(key: string): string {
75+
const url = new URL(decodeURIComponent(location.href))
76+
return url.searchParams.get(key) ?? ''
77+
}
78+
6579
const bind = (row) => {
66-
const redirectUri = location.origin + '/user/profile?type=' + row.type
80+
// 双层 encode 解决钉钉回调 type 参数丢失的问题
81+
const redirectUri = location.origin + '/user/profile?' + encodeURIComponent(`type=${row.type}`)
6782
// 进行跳转
6883
socialAuthRedirect(row.type, encodeURIComponent(redirectUri)).then((res) => {
6984
window.location.href = res
@@ -83,9 +98,8 @@ onMounted(async () => {
8398
8499
watch(
85100
() => route,
86-
(newRoute) => {
101+
() => {
87102
bindSocial()
88-
console.log(newRoute)
89103
},
90104
{
91105
immediate: true

src/views/mall/trade/order/detail/index.vue

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<el-descriptions-item label="付款方式: ">
1717
<dict-tag :type="DICT_TYPE.PAY_CHANNEL_CODE" :value="formData.payChannelCode!" />
1818
</el-descriptions-item>
19-
<el-descriptions-item label="推广用户: " v-if="formData.brokerageUser">
19+
<el-descriptions-item v-if="formData.brokerageUser" label="推广用户: ">
2020
{{ formData.brokerageUser?.nickname }}
2121
</el-descriptions-item>
2222
</el-descriptions>
@@ -26,7 +26,7 @@
2626
<el-descriptions-item label="订单状态: ">
2727
<dict-tag :type="DICT_TYPE.TRADE_ORDER_STATUS" :value="formData.status!" />
2828
</el-descriptions-item>
29-
<el-descriptions-item label-class-name="no-colon">
29+
<el-descriptions-item v-hasPermi="['trade:order:update']" label-class-name="no-colon">
3030
<el-button
3131
v-if="formData.status! === TradeOrderStatusEnum.UNPAID.status"
3232
type="primary"
@@ -150,7 +150,7 @@
150150
<el-descriptions-item label="联系电话: ">{{ formData.receiverMobile }}</el-descriptions-item>
151151
<!-- 快递配送 -->
152152
<div v-if="formData.deliveryType === DeliveryTypeEnum.EXPRESS.type">
153-
<el-descriptions-item label="收货地址: " v-if="formData.receiverDetailAddress">
153+
<el-descriptions-item v-if="formData.receiverDetailAddress" label="收货地址: ">
154154
{{ formData.receiverAreaName }} {{ formData.receiverDetailAddress }}
155155
<el-link
156156
v-clipboard:copy="formData.receiverAreaName + ' ' + formData.receiverDetailAddress"
@@ -159,17 +159,17 @@
159159
type="primary"
160160
/>
161161
</el-descriptions-item>
162-
<el-descriptions-item label="物流公司: " v-if="formData.logisticsId">
162+
<el-descriptions-item v-if="formData.logisticsId" label="物流公司: ">
163163
{{ deliveryExpressList.find((item) => item.id === formData.logisticsId)?.name }}
164164
</el-descriptions-item>
165-
<el-descriptions-item label="运单号: " v-if="formData.logisticsId">
165+
<el-descriptions-item v-if="formData.logisticsId" label="运单号: ">
166166
{{ formData.logisticsNo }}
167167
</el-descriptions-item>
168-
<el-descriptions-item label="发货时间: " v-if="formatDate.deliveryTime">
168+
<el-descriptions-item v-if="formatDate.deliveryTime" label="发货时间: ">
169169
{{ formatDate(formData.deliveryTime) }}
170170
</el-descriptions-item>
171171
<el-descriptions-item v-for="item in 2" :key="item" label-class-name="no-colon" />
172-
<el-descriptions-item label="物流详情: " v-if="expressTrackList.length > 0">
172+
<el-descriptions-item v-if="expressTrackList.length > 0" label="物流详情: ">
173173
<el-timeline>
174174
<el-timeline-item
175175
v-for="(express, index) in expressTrackList"
@@ -183,7 +183,7 @@
183183
</div>
184184
<!-- 自提门店 -->
185185
<div v-if="formData.deliveryType === DeliveryTypeEnum.PICK_UP.type">
186-
<el-descriptions-item label="自提门店: " v-if="formData.pickUpStoreId">
186+
<el-descriptions-item v-if="formData.pickUpStoreId" label="自提门店: ">
187187
{{ pickUpStore?.name }}
188188
</el-descriptions-item>
189189
</div>

src/views/mall/trade/order/index.vue

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,10 @@
125125
<el-input
126126
v-show="true"
127127
v-model="queryParams[queryType.queryParam]"
128+
:type="queryType.queryParam === 'userId' ? 'number' : 'text'"
128129
class="!w-280px"
129130
clearable
130131
placeholder="请输入"
131-
:type="queryType.queryParam === 'userId' ? 'number' : 'text'"
132132
>
133133
<template #prepend>
134134
<el-select
@@ -163,16 +163,24 @@
163163

164164
<!-- 列表 -->
165165
<ContentWrap>
166-
<el-table v-loading="loading" :data="list">
166+
<!-- 添加 row-key="id" 解决列数据中的 table#header 数据不刷新的问题 -->
167+
<el-table v-loading="loading" :data="list" row-key="id">
167168
<OrderTableColumn :list="list" :pick-up-store-list="pickUpStoreList">
168169
<template #default="{ row }">
169-
<!-- TODO 权限后续补齐 -->
170170
<div class="flex items-center justify-center">
171-
<el-button link type="primary" @click="openDetail(row.id)">
171+
<el-button
172+
v-hasPermi="['trade:order:query']"
173+
link
174+
type="primary"
175+
@click="openDetail(row.id)"
176+
>
172177
<Icon icon="ep:notification" />
173178
详情
174179
</el-button>
175-
<el-dropdown @command="(command) => handleCommand(command, row)">
180+
<el-dropdown
181+
v-hasPermi="['trade:order:update']"
182+
@command="(command) => handleCommand(command, row)"
183+
>
176184
<el-button link type="primary">
177185
<Icon icon="ep:d-arrow-right" />
178186
更多

src/views/member/user/detail/UserOrderList.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@
162162

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

0 commit comments

Comments
 (0)