Commit 8be65610 authored by hzl's avatar hzl

feat: tiktok绑定包列表

parent 4f43ce9b
...@@ -7,7 +7,7 @@ import request from '@/utils/request' ...@@ -7,7 +7,7 @@ import request from '@/utils/request'
*/ */
export function getAccountList(params) { export function getAccountList(params) {
return request({ return request({
url: process.env.PUTIN_API + '/oauth/google/accounts', url: process.env.PUTIN_API + '/oauth/accounts',
method: 'get', method: 'get',
params params
}) })
...@@ -48,3 +48,40 @@ export function getFacebookAuthUrl() { ...@@ -48,3 +48,40 @@ export function getFacebookAuthUrl() {
}) })
} }
/**
* 获取TikTok账户列表
* @returns {Promise}
*/
export function getTiktokAccountList() {
return request({
url: process.env.PUTIN_API + '/api/tiktok/oauth/fbAdvertiserList',
method: 'get'
})
}
/**
* 修改账户信息
* @param {Object} params 账户信息
* @returns {Promise}
*/
export function updateAccount(params) {
return request({
url: process.env.PUTIN_API + '/api/tiktok/oauth/fbAdvertiserUpdate',
method: 'get',
params
})
}
/**
* 删除TikTok账户
* @param {Number} id 账户ID
* @returns {Promise}
*/
export function deleteTiktokAccount(id) {
return request({
url: process.env.PUTIN_API + '/api/tiktok/oauth/fbAdvertiserDelete',
method: 'get',
params: { id }
})
}
...@@ -12,6 +12,11 @@ ...@@ -12,6 +12,11 @@
type="primary" type="primary"
@click="facebookAuthorization" @click="facebookAuthorization"
>Facebook</el-button> >Facebook</el-button>
<el-button
class="authorization-btn"
type="primary"
@click="tiktokAuthorization"
>TikTok</el-button>
</div> </div>
<!-- 过滤条件区域 --> <!-- 过滤条件区域 -->
...@@ -50,15 +55,9 @@ ...@@ -50,15 +55,9 @@
style="width: 100%" style="width: 100%"
> >
<el-table-column prop="id" label="ID" width="60" align="center" /> <el-table-column prop="id" label="ID" width="60" align="center" />
<el-table-column prop="username" label="账号名称" align="center" /> <el-table-column prop="actId" label="账户ID" align="center" />
<el-table-column prop="email" label="账号邮箱" align="center" /> <el-table-column prop="name" label="账户名称" align="center" />
<el-table-column label="平台" align="center"> <el-table-column prop="pkg" label="应用包名" align="center" />
<template slot-scope="scope">
<el-tag :type="getPlatformTagType(scope.row.type)">
{{ getPlatformName(scope.row.type) }}
</el-tag>
</template>
</el-table-column>
<!-- <el-table-column label="授权状态" align="center">--> <!-- <el-table-column label="授权状态" align="center">-->
<!-- <template slot-scope="scope">--> <!-- <template slot-scope="scope">-->
<!-- <el-tag :type="scope.row.status === 1 ? 'success' : 'danger'">--> <!-- <el-tag :type="scope.row.status === 1 ? 'success' : 'danger'">-->
...@@ -68,15 +67,14 @@ ...@@ -68,15 +67,14 @@
<!-- </el-table-column>--> <!-- </el-table-column>-->
<el-table-column label="操作" width="180" align="center"> <el-table-column label="操作" width="180" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<!-- <el-button--> <el-button
<!-- type="primary"--> type="primary"
<!-- size="small"--> size="small"
<!-- plain--> plain
<!-- @click="refreshToken(scope.row)"--> @click="editAccount(scope.row)"
<!-- :disabled="scope.row.status !== 2"--> >
<!-- >--> 修改
<!-- 刷新授权--> </el-button>
<!-- </el-button>-->
<el-button <el-button
type="danger" type="danger"
size="small" size="small"
...@@ -89,11 +87,35 @@ ...@@ -89,11 +87,35 @@
</el-table-column> </el-table-column>
</el-table> </el-table>
<!-- 修改账户对话框 -->
<el-dialog
title="修改账户"
:visible.sync="editDialogVisible"
width="500px"
@close="resetEditForm"
>
<el-form :model="editForm" :rules="editRules" ref="editForm" label-width="100px">
<el-form-item label="账户ID" prop="actId">
<el-input v-model="editForm.actId" disabled></el-input>
</el-form-item>
<el-form-item label="账户名称" prop="name">
<el-input v-model="editForm.name" placeholder="请输入账户名称"></el-input>
</el-form-item>
<el-form-item label="应用包名" prop="pkg">
<el-input v-model="editForm.pkg" placeholder="请输入应用包名"></el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="editDialogVisible = false">取消</el-button>
<el-button type="primary" @click="submitEdit" :loading="editLoading">确定</el-button>
</div>
</el-dialog>
</div> </div>
</template> </template>
<script> <script>
import { getAccountList, deleteAccount, refreshToken, getGoogleAuthUrl, getFacebookAuthUrl } from '@/api/accountManagement' import { getAccountList, deleteAccount, refreshToken, getGoogleAuthUrl, getFacebookAuthUrl, getTiktokAccountList, updateAccount, deleteTiktokAccount } from '@/api/accountManagement'
export default { export default {
name: 'AccountManagement', name: 'AccountManagement',
...@@ -110,14 +132,38 @@ export default { ...@@ -110,14 +132,38 @@ export default {
// 平台列表 // 平台列表
platformList: [ platformList: [
{ value: 'google', label: 'Google' }, { value: 'google', label: 'Google' },
{ value: 'facebook', label: 'Facebook' } { value: 'facebook', label: 'Facebook' },
{ value: 'tiktok', label: 'TikTok' }
], ],
// 表格数据 // 表格数据
tableData: [], tableData: [],
// 总记录数 // 总记录数
totalNum: 0, totalNum: 0,
// 加载状态 // 加载状态
listLoading: false listLoading: false,
// 修改对话框相关
editDialogVisible: false,
editLoading: false,
editForm: {
id: null,
actId: '',
name: '',
pkg: ''
},
editRules: {
name: [
{ required: true, message: '请输入账户名称', trigger: 'blur' }
],
pkg: [
{ required: true, message: '请输入应用包名', trigger: 'blur' }
]
}
}
},
computed: {
// 判断是否为TikTok账户
isTikTokAccount() {
return this.tableData.some(item => item.actId || item.pkg)
} }
}, },
mounted() { mounted() {
...@@ -175,6 +221,31 @@ export default { ...@@ -175,6 +221,31 @@ export default {
}) })
}, },
// TikTok账户列表
tiktokAuthorization() {
// 调用TikTok账户列表接口
this.getTiktokAccountList()
},
// 获取TikTok账户列表
async getTiktokAccountList() {
this.listLoading = true
try {
const res = await getTiktokAccountList()
if (res.status === 200) {
this.tableData = res.result.data || []
this.$message.success('获取TikTok账户列表成功')
} else {
this.$message.error(res.message || '获取TikTok账户列表失败')
}
} catch (error) {
console.error('获取TikTok账户列表异常', error)
this.$message.error('获取TikTok账户列表失败')
} finally {
this.listLoading = false
}
},
// 刷新授权 // 刷新授权
async refreshToken(row) { async refreshToken(row) {
try { try {
...@@ -191,6 +262,58 @@ export default { ...@@ -191,6 +262,58 @@ export default {
} }
}, },
// 修改账户
editAccount(row) {
this.editForm = {
id: row.id,
actId: row.actId,
name: row.name,
pkg: row.pkg
}
this.editDialogVisible = true
},
// 提交修改
async submitEdit() {
this.$refs.editForm.validate(async (valid) => {
if (valid) {
this.editLoading = true
try {
const res = await updateAccount({
id: this.editForm.id,
name: this.editForm.name,
pkg: this.editForm.pkg
})
if (res.status === 200) {
this.$message.success('修改成功')
this.editDialogVisible = false
this.getTiktokAccountList()
} else {
this.$message.error(res.message || '修改失败')
}
} catch (error) {
console.error('修改账户异常', error)
this.$message.error('修改失败')
} finally {
this.editLoading = false
}
}
})
},
// 重置修改表单
resetEditForm() {
this.editForm = {
id: null,
actId: '',
name: '',
pkg: ''
}
if (this.$refs.editForm) {
this.$refs.editForm.resetFields()
}
},
// 删除账号 // 删除账号
deleteAccount(row) { deleteAccount(row) {
this.$confirm('确认删除该账号?', '提示', { this.$confirm('确认删除该账号?', '提示', {
...@@ -199,10 +322,10 @@ export default { ...@@ -199,10 +322,10 @@ export default {
type: 'warning' type: 'warning'
}).then(async () => { }).then(async () => {
try { try {
const res = await deleteAccount(row.id) const res = await deleteTiktokAccount(row.id)
if (res.status === 200) { if (res.status === 200) {
this.$message.success('删除成功') this.$message.success('删除成功')
this.getAccountList() this.getTiktokAccountList()
} else { } else {
this.$message.error(res.message || '删除失败') this.$message.error(res.message || '删除失败')
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment