123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- import platform from '@/utils/platform.js'
- import config from '@/config'
- import getEnv from "@/utils/env"
- import {
- getUrlParamsNormal
- } from '@/utils/utils.js'
- // import {
- // getUserInfo,login,getOpendId
- // } from '@/apis/user.js'
- // import {
- // logout
- // } from '@/apis/information.js'
- // const apisFilter = (station, data) => {
- // return new Promise(resolve => {
- // if (station === '1') {
- // getOpenIdAndLogin(data).then((res) => {
- // resolve(res)
- // })
- // } else {
- // getOpenId(data).then((res) => {
- // resolve(res)
- // })
- // }
- // })
- // }
- if (platform() === 'H5') {
- const getWxQuery = (name) => {
- return new URL(window.location.href).searchParams.get(name + '')
- }
- let openIdSt = ''
- // let station = getUrlParamsNormal('stationType') || uni.getStorageSync('stationType')
- // if (getEnv() === 'dev') {
- // const opId = getUrlParamsNormal('wxOpenid') || uni.getStorageSync('wxOpenid')
- // uni.setStorageSync('wxOpenid', opId)
-
- // // if (station) {
- // // uni.setStorageSync('stationType', station)
- // // }
- // openIdSt = opId || uni.getStorageSync('wxOpenid')
- // } else {
- openIdSt = uni.getStorageSync('Authorization')
- // if (station) {
- // uni.setStorageSync('stationType', station)
- // }
- // }
- // if (!openIdSt) {
- // const code = getWxQuery('code')
- // console.log(code,'code');
- // if (code) {
- // getOpendId({ code: code }).then(res => {
- // const { accessToken,username,wxOpenid } = res
- // uni.setStorageSync('wxOpenid', wxOpenid)
- const username = uni.getStorageSync('username')
- console.log(openIdSt,'88');
- setTimeout(() => {
- if (openIdSt && username) { // 登录成功 后更新用户信息
- // uni.setStorageSync('accessToken', accessToken)
- // uni.setStorageSync('username', username)
- // uni.setStorageSync('wxOpenid', wxOpenid)
- // uni.setStorageSync('userInfo', ress)
- // window.history.go(-1)
- }
- if (!openIdSt) { // 未登录过
- // const channel = getUrlParamsNormal('channel')
- // if (channel === 'qrcode') { // 扫码进入的页面
- // uni.reLaunch({
- // url: '/pages/gallery/index'
- // })
- // } else { // 进入登录
- uni.reLaunch({
- url: '/pages/login/index'
- })
- }
- // }
- },100)
- // }).catch(err => {console.log(err,'err')})
- // } else {
- // uni.setStorageSync('indexHref', window.location.href)
- // const state = ''
- // const redirect_uri = window.encodeURIComponent(window.location.href)
- // const appid = config.appid
- // const scope = 'snsapi_base'
- // window.location.href =
- // `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${redirect_uri}&response_type=code&scope=${scope}&state=${state}#wechat_redirect`
- // }
- // } else {
- // uni.setStorageSync('indexHref', window.location.href)
- // const userInfo = uni.getStorageSync('userInfo')
- // if (!userInfo) { // 站点切团长
- // // logout().then(() => {
- // // uni.removeStorageSync('accessToken')
- // // uni.removeStorageSync('tokenType')
- // // uni.removeStorageSync('userInfo')
- // uni.navigateTo({
- // url: '/pages/login/index'
- // })
- // // })
- // }
- // }
- }
|