feat:DLC 功能

DLC
鹿和sa0ChunLuyu 2 years ago
parent 112f25f319
commit ab52efd1d6

1
.gitignore vendored

@ -18,6 +18,7 @@ public_html/hot
storage/app/public/assets/upload storage/app/public/assets/upload
storage/app/log storage/app/log
storage/app/forbidden
storage/*.key storage/*.key
.idea .idea
.env .env

@ -0,0 +1,46 @@
<?php
namespace App\Http\Controllers;
use App\Models\WeChat;
use Illuminate\Http\Request;
use Yo;
class WeChatController extends Controller
{
public function mp_login($we_chat, $code)
{
$url = 'https://api.weixin.qq.com/sns/jscode2session?appid='
. $we_chat->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)
]);
}
}

@ -0,0 +1,10 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class WeChatPayController extends Controller
{
//
}

@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class WeChat extends Model
{
use HasFactory;
}

@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class WeChatPay extends Model
{
use HasFactory;
}

@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('we_chats', function (Blueprint $table) {
$table->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');
}
};

@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('we_chat_pays', function (Blueprint $table) {
$table->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');
}
};

@ -14,6 +14,9 @@ use Illuminate\Support\Facades\Route;
*/ */
$admin_path = 'Admin'; $admin_path = 'Admin';
$zero_path = 'Zero'; $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/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/create", [\App\Http\Controllers\ConfigController::class, 'create']);
Route::post("api/$admin_path/Config/update", [\App\Http\Controllers\ConfigController::class, 'update']); Route::post("api/$admin_path/Config/update", [\App\Http\Controllers\ConfigController::class, 'update']);

@ -2,6 +2,11 @@ import {
$post $post
} from '@/lu/axios.js' } from '@/lu/axios.js'
import $config from '@/config.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({ export const yo = async (data) => await $post({
url: `${$config.url}/api/yo`, url: `${$config.url}/api/yo`,
data data

@ -10,6 +10,7 @@ if (env === 'dev') {
} }
export default { export default {
title: '鹿和开发套件', title: '鹿和开发套件',
app_id: 'wx0d92d2990ec16a55',
token: '0995452A-0D59-44B6-B6CA-88D8B1E257A0', token: '0995452A-0D59-44B6-B6CA-88D8B1E257A0',
url, url,
} }

@ -49,7 +49,6 @@
"quickapp" : {}, "quickapp" : {},
/* */ /* */
"mp-weixin" : { "mp-weixin" : {
/* */
"appid" : "wx0d92d2990ec16a55", "appid" : "wx0d92d2990ec16a55",
"setting" : { "setting" : {
"urlCheck" : false "urlCheck" : false

@ -7,6 +7,10 @@
import { import {
ref ref
} from 'vue' } from 'vue'
import {
WeChatLoginTestAction,
$response
} from '@/api'
const user_code = ref('') const user_code = ref('')
const wxGetUserInfo = (res) => { const wxGetUserInfo = (res) => {
if (!res.detail.iv) { if (!res.detail.iv) {
@ -33,22 +37,41 @@
data: user_code.value 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)
})
}
</script> </script>
<template> <template>
<uni-drawer :ref="drawerRef" mode="right"> <uni-drawer :ref="drawerRef" mode="right">
<view class="navbar_wrapper"></view> <view class="navbar_wrapper"></view>
<textarea :maxlength="-1" class="textarea_wrapper" v-model="user_code" /> <textarea :maxlength="-1" class="textarea_wrapper" v-model="user_code" />
<view class="button_line_wrapper">
<button size="mini" @click="copyContent()"></button> <button size="mini" @click="copyContent()"></button>
<button size="mini" @click="WeChatLoginTest()"></button>
</view>
<textarea :maxlength="-1" class="textarea_wrapper" v-model="login_info" />
</uni-drawer> </uni-drawer>
<uni-section title="用户Code" type="line"> <uni-section title="用户Code" type="line">
<view class="uni-ma-5 uni-pb-5 example_item_wrapper"> <view class="uni-ma-5 uni-pb-5 example_item_wrapper">
<button size="mini" open-type="getUserInfo" @getuserinfo="wxGetUserInfo" <button size="mini" open-type="getUserInfo" @getuserinfo="wxGetUserInfo" withCredentials="true">获取Code</button>
withCredentials="true">获取Code</button>
</view> </view>
</uni-section> </uni-section>
</template> </template>
<style scoped> <style scoped>
.button_line_wrapper {
display: flex;
justify-content: space-around;
}
.textarea_wrapper { .textarea_wrapper {
margin-top: 100rpx; margin-top: 100rpx;
height: 400rpx; height: 400rpx;

Loading…
Cancel
Save