| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- <template>
- <view>
- </view>
- </template>
- <script setup>
- import {
- onLoad
- } from "@dcloudio/uni-app"
- const APPKEY = '4AA7B3944BDF3739'
- const ocode = '1015730314'
- const URL = 'http://192.168.161.78:5173/#/pages/index/index'
- onLoad(() => {
- loginFilter()
- })
- const loginFilter = () => {
- const wxcode = uni.getStorageSync('wxcode')
- if (!wxcode) {
- const wxcode = getQueryString('wxcode')
- if (!wxcode) {
- getWxcodeURL()
- } else {
- uni.setStorageSync('wxcode', wxcode)
- 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(URL)}`
- }
- //获取当前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>
|