From 8a3f1334884bc788788a8cc523b7d88bbef550dd Mon Sep 17 00:00:00 2001 From: Dev Date: Sat, 17 Oct 2026 16:29:14 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E8=A7=92=E8=89=B2=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/controller/user/User.php | 27 +++++++++++++++++++ .../admin/view/user/user/group.html | 22 +++++++++++++++ .../admin/view/user/user/index.html | 1 + .../application/api/controller/Profile.php | 2 ++ backend/application/common.php | 2 +- backend/public/assets/js/backend/user/user.js | 21 ++++++++++++++- frontend/miniapp/config/api.js | 2 +- frontend/miniapp/pages/usercenter/index.js | 22 ++++++++++----- 8 files changed, 89 insertions(+), 10 deletions(-) create mode 100644 backend/application/admin/view/user/user/group.html diff --git a/backend/application/admin/controller/user/User.php b/backend/application/admin/controller/user/User.php index 6908ad6..33a7c94 100644 --- a/backend/application/admin/controller/user/User.php +++ b/backend/application/admin/controller/user/User.php @@ -84,6 +84,33 @@ class User extends Backend return parent::edit($ids); } + /** + * 设置角色组 + */ + public function group($ids = null) + { + $row = $this->model->get($ids); + if (!$row) { + $this->error(__('No Results were found')); + } + if ($this->request->isPost()) { + $this->token(); + $params = $this->request->post('row/a'); + $groupId = isset($params['group_id']) ? intval($params['group_id']) : 0; + if (!$groupId || !\app\admin\model\UserGroup::get($groupId)) { + $this->error('请选择角色组'); + } + $result = $row->allowField(['group_id'])->save(['group_id' => $groupId]); + if ($result === false) { + $this->error('角色组保存失败'); + } + $this->success(); + } + $this->view->assign('row', $row); + $this->view->assign('groupList', build_select('row[group_id]', \app\admin\model\UserGroup::column('id,name'), $row['group_id'], ['class' => 'form-control selectpicker'])); + return $this->view->fetch(); + } + /** * 删除 */ diff --git a/backend/application/admin/view/user/user/group.html b/backend/application/admin/view/user/user/group.html new file mode 100644 index 0000000..299a849 --- /dev/null +++ b/backend/application/admin/view/user/user/group.html @@ -0,0 +1,22 @@ +
+ {:token()} +
+ +
+ +
+
+
+ +
+ {$groupList} +
+
+ +
diff --git a/backend/application/admin/view/user/user/index.html b/backend/application/admin/view/user/user/index.html index 91e1763..d646dd2 100644 --- a/backend/application/admin/view/user/user/index.html +++ b/backend/application/admin/view/user/user/index.html @@ -18,6 +18,7 @@
diff --git a/backend/application/api/controller/Profile.php b/backend/application/api/controller/Profile.php index 711ad40..3d30f62 100644 --- a/backend/application/api/controller/Profile.php +++ b/backend/application/api/controller/Profile.php @@ -33,6 +33,7 @@ class Profile extends Api public function userCenter() { $userInfo = $this->auth->getUserinfo(); + $group = $this->auth->getUser()->group; $userInfo = [ 'id' => $userInfo['id'], 'avatarUrl' => $userInfo['avatar'] ?: $this->request->domain() . '/uploads/avatar/default.png', @@ -40,6 +41,7 @@ class Profile extends Api 'phoneNumber' => '', 'gender' => $userInfo['gender'], 'role' => $userInfo['role'], + 'group_name' => $group ? trim((string)$group['name']) : '', ]; $publishCount = DemandService::where('user_id', $userInfo['id'])->count(); $quoteCount = DemandBiddingService::where(['user_id' => $userInfo['id']])->count(); diff --git a/backend/application/common.php b/backend/application/common.php index adfc26d..b0e4c7c 100644 --- a/backend/application/common.php +++ b/backend/application/common.php @@ -547,7 +547,7 @@ if (!function_exists('convert_keys_to_camelcase')) { if (!function_exists('generate_order_sn')) { function generate_order_sn($prefix = '', $digits = 10) { - $sn = date('Ymd') . substr(implode(NULL, array_map('ord', str_split(substr(uniqid(), 7, 13), 1))), 0, $digits); + $sn = date('Ymd') . substr(implode('', array_map('ord', str_split(substr(uniqid(), 7, 13), 1))), 0, $digits); return strtoupper($prefix) . $sn; } } diff --git a/backend/public/assets/js/backend/user/user.js b/backend/public/assets/js/backend/user/user.js index d3e6108..8f40a56 100644 --- a/backend/public/assets/js/backend/user/user.js +++ b/backend/public/assets/js/backend/user/user.js @@ -44,7 +44,23 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin {field: 'jointime', title: __('Jointime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true}, {field: 'joinip', title: __('Joinip'), formatter: Table.api.formatter.search}, {field: 'status', title: __('Status'), formatter: Table.api.formatter.status, searchList: {normal: __('Normal'), hidden: __('Hidden')}}, - {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} + { + field: 'operate', + title: __('Operate'), + table: table, + events: Table.api.events.operate, + buttons: [ + { + name: 'group', + text: __('角色'), + title: __('角色组'), + classname: 'btn btn-xs btn-info btn-dialog', + icon: 'fa fa-users', + url: 'user/user/group' + } + ], + formatter: Table.api.formatter.operate + } ] ] }); @@ -58,6 +74,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin edit: function () { Controller.api.bindevent(); }, + group: function () { + Controller.api.bindevent(); + }, api: { bindevent: function () { Form.api.bindevent($("form[role=form]")); diff --git a/frontend/miniapp/config/api.js b/frontend/miniapp/config/api.js index ab8c81e..f5bd41e 100644 --- a/frontend/miniapp/config/api.js +++ b/frontend/miniapp/config/api.js @@ -1,7 +1,7 @@ // 接口环境:按小程序运行版本自动切换,无需注释切换域名 // develop: 开发者工具运行/真机预览调试 | trial: 上传后的体验版 | release: 审核发布的正式版 const API_ROOTS = { - develop: 'http://codebg.cn', // 本地开发(phpStudy,hosts 需将 codebg.cn 指向 127.0.0.1) + develop: 'https://code.syoai.cn', // 本地开发(http://codebg.cn) trial: 'https://code.syoai.cn', // 体验版(线上,需 https + 备案域名) release: 'https://code.syoai.cn', // 正式版(线上,需 https + 备案域名) }; diff --git a/frontend/miniapp/pages/usercenter/index.js b/frontend/miniapp/pages/usercenter/index.js index ae51f5a..4b5ba49 100644 --- a/frontend/miniapp/pages/usercenter/index.js +++ b/frontend/miniapp/pages/usercenter/index.js @@ -30,12 +30,6 @@ const menuData = [ url: '', type: 'balance', }, - { - title: '推广中心', - tit: '', - url: '', - type: 'promoter', - }, ], [{ title: '帮助中心', @@ -53,6 +47,16 @@ const menuData = [ ], ]; +// 会员角色组名为 Promoter 时才展示推广中心 +const PROMOTER_GROUP = 'Promoter'; +const promoterMenu = { + title: '推广中心', + tit: '', + url: '', + icon: '', + type: 'promoter', +}; + const orderTagInfos = [{ title: '待付款', iconName: 'wallet', @@ -134,10 +138,14 @@ Page({ customerServiceInfo, } = res.data; // eslint-disable-next-line no-unused-expressions - menuData[0] = menuData[0].filter(item => item.type !== 'quote'); + menuData[0] = menuData[0].filter((item) => item.type !== 'quote' && item.type !== 'promoter'); if (userInfo.role === 'dev') { menuData[0].splice(1, 0, { title: '我投标的需求', tit: '', url: '', icon: '', type: 'quote' }); } + if (userInfo.group_name === PROMOTER_GROUP) { + const balanceIndex = menuData[0].findIndex((item) => item.type === 'balance'); + menuData[0].splice(balanceIndex === -1 ? menuData[0].length : balanceIndex + 1, 0, { ...promoterMenu }); + } menuData[0].forEach((v) => { countsData.forEach((counts) => { if (counts.type === v.type) {