diff --git a/app/Admin/Controllers/Setting/WeChatMp.php b/app/Admin/Controllers/Setting/WeChatMp.php new file mode 100644 index 000000000..cc11f6047 --- /dev/null +++ b/app/Admin/Controllers/Setting/WeChatMp.php @@ -0,0 +1,59 @@ + | + * | Homepage: www.thinksns.com | + * +----------------------------------------------------------------------+ + */ + +namespace Zhiyi\Plus\Admin\Controllers\Setting; + +use Illuminate\Http\Response; +use function Zhiyi\Plus\setting; +use Illuminate\Http\JsonResponse; +use Zhiyi\Plus\Admin\Controllers\Controller; +use Zhiyi\Plus\Admin\Requests\SetWeChatMpConfigure as SetWeChatMpConfigureRequest; + +class WeChatMp extends Controller +{ + /** + * Get configure. + * @return \Illuminate\Http\JsonResponse + */ + public function getConfigure(): JsonResponse + { + $settings = setting('user', 'vendor:wechat-mp', [ + 'appid' => '', + 'secret' => '', + ]); + + return new JsonResponse($settings, Response::HTTP_OK); + } + + /** + * set configure. + * @param \Zhiyi\Plus\Admin\Requests\SetWeChatMpConfigure $request + * @return \Illuminate\Http\Response + */ + public function setConfigure(SetWeChatMpConfigureRequest $request) + { + setting('user')->set('vendor:wechat-mp', [ + 'appid' => $request->input('appid'), + 'secret' => $request->input('secret'), + ]); + + return new Response('', Response::HTTP_NO_CONTENT); + } +} diff --git a/app/Admin/Requests/SetWeChatMpConfigure.php b/app/Admin/Requests/SetWeChatMpConfigure.php new file mode 100644 index 000000000..f772f529c --- /dev/null +++ b/app/Admin/Requests/SetWeChatMpConfigure.php @@ -0,0 +1,51 @@ + | + * | Homepage: www.thinksns.com | + * +----------------------------------------------------------------------+ + */ + +namespace Zhiyi\Plus\Admin\Requests; + +use Illuminate\Foundation\Http\FormRequest; + +class SetWeChatMpConfigure extends FormRequest +{ + /** + * Determine if the user is authorized to make this request. + * + * @return bool + * @author Seven Du + */ + public function authorize(): bool + { + return true; + } + + /** + * Get the validation rules that apply to the request. + * + * @return array + * @author Seven Du + */ + public function rules(): array + { + return [ + 'appid' => 'required|string', + 'secret' => 'required|string', + ]; + } +} diff --git a/resources/assets/admin/api/vendor.js b/resources/assets/admin/api/vendor.js index 5ceb0a49d..23b4c05ac 100644 --- a/resources/assets/admin/api/vendor.js +++ b/resources/assets/admin/api/vendor.js @@ -25,4 +25,5 @@ export const easemob = new VendorRequestGenerator('setting/vendor/easemob'); export const qq = new VendorRequestGenerator('setting/vendor/qq'); export const wechat = new VendorRequestGenerator('setting/vendor/wechat'); export const weibo = new VendorRequestGenerator('setting/vendor/weibo'); +export const wechatMp = new VendorRequestGenerator('setting/vendor/wechat-mp'); diff --git a/resources/assets/admin/component/User.vue b/resources/assets/admin/component/User.vue index a7305debb..027b33024 100644 --- a/resources/assets/admin/component/User.vue +++ b/resources/assets/admin/component/User.vue @@ -47,6 +47,9 @@ 微博登录 + + 微信公众平台 +
  • 环信即时聊天 diff --git a/resources/assets/admin/pages/user-vendor/index.js b/resources/assets/admin/pages/user-vendor/index.js index 54e728875..7d1bf4e63 100644 --- a/resources/assets/admin/pages/user-vendor/index.js +++ b/resources/assets/admin/pages/user-vendor/index.js @@ -1,4 +1,5 @@ export { default as Easemob } from './easemob'; export { default as QQ } from './qq'; export { default as WeChat } from './wechat'; -export { default as Weibo } from './weibo'; \ No newline at end of file +export { default as Weibo } from './weibo'; +export { default as WeChatMp } from './wechat-mp'; \ No newline at end of file diff --git a/resources/assets/admin/pages/user-vendor/wechat-mp.vue b/resources/assets/admin/pages/user-vendor/wechat-mp.vue new file mode 100644 index 000000000..2854e7d40 --- /dev/null +++ b/resources/assets/admin/pages/user-vendor/wechat-mp.vue @@ -0,0 +1,79 @@ + + + + diff --git a/resources/assets/admin/router/user.js b/resources/assets/admin/router/user.js index 0c39ced2e..5c7a67283 100644 --- a/resources/assets/admin/router/user.js +++ b/resources/assets/admin/router/user.js @@ -35,6 +35,7 @@ const routers = { { path: 'vendor-qq', component: vendorPages.QQ, name: 'user:vendor/qq' }, { path: 'vendor-wechat', component: vendorPages.WeChat, name: 'user:vendor/wechat' }, { path: 'vendor-weibo', component: vendorPages.Weibo, name: 'user:vendor/weibo' }, + { path: 'vendor-wechat-mp', component: vendorPages.WeChatMp, name: 'user:vendor/wechat-mp' }, ] }; diff --git a/routes/new-admin.php b/routes/new-admin.php index bf14dc67a..edf9772a9 100644 --- a/routes/new-admin.php +++ b/routes/new-admin.php @@ -69,4 +69,8 @@ // 微博配置 $route->get('setting/vendor/weibo', AdminControllers\Setting\Weibo::class.'@getConfigure'); $route->put('setting/vendor/weibo', AdminControllers\Setting\Weibo::class.'@setConfigure'); + + // 微信公众平台 + $route->get('setting/vendor/wechat-mp', AdminControllers\Setting\WeChatMp::class.'@getConfigure'); + $route->put('setting/vendor/wechat-mp', AdminControllers\Setting\WeChatMp::class.'@setConfigure'); });