diff --git a/.gitignore b/.gitignore
index 7a742a3..da44414 100644
--- a/.gitignore
+++ b/.gitignore
@@ -18,6 +18,7 @@ public_html/hot
storage/app/public/assets/upload
storage/app/log
+storage/app/forbidden
storage/*.key
.idea
.env
diff --git a/app/Http/Controllers/WeChatController.php b/app/Http/Controllers/WeChatController.php
new file mode 100644
index 0000000..02a3220
--- /dev/null
+++ b/app/Http/Controllers/WeChatController.php
@@ -0,0 +1,46 @@
+app_id
+ . '&secret=' . $we_chat->app_secret
+ . '&js_code=' . $code . '&grant_type=authorization_code';
+ $info = file_get_contents($url);
+ $json = json_decode($info);
+ return get_object_vars($json);
+ }
+
+ public function login($code, $app_id)
+ {
+ $we_chat = WeChat::where('app_id', $app_id)->first();
+ $login = false;
+ if (!$we_chat) return $login;
+ switch ($we_chat->type) {
+ case 1:
+
+ break;
+ case 2:
+ $login = $this->mp_login($we_chat, $code);
+ break;
+ }
+ return $login;
+ }
+
+ public function login_test(Request $request)
+ {
+ $code = $request->post('code');
+ $app_id = $request->post('app_id');
+ return Yo::echo([
+ 'info' => $this->login($code, $app_id)
+ ]);
+ }
+}
diff --git a/app/Http/Controllers/WeChatPayController.php b/app/Http/Controllers/WeChatPayController.php
new file mode 100644
index 0000000..1b2830d
--- /dev/null
+++ b/app/Http/Controllers/WeChatPayController.php
@@ -0,0 +1,10 @@
+id();
+ $table->string('name', 50)->comment('名称');
+ $table->tinyInteger('type')->comment('1-公众号 2-小程序');
+ $table->string('app_id', 80)->comment('小程序ID')->index();
+ $table->string('app_secret', 100)->comment('小程序密钥')->index();
+ $table->timestamps();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void
+ {
+ Schema::dropIfExists('we_chats');
+ }
+};
diff --git a/database/migrations/2023_08_13_203344_create_we_chat_pays_table.php b/database/migrations/2023_08_13_203344_create_we_chat_pays_table.php
new file mode 100644
index 0000000..157dac9
--- /dev/null
+++ b/database/migrations/2023_08_13_203344_create_we_chat_pays_table.php
@@ -0,0 +1,32 @@
+id();
+ $table->string('app_id', 80)->comment('APPID')->index();
+ $table->string('pay_id', 20)->comment('商户号');
+ $table->string('number', 100)->comment('证书编号');
+ $table->string('v3', 100)->comment('API KEY V3');
+ $table->string('key', 200)->comment('证书 Key');
+ $table->string('crt', 200)->comment('证书 Crt');
+ $table->timestamps();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void
+ {
+ Schema::dropIfExists('we_chat_pays');
+ }
+};
diff --git a/routes/web.php b/routes/web.php
index b771623..6aa59b0 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -14,6 +14,9 @@ use Illuminate\Support\Facades\Route;
*/
$admin_path = 'Admin';
$zero_path = 'Zero';
+$app_path = 'App';
+Route::post("api/$app_path/WeChat/login_test", [\App\Http\Controllers\WeChatController::class, 'login_test']);
+
Route::post("api/Gateway/close", [\App\Http\Controllers\GatewayController::class, 'close']);
Route::post("api/$admin_path/Config/create", [\App\Http\Controllers\ConfigController::class, 'create']);
Route::post("api/$admin_path/Config/update", [\App\Http\Controllers\ConfigController::class, 'update']);
diff --git a/uniapp/api/index.js b/uniapp/api/index.js
index d0068e7..03c79ce 100644
--- a/uniapp/api/index.js
+++ b/uniapp/api/index.js
@@ -2,6 +2,11 @@ import {
$post
} from '@/lu/axios.js'
import $config from '@/config.js'
+const app_path = 'App'
+export const WeChatLoginTestAction = async (data) => await $post({
+ url: `${$config.url}/api/${app_path}/WeChat/login_test`,
+ data
+})
export const yo = async (data) => await $post({
url: `${$config.url}/api/yo`,
data
diff --git a/uniapp/config.js b/uniapp/config.js
index b586840..9d17923 100644
--- a/uniapp/config.js
+++ b/uniapp/config.js
@@ -10,6 +10,7 @@ if (env === 'dev') {
}
export default {
title: '鹿和开发套件',
+ app_id: 'wx0d92d2990ec16a55',
token: '0995452A-0D59-44B6-B6CA-88D8B1E257A0',
url,
}
\ No newline at end of file
diff --git a/uniapp/manifest.json b/uniapp/manifest.json
index ff9f9f3..0f4457a 100644
--- a/uniapp/manifest.json
+++ b/uniapp/manifest.json
@@ -49,7 +49,6 @@
"quickapp" : {},
/* 快应用特有相关 */
"mp-weixin" : {
- /* 小程序特有相关 */
"appid" : "wx0d92d2990ec16a55",
"setting" : {
"urlCheck" : false
diff --git a/uniapp/pages/package/example/UserCode/UserCode.vue b/uniapp/pages/package/example/UserCode/UserCode.vue
index 35af8b1..7ede768 100644
--- a/uniapp/pages/package/example/UserCode/UserCode.vue
+++ b/uniapp/pages/package/example/UserCode/UserCode.vue
@@ -7,6 +7,10 @@
import {
ref
} from 'vue'
+ import {
+ WeChatLoginTestAction,
+ $response
+ } from '@/api'
const user_code = ref('')
const wxGetUserInfo = (res) => {
if (!res.detail.iv) {
@@ -22,35 +26,54 @@
},
});
}
-
- const drawer_ref = ref(null)
- const drawerRef = (e) => {
- drawer_ref.value = e
- }
-
+
+ const drawer_ref = ref(null)
+ const drawerRef = (e) => {
+ drawer_ref.value = e
+ }
+
const copyContent = () => {
uni.setClipboardData({
data: user_code.value
})
}
+ const login_info = ref('')
+ const WeChatLoginTest = async () => {
+ const user_code_data = JSON.parse(user_code.value)
+ const response = await WeChatLoginTestAction({
+ code: user_code_data.code,
+ app_id: uni.$lu.config.app_id
+ })
+ $response(response, () => {
+ login_info.value = JSON.stringify(response.data.info, null, 4)
+ })
+ }
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ .button_line_wrapper {
+ display: flex;
+ justify-content: space-around;
+ }
+
+ .textarea_wrapper {
+ margin-top: 100rpx;
+ height: 400rpx;
+ }
+
\ No newline at end of file