|
@@ -2,6 +2,9 @@ import { useEffect, useState } from 'react'
|
|
|
import { useParams } from 'react-router-dom';
|
|
|
import wxLogin from './wxLogin'
|
|
|
import { Spin } from 'antd';
|
|
|
+import { UserInfo } from './type';
|
|
|
+import http from '@src/http/index';
|
|
|
+import { getBindPQUserInfo, bindPQUser } from "@src/http/api";
|
|
|
|
|
|
const CONFIG = {
|
|
|
test: {
|
|
@@ -15,26 +18,54 @@ const CONFIG = {
|
|
|
}
|
|
|
|
|
|
const Setting = () => {
|
|
|
- const { code } = useParams<{ code?: string }>(); // /setting/xxx
|
|
|
- const [isLoading, setIsLoading] = useState(false)
|
|
|
-
|
|
|
+ const { code } = useParams<{ code?: string }>();
|
|
|
+ const [isLoading, setIsLoading] = useState(false);
|
|
|
+ const [pqUserInfo, setPqUserInfo] = useState<UserInfo>();
|
|
|
+
|
|
|
useEffect(() => {
|
|
|
- // 获取链接参数 code
|
|
|
- console.log(code)
|
|
|
+ // 设置pq登录信息
|
|
|
+ const pq_userInfo = localStorage.getItem('pq_userInfo');
|
|
|
+ if (pq_userInfo) {
|
|
|
+ setPqUserInfo(JSON.parse(pq_userInfo))
|
|
|
+ } else {
|
|
|
+ http.get(getBindPQUserInfo).then(res => {
|
|
|
+ const { code, data } = res;
|
|
|
+ if (code === 0 && data) {
|
|
|
+ setPqUserInfo(data as UserInfo)
|
|
|
+ } else {
|
|
|
+ renderQrcode()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }, [])
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+ // 获取用户信息
|
|
|
if (code) {
|
|
|
- // 获取用户信息
|
|
|
getPiaoQuanUserInfo(code)
|
|
|
- } else {
|
|
|
+ } else {
|
|
|
renderQrcode()
|
|
|
}
|
|
|
}, [])
|
|
|
|
|
|
const getPiaoQuanUserInfo = async (code: string) => {
|
|
|
setIsLoading(true)
|
|
|
- console.log(code)
|
|
|
- setTimeout(() => {
|
|
|
- setIsLoading(false)
|
|
|
- }, 200)
|
|
|
+ http.post(bindPQUser, {
|
|
|
+ code,
|
|
|
+ appType: 8,
|
|
|
+ appId: 'wx853a8d12eea0e682'
|
|
|
+ }, {
|
|
|
+ headers: {
|
|
|
+ 'Content-Type': 'application/x-www-form-urlencoded',
|
|
|
+ },
|
|
|
+ }).then(res => {
|
|
|
+ const { code, data } = res;
|
|
|
+ if (code === 0 && data) {
|
|
|
+ localStorage.setItem('pq_userInfo', JSON.stringify(data as UserInfo))
|
|
|
+ setPqUserInfo(data as UserInfo)
|
|
|
+ setIsLoading(false)
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
const renderQrcode = () => {
|
|
@@ -53,15 +84,14 @@ const Setting = () => {
|
|
|
<div className='text-2xl font-bold'>视频上传归属用户</div>
|
|
|
</div>
|
|
|
{
|
|
|
- code ? ( isLoading ? <Spin spinning={isLoading} className='mt-10! ml-10!' tip='账号关联中...'>
|
|
|
- </Spin> : (
|
|
|
- <div className="w-full mt-10! ml-10!">
|
|
|
- <div className='text-xl text-black-800'>已完成视频归属用户的绑定!</div>
|
|
|
- <div className='text-xl text-black-600 mt-4'>
|
|
|
- 视频归属用户的微信昵称:可爱的小马
|
|
|
+ pqUserInfo || code ? ( isLoading ? <Spin spinning={isLoading} className='mt-10! ml-10!' tip='账号关联中...'></Spin> : (
|
|
|
+ <div className="w-[450px] m-auto mt-[50px]">
|
|
|
+ <div className='text-xl text-black-800 font-bold'>已完成视频归属用户的绑定!</div>
|
|
|
+ <div className='text-black-600 mt-4'>
|
|
|
+ 视频归属用户的微信昵称:{pqUserInfo?.nickName}
|
|
|
</div>
|
|
|
- <div className='text-xl text-black-600 mt-4'>
|
|
|
- 视频归属用户的票圈UID:5662345
|
|
|
+ <div className='text-black-600 mt-4'>
|
|
|
+ 视频归属用户的票圈UID:{pqUserInfo?.uid}
|
|
|
</div>
|
|
|
</div>
|
|
|
)
|