| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- <template>
- <view>
- </view>
- </template>
- <script setup>
- import {
- onLoad
- } from "@dcloudio/uni-app"
- const APPKEY = '4AA7B3944BDF3739'
- const APPID = 'wxd87cbe1db0437303'
- const ocode = '1015730314'
- const SCOPE = 'snsapi_base'
- const URL = 'https://chtech.ncjti.edu.cn/jiaofei/jiaofeiManage/'
- const URL2 = 'http://192.168.161.78:5173/#/pages/index/index'
- onLoad(() => {
- // loginFilter()
- uni.switchTab({
- url: "/pages/home/home"
- })
- })
- const loginFilter = () => {
- const wxcode = uni.getStorageSync('wxcode')
- if (!wxcode) {
- const wxcode = getQueryString('wxcode')
- if (!wxcode) {
- getWxcodeURL()
- } else {
- alert(wxcode)
- uni.setStorageSync('wxcode', wxcode)
- getCode()
- }
- } else {
- getCode()
- }
- }
- const getCode = () => {
- const code = uni.getStorageSync('code');
- if (!code) {
- const code = getQueryString('code')
- if (!code) {
- alert(666)
- getCodeURL()
- } else {
- alert(code)
- uni.setStorageSync('code', code)
- uni.switchTab({
- url: "/pages/home/home"
- })
- }
- } else {
- uni.switchTab({
- url: "/pages/home/home"
- })
- }
- }
- const getWxcodeURL = () => {
- window.
- location.href =
- `https://open.wecard.qq.com/connect/oauth/authorize?app_key=${APPKEY}&response_type=code&scope=snsapi_base&ocode=${ocode}&redirect_uri=${encodeURIComponent(URL2)}`
- }
- const getCodeURL = () => {
- window.
- location.href =
- `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${APPID}&redirect_uri=${encodeURIComponent(URL)}&response_type=code&scope=${SCOPE}#wechat_redirect`
- }
- //获取当前URL指定参数
- const getQueryString = (name) => {
- // 获取URL
- let url = window.location.href;
- // 正则匹配URL
- let pattern = new RegExp("[?&]" + name + "=([^&]+)", "i");
- let matcher = pattern.exec(url);
- if (matcher == null || matcher.length < 1) {
- return false;
- }
- // 输出指定的参数值
- return decodeURIComponent(matcher[1]);
- }
- </script>
- <style lang="scss" scoped>
- </style>
|