增加留言管理 和微信用户管理
parent
462cac7075
commit
952cb07c51
@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\API\Admin\YeWu;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class WeixinUserController
|
||||||
|
{
|
||||||
|
public function GetList(){
|
||||||
|
$page = request('page', 1);
|
||||||
|
$pageSize = request('pageSize', 15);
|
||||||
|
$searchInfo = request('searchInfo', []);
|
||||||
|
|
||||||
|
$list = DB::table('weixin_user')
|
||||||
|
->select('openid', 'status', 'created_at')
|
||||||
|
->orderBy('created_at', 'desc');
|
||||||
|
|
||||||
|
// 搜索功能
|
||||||
|
if (!empty($searchInfo['info'])) {
|
||||||
|
$list->where('openid', 'like', '%' . $searchInfo['info'] . '%');
|
||||||
|
}
|
||||||
|
|
||||||
|
$count = $list->count();
|
||||||
|
|
||||||
|
$list = $list
|
||||||
|
->offset(($page - 1) * $pageSize)
|
||||||
|
->limit($pageSize)
|
||||||
|
->get();
|
||||||
|
|
||||||
|
return \Yz::Return(true, '获取成功', ['list' => $list, 'count' => $count]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function UpdateStatus(){
|
||||||
|
$openid = request('openid');
|
||||||
|
$status = request('status');
|
||||||
|
|
||||||
|
if (empty($openid) || $status === null) {
|
||||||
|
return \Yz::echoError1('参数不完整');
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = DB::table('weixin_user')
|
||||||
|
->where('openid', $openid)
|
||||||
|
->update(['status' => $status]);
|
||||||
|
|
||||||
|
if ($result) {
|
||||||
|
return \Yz::Return(true, '修改成功');
|
||||||
|
} else {
|
||||||
|
return \Yz::echoError1('修改失败');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,70 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<el-row style="margin: 10px auto;">
|
||||||
|
<el-button type="primary" @click="refresh">刷新</el-button>
|
||||||
|
</el-row>
|
||||||
|
<el-table :data="tableData" style="width: 100%;">
|
||||||
|
<el-table-column prop="openid" label="用户ID" width="200" />
|
||||||
|
<el-table-column prop="content" label="留言内容" min-width="300" />
|
||||||
|
<el-table-column prop="created_at" label="留言时间" width="200" />
|
||||||
|
</el-table>
|
||||||
|
|
||||||
|
<div class="page">
|
||||||
|
<el-pagination v-model:current-page="currentPage" v-model:page-size="pageSize"
|
||||||
|
:page-sizes="[15, 50, 100, 200]" layout="total,sizes, prev, pager, next" :total="total"
|
||||||
|
@size-change="PageSizeChange" @current-change="PageCurrentChange" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { ref, onMounted } from 'vue'
|
||||||
|
import { ElMessage } from 'element-plus'
|
||||||
|
import { GetLiuYanList } from '@/api/api.js'
|
||||||
|
|
||||||
|
let tableData = ref([])
|
||||||
|
let currentPage = ref(1) //当前页码
|
||||||
|
let pageSize = ref(15) //每页数量
|
||||||
|
let total = 0 //总数量
|
||||||
|
|
||||||
|
const GetList = () => {
|
||||||
|
GetLiuYanList({
|
||||||
|
page: currentPage.value,
|
||||||
|
pageSize: pageSize.value
|
||||||
|
}).then(res => {
|
||||||
|
if (res.status) {
|
||||||
|
tableData.value = res.data.list
|
||||||
|
total = res.data.count
|
||||||
|
} else {
|
||||||
|
ElMessage.error(res.msg)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const PageSizeChange = (e) => { // 修改每页数量
|
||||||
|
pageSize.value = e
|
||||||
|
GetList()
|
||||||
|
}
|
||||||
|
|
||||||
|
const PageCurrentChange = (e) => { //切换页码
|
||||||
|
currentPage.value = e
|
||||||
|
GetList()
|
||||||
|
}
|
||||||
|
|
||||||
|
const refresh = () => {
|
||||||
|
GetList()
|
||||||
|
ElMessage.success('刷新成功')
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
GetList()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.page {
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@ -0,0 +1,122 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<!-- 搜索区域 -->
|
||||||
|
<el-row style="margin: 10px auto;">
|
||||||
|
<el-input
|
||||||
|
v-model="searchInfo.info"
|
||||||
|
placeholder="搜索用户ID"
|
||||||
|
clearable
|
||||||
|
@keyup.enter="GetList"
|
||||||
|
style="width: 300px; margin-right: 10px;"
|
||||||
|
/>
|
||||||
|
<el-button type="primary" @click="GetList">搜索</el-button>
|
||||||
|
<el-button type="success" @click="refresh">刷新</el-button>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<!-- 表格区域 -->
|
||||||
|
<el-table :data="tableData" style="width: 100%;">
|
||||||
|
<el-table-column prop="openid" label="用户ID" />
|
||||||
|
<el-table-column prop="status" label="状态" >
|
||||||
|
<template #default="scope">
|
||||||
|
<el-tag :type="scope.row.status === 1 ? 'success' : 'danger'">
|
||||||
|
{{ scope.row.status === 1 ? '可用' : '不可用' }}
|
||||||
|
</el-tag>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="created_at" label="创建时间" />
|
||||||
|
<el-table-column label="操作" >
|
||||||
|
<template #default="scope">
|
||||||
|
<el-switch
|
||||||
|
v-model="scope.row.status"
|
||||||
|
:active-value="1"
|
||||||
|
:inactive-value="0"
|
||||||
|
@change="handleStatusChange(scope.row)"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
|
||||||
|
<!-- 分页区域 -->
|
||||||
|
<div class="page">
|
||||||
|
<el-pagination v-model:current-page="currentPage" v-model:page-size="pageSize"
|
||||||
|
:page-sizes="[15, 50, 100, 200]" layout="total,sizes, prev, pager, next" :total="total"
|
||||||
|
@size-change="PageSizeChange" @current-change="PageCurrentChange" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { ref, onMounted } from 'vue'
|
||||||
|
import { ElMessage } from 'element-plus'
|
||||||
|
import { GetWeixinUserList, WeixinUserUpdateStatus } from '@/api/api.js'
|
||||||
|
|
||||||
|
let tableData = ref([])
|
||||||
|
let currentPage = ref(1) //当前页码
|
||||||
|
let pageSize = ref(15) //每页数量
|
||||||
|
let total = 0 //总数量
|
||||||
|
let searchInfo = ref({ info: '' }) //搜索条件
|
||||||
|
|
||||||
|
const GetList = () => {
|
||||||
|
GetWeixinUserList({
|
||||||
|
page: currentPage.value,
|
||||||
|
pageSize: pageSize.value,
|
||||||
|
searchInfo: searchInfo.value
|
||||||
|
}).then(res => {
|
||||||
|
if (res.status) {
|
||||||
|
tableData.value = res.data.list
|
||||||
|
total = res.data.count
|
||||||
|
} else {
|
||||||
|
ElMessage.error(res.msg)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const PageSizeChange = (e) => { // 修改每页数量
|
||||||
|
pageSize.value = e
|
||||||
|
GetList()
|
||||||
|
}
|
||||||
|
|
||||||
|
const PageCurrentChange = (e) => { //切换页码
|
||||||
|
currentPage.value = e
|
||||||
|
GetList()
|
||||||
|
}
|
||||||
|
|
||||||
|
const refresh = () => {
|
||||||
|
searchInfo.value = { info: '' }
|
||||||
|
currentPage.value = 1
|
||||||
|
GetList()
|
||||||
|
ElMessage.success('刷新成功')
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleStatusChange = (row) => {
|
||||||
|
const newStatus = Number(row.status)
|
||||||
|
WeixinUserUpdateStatus({
|
||||||
|
openid: row.openid,
|
||||||
|
status: newStatus
|
||||||
|
}).then(res => {
|
||||||
|
if (res.status) {
|
||||||
|
ElMessage.success('状态更新成功')
|
||||||
|
} else {
|
||||||
|
// 恢复原状态
|
||||||
|
row.status = newStatus === 1 ? 0 : 1
|
||||||
|
ElMessage.error(res.msg)
|
||||||
|
}
|
||||||
|
}).catch(() => {
|
||||||
|
// 恢复原状态
|
||||||
|
row.status = newStatus === 1 ? 0 : 1
|
||||||
|
ElMessage.error('操作失败')
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
GetList()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.page {
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
Loading…
Reference in New Issue