公众号调试

DLC
鹿和sa0ChunLuyu 2 years ago
parent e4a2a0b865
commit b6988600ee

@ -8,10 +8,12 @@ use Yo;
class WeChatController extends Controller
{
public function auth(Request $request)
public function auth($app_id)
{
$code = $request->get('code');
$state = $request->get('state');
$code = request()->get('code');
$state = request()->get('state');
$we_chat = WeChat::where('app_id', $app_id)->where('type', 1)->first();
if (!$we_chat) return Yo::error_echo(100001, ['公众号']);
$url = $state . "code=$code";
Yo::echo(['url' => $url]);
header("Location: $url");

@ -15,7 +15,7 @@ use Illuminate\Support\Facades\Route;
$admin_path = 'Admin';
$zero_path = 'Zero';
$app_path = 'App';
Route::get("open/Gzh/auth", [\App\Http\Controllers\WeChatController::class, 'auth']);
Route::get("open/Gzh/auth/{app_id}", [\App\Http\Controllers\WeChatController::class, 'auth']);
Route::get("api/Test/Excel/excel_test", [\App\Http\Controllers\ExcelController::class, 'excel_test']);
Route::post("api/Test/Email/email_test", [\App\Http\Controllers\EmailController::class, 'email_test']);

@ -4,12 +4,19 @@ import {
import $config from '@/config.js'
const app_path = 'App'
let url = ''
let gzh = {
id: '',
jump: '',
auth: ''
}
const urlPick = () => {
if ($config.config.length > 0) {
url = $config.config[0].url
gzh = $config.config[0].gzh
for (let i in $config.config) {
if (!!$config.config[i].active) {
url = $config.config[i].url
gzh = $config.config[i].gzh
break
}
}
@ -17,7 +24,7 @@ const urlPick = () => {
}
urlPick()
export const OpenGzhAuthUrl = `${url}/open/Gzh/auth`
export const GzhConfig = gzh
export const WeChatPayPayTestAction = async (data) => await $post({
url: `${url}/api/Test/WeChatPay/pay_test`,
data

@ -3,14 +3,16 @@ const config = [{
url: 'http://lucode3.sa0.online',
gzh: {
id: 'wx526430047d34c85c',
jump: 'http://node/h5/#/pages/package/gzh_auth/gzh_auth?'
jump: 'https://lucode3.sa0.online/h5/#/pages/gzh/login/login?',
auth: 'https://lucode3.sa0.online/open/Gzh/auth/wx526430047d34c85c'
},
}, {
active: false,
url: 'http://127.0.0.1:8000',
gzh: {
id: 'wx526430047d34c85c',
jump: 'http://127.0.0.1:5173/h5/#/pages/gzh/login/login?'
jump: 'http://127.0.0.1:5173/h5/#/pages/gzh/login/login?',
auth: 'https://lucode3.sa0.online/open/Gzh/auth/wx526430047d34c85c'
},
}]
uni.$config = JSON.parse(JSON.stringify(config))

@ -2,7 +2,8 @@
"pages": [{
"path": "pages/main/index/index",
"style": {
"navigationBarTitleText": "鹿和开发模板"
"navigationBarTitleText": "鹿和开发模板",
"navigationStyle": "custom"
}
}, {
"path": "pages/main/my/my",

@ -8,24 +8,16 @@
ref
} from 'vue'
import {
OpenGzhAuthUrl,
WeChatLoginTestAction,
GzhConfig,
$response
} from '@/api'
const user_code = ref('')
const wxGetUserInfo = (res) => {
if (!res.detail.iv) {
uni.$lu.toast("您取消了授权,登录失败");
return false;
}
uni.login({
provider: 'weixin',
success: (loginRes) => {
let d = loginRes
user_code.value = JSON.stringify(d, null, 4)
drawer_ref.value.open()
},
});
let appid = GzhConfig.id
let state = encodeURIComponent(GzhConfig.auth)
let redirect_uri = encodeURIComponent(GzhConfig.jump);
const url = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' + appid + '&redirect_uri=' +
redirect_uri + '&response_type=code&scope=snsapi_base&state=' + state + '#wechat_redirect';
window.location = url;
}
const drawer_ref = ref(null)
@ -59,7 +51,7 @@
<uni-section title="用户Code" type="line">
<view class="uni-ma-5 uni-pb-5 example_item_wrapper">
<button size="mini" open-type="getUserInfo" @getuserinfo="wxGetUserInfo" withCredentials="true">获取Code</button>
<button size="mini" @click="wxGetUserInfo">Code</button>
</view>
</uni-section>
</template>

@ -124,11 +124,17 @@
</view>
</view>
<view class="input_line_wrapper">
<view class="input_line_tag_wrapper">授权地址</view>
<view class="input_line_tag_wrapper">跳转地址</view>
<view class="input_line_input_wrapper">
<uni-easyinput v-model="config_item_create.gzh.jump" placeholder="请输入"></uni-easyinput>
</view>
</view>
<view class="input_line_wrapper">
<view class="input_line_tag_wrapper">授权地址</view>
<view class="input_line_input_wrapper">
<uni-easyinput v-model="config_item_create.gzh.auth" placeholder="请输入"></uni-easyinput>
</view>
</view>
<view class="input_line_wrapper">
<view class="input_line_tag_wrapper">激活状态</view>
<view class="input_line_input_wrapper">
@ -160,11 +166,17 @@
</view>
</view>
<view class="input_line_wrapper">
<view class="input_line_tag_wrapper">授权地址</view>
<view class="input_line_tag_wrapper">跳转地址</view>
<view class="input_line_input_wrapper">
<uni-easyinput v-model="config_arr[k].gzh.jump" placeholder="请输入"></uni-easyinput>
</view>
</view>
<view class="input_line_wrapper">
<view class="input_line_tag_wrapper">授权地址</view>
<view class="input_line_input_wrapper">
<uni-easyinput v-model="config_arr[k].gzh.auth" placeholder="请输入"></uni-easyinput>
</view>
</view>
<view class="input_line_wrapper">
<view class="input_line_tag_wrapper">激活状态</view>
<view class="input_line_input_wrapper">

Loading…
Cancel
Save